From 272bfd44b65ab79dc58422a56e8ef035da9c5784 Mon Sep 17 00:00:00 2001 From: James Haley Date: Thu, 3 Feb 2011 05:38:47 +0000 Subject: Verified various changes in a second sweep through IDA. Fixes: * P_NightmareRespawn fog z and flags restoration * P_MobjThinker respawn time and NOTDMATCH exception * P_RemoveMobj/P_RespawnSpecials timing * P_SpawnBlood order-of-evaluation fix Subversion-branch: /branches/strife-branch Subversion-revision: 2243 --- src/strife/p_mobj.c | 514 ++++++++++++++++++++++++++++------------------------ 1 file changed, 277 insertions(+), 237 deletions(-) diff --git a/src/strife/p_mobj.c b/src/strife/p_mobj.c index b2af4c07..eacb6c2a 100644 --- a/src/strife/p_mobj.c +++ b/src/strife/p_mobj.c @@ -47,6 +47,8 @@ void P_SpawnMapThing (mapthing_t* mthing); // P_SetMobjState // Returns true if the mobj is still present. // +// [STRIFE] Verified unmodified +// int test; boolean @@ -84,7 +86,9 @@ P_SetMobjState // -// P_ExplodeMissile +// P_ExplodeMissile +// +// [STRIFE] Removed randomization of deathstate tics // void P_ExplodeMissile (mobj_t* mo) { @@ -93,84 +97,88 @@ void P_ExplodeMissile (mobj_t* mo) P_SetMobjState (mo, mobjinfo[mo->type].deathstate); // villsa [STRIFE] unused - /*mo->tics -= P_Random()&3; + /* + mo->tics -= P_Random()&3; if (mo->tics < 1) - mo->tics = 1;*/ + mo->tics = 1; + */ mo->flags &= ~MF_MISSILE; if (mo->info->deathsound) - S_StartSound (mo, mo->info->deathsound); + S_StartSound (mo, mo->info->deathsound); } // -// P_XYMovement +// P_XYMovement // -#define STOPSPEED 0x1000 -#define FRICTION 0xe800 +#define STOPSPEED 0x1000 +#define FRICTION 0xe800 void P_XYMovement (mobj_t* mo) -{ - fixed_t ptryx; - fixed_t ptryy; - player_t* player; - fixed_t xmove; - fixed_t ymove; +{ + fixed_t ptryx; + fixed_t ptryy; + player_t* player; + fixed_t xmove; + fixed_t ymove; // villsa [STRIFE] unused - /*if (!mo->momx && !mo->momy) + /* + if (!mo->momx && !mo->momy) { - if (mo->flags & MF_SKULLFLY) - { - // the skull slammed into something - mo->flags &= ~MF_SKULLFLY; - mo->momx = mo->momy = mo->momz = 0; + if (mo->flags & MF_SKULLFLY) + { + // the skull slammed into something + mo->flags &= ~MF_SKULLFLY; + mo->momx = mo->momy = mo->momz = 0; + + P_SetMobjState (mo, mo->info->spawnstate); + } + return; + } + */ - P_SetMobjState (mo, mo->info->spawnstate); - } - return; - }*/ - player = mo->player; - + if (mo->momx > MAXMOVE) - mo->momx = MAXMOVE; + mo->momx = MAXMOVE; else if (mo->momx < -MAXMOVE) - mo->momx = -MAXMOVE; + mo->momx = -MAXMOVE; if (mo->momy > MAXMOVE) - mo->momy = MAXMOVE; + mo->momy = MAXMOVE; else if (mo->momy < -MAXMOVE) - mo->momy = -MAXMOVE; - + mo->momy = -MAXMOVE; + xmove = mo->momx; ymove = mo->momy; - + do { - if (xmove > MAXMOVE/2 || ymove > MAXMOVE/2) - { - ptryx = mo->x + xmove/2; - ptryy = mo->y + ymove/2; - xmove >>= 1; - ymove >>= 1; - } - else - { - ptryx = mo->x + xmove; - ptryy = mo->y + ymove; - xmove = ymove = 0; - } - - if (!P_TryMove (mo, ptryx, ptryy)) - { - // blocked move - if (mo->player) - { // try to slide along it - P_SlideMove (mo); - } + if (xmove > MAXMOVE/2 || ymove > MAXMOVE/2) + { + ptryx = mo->x + xmove/2; + ptryy = mo->y + ymove/2; + xmove >>= 1; + ymove >>= 1; + } + else + { + ptryx = mo->x + xmove; + ptryy = mo->y + ymove; + xmove = ymove = 0; + } + + if (!P_TryMove (mo, ptryx, ptryy)) + { + // blocked move + if (mo->player) + { // try to slide along it + P_SlideMove (mo); + } // villsa [STRIFE] check for bouncy missiles else if(mo->flags & MF_BOUNCE) { @@ -182,78 +190,78 @@ void P_XYMovement (mobj_t* mo) else mo->momx = -mo->momx; - xmove = 0; ymove = 0; } - else if (mo->flags & MF_MISSILE) - { - // explode a missile - if (ceilingline && - ceilingline->backsector && - ceilingline->backsector->ceilingpic == skyflatnum) - { - // Hack to prevent missiles exploding - // against the sky. - // Does not handle sky floors. - P_RemoveMobj (mo); - return; - } - P_ExplodeMissile (mo); - } - else - mo->momx = mo->momy = 0; - } + else if (mo->flags & MF_MISSILE) + { + // explode a missile + if (ceilingline && + ceilingline->backsector && + ceilingline->backsector->ceilingpic == skyflatnum) + { + // Hack to prevent missiles exploding + // against the sky. + // Does not handle sky floors. + P_RemoveMobj (mo); + return; + } + P_ExplodeMissile (mo); + } + else + mo->momx = mo->momy = 0; + } } while (xmove || ymove); // slow down if (player && player->cheats & CF_NOMOMENTUM) { - // debug option for no sliding at all - mo->momx = mo->momy = 0; - return; + // debug option for no sliding at all + mo->momx = mo->momy = 0; + return; } - if (mo->flags & (MF_MISSILE | MF_BOUNCE) ) // villsa [STRIFE] replace skullfly flag with MF_BOUNCE - return; // no friction for missiles ever - + // villsa [STRIFE] replace skullfly flag with MF_BOUNCE + if (mo->flags & (MF_MISSILE | MF_BOUNCE) ) + return; // no friction for missiles ever + if (mo->z > mo->floorz) - return; // no friction when airborne + return; // no friction when airborne if (mo->flags & MF_CORPSE) { - // do not stop sliding - // if halfway off a step with some momentum - if (mo->momx > FRACUNIT/4 - || mo->momx < -FRACUNIT/4 - || mo->momy > FRACUNIT/4 - || mo->momy < -FRACUNIT/4) - { - if (mo->floorz != mo->subsector->sector->floorheight) - return; - } + // do not stop sliding + // if halfway off a step with some momentum + if (mo->momx > FRACUNIT/4 + || mo->momx < -FRACUNIT/4 + || mo->momy > FRACUNIT/4 + || mo->momy < -FRACUNIT/4) + { + if (mo->floorz != mo->subsector->sector->floorheight) + return; + } } if (mo->momx > -STOPSPEED - && mo->momx < STOPSPEED - && mo->momy > -STOPSPEED - && mo->momy < STOPSPEED - && (!player - || (player->cmd.forwardmove== 0 - && player->cmd.sidemove == 0 ) ) ) + && mo->momx < STOPSPEED + && mo->momy > -STOPSPEED + && mo->momy < STOPSPEED + && (!player + || (player->cmd.forwardmove == 0 + && player->cmd.sidemove == 0 ) ) ) { - // if in a walking frame, stop moving - // villsa [STRIFE] TODO - verify - if ( player&&(unsigned)((player->mo->state - states)- S_PLAY_01) < 4) - P_SetMobjState (player->mo, S_PLAY_00); - - mo->momx = 0; - mo->momy = 0; + // if in a walking frame, stop moving + // villsa [STRIFE]: different player state (haleyjd - verified 02/02/11) + if ( player&&(unsigned)((player->mo->state - states) - S_PLAY_01) < 4) + P_SetMobjState (player->mo, S_PLAY_00); + + mo->momx = 0; + mo->momy = 0; } else { - mo->momx = FixedMul (mo->momx, FRICTION); - mo->momy = FixedMul (mo->momy, FRICTION); + mo->momx = FixedMul (mo->momx, FRICTION); + mo->momy = FixedMul (mo->momy, FRICTION); } } @@ -440,57 +448,69 @@ void P_ZMovement (mobj_t* mo) // // P_NightmareRespawn // +// [STRIFE] Modifications for: +// * Destination fog z coordinate +// * Restoration of all Strife mapthing flags +// void P_NightmareRespawn (mobj_t* mobj) { - fixed_t x; - fixed_t y; - fixed_t z; - subsector_t* ss; - mobj_t* mo; - mapthing_t* mthing; - + fixed_t x; + fixed_t y; + fixed_t z; + mobj_t* mo; + mapthing_t* mthing; + x = mobj->spawnpoint.x << FRACBITS; y = mobj->spawnpoint.y << FRACBITS; // somthing is occupying it's position? if (!P_CheckPosition (mobj, x, y) ) - return; // no respwan + return; // no respwan // spawn a teleport fog at old spot // because of removal of the body? mo = P_SpawnMobj (mobj->x, - mobj->y, - mobj->subsector->sector->floorheight , MT_TFOG); + mobj->y, + mobj->subsector->sector->floorheight , MT_TFOG); // initiate teleport sound S_StartSound (mo, sfx_telept); // spawn a teleport fog at the new spot - ss = R_PointInSubsector (x,y); + //ss = R_PointInSubsector (x,y); - mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_TFOG); + // haleyjd [STRIFE]: Uses ONFLOORZ instead of ss->sector->floorheight + mo = P_SpawnMobj (x, y, ONFLOORZ , MT_TFOG); S_StartSound (mo, sfx_telept); // spawn the new monster mthing = &mobj->spawnpoint; - + // spawn it if (mobj->info->flags & MF_SPAWNCEILING) - z = ONCEILINGZ; + z = ONCEILINGZ; else - z = ONFLOORZ; + z = ONFLOORZ; // inherit attributes from deceased one mo = P_SpawnMobj (x,y,z, mobj->type); - mo->spawnpoint = mobj->spawnpoint; + mo->spawnpoint = mobj->spawnpoint; mo->angle = ANG45 * (mthing->angle/45); if (mthing->options & MTF_AMBUSH) - mo->flags |= MF_AMBUSH; + mo->flags |= MF_AMBUSH; + if (mthing->options & MTF_STAND) // [STRIFE] Standing mode, for NPCs + mobj->flags |= MF_STAND; + if (mthing->options & MTF_FRIEND) // [STRIFE] Allies + mobj->flags |= MF_ALLY; + if (mthing->options & MTF_TRANSLUCENT) // [STRIFE] Translucent object + mobj->flags |= MF_SHADOW; + if (mthing->options & MTF_MVIS) // [STRIFE] Alt. Translucency + mobj->flags |= MF_MVIS; mo->reactiontime = 18; - + // remove the old monster, P_RemoveMobj (mobj); } @@ -499,20 +519,25 @@ P_NightmareRespawn (mobj_t* mobj) // // P_MobjThinker // +// [STRIFE] Modified for: +// * Terrain effects +// * Stonecold cheat +// * Altered skill 5 respawn behavior +// void P_MobjThinker (mobj_t* mobj) { // momentum movement if (mobj->momx - || mobj->momy - /*|| (mobj->flags&MF_SKULLFLY)*/ ) // villsa [STRIFE] unused + || mobj->momy + /*|| (mobj->flags&MF_SKULLFLY)*/ ) // villsa [STRIFE] unused { - P_XYMovement (mobj); + P_XYMovement (mobj); - // FIXME: decent NOP/NULL/Nil function pointer please. - if (mobj->thinker.function.acv == (actionf_v) (-1)) - return; // mobj was removed + // FIXME: decent NOP/NULL/Nil function pointer please. + if (mobj->thinker.function.acv == (actionf_v) (-1)) + return; // mobj was removed - // villsa [STRIFE] + // villsa [STRIFE] terrain clipping if(P_GetTerrainType(mobj) == FLOOR_SOLID) mobj->flags &= ~MF_FEETCLIPPED; else @@ -520,22 +545,22 @@ void P_MobjThinker (mobj_t* mobj) } if ( (mobj->z != mobj->floorz && !(mobj->flags & MF_NOGRAVITY)) // villsa [STRIFE] - || mobj->momz ) + || mobj->momz ) { - P_ZMovement (mobj); - - // FIXME: decent NOP/NULL/Nil function pointer please. - if (mobj->thinker.function.acv == (actionf_v) (-1)) - return; // mobj was removed + P_ZMovement (mobj); - // villsa [STRIFE] + // FIXME: decent NOP/NULL/Nil function pointer please. + if (mobj->thinker.function.acv == (actionf_v) (-1)) + return; // mobj was removed + + // villsa [STRIFE] terrain clipping and sounds if(P_GetTerrainType(mobj) == FLOOR_SOLID) - mobj->flags &= ~MF_FEETCLIPPED; - else - { - S_StartSound(mobj, sfx_wsplsh); - mobj->flags |= MF_FEETCLIPPED; - } + mobj->flags &= ~MF_FEETCLIPPED; + else + { + S_StartSound(mobj, sfx_wsplsh); + mobj->flags |= MF_FEETCLIPPED; + } } @@ -544,7 +569,7 @@ void P_MobjThinker (mobj_t* mobj) // calling action functions at transitions if (mobj->tics != -1) { - mobj->tics--; + mobj->tics--; // villsa [STRIFE] stonecold cheat if(stonecold) @@ -552,41 +577,47 @@ void P_MobjThinker (mobj_t* mobj) if(mobj->flags & MF_COUNTKILL) P_DamageMobj(mobj, mobj, mobj, 10); } - - // you can cycle through multiple states in a tic - if (!mobj->tics) - if (!P_SetMobjState (mobj, mobj->state->nextstate) ) - return; // freed itself + + // you can cycle through multiple states in a tic + if (!mobj->tics) + if (!P_SetMobjState (mobj, mobj->state->nextstate) ) + return; // freed itself } else { - // check for nightmare respawn - if (! (mobj->flags & MF_COUNTKILL) ) - return; + // check for nightmare respawn + if (! (mobj->flags & MF_COUNTKILL) ) + return; - if (!respawnmonsters) - return; + if (!respawnmonsters) + return; - mobj->movecount++; + mobj->movecount++; - if (mobj->movecount < 12*TICRATE) - return; + // haleyjd [STRIFE]: respawn time increased from 12 to 16 + if (mobj->movecount < 16*TICRATE) + return; - if ( leveltime&31 ) - return; + if ( leveltime&31 ) + return; - if (P_Random () > 4) - return; + if (P_Random () > 4) + return; - P_NightmareRespawn (mobj); - } + // haleyjd [STRIFE]: NOTDMATCH things don't respawn + if(mobj->flags & MF_NOTDMATCH) + return; + P_NightmareRespawn (mobj); + } } // // P_SpawnMobj // +// [STRIFE] Modifications to reactiontime and for terrain types. +// mobj_t* P_SpawnMobj ( fixed_t x, @@ -657,28 +688,29 @@ P_SpawnMobj // // P_RemoveMobj // -mapthing_t itemrespawnque[ITEMQUESIZE]; -int itemrespawntime[ITEMQUESIZE]; -int iquehead; -int iquetail; - +mapthing_t itemrespawnque[ITEMQUESIZE]; +int itemrespawntime[ITEMQUESIZE]; +int iquehead; +int iquetail; +// +// [STRIFE] Modifications to item respawn timing +// void P_RemoveMobj (mobj_t* mobj) { + // villsa [STRIFE] removed invuln/invis. sphere exceptions if ((mobj->flags & MF_SPECIAL) - && !(mobj->flags & MF_DROPPED) - /*&& (mobj->type != MT_INV) // villsa [STRIFE] unused - && (mobj->type != MT_INS)*/) + && !(mobj->flags & MF_DROPPED)) { - itemrespawnque[iquehead] = mobj->spawnpoint; - itemrespawntime[iquehead] = leveltime; - iquehead = (iquehead+1)&(ITEMQUESIZE-1); + itemrespawnque[iquehead] = mobj->spawnpoint; + itemrespawntime[iquehead] = leveltime + 30*TICRATE; // [STRIFE] + iquehead = (iquehead+1)&(ITEMQUESIZE-1); - // lose one off the end? - if (iquehead == iquetail) - iquetail = (iquetail+1)&(ITEMQUESIZE-1); + // lose one off the end? + if (iquehead == iquetail) + iquetail = (iquetail+1)&(ITEMQUESIZE-1); } - + // unlink from sector and block lists P_UnsetThingPosition (mobj); @@ -695,35 +727,37 @@ void P_RemoveMobj (mobj_t* mobj) // // P_RespawnSpecials // +// [STRIFE] modification to item respawn time handling +// void P_RespawnSpecials (void) { - fixed_t x; - fixed_t y; - fixed_t z; + fixed_t x; + fixed_t y; + fixed_t z; - subsector_t* ss; - mobj_t* mo; - mapthing_t* mthing; + subsector_t* ss; + mobj_t* mo; + mapthing_t* mthing; - int i; + int i; // only respawn items in deathmatch if (deathmatch != 2) - return; // + return; // nothing left to respawn? if (iquehead == iquetail) - return; + return; - // wait at least 30 seconds - if (leveltime - itemrespawntime[iquetail] < 30*TICRATE) - return; + // haleyjd [STRIFE]: 30 second wait is not accounted for here, see above. + if (leveltime < itemrespawntime[iquetail]) + return; mthing = &itemrespawnque[iquetail]; - + x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - + // spawn a teleport fog at the new spot ss = R_PointInSubsector (x,y); mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_IFOG); @@ -732,18 +766,18 @@ void P_RespawnSpecials (void) // find which type to spawn for (i=0 ; i< NUMMOBJTYPES ; i++) { - if (mthing->type == mobjinfo[i].doomednum) - break; + if (mthing->type == mobjinfo[i].doomednum) + break; } - + // spawn it if (mobjinfo[i].flags & MF_SPAWNCEILING) - z = ONCEILINGZ; + z = ONCEILINGZ; else - z = ONFLOORZ; + z = ONFLOORZ; mo = P_SpawnMobj (x,y,z, i); - mo->spawnpoint = *mthing; + mo->spawnpoint = *mthing; mo->angle = ANG45 * (mthing->angle/45); // pull it from the que @@ -772,7 +806,7 @@ void P_SpawnPlayer(mapthing_t* mthing) // not playing? if(!playeringame[mthing->type-1]) - return; + return; p = &players[mthing->type-1]; @@ -785,10 +819,10 @@ void P_SpawnPlayer(mapthing_t* mthing) mobj = P_SpawnMobj (x,y,z, MT_PLAYER); // set color translations for player sprites - if(mthing->type > 1) + if(mthing->type > 1) mobj->flags |= (mthing->type-1)<angle = ANG45 * (mthing->angle/45); + mobj->angle = ANG45 * (mthing->angle/45); mobj->player = p; mobj->health = p->health; @@ -810,11 +844,10 @@ void P_SpawnPlayer(mapthing_t* mthing) // villsa [STRIFE] what a nasty hack... if(gamemap == 10) - p->weaponowned[wp_sigil] = true; - + p->weaponowned[wp_sigil] = true; - // villsa [STRIFE] instead of giving cards in deathmatch mode, set - // accuracy to 50 and give all quest flags + // villsa [STRIFE] instead of just giving cards in deathmatch mode, also + // set accuracy to 50 and give all quest flags if(deathmatch) { int i; @@ -835,7 +868,7 @@ void P_SpawnPlayer(mapthing_t* mthing) // wake up the status bar ST_Start (); // wake up the heads up text - HU_Start (); + HU_Start (); } } @@ -847,12 +880,12 @@ void P_SpawnPlayer(mapthing_t* mthing) // void P_SpawnMapThing (mapthing_t* mthing) { - int i; - int bit; - mobj_t* mobj; - fixed_t x; - fixed_t y; - fixed_t z; + int i; + int bit; + mobj_t* mobj; + fixed_t x; + fixed_t y; + fixed_t z; // count deathmatch start positions if (mthing->type == 11) @@ -897,8 +930,8 @@ void P_SpawnMapThing (mapthing_t* mthing) bit = 1<<(gameskill-1); if (!(mthing->options & bit) ) - return; - + return; + // find which type to spawn for (i=0 ; i< NUMMOBJTYPES ; i++) if (mthing->type == mobjinfo[i].doomednum) @@ -917,7 +950,7 @@ void P_SpawnMapThing (mapthing_t* mthing) // don't spawn keycards and players in deathmatch if (deathmatch && mobjinfo[i].flags & MF_NOTDMATCH) return; - + // don't spawn any monsters if -nomonsters // villsa [STRIFE] Removed MT_SKULL if (nomonsters && (mobjinfo[i].flags & MF_COUNTKILL)) @@ -941,8 +974,10 @@ void P_SpawnMapThing (mapthing_t* mthing) totalkills++; // villsa [STRIFE] unused - /*if (mobj->flags & MF_COUNTITEM) - totalitems++;*/ + /* + if (mobj->flags & MF_COUNTITEM) + totalitems++; + */ mobj->angle = ANG45 * (mthing->angle/45); if (mthing->options & MTF_AMBUSH) @@ -978,13 +1013,13 @@ P_SpawnPuff mobj_t* th; int t = P_Random(); - z += ((t - P_Random())<<10); + z += ((t - P_Random()) << 10); // [STRIFE] Unused //th->momz = FRACUNIT; //th->tics -= P_Random()&3; - th = P_SpawnMobj (x,y,z, MT_STRIFEPUFF); // [STRIFE]: new type + th = P_SpawnMobj(x, y, z, MT_STRIFEPUFF); // [STRIFE]: new type // don't make punches spark on the wall // [STRIFE] Use a separate melee attack range for the player @@ -992,8 +1027,10 @@ P_SpawnPuff P_SetMobjState(th, S_POW2_00); // 141 // villsa [STRIFE] unused - /*if (th->tics < 1) - th->tics = 1;*/ + /* + if (th->tics < 1) + th->tics = 1; + */ } // @@ -1007,8 +1044,6 @@ mobj_t* P_SpawnSparkPuff(fixed_t x, fixed_t y, fixed_t z) return P_SpawnMobj(x, y, ((t - P_Random()) << 10) + z, MT_SPARKPUFF); } - - // // P_SpawnBlood // @@ -1020,24 +1055,27 @@ P_SpawnBlood int damage ) { mobj_t* th; - - z += ((P_Random()-P_Random())<<10); - th = P_SpawnMobj (x,y,z, MT_BLOOD_DEATH); + + int temp = P_Random(); + z += (temp - P_Random()) << 10; + th = P_SpawnMobj(x, y, z, MT_BLOOD_DEATH); th->momz = FRACUNIT*2; - //th->tics -= P_Random()&3; // villsa [STRIFE] unused - // villsa [STRIFE] unused - /*if (th->tics < 1) - th->tics = 1;*/ + /* + th->tics -= P_Random()&3; + + if (th->tics < 1) + th->tics = 1; + */ // villsa [STRIFE] different checks for damage range - if (damage >= 10 && damage <= 13) - P_SetMobjState (th,S_BLOD_00); - else if (damage < 10 && damage >= 7) - P_SetMobjState (th,S_BLOD_01); - else if (damage < 7) - P_SetMobjState (th,S_BLOD_02); + if(damage >= 10 && damage <= 13) + P_SetMobjState(th, S_BLOD_00); + else if(damage >= 7 && damage < 10) + P_SetMobjState(th, S_BLOD_01); + else if(damage < 7) + P_SetMobjState(th, S_BLOD_02); } @@ -1050,9 +1088,11 @@ P_SpawnBlood void P_CheckMissileSpawn (mobj_t* th) { // villsa [STRIFE] unused - /*th->tics -= P_Random()&3; + /* + th->tics -= P_Random()&3; if (th->tics < 1) - th->tics = 1;*/ + th->tics = 1; + */ // move a little forward so an angle can // be computed if it immediately explodes @@ -1061,7 +1101,7 @@ void P_CheckMissileSpawn (mobj_t* th) th->z += (th->momz>>1); if (!P_TryMove (th, th->x, th->y)) - P_ExplodeMissile (th); + P_ExplodeMissile (th); } // Certain functions assume that a mobj_t pointer is non-NULL, -- cgit v1.2.3