[Include] projectile.inc - PeppeAC's physics modified and simpler version
#1

projectile.inc

Version: 1.4.0 || Last Updated: 27 Sept, 2018

Include will let you create SPHERE based physics SIMULATION with real-time variables like Gravity, Ground Friction, Collision Friction (with an object), and Air Resistance.

You can involve an object to act with the simulation under a callback: OnProjectileUpdate.

downloads:

Source (projectile.inc)https://github.com/Agneese-Saini/SA-...projectile.inc
Example: Throw Deaglehttps://github.com/Agneese-Saini/SA-...row_deagle.pwn
Example: M4-Grenade Launcherhttps://github.com/Agneese-Saini/SA-...e_launcher.pwn
Dependency: ColAndreas Pluginhttps://sampforum.blast.hk/showthread.php?tid=586068
* Coming soon: Billiards pool game

functions:
PHP код:
CreateProjectile(Float:xFloat:yFloat:zFloat:vxFloat:vyFloat:vzFloat:rx 0.0Float:ry 0.0Float:rz 0.0Float:spherecol_radius 1.0Float:ground_friction 5.0Float:collision_friction 0.2Float:air_resistance 0.5Float:gravity 10.0Float:playercol_radius 0.8bool:collide_simulation falseFloat:mass 1.0); 
Purpose:
Create's a physics simulation.
Returns:
Simulation id. (range: MAX_PROJECTILES)
Returns INVALID_PROJECTILE_ID if function was unsuccessful.
Parameters:
"x": initial x position
"y": initial y position
"z": initial z position
"vx": initial x velocity
"vy": initial y velocity
"vz": initial z velocity
"rx": initial x rotation (optional)
"ry": initial y rotation (optional)
"rz": initial z rotation (optional)
"spherecol_radius": simulation's collision sphere radius (optional)
"ground_friction": value of friction caused by ground (optional)
"collision_friction": value of friction caused by colliding with an object (optional)
"air_resistance": value of resistance caused by air (optional)
"gravity": value of gravity's pull (optional)
"playercol_radius": value of collision radius of a player, if set to 0.0, there will be no collision with players (optional)
"collide_simulation": true = simulation will be able to detect collision with another simulation and bounce back (optional)
"mass": mass of simulation (only useful if collide_simulation is set to true) (optional)
PHP код:
IsValidProjectile(projid
Purpose:
Validates a projectile's existance.
Returns:
true = projectile exists
false = doesn't exist
Parameters:
"projid": projectile id
PHP код:
DestroyProjectile(projid
Purpose:
Destroys a projectile simulation.
Returns:
1 = projectile was destroyed
0 = projectile id doesn't exist
Parameters:
"projid": projectile id
PHP код:
GetProjectilePoolSize() 
Purpose:
Returns the highest projectile currently in use of the server.
Returns:
The highest projectileid currently in use on the server or -1 if there are no active projectiles
Parameters:
"This function has no parameters."
PHP код:
GetProjectilePos(projid, &Float:x, &Float:y, &Float:z
Purpose:
Gets projectile's current position.
Returns:
1 = function was success
0 = unsuccessful
Parameters:
"projid": projectile id
"x": x position will be stored in here
"y": y position will be stored in here
"z": z position will be stored in here
PHP код:
GetProjectileRot(projid, &Float:rx, &Float:ry, &Float:rz
Purpose:
Gets projectile's current rotation.
Returns:
1 = function was success
0 = unsuccessful
Parameters:
"projid": projectile id
"rx": x rotation will be stored in here
"ry": y rotation will be stored in here
"rz": z rotation will be stored in here
PHP код:
GetProjectileVel(projid, &Float:vx, &Float:vy, &Float:vz
Purpose:
Gets projectile's current velocity.
Returns:
1 = function was success
0 = unsuccessful
Parameters:
"projid": projectile id
"vx": x velocity will be stored in here
"vy": y velocity will be stored in here
"vz": z velocity will be stored in here
PHP код:
UpdateProjectileVel(projidFloat:vxFloat:vyFloat:vz
Purpose:
Sets projectile's current velocity to the values.
Returns:
1 = function was success
0 = unsuccessful
Parameters:
"projid": projectile id
"vx": x velocity to change
"vy": y velocity to change
"vz": z velocity to change
callbacks:
PHP код:
OnProjectileUpdate(projid
Purpose:
Called every time a projectile's position/velocity is changed.
Returns:
This callback does not handle returns
Parameters:
"projid": projectile id
PHP код:
OnProjectileStop(projid
Purpose:
Called when a projectile has no more velocity left (i.e. 0).
Returns:
This callback does not handle returns
Parameters:
"projid": projectile id
PHP код:
OnProjectileCollide(projidtypeFloat:xFloat:yFloat:zextraid
Purpose:
Called when a projectile collides with something.
Returns:
This callback does not handle returns
Parameters:
"projid": projectile id
"type": type of thing the projectile collided with (checkout "definitions" for type defines)
"x": collision x position
"y": collision yposition
"z": collision z position
"extraid": id of the collided thing (PROJECTILE_COLLIDE_GROUND and PROJECTILE_COLLIDE_CIELING won't return any extraid - PROJECTILE_COLLIDE_SIMULATION will return the other simulation's id - PROJECTILE_COLLIDE_OBJECT will return the objectid - PROJECTILE_COLLIDE_PLAYER will return the player's id)
definitions:
PHP код:
#define MAX_PROJECTILES 100 
^^ Define the maximum amount of projectiles that can be created and handled at once
(user can pre-define before inclusion)
PHP код:
#define PROJECTILE_TIMER_INTERVAL 20 
^^ Define the timer interval which will be responsible for updating projectiles' data in every timer step
(user can pre-define before inclusion)
PHP код:
#define INVALID_PROJECTILE_ID -1 
^^ Invalid id definition of a projectile (returned by "CreateProjectile" when function is unsuccessful)
PHP код:
#define PROJECTILE_COLLIDE_GROUND 0
#define PROJECTILE_COLLIDE_CIELING 1
#define PROJECTILE_COLLIDE_SIMULATION 2
#define PROJECTILE_COLLIDE_OBJECT 3
#define PROJECTILE_COLLIDE_PLAYER 4 
^^ Type of projectiles (used in callback: "OnProjectileCollide")
Reply


Messages In This Thread
projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 16.03.2017, 16:12
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Crayder - 16.03.2017, 16:21
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 16.03.2017, 16:26
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Roozevelt - 16.03.2017, 16:32
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Crayder - 16.03.2017, 18:37
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 16.03.2017, 18:46
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Eoussama - 16.03.2017, 18:49
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 16.03.2017, 19:08
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 16.03.2017, 19:31
Re: projectile.inc - PeppeAC's physics modified and simpler version - by RyderX - 16.03.2017, 19:31
Re: projectile.inc - PeppeAC's physics modified and simpler version - by DRIFT_HUNTER - 16.03.2017, 20:16
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Crayder - 16.03.2017, 20:17
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Pottus - 16.03.2017, 22:37
Re: projectile.inc - PeppeAC's physics modified and simpler version - by DRIFT_HUNTER - 16.03.2017, 23:02
Re: projectile.inc - PeppeAC's physics modified and simpler version - by renatog - 17.03.2017, 03:34
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 17.03.2017, 20:03
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 18.03.2017, 15:20
Re: projectile.inc - PeppeAC's physics modified and simpler version - by iKarim - 18.03.2017, 15:40
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 21.03.2017, 03:38
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 21.03.2017, 15:22
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 21.03.2017, 15:32
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 21.03.2017, 15:50
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 21.03.2017, 15:58
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 21.03.2017, 16:05
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 21.03.2017, 16:15
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 21.03.2017, 16:25
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 22.03.2017, 18:06
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 22.03.2017, 18:46
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 22.03.2017, 19:06
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 22.03.2017, 19:12
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 23.03.2017, 06:16
Re: projectile.inc - PeppeAC's physics modified and simpler version - by AndySedeyn - 23.03.2017, 12:17
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 09.04.2017, 19:35
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Jelly23 - 09.04.2017, 20:41
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Kolstin - 11.04.2017, 14:20
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Gammix - 11.04.2017, 16:22
Re: projectile.inc - PeppeAC's physics modified and simpler version - by PeppeAC - 18.05.2017, 13:09
Re: projectile.inc - PeppeAC's physics modified and simpler version - by Riddick94 - 22.10.2018, 17:22

Forum Jump:


Users browsing this thread: 1 Guest(s)