- zombie.cpp.

This commit is contained in:
Christoph Oelckers 2021-11-03 17:41:27 +01:00
parent 95c92153ad
commit aadbca8e5d
2 changed files with 34 additions and 55 deletions

View file

@ -45,7 +45,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS BEGIN_SW_NS
int SpawnZombie2(short); void SpawnZombie2(DSWActor*);
int move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int flordist, uint32_t cliptype, int numtics); int move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int flordist, uint32_t cliptype, int numtics);
void DoPlayerBeginDie(PLAYERp); void DoPlayerBeginDie(PLAYERp);
void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator); void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator);
@ -5657,7 +5657,6 @@ PlayerCheckDeath(PLAYERp pp, short Weapon)
{ {
SPRITEp sp = pp->SpriteP; SPRITEp sp = pp->SpriteP;
USERp u = User[pp->PlayerSprite].Data(); USERp u = User[pp->PlayerSprite].Data();
int SpawnZombie(PLAYERp pp, short);
// Store off what player was struck by // Store off what player was struck by
@ -12194,7 +12193,7 @@ DoBloodWorm(DSWActor* actor)
} }
} }
SpawnZombie2(Weapon); SpawnZombie2(actor);
KillActor(actor); KillActor(actor);
return true; return true;
} }

View file

