diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index cdfa78e7e..1d0853c06 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -475,11 +475,7 @@ bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bo } } else if (chr->chrflags & CHRCFLAG_PUSHABLE) { if (g_Vars.antiplayernum < 0 -#ifdef PLATFORM_N64 - || g_Vars.currentplayer != g_Vars.anti -#else - || g_Vars.currentplayer == g_Vars.bond -#endif + || PLAYER_IS_NOT_ANTI(g_Vars.currentplayer) || (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE) == 0) { canpush = true; } @@ -813,11 +809,7 @@ void bwalkUpdateVertical(void) // Maybe reset counter-op's radius - not sure why // Maybe it gets set to 0 when they die? if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer == g_Vars.anti -#else - && g_Vars.currentplayer != g_Vars.bond -#endif + && PLAYER_IS_ANTI(g_Vars.currentplayer) && g_Vars.currentplayer->bond2.radius != 30 && cdTestVolume(&g_Vars.currentplayer->prop->pos, 30, g_Vars.currentplayer->prop->rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y)) { g_Vars.currentplayer->prop->chr->radius = 30; diff --git a/src/game/chr.c b/src/game/chr.c index 08817916a..8d6e20f9e 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -4662,7 +4662,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) hit->model, hit->hitthing.unk28 / 2, sp90); if (g_Vars.antiplayernum >= 0 - && g_Vars.currentplayer == g_Vars.anti + && PLAYER_IS_ANTI(g_Vars.currentplayer) && (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) { return; } diff --git a/src/game/chraction.c b/src/game/chraction.c index bf35338b5..2b5bc41cb 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -4351,14 +4351,7 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse // Don't damage if attacker was anti and chr is non-interactable by anti if (g_Vars.antiplayernum >= 0 && aprop - -#ifdef PLATFORM_N64 - && aprop == g_Vars.anti->prop -#else - && aprop->type == PROPTYPE_PLAYER - && aprop != g_Vars.bond->prop -#endif - + && PROP_IS_FOR_ANTI_PLAYER(aprop) && (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) { return; } @@ -4498,13 +4491,7 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse // Anti shooting other enemies is lethal if (aprop -#ifdef PLATFORM_N64 - && aprop == g_Vars.anti->prop -#else - && aprop->type == PROPTYPE_PLAYER - && aprop != g_Vars.bond->prop -#endif - + && PROP_IS_FOR_ANTI_PLAYER(aprop) && vprop != g_Vars.bond->prop) { damage *= 100; } @@ -8336,14 +8323,7 @@ void chrAlertOthersOfInjury(struct chrdata *chr, bool dying) s32 numinrange = 0; s32 numchrs = chrsGetNumSlots(); - if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && chr->prop == g_Vars.anti->prop -#else - && chr->prop->type == PROPTYPE_PLAYER - && chr->prop != g_Vars.bond->prop -#endif - ) { + if (g_Vars.antiplayernum >= 0 && PROP_IS_FOR_ANTI_PLAYER(chr->prop)) { return; } @@ -13578,11 +13558,7 @@ void chraTickBg(void) if (targetprop && (targetprop->type == PROPTYPE_CHR || targetprop->type == PROPTYPE_PLAYER)) { if ((targetprop->type == PROPTYPE_PLAYER -#ifdef PLATFORM_N64 - && !(g_Vars.antiplayernum >= 0 && g_Vars.anti && g_Vars.anti->prop == targetprop) -#else - && !(g_Vars.antiplayernum >= 0 && g_Vars.bond && g_Vars.bond->prop != targetprop) -#endif + && !(g_Vars.antiplayernum >= 0 && g_Vars.anti && PROP_IS_FOR_ANTI_PLAYER(targetprop)) && chrCompareTeams(chr, targetprop->chr, COMPARE_ENEMIES)) || CHRRACE(targetprop->chr) == RACE_EYESPY) { s32 time60; diff --git a/src/game/explosions.c b/src/game/explosions.c index c7516f216..72d1877b5 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -847,7 +847,7 @@ void explosionInflictDamage(struct prop *expprop) minfrac = (minfrac * 0.7f + 0.3f) * type->damage; if (g_Vars.antiplayernum >= 0 - && g_Vars.antiplayernum == exp->owner + && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner) && (obj->flags2 & OBJFLAG2_IMMUNETOANTI)) { // anti cannot damage this obj } else if (isfirstframe) { @@ -997,8 +997,16 @@ void explosionInflictDamage(struct prop *expprop) ownerprop = g_Vars.bond->prop; } else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) { ownerprop = g_Vars.coop->prop; - } else if (g_Vars.antiplayernum >= 0 && exp->owner == g_Vars.antiplayernum) { + } else if (g_Vars.antiplayernum >= 0 && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner)) { +#if PLATFORM_N64 ownerprop = g_Vars.anti->prop; +#else + struct chrdata *ownerchr = mpGetChrFromPlayerIndex(exp->owner); + + if (ownerchr) { + ownerprop = ownerchr->prop; + } +#endif } chrDamageByExplosion(chr, minfrac, &spa0, ownerprop, &expprop->pos); @@ -1212,8 +1220,12 @@ u32 explosionTick(struct prop *prop) if (g_Vars.normmplayerisrunning) { chr = mpGetChrFromPlayerIndex(exp->owner); - } else if (g_Vars.antiplayernum >= 0 && exp->owner == g_Vars.antiplayernum) { + } else if (g_Vars.antiplayernum >= 0 && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner)) { +#if PLATFORM_N64 chr = g_Vars.anti->prop->chr; +#else + chr = mpGetChrFromPlayerIndex(exp->owner); +#endif } else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) { chr = g_Vars.coop->prop->chr; } else { diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 6b27e3ad3..5cfb64141 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -1338,11 +1338,7 @@ Gfx *mpRenderModalText(Gfx *gdl) && g_Vars.currentplayer->redbloodfinished && g_Vars.currentplayer->deathanimfinished && !(g_Vars.coopplayernum >= 0 && ((g_Vars.bond->isdead && g_Vars.coop->isdead) || !g_Vars.currentplayer->coopcanrestart || g_InCutscene)) -#ifdef PLATFORM_N64 - && !(g_Vars.antiplayernum >= 0 && ((g_Vars.currentplayer != g_Vars.anti || g_InCutscene))) -#else - && !(g_Vars.antiplayernum >= 0 && ((g_Vars.currentplayer == g_Vars.bond || g_InCutscene))) -#endif + && !(g_Vars.antiplayernum >= 0 && ((PLAYER_IS_NOT_ANTI(g_Vars.currentplayer) || g_InCutscene))) && g_NumReasonsToEndMpMatch == 0) { // Render "Press START" text gdl = text0f153628(gdl); diff --git a/src/game/player.c b/src/game/player.c index 3366d0f69..87346e8b9 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -606,13 +606,7 @@ void playerStartNewLife(void) if (cmd); if (cmd); - if (g_Vars.antiplayernum < 0 -#ifdef PLATFORM_N64 - || g_Vars.currentplayer != g_Vars.anti -#else - || g_Vars.currentplayer == g_Vars.bond -#endif - ) { + if (g_Vars.antiplayernum < 0 || PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) { while (cmd[0] != INTROCMD_END) { switch (cmd[0]) { case INTROCMD_SPAWN: @@ -986,13 +980,7 @@ void playerSpawn(void) } if (g_Vars.mplayerisrunning) { - if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer == g_Vars.anti -#else - && g_Vars.currentplayer != g_Vars.bond -#endif - ) { + if (g_Vars.antiplayernum >= 0 && PLAYER_IS_ANTI(g_Vars.currentplayer)) { numsqdists = 0; force = false; @@ -1194,11 +1182,7 @@ void playerChooseBodyAndHead(s32 *bodynum, s32 *headnum, s32 *arg2) bool solo; if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer == g_Vars.anti -#else - && g_Vars.currentplayer != g_Vars.bond -#endif + && PLAYER_IS_ANTI(g_Vars.currentplayer) && g_Vars.antiheadnum >= 0 && g_Vars.antibodynum >= 0) { *headnum = g_Vars.antiheadnum; @@ -1530,11 +1514,7 @@ void playerTickChrBody(void) #if VERSION >= VERSION_NTSC_1_0 if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer == g_Vars.anti -#else - && g_Vars.currentplayer != g_Vars.bond -#endif + && PLAYER_IS_ANTI(g_Vars.currentplayer) && g_Vars.currentplayer->vv_eyeheight > 159) { g_Vars.currentplayer->vv_eyeheight = 159; } @@ -4733,13 +4713,7 @@ Gfx *playerRenderHud(Gfx *gdl) chr->chrflags |= CHRCFLAG_HIDDEN; } - if (g_Vars.antiplayernum >= 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer == g_Vars.anti -#else - && g_Vars.currentplayer != g_Vars.bond -#endif - ) { + if (g_Vars.antiplayernum >= 0 && PLAYER_IS_ANTI(g_Vars.currentplayer)) { // Anti #ifndef PLATFORM_N64 if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->isremote) { diff --git a/src/game/playerreset.c b/src/game/playerreset.c index 1091ea2a6..6e3e79aa2 100644 --- a/src/game/playerreset.c +++ b/src/game/playerreset.c @@ -186,13 +186,7 @@ void playerReset(void) cmd = (struct cmd32 *)((uintptr_t)cmd + 8); break; case INTROCMD_WEAPON: - if (cmd->param3 == 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer != g_Vars.anti -#else - && (g_Vars.antiplayernum < 0 || g_Vars.currentplayer == g_Vars.bond) -#endif - ) { + if (cmd->param3 == 0 && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) { modelmgrLoadProjectileModeldefs(cmd->param1); @@ -220,13 +214,7 @@ void playerReset(void) cmd = (struct cmd32 *)((uintptr_t)cmd + 16); break; case INTROCMD_AMMO: - if (cmd->param3 == 0 -#ifdef PLATFORM_N64 - && g_Vars.currentplayer != g_Vars.anti -#else - && (g_Vars.antiplayernum < 0 || g_Vars.currentplayer == g_Vars.bond) -#endif - ) { + if (cmd->param3 == 0 && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) { bgunSetAmmoQuantity(cmd->param1, cmd->param2); } cmd = (struct cmd32 *)((uintptr_t)cmd + 16); diff --git a/src/game/prop.c b/src/game/prop.c index 7db390774..ff1e73e7a 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -2358,11 +2358,7 @@ void propsTestForPickup(void) if (g_Vars.currentplayer->bondmovemode != MOVEMODE_CUTSCENE && !g_PlayerInvincible -#ifdef PLATFORM_N64 - && g_Vars.currentplayer != g_Vars.anti -#else - && (g_Vars.antiplayernum < 0 || g_Vars.currentplayer == g_Vars.bond) -#endif + && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer) ) { roomsCopy(g_Vars.currentplayer->prop->rooms, allrooms); diff --git a/src/game/propobj.c b/src/game/propobj.c index aa3ed5893..dbc2540c4 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -9148,7 +9148,7 @@ void autogunTickShoot(struct prop *autogunprop) // (ie. autogun is a Defense autogun or a thrown laptop) if (g_Vars.normmplayerisrunning || (targetprop && (targetprop->type == PROPTYPE_CHR)) - || (g_Vars.antiplayernum >= 0 && targetprop && targetprop == g_Vars.anti->prop)) { + || (g_Vars.antiplayernum >= 0 && targetprop && PROP_IS_FOR_ANTI_PLAYER(targetprop))) { if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { #if VERSION >= VERSION_PAL_FINAL cdGetPos(&hitpos, 11480, "prop/propobj.c"); @@ -15943,11 +15943,7 @@ void objHit(struct shotdata *shotdata, struct hit *hit) } if (g_Vars.antiplayernum < 0 -#ifdef PLATFORM_N64 - || g_Vars.currentplayer != g_Vars.anti -#else - || g_Vars.currentplayer == g_Vars.bond -#endif + || PLAYER_IS_NOT_ANTI(g_Vars.currentplayer) || (obj->flags2 & OBJFLAG2_IMMUNETOANTI) == 0) { if (hit->hitthing.texturenum != 10000) { diff --git a/src/include/constants.h b/src/include/constants.h index 571f09be8..3440de7c6 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -82,6 +82,18 @@ #define PLAYERCOUNT() 1 #endif +#if MAX_LOCAL_PLAYERS > 2 +#define PLAYER_IS_ANTI(plr) (g_Vars.antiplayernum >= 0 && (plr) != g_Vars.bond) +#define PLAYER_IS_NOT_ANTI(plr) (g_Vars.antiplayernum < 0 || (plr) == g_Vars.bond) +#define PROP_IS_FOR_ANTI_PLAYER(plrprop) (g_Vars.antiplayernum >= 0 && g_Vars.anti && (plrprop)->type == PROPTYPE_PLAYER && (plrprop) != g_Vars.bond->prop) +#define EXPLOSION_OWNER_IS_ANTI_PLAYER(expowner) (g_Vars.antiplayernum >= 0 && (expowner) != g_Vars.bondplayernum && mpGetChrFromPlayerIndex((expowner)) != NULL) +#else +#define PLAYER_IS_ANTI(plr) ((plr) == g_Vars.anti) +#define PLAYER_IS_NOT_ANTI(plr) ((plr) != g_Vars.anti) +#define PROP_IS_FOR_ANTI_PLAYER(plrprop) ((plrprop) == g_Vars.anti->prop) +#define EXPLOSION_OWNER_IS_ANTI_PLAYER(expowner) ((expowner) == g_Vars.antiplayernum) +#endif + #define VALIDWEAPON() (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST) #define FUNCISSEC() (VALIDWEAPON() && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7))))