mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-12 06:48:04 +03:00
Attempt at reverting set_user_hitzones()
This commit is contained in:
parent
a720b62aaa
commit
b2f3a52884
137
dlls/fun/fun.cpp
137
dlls/fun/fun.cpp
@ -70,9 +70,22 @@
|
|||||||
// ######## Utils:
|
// ######## Utils:
|
||||||
void FUNUTIL_ResetPlayer(int index)
|
void FUNUTIL_ResetPlayer(int index)
|
||||||
{
|
{
|
||||||
// Reset hitzones
|
g_zones_toHit[index] = (1<<HITGROUP_GENERIC) |
|
||||||
memset(g_bodyhits[index], 0xFF, sizeof(char)*33);
|
(1<<HITGROUP_HEAD) |
|
||||||
|
(1<<HITGROUP_CHEST) |
|
||||||
|
(1<<HITGROUP_STOMACH) |
|
||||||
|
(1<<HITGROUP_LEFTARM) |
|
||||||
|
(1<<HITGROUP_RIGHTARM)|
|
||||||
|
(1<<HITGROUP_LEFTLEG) |
|
||||||
|
(1<<HITGROUP_RIGHTLEG);
|
||||||
|
g_zones_getHit[index] = (1<<HITGROUP_GENERIC) |
|
||||||
|
(1<<HITGROUP_HEAD) |
|
||||||
|
(1<<HITGROUP_CHEST) |
|
||||||
|
(1<<HITGROUP_STOMACH) |
|
||||||
|
(1<<HITGROUP_LEFTARM) |
|
||||||
|
(1<<HITGROUP_RIGHTARM)|
|
||||||
|
(1<<HITGROUP_LEFTLEG) |
|
||||||
|
(1<<HITGROUP_RIGHTLEG);
|
||||||
// Reset silent slippers
|
// Reset silent slippers
|
||||||
g_silent[index] = false;
|
g_silent[index] = false;
|
||||||
}
|
}
|
||||||
@ -527,60 +540,79 @@ 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
|
||||||
{
|
{
|
||||||
int index = params[1];
|
// Sets user hitzones.
|
||||||
if (index < 0 || index > gpGlobals->maxClients){
|
// params[1] = the one(s) who shoot(s), shooter
|
||||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
int shooter = params[1];
|
||||||
return 0;
|
if (shooter == -1)
|
||||||
}
|
shooter = 0;
|
||||||
int target = params[2];
|
// params[2] = the one getting hit
|
||||||
|
int gettingHit = params[2];
|
||||||
|
if (gettingHit == -1)
|
||||||
|
gettingHit = 0;
|
||||||
|
// params[3] = specified hit zones
|
||||||
|
int hitzones = params[3];
|
||||||
|
if (hitzones == -1)
|
||||||
|
hitzones = 255;
|
||||||
|
|
||||||
if (target < 0 || target > gpGlobals->maxClients){
|
//set_user_hitzones(id, 0, 0) // Makes ID not able to shoot EVERYONE - id can shoot on 0 (all) at 0
|
||||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
//set_user_hitzones(0, id, 0) // Makes EVERYONE not able to shoot ID - 0 (all) can shoot id at 0
|
||||||
return 0;
|
if (shooter == 0 && gettingHit == 0) {
|
||||||
}
|
// set hitzones for ALL, both where people can hit and where they can _get_ hit.
|
||||||
int bodyhits = params[3];
|
for (int i = 1; i <= 32; i++) {
|
||||||
|
g_zones_toHit[i] = hitzones;
|
||||||
if (index) {
|
g_zones_getHit[i] = hitzones;
|
||||||
if (MF_IsPlayerIngame(index)) {
|
|
||||||
if (target) {
|
|
||||||
g_bodyhits[index][target] = bodyhits; // pPlayer->bodyhits[target] = bodyhits;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(int i = 1; i <= gpGlobals->maxClients; ++i)
|
|
||||||
g_bodyhits[index][i] = bodyhits; // pPlayer->bodyhits[i] = bodyhits;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(int i = 1; i <= gpGlobals->maxClients; ++i){
|
if (shooter == 0) {
|
||||||
if (target) {
|
// "All" shooters, target (gettingHit) should be existing player id
|
||||||
g_bodyhits[index][target] = bodyhits;
|
if (gettingHit < 1 || gettingHit > gpGlobals->maxClients) {
|
||||||
}
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||||
else {
|
return 0;
|
||||||
for(int i = 1; i <= gpGlobals->maxClients; ++i)
|
|
||||||
g_bodyhits[index][i] = bodyhits; // pPlayer->bodyhits[i] = bodyhits;
|
|
||||||
}
|
}
|
||||||
|
// Where can gettingHit get hit by all?
|
||||||
|
g_zones_getHit[gettingHit] = hitzones;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// "shooter" will now only be able to hit other people in "hitzones". (target should be 0 here)
|
||||||
|
g_zones_toHit[shooter] = hitzones;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_user_hitzones(index, target); = 2 arguments
|
static cell AMX_NATIVE_CALL get_user_hitzones(AMX *amx, cell *params) // get_user_hitzones(index, target); = 2 arguments
|
||||||
{
|
{
|
||||||
int index = params[1];
|
// Gets user hitzones.
|
||||||
if (index < 1 || index > gpGlobals->maxClients) {
|
// params[1] = if this is not 0, return what zones this player can hit
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
int shooter = params[1];
|
||||||
return 0;
|
// 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)) {
|
||||||
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_zones_toHit[shooter];
|
||||||
}
|
}
|
||||||
int target = params[2];
|
else {
|
||||||
if (target < 1 || target > gpGlobals->maxClients) {
|
if (!gettingHit) {
|
||||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (FNullEnt(gettingHit)) {
|
||||||
|
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return g_zones_getHit[gettingHit];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//return GET_PLAYER_POINTER_I(index)->bodyhits[target];
|
|
||||||
return g_bodyhits[index][target];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -768,12 +800,17 @@ int ClientConnect(edict_t *pPlayer, const char *pszName, const char *pszAddress,
|
|||||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) {
|
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr) {
|
||||||
TRACE_LINE(v1, v2, fNoMonsters, e, ptr);
|
TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr); // pentToSkip gotta be the one that is shooting, so filter it
|
||||||
|
|
||||||
if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&e&&(e->v.flags & (FL_CLIENT | FL_FAKECLIENT) )) {
|
int hitIndex = ENTINDEX(ptr->pHit);
|
||||||
if (!(g_bodyhits[ENTINDEX(e)][ENTINDEX(ptr->pHit)]&(1<<ptr->iHitgroup)))
|
if (hitIndex >= 1 && hitIndex <= gpGlobals->maxClients) {
|
||||||
ptr->flFraction = 1.0;
|
if ( !(
|
||||||
|
g_zones_getHit[hitIndex] & (1 << ptr->iHitgroup) // can ptr->pHit get hit in ptr->iHitgroup at all?
|
||||||
|
&& g_zones_toHit[hitIndex] & (1 << ptr->iHitgroup) ) // can pentToSkip hit other people in that hit zone?
|
||||||
|
) {
|
||||||
|
ptr->flFraction = 1.0; // set to not hit anything (1.0 = shot doesn't hit anything)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
@ -786,9 +823,7 @@ void OnAmxxAttach()
|
|||||||
// Reset stuff - hopefully this should
|
// Reset stuff - hopefully this should
|
||||||
for (int i = 1; i <= 32; i++) {
|
for (int i = 1; i <= 32; i++) {
|
||||||
// Reset all hitzones
|
// Reset all hitzones
|
||||||
memset(g_bodyhits[i], 0xFF, sizeof(char)*33);
|
FUNUTIL_ResetPlayer(i);
|
||||||
// Reset all silent slippers
|
|
||||||
g_silent[i] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@
|
|||||||
// Fun-specific defines above
|
// Fun-specific defines above
|
||||||
|
|
||||||
// The stuff below might end up in a class soon
|
// The stuff below might end up in a class soon
|
||||||
//int g_zones_toHit[33]; // where can people hit other people?
|
int g_zones_toHit[33]; // where can people hit other people?
|
||||||
//int g_zones_getHit[33]; // where can people get hit by other people?
|
int g_zones_getHit[33]; // where can people get hit by other people?
|
||||||
char g_bodyhits[33][33];
|
//char g_bodyhits[33][33];
|
||||||
bool g_silent[33]; // used for set_user_footsteps()
|
bool g_silent[33]; // used for set_user_footsteps()
|
||||||
//int g_ResetHUD;
|
//int g_ResetHUD;
|
||||||
bool g_ResetHUDbool;
|
bool g_ResetHUDbool;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user