From 26ba1f601ec2f98ed22bf090e09a61501f315469 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Nov 2022 20:19:22 +0100 Subject: [PATCH] - scriptified the fire extinguisher. --- source/games/duke/src/actors_d.cpp | 62 ---------------- source/games/duke/src/namelist_r.h | 1 - source/games/duke/src/spawn_d.cpp | 18 ----- wadsrc/static/filter/duke/engine/engine.def | 1 + wadsrc/static/zscript.txt | 1 + .../zscript/games/duke/actors/fireext.zs | 73 +++++++++++++++++++ 6 files changed, 75 insertions(+), 81 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/fireext.zs diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index d821c8cde..670f5c26f 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -794,63 +794,6 @@ void movefallers_d(void) // //--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -// -// Duke only -// -//--------------------------------------------------------------------------- - -//--------------------------------------------------------------------------- -// -// Duke only -// -//--------------------------------------------------------------------------- - -static void movefireext(DDukeActor* actor) -{ - int j = fi.ifhitbyweapon(actor); - if (j == -1) return; - - for (int k = 0; k < 16; k++) - { - auto a = randomAngle(); - auto vel = krandf(4) + 4; - auto zvel = -krandf(16) - actor->vel.Z * 0.25; - auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(krandf(-48)), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC); - if (spawned) - { - if (spawned) spawned->spriteextra = Scrap3 + krand() & 3; - spawned->spr.pal = 2; - } - } - - spawn(actor, EXPLOSION2); - S_PlayActorSound(PIPEBOMB_EXPLODE, actor); - S_PlayActorSound(GLASS_HEAVYBREAK, actor); - - if (actor->spr.hitag > 0) - { - DukeStatIterator it(STAT_STANDABLE); - while (auto a1 = it.Next()) - { - if (actor->spr.hitag == a1->spr.hitag && actorflag(a1, SFLAG2_BRIGHTEXPLODE)) - if (a1->spr.shade != -32) - a1->spr.shade = -32; - } - - int x = actor->spr.extra; - spawn(actor, EXPLOSION2); - fi.hitradius(actor, gs.pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); - S_PlayActorSound(PIPEBOMB_EXPLODE, actor); - detonate(actor, EXPLOSION2); - } - else - { - fi.hitradius(actor, gs.seenineblastradius, 10, 15, 20, 25); - deletesprite(actor); - } -} - //--------------------------------------------------------------------------- // // @@ -1002,11 +945,6 @@ void movestandables_d(void) continue; } - else if (picnum == FIREEXT) - { - movefireext(act); - } - else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1)) { moveooz(act, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2); diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index bee5460e2..5d763f523 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -108,7 +108,6 @@ x(MASKWALL12, 150) x(MASKWALL13, 151) x(MASKWALL14, 152) x(MASKWALL15, 153) -x(FIREEXT, 155) x(W_LIGHT, 156) x(SCREENBREAK1, 159) x(SCREENBREAK2, 160) diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 62c4417ef..76d692593 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -1060,24 +1060,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_STANDABLE); break; - case FIREEXT: - act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; - act->spr.extra = gs.impact_damage << 2; - - if (ud.multimode < 2 && act->spr.pal != 0) - { - act->spr.scale = DVector2(0, 0); - ChangeActorStat(act, STAT_MISC); - break; - } - - act->spr.pal = 0; - act->SetOwner(act); - ChangeActorStat(act, STAT_STANDABLE); - act->vel.X = 0.5; - ssp(act, CLIPMASK0); - break; - case TOILET: case STALL: act->spr.lotag = 1; diff --git a/wadsrc/static/filter/duke/engine/engine.def b/wadsrc/static/filter/duke/engine/engine.def index 8f1ce2aec..f93eb82a1 100644 --- a/wadsrc/static/filter/duke/engine/engine.def +++ b/wadsrc/static/filter/duke/engine/engine.def @@ -20,4 +20,5 @@ spawnclasses 547 = DukeCrack2 548 = DukeCrack3 549 = DukeCrack4 + 916 = DukeFireext } diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 3c05aa51c..14d5150a4 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -57,6 +57,7 @@ version "4.10" #include "zscript/games/duke/actors/cactus.zs" #include "zscript/games/duke/actors/tripbomb.zs" #include "zscript/games/duke/actors/crack.zs" +#include "zscript/games/duke/actors/fireext.zs" #include "zscript/games/blood/bloodgame.zs" #include "zscript/games/blood/ui/menu.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/fireext.zs b/wadsrc/static/zscript/games/duke/actors/fireext.zs new file mode 100644 index 000000000..dc145a260 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/fireext.zs @@ -0,0 +1,73 @@ + +class DukeFireext : DukeActor +{ + default + { + statnum STAT_STANDABLE; + pic "FIREEXT"; + } + + override void Initialize() + { + self.cstat = CSTAT_SPRITE_BLOCK_ALL; + self.extra = gs.impact_damage << 2; + + if (ud.multimode < 2 && self.pal != 0) + { + self.scale = (0, 0); + self.ChangeStat(STAT_MISC); + return; + } + + self.pal = 0; + self.ownerActor = self; + self.vel.X = 0.5; + self.DoMove(CLIPMASK0); + } + + override void Tick() + { + int j = self.ifhitbyweapon(); + if (j == -1) return; + + for (int k = 0; k < 16; k++) + { + let a = frandom(0, 360); + let vel = frandom(0, 4) + 4; + let zvel = -frandom(0, 16) - self.vel.Z * 0.25; + let spawned = dlevel.SpawnActor(self.sector, self.pos.plusZ(frandom(-48, 0)), 'DukeScrap', -8, (0.75, 0.75), a, vel, zvel, self); + if (spawned) + { + if (spawned) spawned.spriteextra = DukeScrap.Scrap3 + random(0, 3); + spawned.pal = 2; + } + } + + self.spawn("DukeExplosion2"); + self.PlayActorSound(DukeSnd.PIPEBOMB_EXPLODE); + self.PlayActorSound(DukeSnd.GLASS_HEAVYBREAK); + + if (self.hitag > 0) + { + DukeStatIterator it; + for(let a1 = it.First(STAT_STANDABLE); a1; a1 = it.Next()) + { + if (self.hitag == a1.hitag && a1.actorflag2(SFLAG2_BRIGHTEXPLODE)) + if (a1.shade != -32) + a1.shade = -32; + } + + int x = self.extra; + self.spawn("DukeExplosion2"); + self.hitradius(gs.pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); + self.PlayActorSound(DukeSnd.PIPEBOMB_EXPLODE); + self.detonate("DukeExplosion2"); + } + else + { + self.hitradius(gs.seenineblastradius, 10, 15, 20, 25); + self.Destroy(); + } + } +} +