From 3d04e332fce62404d849172663fc228c1e3700f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Nov 2021 11:30:28 +0100 Subject: [PATCH] - InitChemBomb + PlayerInitFlashBomb --- source/games/sw/src/jweapon.cpp | 42 +++++++++++++-------------------- source/games/sw/src/sumo.cpp | 4 ++-- source/games/sw/src/weapon.cpp | 4 ++-- source/games/sw/src/weapon.h | 2 +- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index ff623ed32..bd3d9f380 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1450,15 +1450,13 @@ int InitSpriteChemBomb(DSWActor* actor) } -int -InitChemBomb(short SpriteNum) +int InitChemBomb(DSWActor* actor) { - SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum].Data(); + SPRITEp sp = &actor->s(); + USERp u = actor->u(); USERp wu; SPRITEp wp; int nx, ny, nz; - short w; // Need to make it take away from inventory weapon list @@ -1470,19 +1468,15 @@ InitChemBomb(short SpriteNum) // Spawn a shot // Inserting and setting up variables - w = SpawnSprite(STAT_MISSILE, MUSHROOM_CLOUD, s_ChemBomb, sp->sectnum, + auto actorNew = SpawnActor(STAT_MISSILE, MUSHROOM_CLOUD, s_ChemBomb, sp->sectnum, nx, ny, nz, sp->ang, CHEMBOMB_VELOCITY); - wp = &sprite[w]; - wu = User[w].Data(); + wp = &actorNew->s(); + wu = actorNew->u(); -// wu->RotNum = 5; -// NewStateGroup_(w, &sg_ChemBomb); SET(wu->Flags, SPR_XFLIP_TOGGLE); -// SetOwner(SpriteNum, w); -// SetOwner(-1, w); - SetOwner(sp->owner, w); // !FRANK + SetOwner(GetOwner(actor), actorNew); wp->yrepeat = 32; wp->xrepeat = 32; wp->shade = -15; @@ -1527,14 +1521,13 @@ InitChemBomb(short SpriteNum) // Inventory Flash Bombs // ////////////////////////////////////////////// -int -PlayerInitFlashBomb(PLAYERp pp) + +int PlayerInitFlashBomb(PLAYERp pp) { - int i; unsigned int stat; int dist, tx, ty, tmin; short damage; - SPRITEp sp = pp->SpriteP, hp; + SPRITEp sp = &pp->Actor()->s(), hp; USERp hu; PlaySound(DIGI_GASPOP, pp, v3df_dontpan | v3df_doppler); @@ -1544,14 +1537,13 @@ PlayerInitFlashBomb(PLAYERp pp) 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()) { - auto itActor = &swActors[i]; - hp = &sprite[i]; - hu = User[i].Data(); + hp = &itActor->s(); + hu = itActor->u(); - if (i == pp->PlayerSprite) + if (itActor == pp->Actor()) break; DISTANCE(hp->x, hp->y, sp->x, sp->y, dist, tx, ty, tmin); @@ -1564,7 +1556,7 @@ PlayerInitFlashBomb(PLAYERp pp) if (!FAFcansee(hp->x, hp->y, hp->z, hp->sectnum, sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sectnum)) continue; - damage = GetDamage(i, pp->PlayerSprite, DMG_FLASHBOMB); + damage = GetDamage(itActor->GetSpriteIndex(), pp->PlayerSprite, DMG_FLASHBOMB); if (hu->sop_parent) { @@ -1589,7 +1581,7 @@ PlayerInitFlashBomb(PLAYERp pp) } else { - ActorPain(i); + ActorPain(itActor->GetSpriteIndex()); SpawnFlashBombOnActor(itActor); } } diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index 225556289..bdc8435c1 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -737,7 +737,7 @@ int InitSumoFart(DSWActor* actor) PlaySound(DIGI_SUMOFART, sp, v3df_follow); - InitChemBomb(SpriteNum); + InitChemBomb(actor); SetSumoFartQuake(SpriteNum); InitSumoNapalm(SpriteNum); @@ -783,7 +783,7 @@ int DoSumoDeathMelt(DSWActor* actor) PlaySound(DIGI_SUMOFART, sp, v3df_follow); u->ID = SUMO_RUN_R0; - InitChemBomb(SpriteNum); + InitChemBomb(actor); u->ID = 0; DoMatchEverything(nullptr, sp->lotag, ON); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index a457af71f..066932830 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -11137,7 +11137,7 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang) SpawnExpZadjust(Weapon, exp, Z(50), Z(10)); - InitChemBomb(explosion); + InitChemBomb(&swActors[explosion]); return explosion; } @@ -11188,7 +11188,7 @@ SpawnNuclearExp(int16_t Weapon) RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); eu->spal = exp->pal = PALETTE_PLAYER1; // Set nuke puff to gray - InitChemBomb(explosion); + InitChemBomb(&swActors[explosion]); // Do central explosion diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 8119a3dc4..36b2c74a9 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -177,7 +177,7 @@ void WallBounce(short SpriteNum, short ang); #define PHOSPHORUS 1397 int PlayerInitChemBomb(PLAYERp pp); -int InitChemBomb(short SpriteNum); +int InitChemBomb(DSWActor*); int PlayerInitCaltrops(PLAYERp pp); int InitBloodSpray(int16_t SpriteNum, bool dogib, short velocity); int SpawnBunnyExp(int16_t Weapon);