Skip to content

Commit

Permalink
- cleaned up movesprite_ex.
Browse files Browse the repository at this point in the history
This needed 5 actor flags to handle some really inane special cases!
  • Loading branch information
coelckers committed Mar 27, 2023
1 parent f7b6307 commit 0c7e265
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 15 deletions.
1 change: 1 addition & 0 deletions source/core/namedef_custom.h
Expand Up @@ -22,3 +22,4 @@ xx(aimoffset)
xx(strength)
xx(autoaimangle)
xx(shootzoffset)
xx(moveclipdist)
5 changes: 5 additions & 0 deletions source/core/thingdef_data.cpp
Expand Up @@ -182,6 +182,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),

};

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/actors.cpp
Expand Up @@ -907,7 +907,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))
Expand Down
27 changes: 14 additions & 13 deletions source/games/duke/src/actors_d.cpp
Expand Up @@ -174,29 +174,30 @@ 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);
}

// 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 = &sector[0];
Expand Down
7 changes: 6 additions & 1 deletion source/games/duke/src/constants.h
Expand Up @@ -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,
Expand Down Expand Up @@ -415,6 +415,11 @@ enum sflags3_t
SFLAG3_HITRADIUS_NODAMAGE = 0x00002000, // Hitradius inflicts no damage, only a damage type.
SFLAG3_HITRADIUS_NOEFFECT = 0x00004000, // Completely immune to hitradius
SFLAG3_HITRADIUS_DONTHURTSPECIES = 0x00008000, // don't hurt others of the shooter's species.
SFLAG3_ST3CONFINED = 0x00010000,
SFLAG3_DONTENTERWATER = 0x00020000,
SFLAG3_DONTENTERWATERONGROUND = 0x00040000,
SFLAG3_RANDOMANGLEONWATER = 0x00080000,
SFLAG3_NORANDOMANGLEWHENBLOCKED = 0x00100000,


};
Expand Down
1 change: 1 addition & 0 deletions source/games/duke/src/game.cpp
Expand Up @@ -682,6 +682,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.
}
}

Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/boss1.zs
Expand Up @@ -8,6 +8,7 @@ class DukeBoss1 : DukeActor
+NODAMAGEPUSH;
+BOSS;
+ALTHITSCANDIRECTION;
+DONTENTERWATER;
}

override void Initialize()
Expand Down
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/games/duke/actors/boss2.zs
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/boss3.zs
Expand Up @@ -4,6 +4,7 @@ class DukeBoss3 : DukeBoss1
{
pic "BOSS3";
-ALTHITSCANDIRECTION;
-DONTENTERWATER;
}

override void PlayFTASound()
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/boss4.zs
Expand Up @@ -4,6 +4,7 @@ class DukeBoss4 : DukeBoss1
{
pic "BOSS4";
-ALTHITSCANDIRECTION;
-DONTENTERWATER;
}

override void PlayFTASound()
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/boss5.zs
Expand Up @@ -4,6 +4,7 @@ class DukeBoss5 : DukeBoss1
{
pic "BOSS5";
-ALTHITSCANDIRECTION;
-DONTENTERWATER;
}
}

Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/commander.zs
Expand Up @@ -8,6 +8,7 @@ class DukeCommander : DukeActor
+NOWATERDIP;
+FLOATING;
+SHOOTCENTERED;
+NORANDOMANGLEWHENBLOCKED;
gutsoffset -24;
falladjustz 0;
}
Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/zscript/games/duke/actors/lizman.zs
Expand Up @@ -7,6 +7,9 @@ class DukeLizMan : DukeActor
+INTERNAL_BADGUY;
+KILLCOUNT;
+GREENSLIMEFOOD;
+DONTENTERWATER;
+RANDOMANGLEONWATER;
moveclipdist 18.25;
}

override void PlayFTASound()
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/games/duke/actors/liztroop.zs
Expand Up @@ -9,6 +9,7 @@ class DukeLizTrooper : DukeActor
+KILLCOUNT;
+GREENSLIMEFOOD;
+TRANSFERPALTOJIBS;
+DONTENTERWATERONGROUND;
}

override void PlayFTASound()
Expand Down
2 changes: 2 additions & 0 deletions wadsrc/static/zscript/games/duke/dukeactor.zs
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 0c7e265

Please sign in to comment.