mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
Add macros for counter-op player determination; Handle some missing checks
This commit is contained in:
1 parent
44a67e60e8
commit
92d3a9f564
10 files changed
+45
-103
No files matched your search
+2
-10
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
+4
-28
@@ -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;
|
||||
|
||||
+15
-3
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
+5
-31
@@ -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) {
|
||||
|
||||
+2
-14
@@ -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);
|
||||
|
||||
+1
-5
@@ -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);
|
||||
|
||||
|
||||
+2
-6
@@ -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) {
|
||||
|
||||
@@ -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))))
|
||||
|
||||
|
||||
Reference in new issue
Block a user