- InitFlashBomb + PlayerInitCaltrops

This commit is contained in:
Christoph Oelckers 2021-11-01 11:35:48 +01:00
parent 3d04e332fc
commit 0b77a73976

View file

@ -1594,8 +1594,7 @@ int
InitFlashBomb(DSWActor* actor) InitFlashBomb(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
int SpriteNum = u->SpriteNum; SPRITEp sp = &actor->s();
SPRITEp sp = &sprite[SpriteNum];
int i; int i;
unsigned int stat; unsigned int stat;
int dist, tx, ty, tmin; int dist, tx, ty, tmin;
@ -1608,12 +1607,11 @@ InitFlashBomb(DSWActor* actor)
for (stat = 0; stat < SIZ(StatDamageList); stat++) for (stat = 0; stat < SIZ(StatDamageList); stat++)
{ {
StatIterator it(StatDamageList[stat]); SWStatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0) while (auto itActor = it.Next())
{ {
auto itActor = &swActors[i]; hp = &itActor->s();
hp = &sprite[i]; hu = itActor->u();
hu = User[i].Data();
DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, tx, ty, tmin); DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, tx, ty, tmin);
if (dist > 16384) // Flash radius if (dist > 16384) // Flash radius
@ -1625,7 +1623,7 @@ InitFlashBomb(DSWActor* actor)
if (!FAFcansee(hp->x, hp->y, hp->z, hp->sectnum, sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sectnum)) if (!FAFcansee(hp->x, hp->y, hp->z, hp->sectnum, sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sectnum))
continue; continue;
damage = GetDamage(i, SpriteNum, DMG_FLASHBOMB); damage = GetDamage(itActor->GetSpriteIndex(), actor->GetSpriteIndex(), DMG_FLASHBOMB);
if (hu->sop_parent) if (hu->sop_parent)
{ {
@ -1645,9 +1643,9 @@ InitFlashBomb(DSWActor* actor)
} }
else else
{ {
if (i != SpriteNum) if (itActor != actor)
{ {
ActorPain(i); ActorPain(itActor->GetSpriteIndex());
SpawnFlashBombOnActor(itActor); SpawnFlashBombOnActor(itActor);
} }
} }
@ -1742,14 +1740,13 @@ void SpawnFlashBombOnActor(DSWActor* actor)
// Inventory Caltrops // Inventory Caltrops
// //
////////////////////////////////////////////// //////////////////////////////////////////////
int
PlayerInitCaltrops(PLAYERp pp) int PlayerInitCaltrops(PLAYERp pp)
{ {
USERp u = User[pp->PlayerSprite].Data(); USERp u = pp->Actor()->u();
USERp wu; USERp wu;
SPRITEp wp; SPRITEp wp;
int nx, ny, nz; int nx, ny, nz;
short w;
short oclipdist; short oclipdist;
@ -1762,17 +1759,11 @@ PlayerInitCaltrops(PLAYERp pp)
ny = pp->posy; ny = pp->posy;
nz = pp->posz + pp->bob_z + Z(8); nz = pp->posz + pp->bob_z + Z(8);
// Throw out several caltrops auto spawnedActor = SpawnActor(STAT_DEAD_ACTOR, CALTROPS, s_Caltrops, pp->cursectnum,
// for(short i=0;i<3;i++)
// {
// Spawn a shot
// Inserting and setting up variables
w = SpawnSprite(STAT_DEAD_ACTOR, CALTROPS, s_Caltrops, pp->cursectnum,
nx, ny, nz, pp->angle.ang.asbuild(), (CHEMBOMB_VELOCITY + RandomRange(CHEMBOMB_VELOCITY)) / 2); nx, ny, nz, pp->angle.ang.asbuild(), (CHEMBOMB_VELOCITY + RandomRange(CHEMBOMB_VELOCITY)) / 2);
auto spawnedActor = &swActors[w]; wp = &spawnedActor->s();
wp = &sprite[w]; wu = spawnedActor->u();
wu = User[w].Data();
// don't throw it as far if crawling // don't throw it as far if crawling
if (TEST(pp->Flags, PF_CRAWLING)) if (TEST(pp->Flags, PF_CRAWLING))
@ -1782,7 +1773,7 @@ PlayerInitCaltrops(PLAYERp pp)
SET(wu->Flags, SPR_XFLIP_TOGGLE); SET(wu->Flags, SPR_XFLIP_TOGGLE);
SetOwner(pp->PlayerSprite, w); SetOwner(pp->Actor(), spawnedActor);
wp->yrepeat = 64; wp->yrepeat = 64;
wp->xrepeat = 64; wp->xrepeat = 64;
wp->shade = -15; wp->shade = -15;
@ -1805,7 +1796,7 @@ PlayerInitCaltrops(PLAYERp pp)
pp->SpriteP->clipdist = 0; pp->SpriteP->clipdist = 0;
wp->clipdist = 0; wp->clipdist = 0;
MissileSetPos(w, DoCaltrops, 1000); MissileSetPos(spawnedActor->GetSpriteIndex(), DoCaltrops, 1000);
pp->SpriteP->clipdist = uint8_t(oclipdist); pp->SpriteP->clipdist = uint8_t(oclipdist);
wp->clipdist = 80L >> 2; wp->clipdist = 80L >> 2;
@ -1818,16 +1809,11 @@ PlayerInitCaltrops(PLAYERp pp)
wu->xchange += pp->xvect >> 14; wu->xchange += pp->xvect >> 14;
wu->ychange += pp->yvect >> 14; wu->ychange += pp->yvect >> 14;
// Caltrops stay around for this many seconds
// wu->WaitTics = CHEMTICS*5;
// }
SetupSpriteForBreak(spawnedActor); // Put Caltrops in the break queue SetupSpriteForBreak(spawnedActor); // Put Caltrops in the break queue
return 0; return 0;
} }
int int InitCaltrops(int16_t SpriteNum)
InitCaltrops(int16_t SpriteNum)
{ {
SPRITEp sp = &sprite[SpriteNum]; SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum].Data(); USERp u = User[SpriteNum].Data();