Skip to content

Commit

Permalink
Moved SWEP.CSMuzzleFlashes to Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
robotboy655 committed Aug 20, 2014
1 parent 95a6945 commit a172321
Showing 1 changed file with 49 additions and 23 deletions.
72 changes: 49 additions & 23 deletions garrysmod/gamemodes/base/entities/weapons/weapon_base/cl_init.lua
@@ -1,7 +1,6 @@

include('shared.lua')


SWEP.PrintName = "Scripted Weapon" -- 'Nice' Weapon name (Shown on HUD)
SWEP.Slot = 0 -- Slot in the weapon selection menu
SWEP.SlotPos = 10 -- Position in the slot
Expand Down Expand Up @@ -93,46 +92,46 @@ end
--[[---------------------------------------------------------
Name: SWEP:FreezeMovement()
Desc: Return true to freeze moving the view
Name: SWEP:FreezeMovement()
Desc: Return true to freeze moving the view
-----------------------------------------------------------]]
function SWEP:FreezeMovement()
return false
end
--[[---------------------------------------------------------
Name: SWEP:ViewModelDrawn( ViewModel )
Desc: Called straight after the viewmodel has been drawn
Name: SWEP:ViewModelDrawn( ViewModel )
Desc: Called straight after the viewmodel has been drawn
-----------------------------------------------------------]]
function SWEP:ViewModelDrawn( ViewModel )
end
--[[---------------------------------------------------------
Name: OnRestore
Desc: Called immediately after a "load"
Name: OnRestore
Desc: Called immediately after a "load"
-----------------------------------------------------------]]
function SWEP:OnRestore()
end
--[[---------------------------------------------------------
Name: OnRemove
Desc: Called just before entity is deleted
Name: OnRemove
Desc: Called just before entity is deleted
-----------------------------------------------------------]]
function SWEP:OnRemove()
end
--[[---------------------------------------------------------
Name: CustomAmmoDisplay
Desc: Return a table
Name: CustomAmmoDisplay
Desc: Return a table
-----------------------------------------------------------]]
function SWEP:CustomAmmoDisplay()
end
--[[---------------------------------------------------------
Name: GetViewModelPosition
Desc: Allows you to re-position the view model
Name: GetViewModelPosition
Desc: Allows you to re-position the view model
-----------------------------------------------------------]]
function SWEP:GetViewModelPosition( pos, ang )
Expand All @@ -141,8 +140,8 @@ function SWEP:GetViewModelPosition( pos, ang )
end
--[[---------------------------------------------------------
Name: TranslateFOV
Desc: Allows the weapon to translate the player's FOV (clientside)
Name: TranslateFOV
Desc: Allows the weapon to translate the player's FOV (clientside)
-----------------------------------------------------------]]
function SWEP:TranslateFOV( current_fov )
Expand All @@ -152,8 +151,8 @@ end
--[[---------------------------------------------------------
Name: DrawWorldModel
Desc: Draws the world model (not the viewmodel)
Name: DrawWorldModel
Desc: Draws the world model (not the viewmodel)
-----------------------------------------------------------]]
function SWEP:DrawWorldModel()
Expand All @@ -163,8 +162,8 @@ end
--[[---------------------------------------------------------
Name: DrawWorldModelTranslucent
Desc: Draws the world model (not the viewmodel)
Name: DrawWorldModelTranslucent
Desc: Draws the world model (not the viewmodel)
-----------------------------------------------------------]]
function SWEP:DrawWorldModelTranslucent()
Expand All @@ -174,8 +173,8 @@ end
--[[---------------------------------------------------------
Name: AdjustMouseSensitivity()
Desc: Allows you to adjust the mouse sensitivity.
Name: AdjustMouseSensitivity
Desc: Allows you to adjust the mouse sensitivity.
-----------------------------------------------------------]]
function SWEP:AdjustMouseSensitivity()
Expand All @@ -184,8 +183,8 @@ function SWEP:AdjustMouseSensitivity()
end
--[[---------------------------------------------------------
Name: GetTracerOrigin()
Desc: Allows you to override where the tracer comes from (in first person view)
Name: GetTracerOrigin
Desc: Allows you to override where the tracer comes from (in first person view)
returning anything but a vector indicates that you want the default action
-----------------------------------------------------------]]
function SWEP:GetTracerOrigin()
Expand All @@ -198,3 +197,30 @@ function SWEP:GetTracerOrigin()
end
--[[---------------------------------------------------------
Name: FireAnimationEvent
Desc: Allows you to override weapon animation events
-----------------------------------------------------------]]
function SWEP:FireAnimationEvent( pos, ang, event, options )
if ( !self.CSMuzzleFlashes ) then return end
-- CS Muzzle flashes
if ( event == 5001 or event == 5011 or event == 5021 or event == 5031 ) then
local data = EffectData()
data:SetFlags( 0 )
data:SetEntity( self.Owner:GetViewModel() )
data:SetAttachment( math.floor( ( event - 4991 ) / 10 ) )
data:SetScale( 1 )
if ( self.CSMuzzleX ) then
util.Effect( "CS_MuzzleFlash_X", data )
else
util.Effect( "CS_MuzzleFlash", data )
end
return true
end
end

0 comments on commit a172321

Please sign in to comment.