- cleaned up checkhitdefault

Only required 4 new flags plus one property...
This commit is contained in:
Christoph Oelckers 2022-12-31 17:16:11 +01:00
parent 125ea52e57
commit 4692cc55f7
22 changed files with 58 additions and 29 deletions

View file

@ -31,4 +31,5 @@ xx(floating_floordist)
xx(floating_ceilingdist)
xx(landmovefactor)
xx(watermovefactor)
xx(gravityfactor)
xx(gravityfactor)
xx(minhitscale)

View file

@ -196,6 +196,10 @@ static FFlagDef DukeActorFlagDefs[] =
DEFINE_FLAG(SFLAG3, MAGMAIMMUNE, DDukeActor, flags3),
DEFINE_FLAG(SFLAG3, DESTRUCTOIMMUNE, DDukeActor, flags3),
DEFINE_FLAG(SFLAG3, NOHITJIBS, DDukeActor, flags3),
DEFINE_FLAG(SFLAG3, CANHURTSHOOTER, DDukeActor, flags3),
DEFINE_FLAG(SFLAG3, NOSHOTGUNBLOOD, DDukeActor, flags3),
DEFINE_FLAG(SFLAG4, DOUBLEHITDAMAGE, DDukeActor, flags4),
DEFINE_FLAG(SFLAG4, NODAMAGETURN, DDukeActor, flags4),
};

View file

@ -1065,10 +1065,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 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))
if (!shrinkersizecheck(actor->GetClass(), act2))
{
continue;
}

View file

