fixed stuff

main
koolaid 2023-11-08 15:46:11 -05:00
parent ec71b5dd53
commit eae4fb4b40
1 changed files with 13 additions and 18 deletions

View File

@ -30,14 +30,12 @@ SWEP.Primary.Automatic = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Automatic = true
SWEP.Secondary.Delay = 1
SWEP.Secondary.Sound = "pooblaster/pooblaster.ogg"
@ -51,7 +49,7 @@ local mdls = {"models/props_docks/channelmarker_gib01.mdl","models/props_c17/dol
function SWEP:PrimaryAttack()
-- This weapon is 'automatic'. This function call below defines
-- the rate of fire. Here we set it to shoot every 0.5 seconds.
self:SetNextPrimaryFire( CurTime() + 0.5 )
self:SetNextPrimaryFire( CurTime() + 0.4 )
self:EmitSound( self.Primary.Sound )
-- Call 'ThrowChair' on self with this model
self:ThrowChair( mdls[math.random(1,table.Count(mdls))] )
@ -61,9 +59,9 @@ end
function SWEP:SecondaryAttack()
-- Though the secondary fire isn't automatic
-- players shouldn't be able to fire too fast
self:SetNextSecondaryFire( CurTime() + 0.1 )
self:SetNextSecondaryFire( CurTime() + 1 )
self:EmitSound( self.Secondary.Sound )
for i=1,10 do
for i=1,20 do
self:ThrowChair( "models/weapons/w_bugbait.mdl" )
end
end
@ -94,32 +92,29 @@ function SWEP:ThrowChair( model_file )
-- but the vector methods prevent duplicitous objects from being created
-- which is faster and more memory efficient
-- AimVector is not directly modified as it is used again later in the function
local aimvec = owner:GetAimVector()
local pos = aimvec * 32 -- This creates a new vector object
pos:Add( owner:EyePos() ) -- This translates the local aimvector to world coordinates
local aimvec = owner:GetAimVector() -- This creates a new vector object
local pos = aimvec * 32
pos:Add( owner:EyePos() )
-- Set the position to the player's eye position plus 16 units forward.
ent:SetPos( pos )
ent:SetPos( pos + VectorRand( -10, 10 ))
-- Set the angles to the player'e eye angles. Then spawn it.
ent:SetAngles( owner:EyeAngles() )
ent:Spawn()
-- Now get the physics object. Whenever we get a physics object
-- we need to test to make sure its valid before using it.
-- If it isn't then we'll remove the entity.
local phys = ent:GetPhysicsObject()
if ( not phys:IsValid() ) then ent:Remove() return end
phys:SetMass(4)
-- Now we apply the force - so the chair actually throws instead
-- of just falling to the ground. You can play with this value here
-- to adjust how fast we throw it.
-- Now that this is the last use of the aimvector vector we created,
-- we can directly modify it instead of creating another copy
if model_file == "models/weapons/w_bugbait.mdl" then
aimvec:Mul( -1000 ) -- Add a random vector with elements [-10, 10)
else
aimvec:Mul( 1000 )
end
aimvec:Mul( 10000 )
aimvec:Add( VectorRand( -100, 100 ) )
phys:ApplyForceCenter( aimvec )
-- Assuming we're playing in Sandbox mode we want to add this
-- entity to the cleanup and undo lists. This is done like so.
@ -129,7 +124,7 @@ function SWEP:ThrowChair( model_file )
undo.AddEntity( ent )
undo.SetPlayer( owner )
undo.Finish()
ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
--ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
ent:SetMaterial("models/props_pipes/GutterMetal01a")
-- A lot of items can clutter the workspace.
-- To fix this we add a 10 second delay to remove the chair after it was spawned.