From 2b4ed0eaf32211102cf21fd51039da67f9a1a2e5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Nov 2021 22:43:59 +0100 Subject: [PATCH] - PlayerCheckDeath --- source/games/sw/src/game.h | 2 +- source/games/sw/src/player.cpp | 27 +++--- source/games/sw/src/sector.cpp | 4 +- source/games/sw/src/weapon.cpp | 103 +++++++++++------------ source/games/sw/src/weapon.h | 4 +- wadsrc/static/zscript/games/sw/swgame.zs | 2 +- 6 files changed, 70 insertions(+), 72 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index d6d9f4509..6a2a6e2cc 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -745,6 +745,7 @@ struct PLAYERstruct DSWActor* remoteActor; DSWActor* PlayerUnderActor; DSWActor* KillerActor; //who killed me + DSWActor* HitBy; // SpriteNum of whatever player was last hit by // interpolation int oposx, oposy, oposz; @@ -910,7 +911,6 @@ struct PLAYERstruct bool NukeInitialized; // Nuke already has counted down short FistAng; // KungFu attack angle uint8_t WpnKungFuMove; // KungFu special moves - short HitBy; // SpriteNum of whatever player was last hit by short Reverb; // Player's current reverb setting short Heads; // Number of Accursed Heads orbiting player int PlayerVersion; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 1e7f86759..cd9271098 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1417,7 +1417,7 @@ void DoPlayerWarpTeleporter(PLAYERp pp) { PlayerUpdateHealth(npp, -npp->Actor()->u()->Health); // Make sure he dies! // telefraged by teleporting player - PlayerCheckDeath(npp, pp->PlayerSprite); + PlayerCheckDeath(npp, pp->Actor()); } } } @@ -1940,7 +1940,7 @@ void DoPlayerSlide(PLAYERp pp) if (!TEST(pp->Flags, PF_DEAD)) { PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -1955,7 +1955,7 @@ void DoPlayerSlide(PLAYERp pp) if (!TEST(pp->Flags, PF_DEAD)) { PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -2104,7 +2104,7 @@ void DoPlayerMove(PLAYERp pp) if (!TEST(pp->Flags, PF_DEAD)) { PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -2131,7 +2131,7 @@ void DoPlayerMove(PLAYERp pp) if (!TEST(pp->Flags, PF_DEAD)) { PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -2520,8 +2520,7 @@ void DriveCrush(PLAYERp pp, int *x, int *y) damage = -(u->Health + 100); PlayerDamageSlide(u->PlayerP, damage, pp->angle.ang.asbuild()); PlayerUpdateHealth(u->PlayerP, damage); - //PlayerCheckDeath(u->PlayerP, -1); - PlayerCheckDeath(u->PlayerP, pp->PlayerSprite); + PlayerCheckDeath(u->PlayerP, pp->Actor()); } } @@ -3130,7 +3129,7 @@ void DoPlayerFall(PLAYERp pp) u->Health = 0; } - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -4466,7 +4465,7 @@ void DoPlayerDive(PLAYERp pp) //PlayerUpdateHealth(pp, PLAYER_DIVE_DAMAGE_AMOUNT); PlayerSound(DIGI_WANGDROWNING, v3df_dontpan|v3df_follow, pp); PlayerUpdateHealth(pp, -3 -(RandomRange(7<<8)>>8)); - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; } @@ -4634,7 +4633,7 @@ int DoPlayerTestPlaxDeath(PLAYERp pp) if (pp->lo_sectp && TEST(pp->lo_sectp->floorstat, FLOOR_STAT_PLAX)) { PlayerUpdateHealth(pp, -u->Health); - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); return true; } @@ -4661,7 +4660,7 @@ void DoPlayerCurrent(PLAYERp pp) USERp u = pp->Actor()->u(); PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -4678,7 +4677,7 @@ void DoPlayerCurrent(PLAYERp pp) USERp u = pp->Actor()->u(); PlayerUpdateHealth(pp, -u->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; @@ -5428,7 +5427,7 @@ char *KilledPlayerMessage(PLAYERp pp, PLAYERp killer) const char *p1 = pp->PlayerName; const char *p2 = killer->PlayerName; - if (pp->HitBy == killer->PlayerSprite) + if (pp->HitBy == killer->Actor()) { sprintf(ds,"%s was killed by %s.",p1,p2); return ds; @@ -6670,7 +6669,7 @@ void PlayerGlobal(PLAYERp pp) ////DSPRINTF(ds,"Squish diff %d, min %d, cz %d, fz %d, lo %d, hi %d",labs(pp->loz - pp->hiz)>>8,min_height>>8, pp->ceiling_dist>>8, pp->floor_dist>>8,pp->lo_sectp-sector,pp->hi_sectp-sector); //MONO_PRINT(ds); PlayerUpdateHealth(pp, -pp->Actor()->u()->Health); // Make sure he dies! - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); if (TEST(pp->Flags, PF_DEAD)) return; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 56c6cfdec..0c58806a4 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -67,7 +67,7 @@ bool TestVatorMatchActive(short match); bool TestSpikeMatchActive(short match); bool TestRotatorMatchActive(short match); bool TestSlidorMatchActive(short match); -int PlayerCheckDeath(PLAYERp, short); +int PlayerCheckDeath(PLAYERp, DSWActor*); void DoVatorOperate(PLAYERp, short); void DoVatorMatch(PLAYERp pp, short match); void DoRotatorOperate(PLAYERp, short); @@ -2131,7 +2131,7 @@ short PlayerTakeSectorDamage(PLAYERp pp) u->DamageTics = DAMAGE_TIME; PlayerUpdateHealth(pp, -sectu->damage); - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); } return 0; } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 8ac165458..88317b30e 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5507,15 +5507,14 @@ RadiusGetDamage(short SpriteNum, short Weapon, int max_damage) } -int -PlayerCheckDeath(PLAYERp pp, short Weapon) +int PlayerCheckDeath(PLAYERp pp, DSWActor* weapActor) { SPRITEp sp = &pp->Actor()->s(); USERp u = pp->Actor()->u(); // Store off what player was struck by - pp->HitBy = Weapon; + pp->HitBy = weapActor; if (u->Health <= 0 && !TEST(pp->Flags, PF_DEAD)) { @@ -5528,24 +5527,23 @@ PlayerCheckDeath(PLAYERp pp, short Weapon) else pp->DeathType = PLAYER_DEATH_FLIP; - if (Weapon < 0) + if (weapActor == nullptr) { - pp->KillerActor = nullptr;; + pp->KillerActor = nullptr; DoPlayerBeginDie(pp); return true; } - auto weapActor = &swActors[Weapon]; SPRITEp wp = &weapActor->s(); USERp wu = weapActor->u(); - if (Weapon > -1 && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) + if (weapActor != nullptr && (wu->ID == RIPPER_RUN_R0 || wu->ID == RIPPER2_RUN_R0)) pp->DeathType = PLAYER_DEATH_RIPPER; - if (Weapon > -1 && wu->ID == CALTROPS) + if (weapActor != nullptr && wu->ID == CALTROPS) pp->DeathType = PLAYER_DEATH_FLIP; - if (Weapon > -1 && wu->ID == NINJA_RUN_R0 && wu->PlayerP) + if (weapActor != nullptr && wu->ID == NINJA_RUN_R0 && wu->PlayerP) { pp->DeathType = PLAYER_DEATH_FLIP; wu->PlayerP->Bloody = true; @@ -5753,7 +5751,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, weapActor->GetSpriteIndex()); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -5823,7 +5821,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -5857,7 +5855,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -5887,7 +5885,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -5917,7 +5915,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -5947,7 +5945,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - if (PlayerCheckDeath(u->PlayerP, Weapon)) + if (PlayerCheckDeath(u->PlayerP, weapActor)) { PlaySound(DIGI_RIPPERHEARTOUT,u->PlayerP,v3df_dontpan|v3df_doppler); @@ -5981,7 +5979,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - if (PlayerCheckDeath(u->PlayerP, Weapon)) + if (PlayerCheckDeath(u->PlayerP, weapActor)) { PlaySound(DIGI_RIPPERHEARTOUT,u->PlayerP,v3df_dontpan|v3df_doppler); @@ -6016,7 +6014,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - if (PlayerCheckDeath(u->PlayerP, Weapon)) + if (PlayerCheckDeath(u->PlayerP, weapActor)) { DoBunnyRipHeart(weapActor); } @@ -6047,7 +6045,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6087,7 +6085,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } } @@ -6124,7 +6122,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -6158,7 +6156,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -6191,7 +6189,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6222,7 +6220,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6258,7 +6256,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -6307,7 +6305,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -6356,7 +6354,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6383,7 +6381,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6408,7 +6406,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6442,7 +6440,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -6482,7 +6480,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6512,7 +6510,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6545,7 +6543,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6576,7 +6574,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6607,7 +6605,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - if (PlayerCheckDeath(u->PlayerP, Weapon)) + if (PlayerCheckDeath(u->PlayerP, weapActor)) { // degrade blood worm life wu->Counter3 += (4*120)/MISSILEMOVETICS; @@ -6644,7 +6642,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6681,7 +6679,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6717,7 +6715,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6750,7 +6748,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6789,7 +6787,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6828,7 +6826,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6856,7 +6854,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6881,7 +6879,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6915,7 +6913,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6946,7 +6944,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -6979,7 +6977,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } if (u->PlayerP->Armor) PlaySound(DIGI_ARMORHIT,u->PlayerP,v3df_dontpan|v3df_follow|v3df_doppler); @@ -7010,7 +7008,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (PlayerTakeDamage(u->PlayerP, weapActor)) { PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -7037,7 +7035,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) PlayerSound(DIGI_GASHURT, v3df_dontpan|v3df_follow|v3df_doppler,pp); PlayerUpdateHealth(u->PlayerP, damage-1000); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -7063,7 +7061,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) else if (u->PlayerP) { //PlayerUpdateHealth(u->PlayerP, damage); - //PlayerCheckDeath(u->PlayerP, Weapon); + //PlayerCheckDeath(u->PlayerP, weapActor); } else { @@ -7105,7 +7103,7 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) if (RANDOM_P2(1024<<4)>>4 < 800) PlayerSound(DIGI_STEPONCALTROPS, v3df_follow|v3df_dontpan, u->PlayerP); PlayerUpdateHealth(u->PlayerP, damage); - PlayerCheckDeath(u->PlayerP, Weapon); + PlayerCheckDeath(u->PlayerP, weapActor); } } else @@ -7172,9 +7170,10 @@ int DoDamage(DSWActor* actor, DSWActor* weapActor) } // Select death text based on ID -const char *DeathString(short SpriteNum) +const char *DeathString(DSWActor* actor) { - USERp ku = User[SpriteNum].Data(); + if (!actor->hasU()) return " "; + USERp ku = actor->u(); switch (ku->ID) { @@ -12985,7 +12984,7 @@ int InitFistAttack(PLAYERp pp) if (PlayerTakeDamage(pp, nullptr)) { PlayerUpdateHealth(pp, -(RandomRange(2<<8)>>8)); - PlayerCheckDeath(pp, -1); + PlayerCheckDeath(pp, nullptr); } } } diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 83d0234a1..92f324868 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -92,7 +92,7 @@ bool MissileSetPos(DSWActor*,ANIMATORp DoWeapon,int dist); int ActorPain(short SpriteNum); int SpawnBreakFlames(DSWActor*); bool PlayerTakeDamage(PLAYERp pp, DSWActor* weapActor); -const char *DeathString(short SpriteNum); +const char *DeathString(DSWActor*); // // Damage Amounts defined in damage.h @@ -233,7 +233,7 @@ void SpriteQueueDelete(DSWActor* actor); int HelpMissileLateral(DSWActor*, int dist); void AddSpriteToSectorObject(DSWActor*,SECTOR_OBJECTp sop); void QueueReset(void); -int PlayerCheckDeath(PLAYERp pp,short Weapon); +int PlayerCheckDeath(PLAYERp pp,DSWActor*); bool SpriteWarpToUnderwater(DSWActor* actor); int PlayerDamageSlide(PLAYERp pp,int damage,short ang); bool VehicleMoveHit(DSWActor*); diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index a4f7f15d9..f18aa755c 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -307,7 +307,7 @@ struct SWPlayer native native bool NukeInitialized; // Nuke already has counted down native int16 FistAng; // KungFu attack angle native uint8 WpnKungFuMove; // KungFu special moves - native int16 HitBy; // SpriteNum of whatever player was last hit by + //native int16 HitBy; // SpriteNum of whatever player was last hit by native int16 Reverb; // Player's current reverb setting native int16 Heads; // Number of Accursed Heads orbiting player native int PlayerVersion;