mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 00:42:08 +00:00
- scriptified FrameEffect
This commit is contained in:
parent
44d4e7a20a
commit
0dc526899b
24 changed files with 108 additions and 138 deletions
|
@ -49,6 +49,7 @@ public:
|
|||
|
||||
int time;
|
||||
int16_t spritesetindex;
|
||||
int16_t dispicnum;
|
||||
|
||||
|
||||
DCoreActor() = default;
|
||||
|
|
|
@ -631,7 +631,8 @@ void DCoreActor::Serialize(FSerializer& arc)
|
|||
("xvel", vel.X)
|
||||
("yvel", vel.Y)
|
||||
("zvel", vel.Z)
|
||||
("viewzoffset", viewzoffset);
|
||||
("viewzoffset", viewzoffset)
|
||||
("dispicnum", dispicnum);
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
|
|
|
@ -222,6 +222,7 @@ DEFINE_FIELD_X(tspritetype, tspritetype, pos)
|
|||
|
||||
DEFINE_GLOBAL_NAMED(wall, walls)
|
||||
DEFINE_GLOBAL_NAMED(sector, sectors)
|
||||
DEFINE_GLOBAL(display_mirror)
|
||||
|
||||
void sector_setfloorz(sectortype* sect, double val)
|
||||
{
|
||||
|
@ -670,6 +671,10 @@ void tspritetype_setSpritePic(tspritetype* targ, DCoreActor* self, unsigned z)
|
|||
{
|
||||
targ->picnum = spriteset[z];
|
||||
}
|
||||
else if (z == ~0)
|
||||
{
|
||||
targ->picnum = self->dispicnum;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_tspritetype, setSpritePic, tspritetype_setSpritePic)
|
||||
|
@ -773,24 +778,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, move, coreactor_move)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void coreactor_setSpritePic(DCoreActor* self, unsigned z)
|
||||
{
|
||||
auto& spriteset = static_cast<PClassActor*>(self->GetClass())->ActorInfo()->SpriteSet;
|
||||
if (z < spriteset.Size())
|
||||
{
|
||||
self->spritesetindex = z;
|
||||
self->spr.picnum = spriteset[z];
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DCoreActor, setSpritePic, coreactor_setSpritePic)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DCoreActor);
|
||||
PARAM_INT(z);
|
||||
coreactor_setSpritePic(self, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void coreactor_backuppos(DCoreActor* self)
|
||||
{
|
||||
self->backuppos();
|
||||
|
|
|
@ -655,31 +655,6 @@ void watersplash2(DDukeActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void frameeffect1(DDukeActor *actor)
|
||||
{
|
||||
auto Owner = actor->GetOwner();
|
||||
if (Owner)
|
||||
{
|
||||
actor->temp_data[0]++;
|
||||
|
||||
if (actor->temp_data[0] > 7)
|
||||
{
|
||||
actor->Destroy();
|
||||
return;
|
||||
}
|
||||
else if (actor->temp_data[0] > 4) actor->spr.cstat |= CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT;
|
||||
else if (actor->temp_data[0] > 2) actor->spr.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
actor->spr.xoffset = Owner->spr.xoffset;
|
||||
actor->spr.yoffset = Owner->spr.yoffset;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool money(DDukeActor* actor, int BLOODPOOL)
|
||||
{
|
||||
auto sectp = actor->sector();
|
||||
|
|
|
@ -1323,9 +1323,6 @@ void moveexplosions_d(void) // STATNUM 5
|
|||
watersplash2(act);
|
||||
continue;
|
||||
|
||||
case FRAMEEFFECT1:
|
||||
frameeffect1(act);
|
||||
continue;
|
||||
case MONEY + 1:
|
||||
case MAIL + 1:
|
||||
case PAPER + 1:
|
||||
|
|
|
@ -1520,9 +1520,6 @@ void moveexplosions_r(void) // STATNUM 5
|
|||
watersplash2(act);
|
||||
continue;
|
||||
|
||||
case FRAMEEFFECT1:
|
||||
frameeffect1(act);
|
||||
continue;
|
||||
case FEATHER + 1: // feather
|
||||
act->spr.pos.Z = act->floorz = getflorzofslopeptr(act->sector(), act->spr.pos.X, act->spr.pos.Y);
|
||||
if (act->sector()->lotag == 800)
|
||||
|
|
|
@ -166,7 +166,12 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
if (sectp->floorpal && !actorflag(h, SFLAG2_NOFLOORPAL))
|
||||
copyfloorpal(t, sectp);
|
||||
|
||||
if (res) continue;
|
||||
if (res)
|
||||
{
|
||||
if (h->dispicnum >= 0)
|
||||
h->dispicnum = t->picnum;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
t1 = h->temp_data[1];
|
||||
|
@ -544,26 +549,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
if (h->temp_data[0] > 1) t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
if (h->temp_data[0] > 2) t->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
|
||||
break;
|
||||
case FRAMEEFFECT1:
|
||||
if (OwnerAc && OwnerAc->spr.statnum < MAXSTATUS)
|
||||
{
|
||||
if (OwnerAc->isPlayer())
|
||||
if (ud.cameraactor == nullptr)
|
||||
if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
|
||||
{
|
||||
t->ownerActor = nullptr;
|
||||
break;
|
||||
}
|
||||
if ((OwnerAc->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
{
|
||||
t->picnum = OwnerAc->dispicnum;
|
||||
t->pal = OwnerAc->spr.pal;
|
||||
t->shade = OwnerAc->spr.shade;
|
||||
t->Angles.Yaw = OwnerAc->spr.Angles.Yaw;
|
||||
t->cstat = CSTAT_SPRITE_TRANSLUCENT | OwnerAc->spr.cstat;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,12 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
if (sectp->floorpal && !actorflag(h, SFLAG2_NOFLOORPAL))
|
||||
copyfloorpal(t, sectp);
|
||||
|
||||
if (res) continue;
|
||||
if (res)
|
||||
{
|
||||
if (h->dispicnum >= 0)
|
||||
h->dispicnum = t->picnum;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
t1 = h->temp_data[1];
|
||||
|
@ -699,30 +704,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
|
|||
if (h->temp_data[0] > 1) t->cstat &= ~CSTAT_SPRITE_XFLIP;
|
||||
if (h->temp_data[0] > 2) t->cstat &= ~CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP;
|
||||
break;
|
||||
case FRAMEEFFECT1:
|
||||
if (OwnerAc && OwnerAc->spr.statnum < MAXSTATUS)
|
||||
{
|
||||
if (OwnerAc->isPlayer())
|
||||
if (ud.cameraactor == nullptr)
|
||||
if (screenpeek == OwnerAc->PlayerIndex() && display_mirror == 0)
|
||||
{
|
||||
t->ownerActor = nullptr;
|
||||
break;
|
||||
}
|
||||
if ((OwnerAc->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
{
|
||||
if (OwnerAc->isPlayer())
|
||||
t->picnum = 1554;
|
||||
else
|
||||
t->picnum = OwnerAc->dispicnum;
|
||||
t->pal = OwnerAc->spr.pal;
|
||||
t->shade = OwnerAc->spr.shade;
|
||||
t->Angles.Yaw = OwnerAc->spr.Angles.Yaw;
|
||||
t->cstat = CSTAT_SPRITE_TRANSLUCENT | OwnerAc->spr.cstat;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
h->dispicnum = t->picnum;
|
||||
|
|
|
@ -39,7 +39,6 @@ void RANDOMSCRAP(DDukeActor* i);
|
|||
void detonate(DDukeActor* i, int explosion);
|
||||
void lotsofstuff(DDukeActor* s, int n, int spawntype);
|
||||
void watersplash2(DDukeActor* i);
|
||||
void frameeffect1(DDukeActor* i);
|
||||
bool money(DDukeActor* i, int BLOODPOOL);
|
||||
bool bloodpool(DDukeActor* i, bool puke);
|
||||
void shell(DDukeActor* i, bool morecheck);
|
||||
|
|
|
@ -268,7 +268,6 @@ void DDukeActor::Serialize(FSerializer& arc)
|
|||
("movflag", movflag)
|
||||
("tempang", tempval)
|
||||
("actorstayput", actorstayput)
|
||||
("dispicnum", dispicnum)
|
||||
("basepicnum", basepicnum)
|
||||
("timetosleep", timetosleep)
|
||||
("floorz", floorz)
|
||||
|
|
|
@ -202,18 +202,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
spawntransporter(actj, act, act->spr.picnum == TRANSPORTERBEAM);
|
||||
break;
|
||||
|
||||
case FRAMEEFFECT1:
|
||||
if (actj)
|
||||
{
|
||||
act->spr.scale = actj->spr.scale;
|
||||
act->temp_data[1] = actj->spr.picnum;
|
||||
}
|
||||
else act->spr.scale = DVector2(0, 0);
|
||||
|
||||
ChangeActorStat(act, STAT_MISC);
|
||||
|
||||
break;
|
||||
|
||||
case BLOOD:
|
||||
act->spr.scale = DVector2(0.25, 0.25);
|
||||
act->spr.pos.Z -= 26;
|
||||
|
|
|
@ -164,20 +164,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
|
|||
spawntransporter(actj, act, act->spr.picnum == TRANSPORTERBEAM);
|
||||
break;
|
||||
|
||||
case FRAMEEFFECT1:
|
||||
if (actj)
|
||||
{
|
||||
act->spr.scale = actj->spr.scale;
|
||||
if (actj->isPlayer())
|
||||
act->temp_data[1] = SMALLSMOKE;
|
||||
else
|
||||
act->temp_data[1] = actj->spr.picnum;
|
||||
}
|
||||
else act->spr.scale = DVector2(0, 0);
|
||||
|
||||
ChangeActorStat(act, STAT_MISC);
|
||||
break;
|
||||
|
||||
case BLOOD:
|
||||
act->spr.scale = DVector2(0.0625, 0.0625);
|
||||
act->spr.pos.Z -= 26;
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
uint8_t spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'.
|
||||
uint16_t movflag;
|
||||
short attackertype, hitextra;
|
||||
short tempval, dispicnum, basepicnum;
|
||||
short tempval, basepicnum;
|
||||
unsigned short timetosleep;
|
||||
DVector2 ovel;
|
||||
DAngle hitang;
|
||||
|
|
|
@ -32,6 +32,7 @@ int PicForName(int intname)
|
|||
{"DukePigCop", "PIGCOP"},
|
||||
{"DukeSmallSmoke", "SMALLSMOKE"},
|
||||
{"DukeMoney", "MONEY"},
|
||||
{"DukeBurning", "BURNING"},
|
||||
};
|
||||
|
||||
for (auto& p : classes)
|
||||
|
|
|
@ -79,6 +79,7 @@ spawnclasses
|
|||
26 = DukePipeBomb
|
||||
940 = DukeBounceMine
|
||||
1650 = DukeMortar
|
||||
2999 = DukeFrameEffect
|
||||
|
||||
1272 = DukeTrash
|
||||
634 = DukeBolt1
|
||||
|
|
|
@ -73,6 +73,7 @@ spawnclasses
|
|||
1168 = DukeStatue
|
||||
1280 = DukeBottle10
|
||||
1172 = DukeVase
|
||||
4095 = DukeFrameEffect
|
||||
|
||||
26 = RedneckDynamite
|
||||
1416 = RedneckMortar
|
||||
|
|
|
@ -58,6 +58,7 @@ version "4.10"
|
|||
#include "zscript/games/duke/actors/respawncontroller.zs"
|
||||
#include "zscript/games/duke/actors/respawnmarker.zs"
|
||||
#include "zscript/games/duke/actors/genericdestructible.zs"
|
||||
#include "zscript/games/duke/actors/frameeffect.zs"
|
||||
|
||||
#include "zscript/games/duke/actors/projectiles.zs"
|
||||
#include "zscript/games/duke/actors/rat.zs"
|
||||
|
@ -91,6 +92,7 @@ version "4.10"
|
|||
#include "zscript/games/duke/actors/heavyhbomb.zs"
|
||||
#include "zscript/games/duke/actors/mortar.zs"
|
||||
|
||||
|
||||
#include "zscript/games/duke/actors/redneckmisc.zs"
|
||||
#include "zscript/games/duke/actors/rabbitspawner.zs"
|
||||
#include "zscript/games/duke/actors/chickenplant.zs"
|
||||
|
|
|
@ -64,7 +64,6 @@ class CoreActor native
|
|||
native void setpos(Vector3 newpos, bool relink = true);
|
||||
native void copypos(CoreActor newpos, bool relink = true);
|
||||
native void move(Vector3 newpos, bool relink = true);
|
||||
native void setSpritePic(int index); // index into actor's spriteset.
|
||||
native void backuppos();
|
||||
native void setPosition(Vector3 pos);
|
||||
native void setPositionZ(Vector3 pos);
|
||||
|
|
|
@ -220,6 +220,7 @@ struct _ native // These are the global variables, the struct is only here to av
|
|||
native readonly double NotifyFontScale;
|
||||
native readonly int paused;
|
||||
native readonly ui uint8 ConsoleState;
|
||||
native readonly int display_mirror;
|
||||
}
|
||||
|
||||
struct System native
|
||||
|
|
|
@ -44,7 +44,7 @@ class DukeCactus : DukeCactusBroke
|
|||
}
|
||||
}
|
||||
|
||||
setSpritePic(1);
|
||||
self.setSpritesetImage(1);
|
||||
self.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class DukeCrane : DukeActor
|
|||
let sect = self.sector;
|
||||
self.cstat |= CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_ONE_SIDE;
|
||||
|
||||
self.setSpritePic(PIC_CLOSED);
|
||||
self.setSpritesetImage(PIC_CLOSED);
|
||||
self.pos.Z = sect.ceilingz + 48;
|
||||
|
||||
self.cranepos = self.pos;
|
||||
|
@ -98,7 +98,7 @@ class DukeCrane : DukeActor
|
|||
{
|
||||
if (self.vel.X < 11.5)
|
||||
{
|
||||
self.setSpritePic(PIC_OPEN);
|
||||
self.setSpritesetImage(PIC_OPEN);
|
||||
self.vel.X += 0.5;
|
||||
}
|
||||
self.DoMove(CLIPMASK0);
|
||||
|
@ -112,7 +112,7 @@ class DukeCrane : DukeActor
|
|||
if (self.temp_data[0] == 2)
|
||||
{
|
||||
if ((sectp.floorz - self.pos.Z) < 64)
|
||||
if (self.spritesetindex != PIC_DEFAULT) self.setSpritePic(self.spritesetindex - 1);
|
||||
if (self.spritesetindex != PIC_DEFAULT) self.setSpritesetImage(self.spritesetindex - 1);
|
||||
|
||||
if ((sectp.floorz - self.pos.Z) < 20)
|
||||
self.temp_data[0]++;
|
||||
|
@ -121,7 +121,7 @@ class DukeCrane : DukeActor
|
|||
{
|
||||
if ((sectp.floorz - self.pos.Z) < 64)
|
||||
{
|
||||
if (self.spritesetindex != PIC_DEFAULT) self.setSpritePic(self.spritesetindex - 1);
|
||||
if (self.spritesetindex != PIC_DEFAULT) self.setSpritesetImage(self.spritesetindex - 1);
|
||||
else
|
||||
{
|
||||
if (self.isactive)
|
||||
|
@ -140,7 +140,7 @@ class DukeCrane : DukeActor
|
|||
}
|
||||
else if (self.temp_data[0] == 3)
|
||||
{
|
||||
self.setSpritePic(self.spritesetindex + 1);
|
||||
self.setSpritesetImage(self.spritesetindex + 1);
|
||||
if (self.spritesetindex == PIC_CLOSED)
|
||||
{
|
||||
let plr = Duke.checkcursectnums(self.temp_sect);
|
||||
|
@ -182,7 +182,7 @@ class DukeCrane : DukeActor
|
|||
{
|
||||
if (self.temp_data[0] == 8 && self.spritesetindex < PIC_CLOSED)
|
||||
if ((sectp.floorz - self.pos.Z) > 32)
|
||||
self.setSpritePic(self.spritesetindex + 1);
|
||||
self.setSpritesetImage(self.spritesetindex + 1);
|
||||
|
||||
if (self.pos.Z < self.cranepos.Z)
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ class DukeCrane : DukeActor
|
|||
p.on_crane = null;
|
||||
self.isactive = false;
|
||||
self.ownerActor = null;
|
||||
self.setSpritePic(PIC_DEFAULT);
|
||||
self.setSpritesetImage(PIC_DEFAULT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
68
wadsrc/static/zscript/games/duke/actors/frameeffect.zs
Normal file
68
wadsrc/static/zscript/games/duke/actors/frameeffect.zs
Normal file
|
@ -0,0 +1,68 @@
|
|||
class DukeFrameEffect : DukeActor
|
||||
{
|
||||
default
|
||||
{
|
||||
statnum STAT_MISC;
|
||||
Pic "SMALLSMOKE";
|
||||
}
|
||||
|
||||
|
||||
override void Initialize()
|
||||
{
|
||||
if (self != self.ownerActor)
|
||||
{
|
||||
self.scale = self.ownerActor.scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.Scale = (0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
override void Tick()
|
||||
{
|
||||
let Owner = self.ownerActor;
|
||||
if (Owner)
|
||||
{
|
||||
self.temp_data[0]++;
|
||||
|
||||
if (self.temp_data[0] > 7)
|
||||
{
|
||||
self.Destroy();
|
||||
return;
|
||||
}
|
||||
else if (self.temp_data[0] > 4) self.cstat |= CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT;
|
||||
else if (self.temp_data[0] > 2) self.cstat |= CSTAT_SPRITE_TRANSLUCENT;
|
||||
self.xoffset = Owner.xoffset;
|
||||
self.yoffset = Owner.yoffset;
|
||||
}
|
||||
}
|
||||
|
||||
override bool animate(tspritetype t)
|
||||
{
|
||||
let OwnerAc = self.ownerActor;
|
||||
if (OwnerAc && OwnerAc.statnum < MAXSTATUS)
|
||||
{
|
||||
if (OwnerAc.isPlayer())
|
||||
if (ud.cameraactor == nullptr)
|
||||
if (Duke.GetViewPlayer() == OwnerAc.GetPlayer() && display_mirror == 0)
|
||||
{
|
||||
t.ownerActor = nullptr;
|
||||
t.scale = (0, 0);
|
||||
return true;
|
||||
}
|
||||
if ((OwnerAc.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
{
|
||||
if (!OwnerAc.isPlayer() || !Raze.isRR()) t.SetSpritePic(OwnerAc, -1);
|
||||
else t.SetSpritePic(OwnerAc, 0);
|
||||
t.pal = OwnerAc.pal;
|
||||
t.shade = OwnerAc.shade;
|
||||
t.angle = OwnerAc.angle;
|
||||
t.cstat = CSTAT_SPRITE_TRANSLUCENT | OwnerAc.cstat;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ class DukeWaterFountain : DukeActor
|
|||
|
||||
override void Initialize()
|
||||
{
|
||||
self.setSpritePic(0);
|
||||
self.setSpritesetImage(0);
|
||||
self.lotag = 1;
|
||||
self.cstat = CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
|
||||
self.extra = 1;
|
||||
|
@ -37,7 +37,7 @@ class DukeWaterFountain : DukeActor
|
|||
if (frame == 3)
|
||||
frame = 1;
|
||||
|
||||
self.setSpritePic(frame);
|
||||
self.setSpritesetImage(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ class DukeWaterFountain : DukeActor
|
|||
if ((self.pos - p.actor.pos.plusZ(28)).Sum() > 32)
|
||||
{
|
||||
self.temp_data[0] = 0;
|
||||
self.setSpritePic(0);
|
||||
self.setSpritesetImage(0);
|
||||
}
|
||||
else self.temp_data[0] = 1;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class DukeWaterFountain : DukeActor
|
|||
{
|
||||
if (self.spritesetindex < 4)
|
||||
{
|
||||
self.setSpritePic(4);
|
||||
self.setSpritesetImage(4);
|
||||
self.spawn("DukeToiletWater");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -282,6 +282,7 @@ struct walltype native
|
|||
struct tspritetype native
|
||||
{
|
||||
native Vector3 pos;
|
||||
native double angle;
|
||||
native sectortype sector;
|
||||
native int16 cstat;
|
||||
//native int16 picnum;
|
||||
|
|
Loading…
Reference in a new issue