- PLAYER::Killer

This commit is contained in:
Christoph Oelckers 2021-11-01 22:17:41 +01:00
parent f2058933ed
commit ba4b5bbbcb
7 changed files with 28 additions and 28 deletions

View file

@ -483,7 +483,7 @@ void TerminateLevel(void)
memset(pp->Wpn, 0, sizeof(pp->Wpn));
memset(pp->InventoryTics, 0, sizeof(pp->InventoryTics));
pp->Killer = -1;
pp->KillerActor = nullptr;;
INITLIST(&pp->PanelSpriteList);
}

View file

@ -780,6 +780,8 @@ struct PLAYERstruct
DSWActor* lowActor, * highActor;
DSWActor* remoteActor;
DSWActor* PlayerUnderActor;
DSWActor* KillerActor; //who killed me
// interpolation
int oposx, oposy, oposz;
@ -837,7 +839,6 @@ struct PLAYERstruct
// under vars are for wading and swimming
short PlayerSprite;
SPRITEp SpriteP;
DSWActor* PlayerUnderActor;
short pnum; // carry along the player number
@ -905,7 +906,6 @@ struct PLAYERstruct
// Death stuff
uint16_t DeathType;
short Kills;
short Killer; //who killed me
short KilledPlayer[MAX_SW_PLAYERS_REG];
short SecretsFound;

View file

@ -2191,7 +2191,7 @@ void PlayerLevelReset(PLAYERp pp)
//pp->Armor = 0;
//PlayerUpdateArmor(pp, 0);
pp->Kills = 0;
pp->Killer = -1;
pp->KillerActor = nullptr;;
pp->NightVision = false;
pp->StartColor = 0;
pp->FadeAmt = 0;
@ -2257,7 +2257,7 @@ void PlayerDeathReset(PLAYERp pp)
puser[pp->pnum].Health = u->Health;
pp->Armor = 0;
PlayerUpdateArmor(pp, 0);
pp->Killer = -1;
pp->KillerActor = nullptr;;
pp->NightVision = false;
pp->StartColor = 0;
pp->FadeAmt = 0;
@ -2336,7 +2336,7 @@ void PlayerGameReset(PLAYERp pp)
PlayerUpdateHealth(pp, 500);
pp->Armor = 0;
PlayerUpdateArmor(pp, 0);
pp->Killer = -1;
pp->KillerActor = nullptr;;
if (pp == Player+screenpeek)
{

View file

@ -5577,9 +5577,9 @@ void DoPlayerBeginDie(PLAYERp pp)
if (numplayers > 1)
{
// Give kill credit to player if necessary
if (pp->Killer >= 0)
if (pp->KillerActor != nullptr)
{
USERp ku = User[pp->Killer].Data();
USERp ku = pp->KillerActor->u();
ASSERT(ku);
@ -5832,9 +5832,9 @@ void DoPlayerDeathFollowKiller(PLAYERp pp)
}
// follow what killed you if its available
if (pp->Killer > -1)
if (pp->KillerActor != nullptr)
{
SPRITEp kp = &sprite[pp->Killer];
SPRITEp kp = &pp->KillerActor->s();
if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum))
{
@ -5942,20 +5942,19 @@ SPRITEp DoPlayerDeathCheckKick(PLAYERp pp)
{
SPRITEp sp = &pp->Actor()->s(), hp;
USERp u = pp->Actor()->u(), hu;
int i;
unsigned stat;
int dist;
int a,b,c;
for (stat = 0; stat < SIZ(StatDamageList); stat++)
{
StatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0)
SWStatIterator it(StatDamageList[stat]);
while (auto itActor = it.Next())
{
hp = &sprite[i];
hu = User[i].Data();
hp = &itActor->s();
hu = itActor->u();
if (i == pp->PlayerSprite)
if (itActor == pp->Actor())
break;
// don't set off mine
@ -5966,7 +5965,7 @@ SPRITEp DoPlayerDeathCheckKick(PLAYERp pp)
if (unsigned(dist) < hu->Radius + 100)
{
pp->Killer = i;
pp->KillerActor = itActor;
u->slide_ang = getangle(sp->x - hp->x, sp->y - hp->y);
u->slide_ang = NORM_ANGLE(u->slide_ang + (RANDOM_P2(128<<5)>>5) - 64);
@ -6908,7 +6907,7 @@ void InitAllPlayers(void)
pp->oldposx = 0;
pp->oldposy = 0;
pp->climb_ndx = 10;
pp->Killer = -1;
pp->KillerActor = nullptr;;
pp->Kills = 0;
pp->bcnt = 0;
pp->UziShellLeftAlt = 0;

View file

@ -550,7 +550,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
("DiveDamageTics", w.DiveDamageTics)
("DeathType", w.DeathType)
("Kills", w.Kills)
("Killer", w.Killer)
("Killer", w.KillerActor)
.Array("KilledPlayer", w.KilledPlayer, countof(w.KilledPlayer))
("SecretsFound", w.SecretsFound)
("Armor", w.Armor)

View file

@ -707,11 +707,11 @@ void KillSprite(int16_t SpriteNum)
{
pp = Player + pnum;
if (pp->Killer > -1)
if (pp->KillerActor != nullptr)
{
if (pp->Killer == SpriteNum)
if (pp->KillerActor == actor)
{
pp->Killer = -1;
pp->KillerActor = nullptr;;
}
}
}

View file

@ -5691,13 +5691,14 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
if (Weapon < 0)
{
pp->Killer = -1;
pp->KillerActor = nullptr;;
DoPlayerBeginDie(pp);
return true;
}
SPRITEp wp = &sprite[Weapon];
USERp wu = User[Weapon].Data();
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))
pp->DeathType = PLAYER_DEATH_RIPPER;
@ -5713,12 +5714,12 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
// keep track of who killed you for death purposes
// need to check all Killer variables when an enemy dies
if (pp->Killer < 0)
if (pp->KillerActor == nullptr)
{
if (wp->owner >= 0)
pp->Killer = wp->owner;
pp->KillerActor = GetOwner(weapActor);
else if (TEST(wp->extra, SPRX_PLAYER_OR_ENEMY))
pp->Killer = Weapon;
pp->KillerActor = weapActor;
}
// start the death process