replace common damage magic numbers with named macros
that stuff always confused me before lol
This commit is contained in:
1 parent
fe3ff15539
commit
3b60cb2bcd
10 files changed
+46
-42
No files matched your search
+2
-2
@@ -3247,7 +3247,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
|
||||
return;
|
||||
|
||||
if (players[respawnplayer].mo)
|
||||
P_DamageMobj(players[respawnplayer].mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(players[respawnplayer].mo, NULL, NULL, DMG_INSTAKILL);
|
||||
demo_extradata[playernum] |= DXD_RESPAWN;
|
||||
}
|
||||
|
||||
@@ -3949,7 +3949,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
||||
if (!players[playernum].spectator)
|
||||
{
|
||||
if (players[playernum].mo)
|
||||
P_DamageMobj(players[playernum].mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(players[playernum].mo, NULL, NULL, DMG_INSTAKILL);
|
||||
else
|
||||
players[playernum].playerstate = PST_REBORN;
|
||||
}
|
||||
|
||||
+2
-2
@@ -4586,7 +4586,7 @@ void G_ReadDemoExtraData(void)
|
||||
if (extradata & DXD_RESPAWN)
|
||||
{
|
||||
if (players[p].mo)
|
||||
P_DamageMobj(players[p].mo, NULL, NULL, 10000); // Is this how this should work..?
|
||||
P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..?
|
||||
}
|
||||
if (extradata & DXD_SKIN)
|
||||
{
|
||||
@@ -4652,7 +4652,7 @@ void G_ReadDemoExtraData(void)
|
||||
{
|
||||
players[p].spectator = true;
|
||||
if (players[p].mo)
|
||||
P_DamageMobj(players[p].mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL);
|
||||
else
|
||||
players[p].playerstate = PST_REBORN;
|
||||
}
|
||||
|
||||
+6
-4
@@ -3920,10 +3920,12 @@ void A_MineExplode(mobj_t *actor)
|
||||
for (d = 0; d < 16; d++)
|
||||
K_SpawnKartExplosion(actor->x, actor->y, actor->z, explodedist + 32*mapobjectscale, 32, type, d*(ANGLE_45/4), true, false, actor->target); // 32 <-> 64
|
||||
|
||||
skincolors_t color = SKINCOLOR_KETCHUP;
|
||||
|
||||
if (actor->target && actor->target->player)
|
||||
K_SpawnMineExplosion(actor, actor->target->player->skincolor);
|
||||
else
|
||||
K_SpawnMineExplosion(actor, SKINCOLOR_KETCHUP);
|
||||
color = actor->target->player->skincolor;
|
||||
|
||||
K_SpawnMineExplosion(actor, color);
|
||||
|
||||
P_SpawnMobj(actor->x, actor->y, actor->z, MT_MINEEXPLOSIONSOUND);
|
||||
|
||||
@@ -10137,7 +10139,7 @@ void A_RemoteDamage(mobj_t *actor)
|
||||
if (locvar2 == 1) // Kill mobj!
|
||||
{
|
||||
if (target->player) // players die using P_DamageMobj instead for some reason
|
||||
P_DamageMobj(target, source, source, 10000);
|
||||
P_DamageMobj(target, source, source, DMG_INSTAKILL);
|
||||
else
|
||||
P_KillMobj(target, source, source);
|
||||
}
|
||||
|
||||
+6
-7
@@ -2364,10 +2364,9 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN
|
||||
* player is hit by a ring, the player who shot it. In some
|
||||
* cases, the target will go after this object after
|
||||
* receiving damage. This can be NULL.
|
||||
* \param damage Amount of damage to be dealt. 10000 is instant death.
|
||||
* \param damage Amount of damage to be dealt. DMG_INSTAKILL is instant death.
|
||||
* \return True if the target sustained damage, otherwise false.
|
||||
* \todo Clean up this mess, split into multiple functions.
|
||||
* \todo Get rid of the magic number 10000.
|
||||
* \sa P_KillMobj
|
||||
*/
|
||||
boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage)
|
||||
@@ -2384,8 +2383,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
// Spectator handling
|
||||
if (netgame)
|
||||
{
|
||||
if (damage == 42000 && target->player && target->player->spectator)
|
||||
damage = 10000;
|
||||
if (damage == DMG_SPECTATOR && target->player && target->player->spectator)
|
||||
damage = DMG_INSTAKILL;
|
||||
else if (target->player && target->player->spectator)
|
||||
return false;
|
||||
|
||||
@@ -2524,7 +2523,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
{
|
||||
if ((G_BattleGametype()) && cv_suddendeath.value
|
||||
&& !player->powers[pw_flashing] && !player->powers[pw_invulnerability])
|
||||
damage = 10000;
|
||||
damage = DMG_INSTAKILL;
|
||||
}
|
||||
|
||||
// Player hits another player
|
||||
@@ -2538,7 +2537,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
return false;
|
||||
|
||||
// Instant-Death
|
||||
if (damage == 10000)
|
||||
if (damage == DMG_INSTAKILL)
|
||||
P_KillPlayer(player, source, damage);
|
||||
else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing])
|
||||
{
|
||||
@@ -2591,7 +2590,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
else
|
||||
{
|
||||
player->health -= damage; // mirror mobj health here
|
||||
if (damage < 10000)
|
||||
if (damage < DMG_INSTAKILL)
|
||||
{
|
||||
target->player->powers[pw_flashing] = K_GetKartFlashing(target->player);
|
||||
if (damage > 0) // don't spill emeralds/ammo/panels for shield damage
|
||||
|
||||
@@ -435,6 +435,10 @@ typedef struct BasicFF_s
|
||||
INT32 Magnitude; ///< Magnitude of the effect, in the range from 0 through 10,000.
|
||||
} BasicFF_t;
|
||||
|
||||
// replace damage magic numbers with smth readable
|
||||
#define DMG_INSTAKILL 10000
|
||||
#define DMG_SPECTATOR 42000
|
||||
|
||||
void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period);
|
||||
void P_ForceConstant(const BasicFF_t *FFInfo);
|
||||
void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End);
|
||||
|
||||
+4
-4
@@ -724,7 +724,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||
HU_SetCEchoDuration(5);
|
||||
HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[thing->player-players]));
|
||||
I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[thing->player-players]);
|
||||
P_DamageMobj(thing, tmthing, tmthing->target, 10000);
|
||||
P_DamageMobj(thing, tmthing, tmthing->target, DMG_INSTAKILL);
|
||||
P_KillMobj(tmthing, thing, thing);
|
||||
}
|
||||
|
||||
@@ -991,7 +991,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||
HU_SetCEchoDuration(5);
|
||||
HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[tmthing->player-players]));
|
||||
I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[tmthing->player-players]);
|
||||
P_DamageMobj(tmthing, thing, thing->target, 10000);
|
||||
P_DamageMobj(tmthing, thing, thing->target, DMG_INSTAKILL);
|
||||
P_KillMobj(thing, tmthing, tmthing);
|
||||
}
|
||||
|
||||
@@ -3674,7 +3674,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
|
||||
{
|
||||
// Crush the object
|
||||
if (netgame && thing->player && thing->player->spectator)
|
||||
P_DamageMobj(thing, NULL, NULL, 42000); // Respawn crushed spectators
|
||||
P_DamageMobj(thing, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators
|
||||
else
|
||||
{
|
||||
if (!killer)
|
||||
@@ -3684,7 +3684,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
|
||||
killer->threshold = 44; // Special flag for crushing
|
||||
}
|
||||
if (!thing->player)
|
||||
P_DamageMobj(thing, killer, killer, 10000);
|
||||
P_DamageMobj(thing, killer, killer, DMG_INSTAKILL);
|
||||
else
|
||||
K_SquishPlayer(thing->player, killer, killer); // SRB2kart - Squish instead of kill
|
||||
}
|
||||
|
||||
+17
-14
@@ -435,7 +435,7 @@ void P_ExplodeMissile(mobj_t *mo)
|
||||
}
|
||||
|
||||
// Hack: Release an animal.
|
||||
P_DamageMobj(mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(mo, NULL, NULL, DMG_INSTAKILL);
|
||||
}
|
||||
|
||||
mo->flags &= ~MF_MISSILE;
|
||||
@@ -1363,12 +1363,16 @@ void P_XYMovement(mobj_t *mo)
|
||||
oldy = mo->y;
|
||||
|
||||
// adjust various things based on slope
|
||||
if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) {
|
||||
if (!P_IsObjectOnGround(mo)) { // We fell off at some point? Do the twisty thing!
|
||||
if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)
|
||||
{
|
||||
if (!P_IsObjectOnGround(mo)) // We fell off at some point? Do the twisty thing!
|
||||
{
|
||||
P_SlopeLaunch(mo);
|
||||
xmove = mo->momx;
|
||||
ymove = mo->momy;
|
||||
} else { // Still on the ground.
|
||||
}
|
||||
else // Still on the ground.
|
||||
{
|
||||
slopemom.x = xmove;
|
||||
slopemom.y = ymove;
|
||||
slopemom.z = 0;
|
||||
@@ -1381,7 +1385,8 @@ void P_XYMovement(mobj_t *mo)
|
||||
|
||||
oldslope = mo->standingslope;
|
||||
}
|
||||
} else if (P_IsObjectOnGround(mo) && !mo->momz)
|
||||
}
|
||||
else if (P_IsObjectOnGround(mo) && !mo->momz)
|
||||
predictedz = mo->z;
|
||||
|
||||
// Pushables can break some blocks
|
||||
@@ -3008,11 +3013,6 @@ void P_MobjCheckWater(mobj_t *mobj)
|
||||
else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz > FixedMul(-min, mobj->scale))
|
||||
mobj->momz = FixedMul(-min, mobj->scale);
|
||||
|
||||
/*if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->momz > FixedMul(max, mobj->scale))
|
||||
mobj->momz = FixedMul(max, mobj->scale);
|
||||
else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz < FixedMul(-max, mobj->scale))
|
||||
mobj->momz = FixedMul(-max, mobj->scale);*/
|
||||
|
||||
p->kartstuff[k_waterskip]++;
|
||||
}
|
||||
|
||||
@@ -4856,7 +4856,13 @@ static void P_Boss7Thinker(mobj_t *mobj)
|
||||
continue;
|
||||
|
||||
mo2 = (mobj_t *)th;
|
||||
if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum)
|
||||
|
||||
if (mo2->type != MT_BOSS3WAYPOINT)
|
||||
continue;
|
||||
if (!mo2->spawnpoint)
|
||||
continue;
|
||||
|
||||
if ((mo2->spawnpoint->options & 7) == waypointNum)
|
||||
{
|
||||
hitspot = mo2;
|
||||
break;
|
||||
@@ -5699,9 +5705,6 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
|
||||
if (!dest || dest->health <= 0 || !dest->player || !source->tracer)
|
||||
return;
|
||||
|
||||
// change angle
|
||||
//source->angle = R_PointToAngle2(source->x, source->y, tx, ty);
|
||||
|
||||
// change slope
|
||||
dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z);
|
||||
|
||||
|
||||
+2
-2
@@ -3339,10 +3339,10 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
|
||||
case 6: // Death Pit (Camera Tilt)
|
||||
case 7: // Death Pit (No Camera Tilt)
|
||||
if (roversector || P_MobjReadyToTrigger(player->mo, sector))
|
||||
P_DamageMobj(player->mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL);
|
||||
break;
|
||||
case 8: // Instant Kill
|
||||
P_DamageMobj(player->mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL);
|
||||
break;
|
||||
case 9: // Ring Drainer (Floor Touch)
|
||||
case 10: // Ring Drainer (No Floor Touch)
|
||||
|
||||
+1
-1
@@ -670,7 +670,7 @@ void P_Ticker(boolean run)
|
||||
if (!players[i].mo)
|
||||
continue;
|
||||
|
||||
P_DamageMobj(players[i].mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(players[i].mo, NULL, NULL, DMG_INSTAKILL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-6
@@ -362,7 +362,6 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor)
|
||||
if (inflictor)
|
||||
{
|
||||
ang = R_PointToAngle2(inflictor->x, inflictor->y, player->mo->x, player->mo->y); // SRB2kart
|
||||
//ang = R_PointToAngle2(inflictor->x-inflictor->momx, inflictor->y - inflictor->momy, player->mo->x - player->mo->momx, player->mo->y - player->mo->momy);
|
||||
|
||||
// explosion and rail rings send you farther back, making it more difficult
|
||||
// to recover
|
||||
@@ -2485,7 +2484,7 @@ static void P_MovePlayer(player_t *player)
|
||||
&& !(player->mo->flags & MF_NOCLIP))
|
||||
{
|
||||
if ((netgame || multiplayer) && player->spectator)
|
||||
P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators
|
||||
P_DamageMobj(player->mo, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators
|
||||
else
|
||||
{
|
||||
K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished.
|
||||
@@ -2676,9 +2675,6 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius)
|
||||
if (mo->flags & MF_MONITOR)
|
||||
continue; // Monitors cannot be 'nuked'.
|
||||
|
||||
//if (!G_BattleGametype() && mo->type == MT_PLAYER)
|
||||
// continue; // Don't hurt players in Co-Op!
|
||||
|
||||
if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius)
|
||||
continue; // Workaround for possible integer overflow in the below -Red
|
||||
|
||||
@@ -4294,7 +4290,7 @@ void P_DoTimeOver(player_t *player)
|
||||
if (player->mo)
|
||||
{
|
||||
S_StopSound(player->mo);
|
||||
P_DamageMobj(player->mo, NULL, NULL, 10000);
|
||||
P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL);
|
||||
}
|
||||
|
||||
player->lives = 0;
|
||||
|
||||
Reference in new issue
Block a user