- flammable actors scriptified.

This commit is contained in:
Christoph Oelckers 2022-11-14 16:31:45 +01:00
parent 190fd1827e
commit 5fea500f92
20 changed files with 239 additions and 153 deletions

View file

@ -614,65 +614,6 @@ void movefx(void)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void moveflammable(DDukeActor* actor, int pool)
{
double scale;
if (actor->temp_data[0] == 1)
{
actor->temp_data[1]++;
if ((actor->temp_data[1] & 3) > 0) return;
if (actorflag(actor, SFLAG_FLAMMABLEPOOLEFFECT) && actor->temp_data[1] == 32)
{
actor->spr.cstat = 0;
auto spawned = spawn(actor, pool);
if (spawned)
{
spawned->spr.pal = 2;
spawned->spr.shade = 127;
}
}
else
{
if (actor->spr.shade < 64) actor->spr.shade++;
else
{
deletesprite(actor);
return;
}
}
scale = actor->spr.scale.X - (krand() & 7) * REPEAT_SCALE;
if (scale < 0.15625)
{
deletesprite(actor);
return;
}
actor->spr.scale.X = (scale);
scale = actor->spr.scale.Y - (krand() & 7) * REPEAT_SCALE;
if (scale < 0.0625)
{
deletesprite(actor);
return;
}
actor->spr.scale.Y = (scale);
}
if (actorflag(actor, SFLAG_FALLINGFLAMMABLE))
{
makeitfall(actor);
actor->ceilingz = actor->sector()->ceilingz;
}
}
//---------------------------------------------------------------------------
//
//

View file

@ -1188,11 +1188,6 @@ void movestandables_d(void)
continue;
}
else if (AFLAMABLE(picnum))
{
moveflammable(act, BLOODPOOL);
}
else if (picnum == TRIPBOMB)
{
movetripbomb(act);

View file

@ -826,12 +826,6 @@ void movestandables_r(void)
continue;
}
else if (AFLAMABLE(picnum))
{
moveflammable(act, BLOODPOOL);
}
else if (picnum >= CRACK1 && picnum <= CRACK1 + 3)
{
movecrack(act);

View file

@ -192,11 +192,6 @@ void SetDispatcher()
}
int TILE_BOX;
int TILE_TREE1;
int TILE_TREE2;
int TILE_TIRE;
int TILE_CONE;
int TILE_W_FORCEFIELD;
int TILE_SCRAP6;
int TILE_APLAYER;

View file

@ -311,11 +311,6 @@ void initactorflags_d()
gs.weaponsandammosprites[13] = FREEZESPRITE;
gs.weaponsandammosprites[14] = FREEZEAMMO;
TILE_BOX = BOX;
TILE_TREE1 = TREE1;
TILE_TREE2 = TREE2;
TILE_TIRE = TIRE;
TILE_CONE = CONE;
TILE_W_FORCEFIELD = W_FORCEFIELD;
TILE_SCRAP6 = SCRAP6;
TILE_APLAYER = APLAYER;

View file

@ -281,11 +281,6 @@ void initactorflags_r()
gs.weaponsandammosprites[13] = TITSPRITE;
gs.weaponsandammosprites[14] = FREEZEAMMO;
TILE_BOX = BOX;
TILE_TREE1 = TREE1;
TILE_TREE2 = TREE2;
TILE_TIRE = TIRE;
TILE_CONE = CONE;
TILE_W_FORCEFIELD = W_FORCEFIELD;
TILE_SCRAP6 = SCRAP6;
TILE_APLAYER = APLAYER;

View file

@ -32,7 +32,6 @@ void movefta();
void clearcameras(int i, player_struct* p);
void RANDOMSCRAP(DDukeActor* i);
void movecrane(DDukeActor* i, int crane);
void moveflammable(DDukeActor* i, int pool);
void detonate(DDukeActor* i, int explosion);
void movemasterswitch(DDukeActor* i);
void movetrash(DDukeActor* i);

View file

