From f1d6e0e6bb30e74338fc55447817d9f3e93bed4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Nov 2022 16:56:29 +0100 Subject: [PATCH] - scriptified Duke's shooting gallery targets. --- source/games/duke/src/actors_d.cpp | 46 ------------- source/games/duke/src/spawn_d.cpp | 7 -- source/games/duke/src/vmexports.cpp | 13 ++++ .../static/filter/dukelike/engine/engine.def | 3 + wadsrc/static/zscript.txt | 1 + .../zscript/games/duke/actors/ducktarget.zs | 68 +++++++++++++++++++ wadsrc/static/zscript/games/duke/dukeactor.zs | 1 + 7 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/ducktarget.zs diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 20f08c879..858098940 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1826,52 +1826,6 @@ void moveactors_d(void) if (isWorldTour()) flamethrowerflame(act); continue; - case DUCK: - case TARGET: - if (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) - { - act->temp_data[0]++; - if (act->temp_data[0] > 60) - { - act->temp_data[0] = 0; - act->spr.cstat = CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_ALIGNMENT_WALL; - act->spr.extra = 1; - } - } - else - { - int j = fi.ifhitbyweapon(act); - if (j >= 0) - { - act->spr.cstat = CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_YCENTER; - k = 1; - - DukeStatIterator itr(STAT_ACTOR); - while (auto act2 = itr.Next()) - { - if (act2->spr.lotag == act->spr.lotag && - act2->spr.picnum == act->spr.picnum) - { - if ((act2->spr.hitag && !(act2->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)) || - (!act2->spr.hitag && (act2->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)) - ) - { - k = 0; - break; - } - } - } - - if (k == 1) - { - operateactivators(act->spr.lotag, nullptr); - fi.operateforcefields(act, act->spr.lotag); - operatemasterswitches(act->spr.lotag); - } - } - } - continue; - case HELECOPT: case DUKECAR: diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 1c7bbb2a5..3c461df3c 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -513,13 +513,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.cstat |= CSTAT_SPRITE_INVISIBLE; ChangeActorStat(act, STAT_STANDABLE); break; - case TARGET: - case DUCK: - case LETTER: - act->spr.extra = 1; - act->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL; - ChangeActorStat(act, STAT_ACTOR); - break; case OCTABRAINSTAYPUT: case LIZTROOPSTAYPUT: case PIGCOPSTAYPUT: diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 2d4ab20d3..60911cee3 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -668,6 +668,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, insertspriteq, insertspriteq) return 0; } +void DukeActor_operateforcefields(DDukeActor* self, int tag) +{ + fi.operateforcefields(self, tag); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, operateforcefields, DukeActor_operateforcefields) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(tag); + fi.operateforcefields(self, tag); + return 0; +} + // temporary helpers to hide the fact that these flags are not part of the actor yet. DEFINE_ACTION_FUNCTION(DDukeActor, actorflag1) diff --git a/wadsrc/static/filter/dukelike/engine/engine.def b/wadsrc/static/filter/dukelike/engine/engine.def index 4964bdc6d..1f951ba71 100644 --- a/wadsrc/static/filter/dukelike/engine/engine.def +++ b/wadsrc/static/filter/dukelike/engine/engine.def @@ -71,6 +71,9 @@ spawnclasses 753 = DukeStatue 1157 = DukeBottle10 765 = DukeVase + 4502 = DukeLetter + 4361 = DukeDuck + 4359 = DukeTarget 1272 = DukeTrash 634 = DukeBolt1 diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index a07b3a9c5..a362f53b1 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -85,6 +85,7 @@ version "4.10" #include "zscript/games/duke/actors/bloodsplats.zs" #include "zscript/games/duke/actors/reactor.zs" #include "zscript/games/duke/actors/destructibles.zs" +#include "zscript/games/duke/actors/ducktarget.zs" #include "zscript/games/duke/actors/redneckmisc.zs" #include "zscript/games/duke/actors/rabbitspawner.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/ducktarget.zs b/wadsrc/static/zscript/games/duke/actors/ducktarget.zs new file mode 100644 index 000000000..28eaddcc6 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/ducktarget.zs @@ -0,0 +1,68 @@ +class DukeLetter : DukeActor +{ + default + { + pic "LETTER"; + statnum STAT_ACTOR; + extra 1; + } + + override void Initialize() + { + self.cstat |= CSTAT_SPRITE_BLOCK_ALL; + } +} + +class DukeDuck : DukeLetter // shooting gallery target +{ + default + { + pic "DUCK"; + } + override void Tick() + { + if (self.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) + { + self.temp_data[0]++; + if (self.temp_data[0] > 60) + { + self.temp_data[0] = 0; + self.cstat = CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_ALIGNMENT_WALL; + self.extra = 1; + } + } + else + { + int j = self.ifhitbyweapon(); + if (j >= 0) + { + self.cstat = CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_YCENTER; + + DukeStatIterator itr; + for(let act2 = itr.First(STAT_ACTOR); act2; act2 = itr.Next()) + { + if (act2.lotag == self.lotag && act2.GetClass() == self.GetClass()) + { + if ((act2.hitag && !(act2.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)) || + (!act2.hitag && (act2.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR)) + ) + return; + } + } + + // got the last one. Receive your reward! + dlevel.operateactivators(self.lotag, nullptr); + self.operateforcefields(self.lotag); + dlevel.operatemasterswitches(self.lotag); + } + } + } +} + +class DukeTarget : DukeDuck +{ + default + { + pic "TARGET"; + } +} diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 707ea24dd..ebbc94c4b 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -210,6 +210,7 @@ class DukeActor : CoreActor native native void shoot(Name spawnclass); native void setClipDistFromTile(); native void insertspriteq(); + native void operateforcefields(int tag); // temporary flag accessors - need to be eliminated once we can have true actor flags