CreateProjectile: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This creates a projectile of the specified type on the specified coords. | This creates a projectile of the specified type on the specified coords. | ||
If certain optional arguments aren't specified, the projectile's characteristics will be retrieved from the weaponType. | |||
==Usage== | ==Usage== | ||
Line 7: | Line 8: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool createProjectile ( element creator, int | bool createProjectile ( element creator, int weaponType, [ float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Required Arguments== | ==Required Arguments== | ||
*'''creator:''' The [[element]] representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be [[getLocalPlayer]](). | *'''creator:''' The [[element]] representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be [[getLocalPlayer]](). | ||
*''' | *'''weaponType:''' [[int]] representing the projectile weaponType (characteristics). Valid IDs are: | ||
{{Projectiles}} | {{Projectiles}} | ||
Line 22: | Line 23: | ||
*'''rotX''','''rotY''','''rotZ''': [[float]] starting rotation for the projectile. | *'''rotX''','''rotY''','''rotZ''': [[float]] starting rotation for the projectile. | ||
*'''velX''','''velY''','''velZ''': [[float]] starting velocity for the projectile. | *'''velX''','''velY''','''velZ''': [[float]] starting velocity for the projectile. | ||
*'''model''': Integer representing the projectile's model, uses default model for weaponType if not specified. | |||
==Returns== | ==Returns== |
Revision as of 10:19, 20 February 2008
This creates a projectile of the specified type on the specified coords. If certain optional arguments aren't specified, the projectile's characteristics will be retrieved from the weaponType.
Usage
Client-side only.
Syntax
bool createProjectile ( element creator, int weaponType, [ float posX, float posY, float posZ, float force = 1.0, element target = nil, float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model ] )
Required Arguments
- creator: The element representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be getLocalPlayer().
- weaponType: int representing the projectile weaponType (characteristics). Valid IDs are:
ID | Name/Description |
---|---|
16 | Grenade |
17 | Tear Gas Grenade |
18 | Molotov |
19 | Rocket (simple) |
20 | Rocket (heat seeking) |
21 | Air Bomb |
39 | Satchel Charge |
58 | Hydra flare |
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- posX,posY,posZ: float starting coordinates for the projectile. They are coordinates of creator by default.
- force: float representing the starting force of the projectile.
- target: element target used for heat seeking rockets.
- rotX,rotY,rotZ: float starting rotation for the projectile.
- velX,velY,velZ: float starting velocity for the projectile.
- model: Integer representing the projectile's model, uses default model for weaponType if not specified.
Returns
Returns true if projectile creation was succesfull. Returns false if unable to create a projectile (wrong weapon ID or projectiles limit was reached).
Example
This example makes a rocket minigun (minigun shooting with rockets).
-- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if source == getLocalPlayer() and weapon == 38 then -- if source is a local player and he uses minigun... if not createProjectile(getLocalPlayer(),19,getElementPosition(getLocalPlayer()),200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire",getRootElement(),onClientPlayerWeaponFireFunc)