From 9f01c87ccbe6215f12b6f530554e0d470029d23a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Dec 2022 01:14:45 +0100 Subject: [PATCH] - scriptified the native part of FireflyFlyingEffect. --- source/games/duke/src/actors_d.cpp | 65 +------------------ source/games/duke/src/spawn_d.cpp | 5 -- .../duke.worldtour/rmapinfo.spawnclasses | 1 + wadsrc/static/zscript.txt | 1 + .../zscript/games/duke/actors/firefly.zs | 47 ++++++++++++++ 5 files changed, 50 insertions(+), 69 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/firefly.zs diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 912965d68..ef4e43f5b 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -991,69 +991,6 @@ void movetransports_d(void) // //--------------------------------------------------------------------------- -static void fireflyflyingeffect(DDukeActor *actor) -{ - double xx; - int p = findplayer(actor, &xx); - execute(actor, p, xx); - if (actor->ObjectFlags & OF_EuthanizeMe) return; // killed by script. - - auto Owner = actor->GetOwner(); - if (!Owner || Owner->spr.picnum != DTILE_FIREFLY) - { - actor->Destroy(); - return; - } - - if (Owner->spr.scale.X >= 0.375 || Owner->spr.pal == 1) - actor->spr.cstat |= CSTAT_SPRITE_INVISIBLE; - else - actor->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; - - auto dvec = Owner->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY(); - double dist = dvec.Length(); - - if (dist != 0.0) dvec /= dist; - actor->spr.pos = Owner->spr.pos + DVector3(dvec.X * -0.625, dvec.Y * -0.625, 8); - - if (Owner->spr.extra <= 0) - { - actor->Destroy(); - } - -} -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void moveexplosions_d(void) // STATNUM 5 -{ - DukeStatIterator it(STAT_MISC); - while (auto act = it.Next()) - { - if (act->spr.scale.X == 0 || act->spr.sectp == nullptr || actorflag(act, SFLAG2_DIENOW)) - { - act->Destroy(); - } - else if (isWorldTour() && act->spr.picnum == DTILE_FIREFLYFLYINGEFFECT) - { - fireflyflyingeffect(act); - } - else - { - CallTick(act); - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void handle_se06_d(DDukeActor* actor) { auto sc = actor->sector(); @@ -1609,7 +1546,7 @@ void think_d(void) tickstat(STAT_PROJECTILE); //ST 4 moveplayers(); //ST 10 movefallers_d(); //ST 12 - moveexplosions_d(); //ST 5 + tickstat(STAT_MISC, true); //ST 5 actortime.Reset(); actortime.Clock(); diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 034c9138c..c78a7a715 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -123,11 +123,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_ZOMBIEACTOR); } return act; - case DTILE_FIREFLYFLYINGEFFECT: - act->SetOwner(actj); - ChangeActorStat(act, STAT_MISC); - act->spr.scale = DVector2(0.25, 0.25); - return act; case DTILE_LAVAPOOLBUBBLE: if (actj->spr.scale.X < 0.46875) return act; diff --git a/wadsrc/static/filter/duke.worldtour/rmapinfo.spawnclasses b/wadsrc/static/filter/duke.worldtour/rmapinfo.spawnclasses index d17dcaeb1..59e1af67d 100644 --- a/wadsrc/static/filter/duke.worldtour/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/duke.worldtour/rmapinfo.spawnclasses @@ -6,4 +6,5 @@ spawnclasses 5737 = DukeGenericDestructible, "WTGLASS2", "", "GLASS_BREAKING", spawnglass 5294 = DeveloperCommentary 1891 = DukeFlamethrowerFlame + 5296 = DukeFireflyFlyingEffect } diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index edcdf53a7..505f18e63 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -103,6 +103,7 @@ version "4.10" #include "zscript/games/duke/actors/toilet.zs" #include "zscript/games/duke/actors/flamethrowerflame.zs" +#include "zscript/games/duke/actors/firefly.zs" #include "zscript/games/duke/actors/redneckmisc.zs" #include "zscript/games/duke/actors/emptybike.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/firefly.zs b/wadsrc/static/zscript/games/duke/actors/firefly.zs new file mode 100644 index 000000000..3d219107d --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/firefly.zs @@ -0,0 +1,47 @@ + +// for now only the effect is scriptified. + +class DukeFireflyFlyingEffect : DukeActor +{ + default + { + pic "FIREFLYFLYINGEFFECT"; + } + + override void Initialize() + { + self.scale = (0.25, 0.25); + self.ChangeStat(STAT_MISC); + } + + override void Tick() + { + Super.Tick(); + if (bDestroyed) return; // killed by script. + + + let Owner = self.ownerActor; + if (!Owner || !Owner.checkType("FIREFLY")) + { + self.Destroy(); + return; + } + + if (Owner.scale.X >= 0.375 || Owner.pal == 1) + self.cstat |= CSTAT_SPRITE_INVISIBLE; + else + self.cstat &= ~CSTAT_SPRITE_INVISIBLE; + + let p = self.findplayer(); + let dvec = Owner.pos.XY - p.actor.pos.XY; + double dist = dvec.Length(); + + if (dist != 0.0) dvec /= dist; + self.pos = Owner.pos + (dvec.X * -0.625, dvec.Y * -0.625, 8); + + if (Owner.extra <= 0) + { + self.Destroy(); + } + } +}