From 4812e1431ec9cc46af45fdb1ca9edfc1fbb2622a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Dec 2022 14:28:59 +0100 Subject: [PATCH] - made fallspecial game independent and eliminated all the wrapping and callback weirdness with fall. --- source/core/thingdef_data.cpp | 1 + source/games/duke/src/actors.cpp | 78 +++++++++++++++- source/games/duke/src/actors_d.cpp | 11 --- source/games/duke/src/actors_r.cpp | 90 ------------------- source/games/duke/src/constants.h | 1 + source/games/duke/src/dispatch.cpp | 4 - source/games/duke/src/duke3d.h | 1 - source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/vmexports.cpp | 2 +- .../zscript/games/duke/actors/minion.zs | 13 ++- 10 files changed, 89 insertions(+), 114 deletions(-) diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index acd4f952a..67990e658 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -193,6 +193,7 @@ static FFlagDef DukeActorFlagDefs[] = DEFINE_FLAG(SFLAG3, NOJIBS, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, NOVERTICALMOVE, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, MOVE_NOPLAYERINTERACT, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, MAGMAIMMUNE, DDukeActor, flags3), }; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index bcd180ad3..f9e0f958e 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -3826,13 +3826,87 @@ void alterang(int ang, DDukeActor* actor, int playernum) } } +//--------------------------------------------------------------------------- +// +// special checks for RR's extended sector types, now available everywhere +// +//--------------------------------------------------------------------------- + +static int fallspecial(DDukeActor* actor, int playernum) +{ + int sphit = 0; + if (ud.mapflags & MFLAG_ALLSECTORTYPES) + { + if (actor->sector()->lotag == ST_801_ROCKY) + { + if (actor->GetClass() == RedneckRockClass) + { + spawn(actor, RedneckRock2Class); + spawn(actor, RedneckRock2Class); + addspritetodelete(); + } + return 0; + } + else if (actor->sector()->lotag == ST_802_KILLBADGUYS) + { + if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F) + { + spawnguts(actor, DukeJibs6Class, 5); + S_PlayActorSound(SQUISHED, actor); + addspritetodelete(); + } + return 0; + } + else if (actor->sector()->lotag == ST_803_KILLROCKS) + { + if (actor->GetClass() == RedneckRock2Class) + addspritetodelete(); + return 0; + } + } + if (ud.mapflags & (MFLAG_ALLSECTORTYPES | MFLAG_SECTORTYPE800)) + { + if (actor->sector()->lotag == ST_800_KILLSTUFF) + { + if (!actor->isPlayer() && badguy(actor) && actor->spriteextra < 128) + { + actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F; + actor->vel.Z = 8000 / 256.; + actor->spr.extra = 0; + actor->spriteextra++; + sphit = 1; + } + else if (!actor->isPlayer()) + { + if (!actor->spriteextra) + addspritetodelete(); + return 0; + } + actor->attackertype = DukeShotSparkClass; + actor->hitextra = 1; + } + } + if (tilesurface(actor->sector()->floortexture) == TSURF_MAGMA) + { + if (!(actor->flags3 & SFLAG3_MAGMAIMMUNE) && actor->spr.pal != 19) + { + if ((krand() & 3) == 1) + { + actor->attackertype = DukeShotSparkClass; + actor->hitextra = 5; + } + } + } + return sphit; +} + //--------------------------------------------------------------------------- // // the indirections here are to keep this core function free of game references // //--------------------------------------------------------------------------- -void fall_common(DDukeActor *actor, int playernum, int(*fallspecial)(DDukeActor*, int)) +void fall(DDukeActor *actor, int playernum) { actor->spr.xoffset = 0; actor->spr.yoffset = 0; @@ -3840,7 +3914,7 @@ void fall_common(DDukeActor *actor, int playernum, int(*fallspecial)(DDukeActor* { double grav; - int sphit = fallspecial? fallspecial(actor, playernum) : 0; + int sphit = fallspecial(actor, playernum); if (floorspace(actor->sector())) grav = 0; else diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 9b1632a2f..025ca9490 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -864,17 +864,6 @@ void moveeffectors_d(void) //STATNUM 3 // //--------------------------------------------------------------------------- -void fall_d(DDukeActor *actor, int g_p) -{ - fall_common(actor, g_p, nullptr); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void think_d(void) { thinktime.Reset(); diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 4a5b86d2f..cd31e6d03 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1025,96 +1025,6 @@ void fakebubbaspawn(DDukeActor *actor, player_struct* p) } } -//--------------------------------------------------------------------------- -// -// special checks in fall that only apply to RR. -// -//--------------------------------------------------------------------------- - -static int fallspecial(DDukeActor *actor, int playernum) -{ - int sphit = 0; - if (ud.mapflags & MFLAG_ALLSECTORTYPES) - { - if (actor->sector()->lotag == ST_801_ROCKY) - { - if (actor->GetClass() == RedneckRockClass) - { - spawn(actor, RedneckRock2Class); - spawn(actor, RedneckRock2Class); - addspritetodelete(); - } - return 0; - } - else if (actor->sector()->lotag == ST_802_KILLBADGUYS) - { - if (!actor->isPlayer() && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F) - { - spawnguts(actor, DukeJibs6Class, 5); - S_PlayActorSound(SQUISHED, actor); - addspritetodelete(); - } - return 0; - } - else if (actor->sector()->lotag == ST_803_KILLROCKS) - { - if (actor->GetClass() == RedneckRock2Class) - addspritetodelete(); - return 0; - } - } - if (ud.mapflags & (MFLAG_ALLSECTORTYPES | MFLAG_SECTORTYPE800)) - { - if (actor->sector()->lotag == ST_800_KILLSTUFF) - { - if (actor->spr.picnum == RTILE_AMMO) - { - addspritetodelete(); - return 0; - } - if (!actor->isPlayer() && (badguy(actor)) && (!isRRRA() || actor->spriteextra < 128)) - { - actor->spr.pos.Z = actor->floorz - FOURSLEIGHT_F; - actor->vel.Z = 8000 / 256.; - actor->spr.extra = 0; - actor->spriteextra++; - sphit = 1; - } - else if (!actor->isPlayer()) - { - if (!actor->spriteextra) - addspritetodelete(); - return 0; - } - actor->attackertype = DukeShotSparkClass; - actor->hitextra = 1; - } - } - if (tilesurface(actor->sector()->floortexture) == TSURF_MAGMA) - { - if (actor->spr.picnum != RTILE_MINION && actor->spr.pal != 19) - { - if ((krand() & 3) == 1) - { - actor->attackertype = DukeShotSparkClass; - actor->hitextra = 5; - } - } - } - return sphit; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void fall_r(DDukeActor* ac, int g_p) -{ - fall_common(ac, g_p, fallspecial); -} - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 13943af38..9c448ad2f 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -438,6 +438,7 @@ enum sflags3_t SFLAG3_NOJIBS = 0x01000000, SFLAG3_NOVERTICALMOVE = 0x02000000, SFLAG3_MOVE_NOPLAYERINTERACT = 0x04000000, + SFLAG3_MAGMAIMMUNE = 0x08000000, }; using EDukeFlags3 = TFlags; diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 4676f26d7..187c19bda 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -48,8 +48,6 @@ void addweapon_d(player_struct* p, int weapon, bool wswitch); void addweapon_r(player_struct* p, int weapon, bool wswitch); int ifhitbyweapon_r(DDukeActor* sn); int ifhitbyweapon_d(DDukeActor* sn); -void fall_d(DDukeActor* i, int g_p); -void fall_r(DDukeActor* i, int g_p); void incur_damage_d(player_struct* p); void incur_damage_r(player_struct* p); void selectweapon_d(int snum, int j); @@ -88,7 +86,6 @@ void SetDispatcher() addweapon_d, ifhitbyweapon_d, - fall_d, incur_damage_d, selectweapon_d, @@ -113,7 +110,6 @@ void SetDispatcher() addweapon_r, ifhitbyweapon_r, - fall_r, incur_damage_r, selectweapon_r, diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index d3f08626a..883626713 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -82,7 +82,6 @@ struct Dispatcher void (*addweapon)(player_struct *p, int weapon, bool wswitch); int (*ifhitbyweapon)(DDukeActor* sectnum); - void (*fall)(DDukeActor* actor, int g_p); // player void (*incur_damage)(player_struct* p); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 921d6a69e..31f5a06b6 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1792,7 +1792,7 @@ int ParseState::parse(void) insptr++; g_ac->spr.xoffset = 0; g_ac->spr.yoffset = 0; - fi.fall(g_ac, g_p); + fall(g_ac, g_p); break; case concmd_enda: case concmd_break: diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 4767e8417..e86e1daa6 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -818,7 +818,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, ChangeType, Duke_ChangeType) void Duke_fall(DDukeActor* self, player_struct* p) { - fi.fall(self, p->GetPlayerNum()); + fall(self, p->GetPlayerNum()); } DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, fall, Duke_fall) diff --git a/wadsrc/static/zscript/games/duke/actors/minion.zs b/wadsrc/static/zscript/games/duke/actors/minion.zs index 8dee5551f..d0c9ffe21 100644 --- a/wadsrc/static/zscript/games/duke/actors/minion.zs +++ b/wadsrc/static/zscript/games/duke/actors/minion.zs @@ -13,11 +13,16 @@ class RedneckMinion : DukeActor { self.scale = (0.25, 0.25); self.setClipDistFromTile(); - if (Raze.isRRRA() && ud.ufospawnsminion) - self.pal = 8; - if (self.pal == 19) + if (Raze.isRRRA()) { - self.bHitradius_NoEffect = true; + if (ud.ufospawnsminion) + self.pal = 8; + + if (self.pal == 19) + { + self.bHitradius_NoEffect = true; + self.bMagmaImmune = true; + } } }