WEAPON/ShootBullet

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Bug)
(Added new parameters)
 
Line 2: Line 2:
 
|Description=A convenience function to shoot bullets.
 
|Description=A convenience function to shoot bullets.
  
{{Bug|Pull=1502|This does not take SWEP.Primary/Secondary.Ammo into account.}}
+
{{Bug|Pull=1502|Fixed=|This does not take SWEP.Primary/Secondary.Ammo into account.}}
 
|Realm=Shared
 
|Realm=Shared
 
|Predicted=No
 
|Predicted=No
Line 22: Line 22:
 
|name=aimcone
 
|name=aimcone
 
|desc=Spread of bullets
 
|desc=Spread of bullets
 +
}}
 +
{{Arg
 +
|type=string
 +
|name=ammo_type
 +
|desc=Ammo type of the bullets
 +
{{NextUpdate}}
 +
|default=self.Primary.Ammo
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=force
 +
|desc=Force of the bullets
 +
{{NextUpdate}}
 +
|default=1
 +
}}
 +
{{Arg
 +
|type=number
 +
|name=tracer
 +
|desc=Show a tracer on every x bullets
 +
{{NextUpdate}}
 +
|default=5
 
}}
 
}}
 
{{Example
 
{{Example

Latest revision as of 18:01, 10 September 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

Next Update Change

This feature is only available in the next update.

Arguments

number force=1

Force of the bullets

Next Update Change

This feature is only available in the next update.

Arguments

number tracer=5

Show a tracer on every x bullets

Next Update Change

This feature is only available in the next update.

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