@ -199,10 +199,10 @@ int ifhitbyweapon_d(DDukeActor *actor)
else
{
if (actor->hitextra == 0)
if (actor->attackertype == DukeShrinkSparkClass && actor->spr.scale.X < 0.375)
if (!shrinkersizecheck(actor->attackertype, actor))
return -1;
if (actor->attackertype == DukeFireflyClass && actor->spr.scale.X < 0.75)
if (actor->spr.scale.X < actor->FloatVar(NAME_minhitscale))
{
return -1;
}

View file

@ -209,10 +209,6 @@ int ifhitbyweapon_r(DDukeActor *actor)
}
else
{
if (actor->hitextra == 0)
if (actor->spr.scale.X < 0.375)
return -1;
actor->spr.extra -= actor->hitextra;
auto Owner = actor->GetOwner();
if (!(actor->flags2 & SFLAG2_IGNOREHITOWNER) && Owner && Owner->spr.statnum < MAXSTATUS)

View file

@ -441,11 +441,23 @@ enum sflags3_t
SFLAG3_MAGMAIMMUNE = 0x08000000,
SFLAG3_DESTRUCTOIMMUNE = 0x10000000,
SFLAG3_NOHITJIBS = 0x20000000,
SFLAG3_CANHURTSHOOTER = 0x40000000,
SFLAG3_NOSHOTGUNBLOOD = 0x80000000,
};
using EDukeFlags3 = TFlags<sflags3_t, uint32_t>;
DEFINE_TFLAGS_OPERATORS(EDukeFlags3)
enum sflags4_t
{
SFLAG4_DOUBLEHITDAMAGE = 0x00000001,
SFLAG4_NODAMAGETURN = 0x00000002,
};
using EDukeFlags4 = TFlags<sflags4_t, uint32_t>;
DEFINE_TFLAGS_OPERATORS(EDukeFlags4)
// these get stored as user flags inside the texture manager.
enum
{

View file

@ -304,6 +304,13 @@ inline bool DDukeActor::isPlayer() const
return IsKindOf(DukePlayerBaseClass);
}
inline bool shrinkersizecheck(PClass* type, DDukeActor* act2)
{
// 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.
return type != DukeShrinkSparkClass || (act2->spr.scale.X >= 0.375);
}
inline void setPlayerActorViewZOffset(DDukeActor* const pact)
{

View file

@ -318,6 +318,7 @@ void DDukeActor::Serialize(FSerializer& arc)
("flags1", flags1)
("flags2", flags2)
("flags3", flags3)
("flags4", flags4)
("curmove", curMove)
("curaction", curAction)
("curai", curAI)

View file

@ -164,14 +164,14 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
if ((targ->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL) && targ->spr.hitag == 0 && targ->spr.lotag == 0 && targ->spr.statnum == STAT_DEFAULT)
return;
if ((proj->spr.picnum == DTILE_FREEZEBLAST || proj->GetOwner() != targ) && targ->spr.statnum != STAT_PROJECTILE)
if (((proj->flags3 & SFLAG3_CANHURTSHOOTER) || proj->GetOwner() != targ) && targ->spr.statnum != STAT_PROJECTILE)
{
if (badguy(targ))
{
if (isWorldTour() && targ->spr.picnum == DTILE_FIREFLY && targ->spr.scale.X < 0.75)
if (targ->spr.scale.X < targ->FloatVar(NAME_minhitscale))
return;
if (proj->spr.picnum == DTILE_RPG) proj->spr.extra <<= 1;
if (proj->flags4 & SFLAG4_DOUBLEHITDAMAGE) proj->spr.extra <<= 1;
if (!(targ->flags3 & SFLAG3_NOHITJIBS) && !(proj->flags3 & SFLAG3_NOHITJIBS))
{
@ -189,7 +189,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
auto Owner = proj->GetOwner();
if (Owner && Owner->isPlayer() && targ->spr.picnum != DTILE_ROTATEGUN && targ->spr.picnum != DTILE_DRONE)
if (Owner && Owner->isPlayer() && !(targ->flags3 & SFLAG3_NOSHOTGUNBLOOD))
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
{
shoot(targ, DukeBloodSplat3Class);
@ -215,7 +215,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
ChangeActorStat(targ, STAT_ACTOR);
targ->timetosleep = SLEEPTIME;
}
if ((targ->spr.scale.X < 0.375 || targ->spr.picnum == DTILE_SHARK) && proj->spr.picnum == DTILE_SHRINKSPARK) return;
if (!shrinkersizecheck(proj->GetClass(), targ)) return;
}
if (targ->spr.statnum != STAT_ZOMBIEACTOR)
@ -231,7 +231,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
return;
auto tOwner = targ->GetOwner();
if (hitpic == DukeFireballClass && tOwner && tOwner->GetClass() != DukeFireballClass)
if (hitpic == DukeFireballClass && tOwner && tOwner->GetClass() != DukeFireballClass) // hack alert! Even with damage types this special check needs to stay.
hitpic = DukeFlamethrowerFlameClass;
}
@ -243,7 +243,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
if (targ->spr.statnum == STAT_PLAYER)
{
auto p = targ->spr.yint;
auto p = targ->PlayerIndex();
if (ps[p].newOwner != nullptr)
{
ps[p].newOwner = nullptr;
@ -258,7 +258,7 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
}
}
if (targ->spr.scale.X < 0.375 && proj->GetClass() == DukeShrinkSparkClass)
if (!shrinkersizecheck(proj->GetClass(), targ))
return;
auto hitowner = targ->GetHitOwner();

View file

@ -164,12 +164,11 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj)
if ((targ->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL) && targ->spr.hitag == 0 && targ->spr.lotag == 0 && targ->spr.statnum == 0)
return;
if ((proj->spr.picnum == RTILE_SAWBLADE || proj->spr.picnum == RTILE_FREEZEBLAST || proj->GetOwner() != targ) && targ->spr.statnum != 4)
if (((proj->flags3 & SFLAG3_CANHURTSHOOTER) || proj->GetOwner() != targ) && targ->spr.statnum != STAT_PROJECTILE)
{
if (badguy(targ) == 1)
{
if (proj->spr.picnum == RTILE_RPG) proj->spr.extra <<= 1;
else if (isRRRA() && proj->spr.picnum == RTILE_RPG2) proj->spr.extra <<= 1;
if (proj->flags4 & SFLAG4_DOUBLEHITDAMAGE) proj->spr.extra <<= 1;
if (!(targ->flags3 & SFLAG3_NOHITJIBS) && !(proj->flags3 & SFLAG3_NOHITJIBS))
{
@ -187,7 +186,7 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj)
auto Owner = proj->GetOwner();
if (Owner && Owner->isPlayer() && targ->spr.picnum != RTILE_DRONE)
if (Owner && Owner->isPlayer() && !(targ->flags3 & SFLAG3_NOSHOTGUNBLOOD))
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
{
shoot(targ, DukeBloodSplat3Class);
@ -203,25 +202,25 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj)
}
}
if (targ->spr.statnum != 2)
if (targ->spr.statnum != STAT_ZOMBIEACTOR)
{
if (proj->spr.picnum == RTILE_FREEZEBLAST && ((targ->isPlayer() && targ->spr.pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ)))
if ((proj->flags2 & SFLAG2_FREEZEDAMAGE) && ((targ->isPlayer() && targ->spr.pal == 1) || (gs.freezerhurtowner == 0 && proj->GetOwner() == targ)))
return;
targ->attackertype = static_cast<PClassActor*>(proj->GetClass());
targ->hitextra += proj->spr.extra;
if (targ->spr.picnum != RTILE_COW)
if (!(targ->flags4 & SFLAG4_NODAMAGETURN))
targ->hitang = proj->spr.Angles.Yaw;
targ->SetHitOwner(proj->GetOwner());
}
if (targ->spr.statnum == 10)
if (targ->spr.statnum == STAT_PLAYER)
{
auto p = targ->PlayerIndex();
if (ps[p].newOwner != nullptr)
{
ps[p].newOwner = nullptr;
ps[p].GetActor()->restorepos();
ps[p].GetActor()->restoreloc();
updatesector(ps[p].GetActor()->getPosWithOffsetZ(), &ps[p].cursector);

View file

@ -653,7 +653,7 @@ void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
}
if (!found)
{
actor->spr.picnum = 0;
actor->spr.setspritetexture(FNullTextureID());
actor->spr.cstat2 = CSTAT2_SPRITE_NOFIND;
actor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
ChangeActorStat(actor, STAT_REMOVED);

View file

@ -105,6 +105,7 @@ public:
EDukeFlags1 flags1;
EDukeFlags2 flags2;
EDukeFlags3 flags3;
EDukeFlags4 flags4;
TObjPtr<DDukeActor*> temp_actor, seek_actor;
TArray<GameVarValue> uservars;

View file

@ -13,6 +13,7 @@ class DukeDrone : DukeActor
+QUICKALTERANG;
+NOJIBS;
+NOHITJIBS;
+NOSHOTGUNBLOOD;
falladjustz 0;
floating_floordist 30;
floating_ceilingdist 50;

View file

@ -15,6 +15,7 @@ class DukeRotateGun : DukeActor
+NOVERTICALMOVE;
+MOVE_NOPLAYERINTERACT;
+NOHITJIBS;
+NOSHOTGUNBLOOD;
sparkoffset -8;
aimoffset 32;

View file

@ -10,6 +10,7 @@ class DukeTurret : DukeActor
+KILLCOUNT;
+NOVERTICALMOVE;
+NOHITJIBS;
+NOSHOTGUNBLOOD;
aimoffset 32;
}

View file

@ -18,6 +18,7 @@ class DukeRPG : DukeProjectile
+DOUBLEDMGTHRUST;
+NOFLOORPAL;
+BREAKMIRRORS;
+DOUBLEHITDAMAGE;
DukeProjectile.SpawnSound "RPG_SHOOT";
}

View file

@ -6,6 +6,7 @@ class RedneckCow : DukeActor
{
pic "COW";
+BADGUY;
+NODAMAGETURN;
Strength COWSTRENGTH;
}

View file

@ -12,6 +12,7 @@ class RedneckMosquito : DukeActor
+QUICKALTERANG;
+NOJIBS;
+NOHITJIBS;
+NOSHOTGUNBLOOD;
falladjustz 0;
floating_floordist 30;
floating_ceilingdist 50;

View file

@ -11,6 +11,7 @@ class RedneckBoatGrenade : RedneckDynamiteArrow // RRRA only
pic "BOATGRENADE";
-DOUBLEDMGTHRUST;
-ALWAYSROTATE2;
-DOUBLEHITDAMAGE;
DukeProjectile.SpawnSound "MORTAR";
}