@ -11,11 +11,6 @@ inline int rnd(int X)
return ((krand() >> 8) >= (255 - (X)));
}
inline bool AFLAMABLE(int X)
{
return (X == TILE_BOX || X == TILE_TREE1 || X == TILE_TREE2 || X == TILE_TIRE || X == TILE_CONE);
}
inline int badguypic(int const tileNum)
{
return ((gs.actorinfo[tileNum].flags & (SFLAG_INTERNAL_BADGUY | SFLAG_BADGUY)) != 0);

View file

@ -3,11 +3,6 @@
BEGIN_DUKE_NS
// These are all globally accessed tiles.
extern int TILE_BOX;
extern int TILE_TREE1;
extern int TILE_TREE2;
extern int TILE_TIRE;
extern int TILE_CONE;
extern int TILE_W_FORCEFIELD;
extern int TILE_SCRAP6;
extern int TILE_APLAYER;

View file

@ -1064,21 +1064,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
}
}
break;
case TREE1:
case TREE2:
case TIRE:
case CONE:
case BOX:
if (actorflag(proj, SFLAG_INFLAME))
{
if (targ->temp_data[0] == 0)
{
targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
targ->temp_data[0] = 1;
spawn(targ, BURNING);
}
}
break;
case CACTUS:
// case CACTUSBROKE:
if (actorflag(proj, SFLAG_INFLAME))

View file

@ -2108,21 +2108,6 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
}
break;
case TREE1:
case TREE2:
case TIRE:
case BOX:
if (actorflag(proj, SFLAG_INFLAME))
{
if (targ->temp_data[0] == 0)
{
targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
targ->temp_data[0] = 1;
spawn(targ, BURNING);
}
}
break;
case CACTUS:
// case CACTUSBROKE:
if (actorflag(proj, SFLAG_INFLAME))

View file

@ -285,16 +285,13 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
{
if (actj->spr.pal == 1)
act->spr.pal = 1;
else if (actj->spr.pal != 6 && actj->spr.picnum != NUKEBARREL && actj->spr.picnum != TIRE)
else if (actj->spr.pal != 6 && actj->spr.picnum != NUKEBARREL)
{
if (actj->spr.picnum == FECES)
act->spr.pal = 7; // Brown
else act->spr.pal = 2; // Red
}
else act->spr.pal = 0; // green
if (actj->spr.picnum == TIRE)
act->spr.shade = 127;
}
act->spr.cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR;
if (act->spr.picnum == LAVAPOOL) // Twentieth Anniversary World Tour
@ -1031,16 +1028,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
}
break;
case TREE1:
case TREE2:
case TIRE:
case CONE:
case BOX:
act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
act->spr.extra = 1;
ChangeActorStat(act, STAT_STANDABLE);
break;
case FLOORFLAME:
act->spr.shade = -127;
ChangeActorStat(act, STAT_STANDABLE);

View file

@ -331,14 +331,11 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
{
if (actj->spr.pal == 1)
act->spr.pal = 1;
else if (actj->spr.pal != 6 && actj->spr.picnum != NUKEBARREL && actj->spr.picnum != TIRE)
else if (actj->spr.pal != 6 && actj->spr.picnum != NUKEBARREL)
{
act->spr.pal = 2; // Red
}
else act->spr.pal = 0; // green
if (actj->spr.picnum == TIRE)
act->spr.shade = 127;
}
act->spr.cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR;
[[fallthrough]];
@ -1237,14 +1234,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
}
act->spr.shade = act->sector()->floorshade;
break;
case TREE1:
case TREE2:
case TIRE:
act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
act->spr.extra = 1;
ChangeActorStat(act, STAT_STANDABLE);
break;
case CAMERA1:
case CAMERA1 + 1:
case CAMERA1 + 2:

View file

