- made Duke actor flags type safe and added a few new definitions that are not active yet.

This commit is contained in:
Christoph Oelckers 2022-01-02 10:17:44 +01:00
parent daa07b9e55
commit cc6d52013d
5 changed files with 83 additions and 3 deletions

View file

@ -312,8 +312,24 @@ enum sflags_t
SFLAG_KILLCOUNT = 0x10000000,
SFLAG_NOCANSEECHECK = 0x20000000,
SFLAG_HITRADIUSCHECK = 0x40000000,
SFLAG_MOVEFTA_CHECKSEE = 0x80000000,
};
using EDukeFlags1 = TFlags<sflags_t, uint32_t>;
DEFINE_TFLAGS_OPERATORS(EDukeFlags1)
enum sflags2_t
{
SFLAG2_NOVEFTA_MAKESTANDABLE = 0x00000001,
SFLAG2_TRIGGER_IFHITSECTOR = 0x00000002,
SFLAG2_MOVEFTA_WAKEUPCHECK = 0x00000004,
SFLAG2_MOVEFTA_CHECKSEEWITHPAL8 = 0x00000008, // let's hope this can be done better later. For now this was what blocked merging the Duke and RR variants of movefta
};
using EDukeFlags2 = TFlags<sflags2_t, uint32_t>;
DEFINE_TFLAGS_OPERATORS(EDukeFlags2)
enum
{
TFLAG_WALLSWITCH = 1

View file

@ -243,6 +243,28 @@ void initactorflags_d()
STRIPEBALL
});
setflag(SFLAG2_TRIGGER_IFHITSECTOR, { EXPLOSION2 });
setflag(SFLAG2_NOVEFTA_MAKESTANDABLE, {
RUBBERCAN,
EXPLODINGBARREL,
WOODENHORSE,
HORSEONSIDE,
CANWITHSOMETHING,
CANWITHSOMETHING2,
CANWITHSOMETHING3,
CANWITHSOMETHING4,
FIREBARREL,
FIREVASE,
NUKEBARREL,
NUKEBARRELDENTED,
NUKEBARRELLEAKED,
TRIPBOMB
});
// The feature guarded by this flag does not exist in Duke, it always acts as if the flag was set.
for (auto& ainf : gs.actorinfo) ainf.flags |= SFLAG_MOVEFTA_CHECKSEE;
gs.actorinfo[ORGANTIC].aimoffset = 32 << 8;
gs.actorinfo[ROTATEGUN].aimoffset = 32 << 8;

View file

@ -205,6 +205,34 @@ void initactorflags_r()
STRIPEBALL
});
setflag(SFLAG_MOVEFTA_CHECKSEE, { VIXEN });
if (isRRRA())
{
setflag(SFLAG_MOVEFTA_CHECKSEE, { COOT, COOTSTAYPUT, BIKER, BIKERB, BIKERBV2, CHEER, CHEERB,
CHEERSTAYPUT, MINIONBOAT, HULKBOAT, CHEERBOAT, RABBIT, COOTPLAY, BILLYPLAY, MAKEOUT, MAMA });
}
setflag(SFLAG2_TRIGGER_IFHITSECTOR, { EXPLOSION2, EXPLOSION3 });
setflag(SFLAG2_NOVEFTA_MAKESTANDABLE, {
RUBBERCAN,
EXPLODINGBARREL,
WOODENHORSE,
HORSEONSIDE,
CANWITHSOMETHING,
FIREBARREL,
FIREVASE,
NUKEBARREL,
NUKEBARRELDENTED,
NUKEBARRELLEAKED
});
setflag(SFLAG2_MOVEFTA_WAKEUPCHECK, { HEN, COW, PIG, DOGRUN });
if (isRRRA())
{
setflag(SFLAG2_MOVEFTA_WAKEUPCHECK, { RABBIT });
setflag(SFLAG2_MOVEFTA_CHECKSEEWITHPAL8, { MINION });
}
gs.actorinfo[RPG2].flags |= SFLAG_FORCEAUTOAIM;

View file

@ -27,17 +27,22 @@ inline int bossguypic(int const tileNum)
return ((gs.actorinfo[tileNum].flags & (SFLAG_BOSS)) != 0);
}
inline int actorflag(DDukeActor * actor, int mask)
inline int actorflag(DDukeActor * actor, EDukeFlags1 mask)
{
return (((gs.actorinfo[actor->spr.picnum].flags) & mask) != 0);
}
inline int actorflag(DDukeActor* actor, EDukeFlags2 mask)
{
return (((gs.actorinfo[actor->spr.picnum].flags2) & mask) != 0);
}
inline int actorfella(DDukeActor* actor)
{
return actorflag(actor, SFLAG_KILLCOUNT);
}
inline void setflag(int flag, const std::initializer_list<short>& types)
inline void setflag(EDukeFlags1 flag, const std::initializer_list<short>& types)
{
for (auto val : types)
{
@ -45,6 +50,14 @@ inline void setflag(int flag, const std::initializer_list<short>& types)
}
}
inline void setflag(EDukeFlags2 flag, const std::initializer_list<short>& types)
{
for (auto val : types)
{
gs.actorinfo[val].flags2 |= flag;
}
}
inline bool inventory(DDukeActor* S)
{
return !!(gs.actorinfo[S->spr.picnum].flags & SFLAG_INVENTORY);

View file

@ -120,7 +120,8 @@ struct animwalltype
struct ActorInfo
{
uint32_t scriptaddress;
uint32_t flags;
EDukeFlags1 flags;
EDukeFlags2 flags2;
int aimoffset;
int falladjustz;
int gutsoffset;