- scriptified the native part of FireflyFlyingEffect.

This commit is contained in:
Christoph Oelckers 2022-12-12 01:14:45 +01:00
parent 9783b8c402
commit 9f01c87ccb
5 changed files with 50 additions and 69 deletions

View file

@ -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) void handle_se06_d(DDukeActor* actor)
{ {
auto sc = actor->sector(); auto sc = actor->sector();
@ -1609,7 +1546,7 @@ void think_d(void)
tickstat(STAT_PROJECTILE); //ST 4 tickstat(STAT_PROJECTILE); //ST 4
moveplayers(); //ST 10 moveplayers(); //ST 10
movefallers_d(); //ST 12 movefallers_d(); //ST 12
moveexplosions_d(); //ST 5 tickstat(STAT_MISC, true); //ST 5
actortime.Reset(); actortime.Reset();
actortime.Clock(); actortime.Clock();

View file

@ -123,11 +123,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
ChangeActorStat(act, STAT_ZOMBIEACTOR); ChangeActorStat(act, STAT_ZOMBIEACTOR);
} }
return act; 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: case DTILE_LAVAPOOLBUBBLE:
if (actj->spr.scale.X < 0.46875) if (actj->spr.scale.X < 0.46875)
return act; return act;

View file

@ -6,4 +6,5 @@ spawnclasses
5737 = DukeGenericDestructible, "WTGLASS2", "", "GLASS_BREAKING", spawnglass 5737 = DukeGenericDestructible, "WTGLASS2", "", "GLASS_BREAKING", spawnglass
5294 = DeveloperCommentary 5294 = DeveloperCommentary
1891 = DukeFlamethrowerFlame 1891 = DukeFlamethrowerFlame
5296 = DukeFireflyFlyingEffect
} }

View file

@ -103,6 +103,7 @@ version "4.10"
#include "zscript/games/duke/actors/toilet.zs" #include "zscript/games/duke/actors/toilet.zs"
#include "zscript/games/duke/actors/flamethrowerflame.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/redneckmisc.zs"
#include "zscript/games/duke/actors/emptybike.zs" #include "zscript/games/duke/actors/emptybike.zs"

View file

@ -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();
}
}
}