From 46f7e38e46dda3d7d8dc258bc106aff030470e52 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Dec 2022 19:12:35 +0100 Subject: [PATCH] - cleaned up movesprite_ex. This needed 5 actor flags to handle some really inane special cases! --- source/core/namedef_custom.h | 1 + source/core/thingdef_data.cpp | 5 ++++ source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/actors_d.cpp | 27 ++++++++++--------- source/games/duke/src/constants.h | 7 ++++- source/games/duke/src/game.cpp | 1 + .../static/zscript/games/duke/actors/boss1.zs | 1 + .../static/zscript/games/duke/actors/boss2.zs | 2 ++ .../static/zscript/games/duke/actors/boss3.zs | 1 + .../static/zscript/games/duke/actors/boss4.zs | 1 + .../static/zscript/games/duke/actors/boss5.zs | 1 + .../zscript/games/duke/actors/commander.zs | 1 + .../zscript/games/duke/actors/lizman.zs | 3 +++ .../zscript/games/duke/actors/liztroop.zs | 1 + wadsrc/static/zscript/games/duke/dukeactor.zs | 2 ++ 15 files changed, 41 insertions(+), 15 deletions(-) diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index bf5c08bc5..5c8e6bc60 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -22,3 +22,4 @@ xx(aimoffset) xx(strength) xx(autoaimangle) xx(shootzoffset) +xx(moveclipdist) \ No newline at end of file diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index 6e752e6fb..cb4795388 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -183,6 +183,11 @@ static FFlagDef DukeActorFlagDefs[] = DEFINE_FLAG(SFLAG3, HITRADIUS_NODAMAGE, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, HITRADIUS_NOEFFECT, DDukeActor, flags3), DEFINE_FLAG(SFLAG3, HITRADIUS_DONTHURTSPECIES, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, ST3CONFINED, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, DONTENTERWATER, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, DONTENTERWATERONGROUND, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, RANDOMANGLEONWATER, DDukeActor, flags3), + DEFINE_FLAG(SFLAG3, NORANDOMANGLEWHENBLOCKED, DDukeActor, flags3), }; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index b80213e9f..97f526574 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -902,7 +902,7 @@ void hitradius(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4 } else if (act2->spr.extra >= 0 && act2 != actor && ((act2->flags1 & SFLAG_HITRADIUS_FORCEEFFECT) || badguy(act2) || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL))) { - // this is a damage type check, not a projectile type check. + // this should be a damage type check, not a projectile type check. // It's also quite broken because it doesn't check for being shrunk but tries to guess it from the size. // Unfortunately, with CON there is no way to retrieve proper shrunk state in any way. if (actor->GetClass() == DukeShrinkSparkClass && (act2->spr.scale.X < 0.375)) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 9ab5d01a6..ce389bd4f 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -174,13 +174,14 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip else { // todo: move this mess to the actor definitions once we have them all available. - double clipdist; - if (actor->spr.picnum == DTILE_LIZMAN) - clipdist = 18.25; - else if ((actor->flags1 & SFLAG_BADGUY)) - clipdist = actor->clipdist; - else - clipdist = 12; + double clipdist = actor->FloatVar(NAME_moveclipdist); + if (clipdist == 0) + { + if ((actor->flags1 & SFLAG_BADGUY) && !isRR()) + clipdist = actor->clipdist; + else + clipdist = 12; + } clipmove(ppos, &dasectp, change * 0.5, clipdist, 4., 4., cliptype, result); } @@ -188,15 +189,15 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip // conditional code from hell... if (dasectp == nullptr || (dasectp != nullptr && ((actor->actorstayput != nullptr && actor->actorstayput != dasectp) || - ((actor->spr.picnum == DTILE_BOSS2) && actor->spr.pal == 0 && dasectp->lotag != ST_3) || - ((actor->spr.picnum == DTILE_BOSS1 || actor->spr.picnum == DTILE_BOSS2) && dasectp->lotag == ST_1_ABOVE_WATER) || - (dasectp->lotag == ST_1_ABOVE_WATER && (actor->spr.picnum == DTILE_LIZMAN || (actor->spr.picnum == DTILE_LIZTROOP && actor->vel.Z == 0))) - )) + ((actor->flags3 & SFLAG3_ST3CONFINED) && actor->spr.pal == 0 && dasectp->lotag != ST_3_BOSS2) || + ((actor->flags3 & SFLAG3_DONTENTERWATER) && dasectp->lotag == ST_1_ABOVE_WATER) || + ((actor->flags3 & SFLAG3_DONTENTERWATERONGROUND) && actor->vel.Z == 0 && dasectp->lotag == ST_1_ABOVE_WATER)) + ) ) { - if (dasectp && dasectp->lotag == ST_1_ABOVE_WATER && actor->spr.picnum == DTILE_LIZMAN) + if (dasectp && dasectp->lotag == ST_1_ABOVE_WATER && (actor->flags3 & SFLAG3_RANDOMANGLEONWATER)) actor->spr.Angles.Yaw = randomAngle(); - else if ((actor->counter&3) == 1 && actor->spr.picnum != DTILE_COMMANDER) + else if ((actor->counter&3) == 1 && !(actor->flags3 & SFLAG3_NORANDOMANGLEWHENBLOCKED)) actor->spr.Angles.Yaw = randomAngle(); SetActor(actor,actor->spr.pos); if (dasectp == nullptr) dasectp = §or[0]; diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 5f7df9793..0964e48c2 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -115,7 +115,7 @@ enum ST_0_NO_EFFECT = 0, ST_1_ABOVE_WATER = 1, ST_2_UNDERWATER = 2, - ST_3 = 3, + ST_3_BOSS2 = 3, // ^^^ maybe not complete substitution in code ST_9_SLIDING_ST_DOOR = 9, ST_15_WARP_ELEVATOR = 15, @@ -416,6 +416,11 @@ enum sflags3_t SFLAG3_HITRADIUS_NODAMAGE = 0x00004000, // Hitradius inflicts no damage, only a damage type. SFLAG3_HITRADIUS_NOEFFECT = 0x00008000, // Completely immune to hitradius SFLAG3_HITRADIUS_DONTHURTSPECIES = 0x00010000, // don't hurt others of the shooter's species. + SFLAG3_ST3CONFINED = 0x00020000, + SFLAG3_DONTENTERWATER = 0x00040000, + SFLAG3_DONTENTERWATERONGROUND = 0x00080000, + SFLAG3_RANDOMANGLEONWATER = 0x00100000, + SFLAG3_NORANDOMANGLEWHENBLOCKED = 0x00200000, }; diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index f011984f6..f71defd4c 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -684,6 +684,7 @@ DEFINE_PROPERTY(setgamedefaults, 0, DukeActor) { defaults->flags1 |= SFLAG_MOVEFTA_WAKEUPCHECK; // Animals were not supposed to have this, but due to a coding bug the logic was unconditional for everything in the game. defaults->flags2 |= SFLAG2_NODAMAGEPUSH; // RR does not have this feature, so set the flag for everything, this allows disabling it if wanted later. + defaults->flags3 |= SFLAG3_RANDOMANGLEONWATER; // RR does this for all badguys, Duke only for the LizMan. } } diff --git a/wadsrc/static/zscript/games/duke/actors/boss1.zs b/wadsrc/static/zscript/games/duke/actors/boss1.zs index 6b85122c1..14f7b1f21 100644 --- a/wadsrc/static/zscript/games/duke/actors/boss1.zs +++ b/wadsrc/static/zscript/games/duke/actors/boss1.zs @@ -8,6 +8,7 @@ class DukeBoss1 : DukeActor +NODAMAGEPUSH; +BOSS; +ALTHITSCANDIRECTION; + +DONTENTERWATER; } override void Initialize() diff --git a/wadsrc/static/zscript/games/duke/actors/boss2.zs b/wadsrc/static/zscript/games/duke/actors/boss2.zs index dd79388cf..49543020c 100644 --- a/wadsrc/static/zscript/games/duke/actors/boss2.zs +++ b/wadsrc/static/zscript/games/duke/actors/boss2.zs @@ -6,6 +6,8 @@ class DukeBoss2 : DukeBoss1 -ALTHITSCANDIRECTION; +NONSMOKYROCKET; // If this wasn't needed for a CON defined actor it could be handled better +SPECIALINIT; + +ST3CONFINED; + +DONTENTERWATER; } override void PlayFTASound() diff --git a/wadsrc/static/zscript/games/duke/actors/boss3.zs b/wadsrc/static/zscript/games/duke/actors/boss3.zs index defed8d95..e4d4614d1 100644 --- a/wadsrc/static/zscript/games/duke/actors/boss3.zs +++ b/wadsrc/static/zscript/games/duke/actors/boss3.zs @@ -4,6 +4,7 @@ class DukeBoss3 : DukeBoss1 { pic "BOSS3"; -ALTHITSCANDIRECTION; + -DONTENTERWATER; } override void PlayFTASound() diff --git a/wadsrc/static/zscript/games/duke/actors/boss4.zs b/wadsrc/static/zscript/games/duke/actors/boss4.zs index a3197ecbd..5ffeba2e6 100644 --- a/wadsrc/static/zscript/games/duke/actors/boss4.zs +++ b/wadsrc/static/zscript/games/duke/actors/boss4.zs @@ -4,6 +4,7 @@ class DukeBoss4 : DukeBoss1 { pic "BOSS4"; -ALTHITSCANDIRECTION; + -DONTENTERWATER; } override void PlayFTASound() diff --git a/wadsrc/static/zscript/games/duke/actors/boss5.zs b/wadsrc/static/zscript/games/duke/actors/boss5.zs index 3bb83516d..9a392f580 100644 --- a/wadsrc/static/zscript/games/duke/actors/boss5.zs +++ b/wadsrc/static/zscript/games/duke/actors/boss5.zs @@ -4,6 +4,7 @@ class DukeBoss5 : DukeBoss1 { pic "BOSS5"; -ALTHITSCANDIRECTION; + -DONTENTERWATER; } } diff --git a/wadsrc/static/zscript/games/duke/actors/commander.zs b/wadsrc/static/zscript/games/duke/actors/commander.zs index 478a18f8c..3a26fa43c 100644 --- a/wadsrc/static/zscript/games/duke/actors/commander.zs +++ b/wadsrc/static/zscript/games/duke/actors/commander.zs @@ -8,6 +8,7 @@ class DukeCommander : DukeActor +NOWATERDIP; +FLOATING; +SHOOTCENTERED; + +NORANDOMANGLEWHENBLOCKED; gutsoffset -24; falladjustz 0; } diff --git a/wadsrc/static/zscript/games/duke/actors/lizman.zs b/wadsrc/static/zscript/games/duke/actors/lizman.zs index e9374b0e7..6d285ad4a 100644 --- a/wadsrc/static/zscript/games/duke/actors/lizman.zs +++ b/wadsrc/static/zscript/games/duke/actors/lizman.zs @@ -7,6 +7,9 @@ class DukeLizMan : DukeActor +INTERNAL_BADGUY; +KILLCOUNT; +GREENSLIMEFOOD; + +DONTENTERWATER; + +RANDOMANGLEONWATER; + moveclipdist 18.25; } override void PlayFTASound() diff --git a/wadsrc/static/zscript/games/duke/actors/liztroop.zs b/wadsrc/static/zscript/games/duke/actors/liztroop.zs index f981f7688..1e44ba2ab 100644 --- a/wadsrc/static/zscript/games/duke/actors/liztroop.zs +++ b/wadsrc/static/zscript/games/duke/actors/liztroop.zs @@ -8,6 +8,7 @@ class DukeLizTrooper : DukeActor +KILLCOUNT; +GREENSLIMEFOOD; +TRANSFERPALTOJIBS; + +DONTENTERWATERONGROUND; } override void Initialize() diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 4892a4ea3..348bd8894 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -241,6 +241,7 @@ class DukeActor : CoreActor native meta double sparkoffset; meta double projectilespread; meta double shootzoffset; + meta double moveclipdist; property prefix: none; property gutsoffset: gutsoffset; @@ -251,6 +252,7 @@ class DukeActor : CoreActor native property sparkoffset: sparkoffset; property projectilespread: projectilespread; property shootzoffset: shootzoffset; + property moveclipdist: moveclipdist; native void SetSpritesetImage(int index); native int GetSpritesetSize();