@ -748,12 +748,10 @@ ACTOR_ACTION_SET ZombieActionSet =
nullptr nullptr
}; };
int int SetupZombie(DSWActor* actor)
SetupZombie(short SpriteNum)
{ {
auto actor = &swActors[SpriteNum]; SPRITEp sp = &actor->s();
SPRITEp sp = &sprite[SpriteNum]; USERp u = actor->u();
USERp u = User[SpriteNum].Data();
ANIMATOR DoActorDecide; ANIMATOR DoActorDecide;
u->Health = 100; u->Health = 100;
@ -774,30 +772,24 @@ SetupZombie(short SpriteNum)
return 0; return 0;
} }
int void SpawnZombie(PLAYERp pp, DSWActor* weaponActor)
SpawnZombie(PLAYERp pp, short Weapon)
{ {
short New;
SPRITEp np; SPRITEp np;
USERp nu; USERp nu;
short owner;
owner = sprite[Weapon].owner; auto ownerActor = GetOwner(weaponActor);
if (owner < 0) if (ownerActor == nullptr)
return -1; return;
//Zombies++; auto actorNew = SpawnActor(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0);
np = &actorNew->s();
New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); nu = actorNew->u();
auto actorNew = &swActors[New];
np = &sprite[New];
nu = User[New].Data();
np->sectnum = pp->cursectnum; np->sectnum = pp->cursectnum;
np->owner = owner; SetOwner(actorNew, ownerActor);
np->pal = nu->spal = User[owner]->spal; np->pal = nu->spal = ownerActor->u()->spal;
np->ang = RANDOM_P2(2048); np->ang = RANDOM_P2(2048);
SetupZombie(New); SetupZombie(actorNew);
//np->shade = sprite[pp->PlayerSprite].shade; //np->shade = sprite[pp->PlayerSprite].shade;
np->shade = -10; np->shade = -10;
SET(nu->Flags2, SPR2_DONT_TARGET_OWNER); SET(nu->Flags2, SPR2_DONT_TARGET_OWNER);
@ -812,15 +804,12 @@ SpawnZombie(PLAYERp pp, short Weapon)
RESET(nu->Flags, SPR_FALLING); RESET(nu->Flags, SPR_FALLING);
// if I didn't do this here they get stuck in the air sometimes // if I didn't do this here they get stuck in the air sometimes
DoActorZrange(New); DoActorZrange(actorNew->GetSpriteIndex());
return New;
} }
int void SpawnZombie2(DSWActor* actor)
SpawnZombie2(short Weapon)
{ {
SPRITEp sp = &sprite[Weapon]; SPRITEp sp = &actor->s();
short New; short New;
SPRITEp np; SPRITEp np;
USERp nu; USERp nu;
@ -828,16 +817,16 @@ SpawnZombie2(short Weapon)
SECT_USERp sectu = SectUser[sp->sectnum].Data(); SECT_USERp sectu = SectUser[sp->sectnum].Data();
SECTORp sectp = &sector[sp->sectnum]; SECTORp sectp = &sector[sp->sectnum];
owner = sprite[Weapon].owner; auto ownerActor = GetOwner(actor);
if (owner < 0) if (ownerActor == nullptr)
return -1; return;
if (sectu && (TEST(sectp->extra, SECTFX_LIQUID_MASK) != SECTFX_LIQUID_NONE)) if (sectu && (TEST(sectp->extra, SECTFX_LIQUID_MASK) != SECTFX_LIQUID_NONE))
return -1; return;
if (SectorIsUnderwaterArea(sp->sectnum)) if (SectorIsUnderwaterArea(sp->sectnum))
return -1; return;
//if (FAF_ConnectArea(sp->sectnum)) //if (FAF_ConnectArea(sp->sectnum))
// return(-1); // return(-1);
@ -847,20 +836,18 @@ SpawnZombie2(short Weapon)
int sectnum = sp->sectnum; int sectnum = sp->sectnum;
updatesectorz(sp->x, sp->y, sp->z + Z(10), &sectnum); updatesectorz(sp->x, sp->y, sp->z + Z(10), &sectnum);
if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum)) if (sectnum >= 0 && SectorIsUnderwaterArea(sectnum))
return -1; return;
} }
//Zombies++; auto actorNew = SpawnActor(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0);
New = SpawnSprite(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 0); np = &actorNew->s();
auto actorNew = &swActors[New]; nu = actorNew->u();
np = &sprite[New];
nu = User[New].Data();
nu->Counter3 = 0; nu->Counter3 = 0;
np->owner = owner; SetOwner(ownerActor, actorNew);
np->pal = nu->spal = User[owner]->spal; np->pal = nu->spal = ownerActor->u()->spal;
np->ang = RANDOM_P2(2048); np->ang = RANDOM_P2(2048);
SetupZombie(New); SetupZombie(actorNew);
//np->shade = sprite[pp->PlayerSprite].shade; //np->shade = sprite[pp->PlayerSprite].shade;
np->shade = -10; np->shade = -10;
SET(nu->Flags2, SPR2_DONT_TARGET_OWNER); SET(nu->Flags2, SPR2_DONT_TARGET_OWNER);
@ -875,16 +862,12 @@ SpawnZombie2(short Weapon)
RESET(nu->Flags, SPR_FALLING); RESET(nu->Flags, SPR_FALLING);
// if I didn't do this here they get stuck in the air sometimes // if I didn't do this here they get stuck in the air sometimes
DoActorZrange(New); DoActorZrange(actorNew->GetSpriteIndex());
return New;
} }
int int DoZombieMove(DSWActor* actor)
DoZombieMove(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
int SpriteNum = u->SpriteNum;
if (u->Counter3++ >= ZOMBIE_TIME_LIMIT) if (u->Counter3++ >= ZOMBIE_TIME_LIMIT)
{ {
@ -935,12 +918,10 @@ DoZombieMove(DSWActor* actor)
return 0; return 0;
} }
int int NullZombie(DSWActor* actor)
NullZombie(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
int SpriteNum = u->SpriteNum;
if (u->Counter3++ >= ZOMBIE_TIME_LIMIT) if (u->Counter3++ >= ZOMBIE_TIME_LIMIT)
{ {
InitBloodSpray(actor,true,105); InitBloodSpray(actor,true,105);
@ -975,7 +956,6 @@ NullZombie(DSWActor* actor)
int DoZombiePain(DSWActor* actor) int DoZombiePain(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
int SpriteNum = u->SpriteNum;
NullZombie(actor); NullZombie(actor);