@ -191,6 +191,14 @@ DDukeActor* DukeActor_Spawn(DDukeActor* origin, int intname)
{
picnum = TileFiles.tileForName("TOILETWATER");
}
else if (FName(ENamedName(intname)) == FName("DukeBurning"))
{
picnum = TileFiles.tileForName("BURNIMG");
}
if (FName(ENamedName(intname)) == FName("DukeBloodPool"))
{
picnum = TileFiles.tileForName("BLOODPOOL");
}
if (picnum == -1)
{
@ -224,6 +232,44 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofglass, DukeActor_Lotsofglass)
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, makeitfall, makeitfall)
{
PARAM_SELF_PROLOGUE(DDukeActor);
makeitfall(self);
return 0;
}
// temporary helpers.
DEFINE_ACTION_FUNCTION(DDukeActor, actorflag1)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(mask);
ACTION_RETURN_BOOL(!!actorflag(self, EDukeFlags1::FromInt(mask)));
}
DEFINE_ACTION_FUNCTION(DDukeActor, actorflag2)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(mask);
ACTION_RETURN_BOOL(!!actorflag(self, EDukeFlags2::FromInt(mask)));
}
DEFINE_ACTION_FUNCTION(DDukeActor, attackerflag1)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(mask);
ACTION_RETURN_BOOL(!!attackerflag(self, EDukeFlags1::FromInt(mask)));
}
DEFINE_ACTION_FUNCTION(DDukeActor, attackerflag2)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(mask);
ACTION_RETURN_BOOL(!!attackerflag(self, EDukeFlags2::FromInt(mask)));
}
//---------------------------------------------------------------------------
//
// DukePlayer

View file

@ -7,5 +7,9 @@ spawnclasses
565 = DukeWaterFountain
566 = DukeWaterFountain
567 = DukeWaterFountainBroke
951 = DukeBox
978 = DukeCone
908 = DukeTree1
910 = DukeTree2
990 = DukeTire
}

View file

@ -7,4 +7,9 @@ spawnclasses
1094 = DukeWaterFountain
1095 = DukeWaterFountain
1096 = DukeWaterFountainBroke
1211 = DukeBox
1191 = DukeTree1
1193 = DukeTree2
1230 = DukeTire
}

View file

@ -52,6 +52,7 @@ version "4.9"
#include "zscript/games/duke/ui/menu.zs"
#include "zscript/games/duke/actors/crane.zs"
#include "zscript/games/duke/actors/waterfountain.zs"
#include "zscript/games/duke/actors/flammables.zs"
#include "zscript/games/blood/bloodgame.zs"
#include "zscript/games/blood/ui/menu.zs"

View file