View file

@ -9,6 +9,7 @@ class RedneckSawBlade : DukeProjectile
{
default
{
+CANHURTSHOOTER;
spriteset "SAWBLADE", "SAWBLADE2", "SAWBLADE3", "SAWBLADE4", "SAWBLADE5", "SAWBLADE6", "SAWBLADE7", "SAWBLADE8",
"CHEERBLADE", "CHEERBLADE2", "CHEERBLADE3", "CHEERBLADE4";
Strength THROWSAW_WEAPON_STRENGTH;

View file

@ -86,6 +86,7 @@ class DukeFirefly : DukeLizTrooper // recycles part of the Liztrooper code and d
+INTERNAL_BADGUY;
+KILLCOUNT;
-DONTENTERWATERONGROUND;
minhitscale 0.75;
Strength FF_STRENGTH;
}

View file

@ -260,6 +260,7 @@ class DukeActor : CoreActor native
meta double landmovefactor;
meta double watermovefactor;
meta double gravityfactor;
meta double minhitscale;
property prefix: none;
property gutsoffset: gutsoffset;
@ -280,6 +281,7 @@ class DukeActor : CoreActor native
property landmovefactor: landmovefactor;
property watermovefactor: watermovefactor;
property gravityfactor: gravityfactor;
property minhitscale: minhitscale;
native void SetSpritesetImage(int index);