- scriptified Duke's shooting gallery targets.

This commit is contained in:
Christoph Oelckers 2022-11-30 16:56:29 +01:00
parent e69772637c
commit f1d6e0e6bb
7 changed files with 86 additions and 53 deletions

View file

@ -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:

View file

@ -513,13 +513,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
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:

View file

@ -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)

View file

@ -71,6 +71,9 @@ spawnclasses
753 = DukeStatue
1157 = DukeBottle10
765 = DukeVase
4502 = DukeLetter
4361 = DukeDuck
4359 = DukeTarget
1272 = DukeTrash
634 = DukeBolt1

View file

@ -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"

View file

@ -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";
}
}

View file

@ -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