From f89ccec829e0d8d8b1a4f35b997069c6e5f675cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Nov 2022 11:17:41 +0100 Subject: [PATCH] - scriptified Duke's reactor. --- source/games/duke/src/actors.cpp | 133 -------------- source/games/duke/src/actors_d.cpp | 9 - source/games/duke/src/actors_r.cpp | 9 - source/games/duke/src/animatesprites_d.cpp | 3 - source/games/duke/src/animatesprites_r.cpp | 3 - source/games/duke/src/funct.h | 1 - source/games/duke/src/spawn_d.cpp | 3 - source/games/duke/src/spawn_r.cpp | 3 - .../static/filter/dukelike/engine/engine.def | 5 + .../static/filter/redneck/engine/engine.def | 4 + wadsrc/static/zscript.txt | 3 +- .../zscript/games/duke/actors/reactor.zs | 173 ++++++++++++++++++ 12 files changed, 184 insertions(+), 165 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/reactor.zs diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 3f0dc5783..4a1a5298d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -608,139 +608,6 @@ void detonate(DDukeActor *actor, int explosion) // //--------------------------------------------------------------------------- -void reactor(DDukeActor* const actor, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK) -{ - auto sectp = actor->sector(); - - if (actor->temp_data[4] == 1) - { - DukeSectIterator it(actor->sector()); - while (auto a2 = it.Next()) - { - if (a2->spr.picnum == SECTOREFFECTOR) - { - if (a2->spr.lotag == 1) - { - a2->spr.lotag = -1; - a2->spr.hitag = -1; - } - } - else if (a2->spr.picnum == REACTOR) - { - a2->spr.picnum = REACTORBURNT; - } - else if (a2->spr.picnum == REACTOR2) - { - a2->spr.picnum = REACTOR2BURNT; - } - else if (a2->spr.picnum == REACTORSPARK || a2->spr.picnum == REACTOR2SPARK) - { - a2->spr.cstat = CSTAT_SPRITE_INVISIBLE; - } - } - return; - } - - if (actor->temp_data[1] >= 20) - { - actor->temp_data[4] = 1; - return; - } - - double xx; - int p = findplayer(actor, &xx); - - actor->temp_data[2]++; - if (actor->temp_data[2] == 4) actor->temp_data[2] = 0; - - if (xx < 256) - { - if ((krand() & 255) < 16) - { - if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN)) - S_PlayActorSound(DUKE_LONGTERM_PAIN, ps[p].GetActor()); - - S_PlayActorSound(SHORT_CIRCUIT, actor); - - ps[p].GetActor()->spr.extra--; - SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); - } - actor->temp_data[0] += 128; - if (actor->temp_data[3] == 0) - actor->temp_data[3] = 1; - } - else actor->temp_data[3] = 0; - - if (actor->temp_data[1]) - { - actor->temp_data[1]++; - - actor->temp_data[4] = FloatToFixed<8>(actor->spr.pos.Z); - actor->spr.pos.Z = sectp->floorz - zrand(sectp->floorz - sectp->ceilingz); - - switch (actor->temp_data[1]) - { - case 3: - { - //Turn on all of those flashing sectoreffector. - fi.hitradius(actor, 4096, - gs.impact_damage << 2, - gs.impact_damage << 2, - gs.impact_damage << 2, - gs.impact_damage << 2); - DukeStatIterator it(STAT_STANDABLE); - while (auto a2 = it.Next()) - { - if (ismasterswitch(a2)) - if (a2->spr.hitag == actor->spr.hitag) - if (a2->spr.yint == 0) - a2->spr.yint = 1; - } - break; - } - case 4: - case 7: - case 10: - case 15: - { - DukeSectIterator it(actor->sector()); - while (auto a2 = it.Next()) - { - if (a2 != actor) - { - a2->Destroy(); - break; - } - } - break; - } - } - for (int x = 0; x < 16; x++) - RANDOMSCRAP(actor); - - actor->spr.pos.Z = FixedToFloat<8>(actor->temp_data[4]); - actor->temp_data[4] = 0; - - } - else - { - int j = fi.ifhitbyweapon(actor); - if (j >= 0) - { - for (int x = 0; x < 32; x++) - RANDOMSCRAP(actor); - if (actor->spr.extra < 0) - actor->temp_data[1] = 1; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void watersplash2(DDukeActor* actor) { auto sectp = actor->sector(); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index dc8e3182f..087b9dbd6 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1913,15 +1913,6 @@ void moveactors_d(void) case HEAVYHBOMB: heavyhbomb(act); continue; - - case REACTORBURNT: - case REACTOR2BURNT: - continue; - - case REACTOR: - case REACTOR2: - reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK); - continue; } if (monsterCheatCheck(act) && badguy(act)) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index a3bfb8383..4ec88a360 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1664,15 +1664,6 @@ void moveactors_r(void) case DYNAMITE: heavyhbomb(act); continue; - - case REACTORBURNT: - case REACTOR2BURNT: - continue; - - case REACTOR: - case REACTOR2: - reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK); - continue; } diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 2be7651d9..69dc7e8d7 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -544,9 +544,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi case WATERSPLASH2: t->picnum = WATERSPLASH2 + t1; break; - case REACTOR2: - t->picnum = h->spr.picnum + h->temp_data[2]; - break; case SHELL: t->picnum = h->spr.picnum + (h->temp_data[0] & 1); [[fallthrough]]; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index d7f3d67c5..62c50469b 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -698,9 +698,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi case WATERSPLASH2: t->picnum = WATERSPLASH2 + t1; break; - case REACTOR2: - t->picnum = h->spr.picnum + h->temp_data[2]; - break; case SHELL: t->picnum = h->spr.picnum + (h->temp_data[0] & 1); [[fallthrough]]; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 0368b559d..00b5953ee 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -38,7 +38,6 @@ void clearcameras(player_struct* p); void RANDOMSCRAP(DDukeActor* i); void detonate(DDukeActor* i, int explosion); void lotsofstuff(DDukeActor* s, int n, int spawntype); -void reactor(DDukeActor* i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK); void watersplash2(DDukeActor* i); void frameeffect1(DDukeActor* i); bool money(DDukeActor* i, int BLOODPOOL); diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index f958426e2..7ebcdd247 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -672,9 +672,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.scale = DVector2(0.140625, 0.140625); act->spr.yint = 4; - [[fallthrough]]; - case REACTOR2: - case REACTOR: if (initreactor(actj, act, false)) return act; break; diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 26f79cda4..bd556957a 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -685,9 +685,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->SetOwner(act); act->spr.scale = DVector2(0.140625, 0.140625); act->spr.yint = 4; - [[fallthrough]]; - case REACTOR2: - case REACTOR: if (initreactor(actj, act, false)) return act; break; diff --git a/wadsrc/static/filter/dukelike/engine/engine.def b/wadsrc/static/filter/dukelike/engine/engine.def index fe2f5764f..8322c349a 100644 --- a/wadsrc/static/filter/dukelike/engine/engine.def +++ b/wadsrc/static/filter/dukelike/engine/engine.def @@ -61,6 +61,11 @@ spawnclasses 1641 = DukeFreezeBlast 1636 = DukeSpit 1360 = DukeCoolExplosion1 + 578 = DukeReactor2 + 580 = DukeReactor2Spark + 1088 = DukeReactor + 1092 = DukeReactorSpark + 1272 = DukeTrash 634 = DukeBolt1 diff --git a/wadsrc/static/filter/redneck/engine/engine.def b/wadsrc/static/filter/redneck/engine/engine.def index 524361b6f..d20ea8b2a 100644 --- a/wadsrc/static/filter/redneck/engine/engine.def +++ b/wadsrc/static/filter/redneck/engine/engine.def @@ -63,6 +63,10 @@ spawnclasses 1774 = RedneckDynamiteArrow 3390 = RedneckShitBall 3400 = RedneckSawBlade + 1107 = DukeReactor2 + 1109 = DukeReactor2Spark + 2239 = DukeReactor + 2243 = DukeReactorSpark 285 = RedneckChickenSpawner1 286 = RedneckChickenSpawner2 diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index c98c883f9..25a3f98c1 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -57,7 +57,6 @@ version "4.10" #include "zscript/games/duke/actors/soundcontroller.zs" #include "zscript/games/duke/actors/respawncontroller.zs" #include "zscript/games/duke/actors/respawnmarker.zs" -#include "zscript/games/duke/actors/bloodsplats.zs" #include "zscript/games/duke/actors/projectiles.zs" #include "zscript/games/duke/actors/rat.zs" @@ -82,6 +81,8 @@ version "4.10" #include "zscript/games/duke/actors/forcesphere.zs" #include "zscript/games/duke/actors/recon.zs" #include "zscript/games/duke/actors/ooz.zs" +#include "zscript/games/duke/actors/bloodsplats.zs" +#include "zscript/games/duke/actors/reactor.zs" #include "zscript/games/duke/actors/genericdestructible.zs" #include "zscript/games/duke/actors/redneckmisc.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/reactor.zs b/wadsrc/static/zscript/games/duke/actors/reactor.zs new file mode 100644 index 000000000..f8c21af9c --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/reactor.zs @@ -0,0 +1,173 @@ +class DukeReactor : DukeActor +{ + default + { + spriteset "REACTOR", "REACTORBURNT"; + statnum STAT_ZOMBIEACTOR; + shade -17; + pal 0; + } + + + override void Initialize() + { + self.extra = gs.impact_damage; + self.cstat |= CSTAT_SPRITE_BLOCK_ALL; // Make it hitable + if (ud.multimode < 2 && self.pal != 0) + { + self.scale = (0, 0); + self.ChangeStat(STAT_MISC); + } + } + + + override void Tick() + { + if (self.spritesetindex == 1) return; // this one's already dead. + let sectp = self.sector; + + if (self.temp_data[4] == 1) + { + DukeSectIterator it; + for (let a2 = it.First(self.sector); a2; a2 = it.Next()) + { + if (a2.statnum == STAT_EFFECTOR) + { + if (a2.lotag == SE_1_PIVOT) + { + a2.lotag = -1; + a2.hitag = -1; + } + } + else if (a2 is "DukeReactor") + { + a2.SetSpritesetImage(1); + } + else if (a2 is "DukeReactorSpark") + { + a2.cstat = CSTAT_SPRITE_INVISIBLE; + } + } + return; + } + + if (self.temp_data[1] >= 20) + { + self.temp_data[4] = 1; + return; + } + + double xx; + DukePlayer p; + [p, xx] = self.FindPlayer(); + + // This was defined for REACTOR2, which doesn't have any animation frames + //self.temp_data[2]++; + //if (self.temp_data[2] == 4) self.temp_data[2] = 0; + //self.SetSpriteSetImage(self.temp_data[2]); + + if (xx < 256) + { + if (random(0, 255) < 16) + { + if (!p.actor.CheckSoundPlaying("PLAYER_LONGTERM_PAIN")) + p.actor.PlayActorSound("PLAYER_LONGTERM_PAIN"); + + self.PlayActorSound("SHORT_CIRCUIT"); + + p.actor.extra--; + p.pals = Color(32, 32, 0, 0); + } + self.temp_data[0] += 128; + if (self.temp_data[3] == 0) + self.temp_data[3] = 1; + } + else self.temp_data[3] = 0; + + if (self.temp_data[1]) + { + self.temp_data[1]++; + + double zsave = self.pos.Z; + self.pos.Z = sectp.floorz - frandom(0, sectp.floorz - sectp.ceilingz); + + switch (self.temp_data[1]) + { + case 3: + { + //Turn on all of those flashing sectoreffector. + self.hitradius(4096, + gs.impact_damage << 2, + gs.impact_damage << 2, + gs.impact_damage << 2, + gs.impact_damage << 2); + DukeStatIterator it; + for (let a2 = it.First(STAT_STANDABLE); a2; a2 = it.Next()) + { + if (a2 is 'DukeMasterSwitch' && a2.hitag == self.hitag && a2.yint == 0) + a2.yint = 1; + } + break; + } + case 4: + case 7: + case 10: + case 15: + { + DukeSectIterator it; + for (let a2 = it.First(self.sector); a2; a2 = it.Next()) + { + if (a2 != self) + { + a2.Destroy(); + break; + } + } + break; + } + } + for (int x = 0; x < 16; x++) + self.RANDOMSCRAP(); + + self.pos.Z = zsave; + self.temp_data[4] = 0; + + } + else + { + int j = self.ifhitbyweapon(); + if (j >= 0) + { + for (int x = 0; x < 32; x++) + self.RANDOMSCRAP(); + if (self.extra < 0) + self.temp_data[1] = 1; + } + } + } +} + +class DukeReactor2 : DukeReactor +{ + default + { + spriteset "REACTOR2", "REACTOR2BURNT"; + } +} + +// These are inert and only needed for checking above. +class DukeReactorSpark : DukeActor +{ + default + { + pic "REACTORSPARK"; + } +} + +class DukeReactor2Spark : DukeActor +{ + default + { + pic "REACTOR2SPARK"; + } +}