updated set_user_hitzones, added get_user_hitzones

This commit is contained in:
Johnny Bergström 2004-03-10 22:32:10 +00:00
parent 1e69aaff18
commit b505bdb7e8
2 changed files with 60 additions and 18 deletions

View File

@ -518,13 +518,19 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_user_hitzones(index = 0, target = 0, body = 255); = 3 arguments static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_user_hitzones(index = 0, target = 0, body = 255); = 3 arguments
{ {
// Gets user gravity. // Sets user hitzones.
// params[1] = the one(s) who shoot(s), shooter // params[1] = the one(s) who shoot(s), shooter
int shooter = params[1]; int shooter = params[1];
if (shooter == -1)
shooter = 0;
// params[2] = the one getting hit // params[2] = the one getting hit
int gettingHit = params[2]; int gettingHit = params[2];
if (gettingHit == -1)
gettingHit = 0;
// params[3] = specified hit zones // params[3] = specified hit zones
int hitzones = params[3]; int hitzones = params[3];
if (hitzones == -1)
hitzones = 255;
//set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0 //set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0
//set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0 //set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0
@ -554,6 +560,39 @@ static cell AMX_NATIVE_CALL set_user_hitzones(AMX *amx, cell *params) // set_use
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_user_hitzones(index, target); = 2 arguments
{
// Gets user hitzones.
// params[1] = if this is not 0, return what zones this player can hit
int shooter = params[1];
// params[2] = if shooter was 0, and if this is a player, return what zones this player can get hit in, else... make runtime error?
int gettingHit = params[2];
if (shooter) {
if (FNullEnt(shooter)) {
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
return g_zones_toHit[shooter];
}
else {
if (!gettingHit) {
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
else {
if (FNullEnt(gettingHit)) {
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
else {
return g_zones_getHit[gettingHit];
}
}
}
}
static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_noclip(index, noclip = 0); = 2 arguments static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_noclip(index, noclip = 0); = 2 arguments
{ {
// Sets user to no clipping mode. // Sets user to no clipping mode.
@ -661,7 +700,7 @@ AMX_NATIVE_INFO fun_Exports[] = {
{"set_user_gravity", set_user_gravity}, {"set_user_gravity", set_user_gravity},
{"get_user_gravity", get_user_gravity}, {"get_user_gravity", get_user_gravity},
{"set_user_hitzones", set_user_hitzones}, {"set_user_hitzones", set_user_hitzones},
//{"get_hitzones", get_hitzones}, {"get_user_hitzones", get_user_hitzones},
{"set_user_noclip", set_user_noclip}, {"set_user_noclip", set_user_noclip},
{"get_user_noclip", get_user_noclip}, {"get_user_noclip", get_user_noclip},
{"set_user_footsteps", set_user_footsteps}, {"set_user_footsteps", set_user_footsteps},

View File

@ -31,26 +31,29 @@ native set_user_origin(index, origin[3]);
native set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16); native set_user_rendering(index, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16);
/* Gives item to player, name of item can start /* Gives item to player, name of item can start
* with weapon_, ammo_ and item_. This event * with weapon_, ammo_ and item_. This event
* is announced with proper message to all players. */ * is announced with proper message to all players. */
native give_item(index, const item[]); native give_item(index, const item[]);
/* (not yet implemented, don't know how to use native) /* Sets hit zones for player.
* Sets hit zones for player. This event is announced * Parts of body are as bits:
* with proper message to all players. * 1 - generic
* Parts of body are as bits: * 2 - head
* 2 - head * 4 - chest
* 4 - chest * 8 - stomach
* 8 - stomach * 16 - left arm
* 16 - left arm * 32 - right arm
* 32 - right arm * 64 - left leg
* 64 - left leg * 128 - right leg
* 128 - right leg */ * Set index to a player's index and leave target at 0 to define what bodyparts this player can hit when he is firing.
//native set_hitzones(body = 255); * Set index to 0 and target to a player's index to define what bodyparts on player other players can hit when they are firing. */
* Set both index and target to 0 to define globally what bodyparts people can hit and what bodyparts can be hit when firing. */
native set_user_hitzones(index = 0, target = 0, body = 255); native set_user_hitzones(index = 0, target = 0, body = 255);
/* Get current hitzones. */ /* Get user hitzones.
//native get_hitzones(); * To get what bodyparts a player can hit when firing, set the player's index to index and target to 0.
* To get what bodyparts other players can hit when firing at player, set index to 0 and target to player's index. */
native get_user_hitzones(index, target);
/* Sets users max. speed. */ /* Sets users max. speed. */
native set_user_maxspeed(index, Float:speed = -1.0); native set_user_maxspeed(index, Float:speed = -1.0);