@ -7,6 +7,7 @@ enum EClipMask
class CoreActor native
{
const REPEAT_SCALE = 1. / 64.;
native readonly sectortype sector;
native int16 cstat;

View file

@ -0,0 +1,117 @@
class DukeFlammable : DukeActor
{
default
{
statnum STAT_STANDABLE;
}
override void Initialize()
{
self.cstat = CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
self.extra = 1;
}
override void Tick()
{
if (self.temp_data[0] == 1)
{
self.temp_data[1]++;
if ((self.temp_data[1] & 3) > 0) return;
if (self.actorflag1(SFLAG_FLAMMABLEPOOLEFFECT) && self.temp_data[1] == 32)
{
self.cstat = 0;
let spawned = self.spawn("DukeBloodPool");
if (spawned)
{
spawned.pal = 2;
spawned.shade = 127;
}
}
else
{
if (self.shade < 64) self.shade++;
else
{
self.Destroy();
return;
}
}
double scale = self.scale.X - random(0, 7) * REPEAT_SCALE;
if (scale < 0.15625)
{
self.Destroy();
return;
}
self.scale.X = scale;
scale = self.scale.Y - random(0, 7) * REPEAT_SCALE;
if (scale < 0.0625)
{
self.Destroy();
return;
}
self.scale.Y = scale;
}
if (self.actorflag1(SFLAG_FALLINGFLAMMABLE))
{
self.makeitfall();
self.ceilingz = self.sector.ceilingz;
}
}
override void onHit(DukeActor hitter)
{
if (hitter.actorflag1(SFLAG_INFLAME))
{
if (self.temp_data[0] == 0)
{
self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
self.temp_data[0] = 1;
self.spawn("DukeBurning");
}
}
}
}
class DukeBox : DukeFlammable
{
default
{
pic "BOX";
}
}
class DukeTree1 : DukeFlammable
{
default
{
pic "TREE1";
}
}
class DukeTree2 : DukeFlammable
{
default
{
pic "TREE2";
}
}
class DukeTire : DukeFlammable
{
default
{
pic "TIRE";
}
}
class DukeCone : DukeFlammable
{
default
{
pic "CONE";
}
}

View file

@ -71,6 +71,7 @@ class DukeActor : CoreActor native
native void PlayActorSound(int snd);
native DukeActor spawn(Name type);
native void lotsofglass(int count);
native void makeitfall();
virtual void BeginPlay() {}
virtual void Initialize() {}
@ -79,6 +80,14 @@ class DukeActor : CoreActor native
virtual void onUse(DukePlayer user) {}
virtual bool animate(tspritetype tspr) { return false; }
virtual void RunState() {} // this is the CON function.
// temporary flag accessors - need to be eliminated once we can have true actor flags
native int actorflag1(int mask);
native int actorflag2(int mask);
native int attackerflag1(int mask);
native int attackerflag2(int mask);
}
extend struct _
@ -114,3 +123,56 @@ struct DukeSpriteIterator
native DukeActor Next();
native DukeActor First();
}
// this is only temporary. We cannot check the actor flags as long as we still need to deal with internal actors whose picnum defines their type.
enum sflags_t
{
SFLAG_INVENTORY = 0x00000001,
SFLAG_SHRINKAUTOAIM = 0x00000002,
SFLAG_BADGUY = 0x00000004,
SFLAG_FORCEAUTOAIM = 0x00000008,
SFLAG_BOSS = 0x00000010,
SFLAG_BADGUYSTAYPUT = 0x00000020,
SFLAG_GREENSLIMEFOOD = 0x00800040,
SFLAG_NODAMAGEPUSH = 0x00000080,
SFLAG_NOWATERDIP = 0x00000100,
SFLAG_INTERNAL_BADGUY = 0x00000200, // a separate flag is needed for the internal ones because SFLAG_BADGUY has additional semantics.
SFLAG_KILLCOUNT = 0x00000400,
SFLAG_NOCANSEECHECK = 0x00000800,
SFLAG_HITRADIUSCHECK = 0x00001000,
SFLAG_MOVEFTA_CHECKSEE = 0x00002000,
SFLAG_MOVEFTA_MAKESTANDABLE = 0x00004000,
SFLAG_TRIGGER_IFHITSECTOR = 0x00008000,
SFLAG_MOVEFTA_WAKEUPCHECK = 0x00010000,
SFLAG_MOVEFTA_CHECKSEEWITHPAL8 = 0x00020000, // let's hope this can be done better later. For now this was what blocked merging the Duke and RR variants of movefta
SFLAG_NOSHADOW = 0x00040000,
SFLAG_SE24_NOCARRY = 0x00080000,
SFLAG_NOINTERPOLATE = 0x00100000,
SFLAG_FALLINGFLAMMABLE = 0x00200000,
SFLAG_FLAMMABLEPOOLEFFECT = 0x00400000,
SFLAG_INFLAME = 0x00800000,
SFLAG_NOFLOORFIRE = 0x01000000,
SFLAG_HITRADIUS_FLAG1 = 0x02000000,
SFLAG_HITRADIUS_FLAG2 = 0x04000000,
SFLAG_CHECKSLEEP = 0x08000000,
SFLAG_NOTELEPORT = 0x10000000,
SFLAG_SE24_REMOVE = 0x20000000,
SFLAG_BLOCK_TRIPBOMB = 0x40000000,
SFLAG_NOFALLER = 0x80000000,
};
enum sflags2_t
{
SFLAG2_USEACTIVATOR = 0x00000001,
SFLAG2_NOROTATEWITHSECTOR = 0x00000002,
SFLAG2_SHOWWALLSPRITEONMAP = 0x00000004,
SFLAG2_NOFLOORPAL = 0x00000008,
SFLAG2_EXPLOSIVE = 0x00000010,
SFLAG2_BRIGHTEXPLODE = 0x00000020,
SFLAG2_DOUBLEDMGTHRUST = 0x00000040,
SFLAG2_BREAKMIRRORS = 0x00000080,
SFLAG2_CAMERA = 0x00000100,
SFLAG2_DONTANIMATE = 0x00000200,
SFLAG2_INTERPOLATEANGLE = 0x00000400,
};