WEAPON/ShootBullet

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added new parameters)
Line 27: Line 27:
 
|name=ammo_type
 
|name=ammo_type
 
|desc=Ammo type of the bullets
 
|desc=Ammo type of the bullets
{{NextUpdate}}
 
 
|default=self.Primary.Ammo
 
|default=self.Primary.Ammo
 
}}
 
}}
Line 34: Line 33:
 
|name=force
 
|name=force
 
|desc=Force of the bullets
 
|desc=Force of the bullets
{{NextUpdate}}
 
 
|default=1
 
|default=1
 
}}
 
}}
Line 41: Line 39:
 
|name=tracer
 
|name=tracer
 
|desc=Show a tracer on every x bullets
 
|desc=Show a tracer on every x bullets
{{NextUpdate}}
 
 
|default=5
 
|default=5
 
}}
 
}}

Revision as of 16:56, 12 November 2019

 WEAPON:ShootBullet( )

Contents

Description

A convenience function to shoot bullets.

BUG

This does not take SWEP.Primary/Secondary.Ammo into account.

Pull Request: #1502

This bug will be fixed in the next update.

Arguments

number damage

The damage of the bullet

Arguments

number num_bullets

Amount of bullets to shoot

Arguments

number aimcone

Spread of bullets

Arguments

string ammo_type=self.Primary.Ammo

Ammo type of the bullets

Arguments

number force=1

Force of the bullets

Arguments

number tracer=5

Show a tracer on every x bullets

Examples

Example

As defined in weapon_base

function SWEP:ShootBullet( damage, num_bullets, aimcone )
	
	local bullet = {}
	bullet.Num 	= num_bullets
	bullet.Src 	= self.Owner:GetShootPos() -- Source
	bullet.Dir 	= self.Owner:GetAimVector() -- Dir of bullet
	bullet.Spread 	= Vector( aimcone, aimcone, 0 )	 -- Aim Cone
	bullet.Tracer	= 5 -- Show a tracer on every x bullets 
	bullet.Force	= 1 -- Amount of force to give to phys objects
	bullet.Damage	= damage
	bullet.AmmoType = "Pistol"
	
	self.Owner:FireBullets( bullet )
	
	self:ShootEffects()
	
end


Personal tools
Navigation