16.03.2017, 16:12
(
Последний раз редактировалось Gammix; 28.09.2018 в 03:34.
)
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:
* Coming soon: Billiards pool game
functions:
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 Deagle | https://github.com/Agneese-Saini/SA-...row_deagle.pwn |
Example: M4-Grenade Launcher | https://github.com/Agneese-Saini/SA-...e_launcher.pwn |
Dependency: ColAndreas Plugin | https://sampforum.blast.hk/showthread.php?tid=586068 |
functions:
PHP код:
CreateProjectile(Float:x, Float:y, Float:z, Float:vx, Float:vy, Float:vz, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, Float:spherecol_radius = 1.0, Float:ground_friction = 5.0, Float:collision_friction = 0.2, Float:air_resistance = 0.5, Float:gravity = 10.0, Float:playercol_radius = 0.8, bool:collide_simulation = false, Float:mass = 1.0);
Purpose:Create's a physics simulation.Returns:Simulation id. (range: MAX_PROJECTILES)Parameters:
Returns INVALID_PROJECTILE_ID if function was unsuccessful."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 existsParameters:"projid": projectile id
false = doesn't exist
PHP код:
DestroyProjectile(projid)
Purpose:Destroys a projectile simulation.Returns:1 = projectile was destroyedParameters:
0 = projectile id doesn't exist"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 projectilesParameters:"This function has no parameters."
PHP код:
GetProjectilePos(projid, &Float:x, &Float:y, &Float:z)
Purpose:Gets projectile's current position.Returns:1 = function was successParameters:
0 = unsuccessful"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 successParameters:
0 = unsuccessful"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 successParameters:
0 = unsuccessful"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(projid, Float:vx, Float:vy, Float:vz)
Purpose:callbacks:Sets projectile's current velocity to the values.Returns:1 = function was successParameters:
0 = unsuccessful"projid": projectile id
"vx": x velocity to change
"vy": y velocity to change
"vz": z velocity to change
PHP код:
OnProjectileUpdate(projid)
Purpose:Called every time a projectile's position/velocity is changed.Returns:This callback does not handle returnsParameters:"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 returnsParameters:"projid": projectile id
PHP код:
OnProjectileCollide(projid, type, Float:x, Float:y, Float:z, extraid)
Purpose:definitions:Called when a projectile collides with something.Returns:This callback does not handle returnsParameters:"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)
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")