- SpawnNuclearExp

This commit is contained in:
Christoph Oelckers 2021-11-05 00:29:58 +01:00
parent 2480beebcf
commit 3a16ac673c
2 changed files with 40 additions and 48 deletions

View file

@ -6567,7 +6567,7 @@ DoDamage(short SpriteNum, short Weapon)
} }
if (wu->Radius == NUKE_RADIUS) if (wu->Radius == NUKE_RADIUS)
SpawnNuclearExp(Weapon); SpawnNuclearExp(weapActor);
else else
SpawnBoltExp(Weapon); SpawnBoltExp(Weapon);
SetSuicide(weapActor); SetSuicide(weapActor);
@ -6641,7 +6641,7 @@ DoDamage(short SpriteNum, short Weapon)
} }
if (wu->Radius == NUKE_RADIUS) if (wu->Radius == NUKE_RADIUS)
SpawnNuclearExp(Weapon); SpawnNuclearExp(weapActor);
else else
SpawnBoltExp(Weapon); SpawnBoltExp(Weapon);
SetSuicide(weapActor); SetSuicide(weapActor);
@ -10096,7 +10096,7 @@ DoRocket(DSWActor* actor)
SpawnBunnyExp(Weapon); SpawnBunnyExp(Weapon);
} }
else if (u->Radius == NUKE_RADIUS) else if (u->Radius == NUKE_RADIUS)
SpawnNuclearExp(Weapon); SpawnNuclearExp(actor);
else else
SpawnBoltExp(Weapon); SpawnBoltExp(Weapon);
@ -11000,24 +11000,22 @@ SpawnTankShellExp(int16_t Weapon)
} }
int void SpawnNuclearSecondaryExp(DSWActor* actor, short ang)
SpawnNuclearSecondaryExp(int16_t Weapon, short ang)
{ {
SPRITEp sp = &sprite[Weapon]; SPRITEp sp = &actor->s();
USERp u = User[Weapon].Data(); USERp u = actor->u();
SPRITEp exp; SPRITEp exp;
USERp eu; USERp eu;
short explosion;
ASSERT(u); ASSERT(u);
explosion = SpawnSprite(STAT_MISSILE, GRENADE_EXP, s_GrenadeExp, sp->sectnum, auto expActor = SpawnActor(STAT_MISSILE, GRENADE_EXP, s_GrenadeExp, sp->sectnum,
sp->x, sp->y, sp->z, sp->ang, 512); sp->x, sp->y, sp->z, sp->ang, 512);
exp = &sprite[explosion]; exp = &expActor->s();
eu = User[explosion].Data(); eu = expActor->u();
exp->hitag = LUMINOUS; //Always full brightness exp->hitag = LUMINOUS; //Always full brightness
SetOwner(sp->owner, explosion); SetOwner(GetOwner(actor), expActor);
exp->shade = -128; exp->shade = -128;
exp->xrepeat = 218; exp->xrepeat = 218;
exp->yrepeat = 152; exp->yrepeat = 152;
@ -11032,42 +11030,39 @@ SpawnNuclearSecondaryExp(int16_t Weapon, short ang)
eu->xchange = MOVEx(vel, ang); eu->xchange = MOVEx(vel, ang);
eu->ychange = MOVEy(vel, ang); eu->ychange = MOVEy(vel, ang);
eu->Radius = 200; // was NUKE_RADIUS eu->Radius = 200; // was NUKE_RADIUS
SetCollision(eu, move_missile(explosion, eu->xchange, eu->ychange, 0, SetCollision(eu, move_missile(expActor->GetSpriteIndex(), eu->xchange, eu->ychange, 0,
eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS)); eu->ceiling_dist, eu->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS));
if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, exp->z - sp->z) < 1024) if (FindDistance3D(exp->x - sp->x, exp->y - sp->y, exp->z - sp->z) < 1024)
{ {
KillSprite(explosion); KillActor(expActor);
return -1; return;
} }
SpawnExpZadjust(Weapon, exp, Z(50), Z(10)); SpawnExpZadjust(actor->GetSpriteIndex(), exp, Z(50), Z(10));
InitChemBomb(expActor);
InitChemBomb(&swActors[explosion]);
return explosion;
} }
int void SpawnNuclearExp(DSWActor* actor)
SpawnNuclearExp(int16_t Weapon)
{ {
SPRITEp sp = &sprite[Weapon]; SPRITEp sp = &actor->s();
USERp u = User[Weapon].Data(); USERp u = actor->u();
SPRITEp exp; SPRITEp exp;
USERp eu; USERp eu;
short explosion,ang=0; short ang=0;
PLAYERp pp = nullptr; PLAYERp pp = nullptr;
short rnd_rng; short rnd_rng;
ASSERT(u); ASSERT(u);
if (u && TEST(u->Flags, SPR_SUICIDE)) if (u && TEST(u->Flags, SPR_SUICIDE))
return -1; return;
PlaySound(DIGI_NUCLEAREXP, sp, v3df_dontpan | v3df_doppler); PlaySound(DIGI_NUCLEAREXP, actor, v3df_dontpan | v3df_doppler);
if (sp->owner) auto own = GetOwner(actor);
if (own && own->hasU())
{ {
pp = User[sp->owner]->PlayerP; pp = own->u()->PlayerP;
rnd_rng = RandomRange(1000); rnd_rng = RandomRange(1000);
if (rnd_rng > 990) if (rnd_rng > 990)
@ -11079,13 +11074,13 @@ SpawnNuclearExp(int16_t Weapon)
} }
// Spawn big mushroom cloud // Spawn big mushroom cloud
explosion = SpawnSprite(STAT_MISSILE, MUSHROOM_CLOUD, s_NukeMushroom, sp->sectnum, auto expActor = SpawnActor(STAT_MISSILE, MUSHROOM_CLOUD, s_NukeMushroom, sp->sectnum,
sp->x, sp->y, sp->z, sp->ang, 0); sp->x, sp->y, sp->z, sp->ang, 0);
exp = &sprite[explosion]; exp = &expActor->s();
eu = User[explosion].Data(); eu = expActor->u();
exp->hitag = LUMINOUS; //Always full brightness exp->hitag = LUMINOUS; //Always full brightness
SetOwner(sp->owner, explosion); SetOwner(own, expActor);
exp->shade = -128; exp->shade = -128;
exp->xrepeat = 255; exp->xrepeat = 255;
exp->yrepeat = 255; exp->yrepeat = 255;
@ -11094,17 +11089,16 @@ SpawnNuclearExp(int16_t Weapon)
RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); RESET(exp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
eu->spal = exp->pal = PALETTE_PLAYER1; // Set nuke puff to gray eu->spal = exp->pal = PALETTE_PLAYER1; // Set nuke puff to gray
InitChemBomb(&swActors[explosion]); InitChemBomb(expActor);
// Do central explosion // Do central explosion
explosion = SpawnSprite(STAT_MISSILE, MUSHROOM_CLOUD, s_GrenadeExp, sp->sectnum, expActor = SpawnActor(STAT_MISSILE, MUSHROOM_CLOUD, s_GrenadeExp, sp->sectnum,
sp->x, sp->y, sp->z, sp->ang, 0); sp->x, sp->y, sp->z, sp->ang, 0);
auto expActor = &swActors[explosion]; exp = &expActor->s();
exp = &sprite[explosion]; eu = expActor->u();
eu = User[explosion].Data();
SetOwner(sp->owner, explosion); SetOwner(own, expActor);
exp->shade = -128; exp->shade = -128;
exp->xrepeat = 218; exp->xrepeat = 218;
exp->yrepeat = 152; exp->yrepeat = 152;
@ -11115,26 +11109,24 @@ SpawnNuclearExp(int16_t Weapon)
eu->Radius = NUKE_RADIUS; eu->Radius = NUKE_RADIUS;
SpawnExpZadjust(Weapon, exp, Z(30), Z(30)); SpawnExpZadjust(actor->GetSpriteIndex(), exp, Z(30), Z(30));
DoExpDamageTest(expActor); DoExpDamageTest(expActor);
// Nuclear effects // Nuclear effects
SetNuclearQuake(explosion); SetNuclearQuake(actor->GetSpriteIndex());
SetFadeAmt(pp, -80, 1); // Nuclear flash SetFadeAmt(pp, -80, 1); // Nuclear flash
// Secondary blasts // Secondary blasts
ang = RANDOM_P2(2048); ang = RANDOM_P2(2048);
SpawnNuclearSecondaryExp(explosion, ang); SpawnNuclearSecondaryExp(expActor, ang);
ang = ang + 512 + RANDOM_P2(256); ang = ang + 512 + RANDOM_P2(256);
SpawnNuclearSecondaryExp(explosion, ang); SpawnNuclearSecondaryExp(expActor, ang);
ang = ang + 512 + RANDOM_P2(256); ang = ang + 512 + RANDOM_P2(256);
SpawnNuclearSecondaryExp(explosion, ang); SpawnNuclearSecondaryExp(expActor, ang);
ang = ang + 512 + RANDOM_P2(256); ang = ang + 512 + RANDOM_P2(256);
SpawnNuclearSecondaryExp(explosion, ang); SpawnNuclearSecondaryExp(expActor, ang);
return explosion;
} }
void SpawnTracerExp(DSWActor* actor) void SpawnTracerExp(DSWActor* actor)

View file

@ -241,7 +241,7 @@ int SpawnSplash(DSWActor*);
void SpawnMineExp(DSWActor*); void SpawnMineExp(DSWActor*);
void SpawnLittleExp(DSWActor*); void SpawnLittleExp(DSWActor*);
DSWActor* SpawnLargeExp(DSWActor*); DSWActor* SpawnLargeExp(DSWActor*);
int SpawnNuclearExp(int16_t Weapon); void SpawnNuclearExp(DSWActor* actor);
int SpawnBoltExp(int16_t Weapon); int SpawnBoltExp(int16_t Weapon);
void SpawnTracerExp(DSWActor* Weapon); void SpawnTracerExp(DSWActor* Weapon);
int SpawnGoroFireballExp(int16_t Weapon); int SpawnGoroFireballExp(int16_t Weapon);