From 4692cc55f7a43e5a1574c3da74a3de67ab2c2607 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 31 Dec 2022 17:16:11 +0100 Subject: [PATCH] - cleaned up checkhitdefault Only required 4 new flags plus one property... --- source/core/namedef_custom.h | 3 ++- source/core/thingdef_data.cpp | 4 ++++ source/games/duke/src/actors.cpp | 5 +---- source/games/duke/src/actors_d.cpp | 4 ++-- source/games/duke/src/actors_r.cpp | 4 ---- source/games/duke/src/constants.h | 12 ++++++++++++ source/games/duke/src/inlines.h | 7 +++++++ source/games/duke/src/savegame.cpp | 1 + source/games/duke/src/sectors_d.cpp | 16 ++++++++-------- source/games/duke/src/sectors_r.cpp | 17 ++++++++--------- source/games/duke/src/spawn.cpp | 2 +- source/games/duke/src/types.h | 1 + .../games/duke/actors/dukeenemies/drone.zs | 1 + .../games/duke/actors/dukeenemies/rotategun.zs | 1 + .../games/duke/actors/dukeenemies/turret.zs | 1 + .../games/duke/actors/dukeweapons/rpg.zs | 1 + .../games/duke/actors/redneckenemies/cow.zs | 1 + .../duke/actors/redneckenemies/mosquito.zs | 1 + .../duke/actors/redneckweapons/boatcannon.zs | 1 + .../games/duke/actors/redneckweapons/ripsaw.zs | 1 + .../games/duke/actors/worldtour/firefly.zs | 1 + wadsrc/static/zscript/games/duke/dukeactor.zs | 2 ++ 22 files changed, 58 insertions(+), 29 deletions(-) diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index d309ad9a7..6c7f605e2 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -31,4 +31,5 @@ xx(floating_floordist) xx(floating_ceilingdist) xx(landmovefactor) xx(watermovefactor) -xx(gravityfactor) \ No newline at end of file +xx(gravityfactor) +xx(minhitscale) diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index b8a45558b..6c0493a62 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -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), }; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index f67132ee8..5809d5a1b 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -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; } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index d5bfd6d07..dafee9036 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -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; } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index f3f053309..7f212047c 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -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) diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 8c07e3760..8ffb099b6 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -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; DEFINE_TFLAGS_OPERATORS(EDukeFlags3) +enum sflags4_t +{ + SFLAG4_DOUBLEHITDAMAGE = 0x00000001, + SFLAG4_NODAMAGETURN = 0x00000002, +}; + +using EDukeFlags4 = TFlags; +DEFINE_TFLAGS_OPERATORS(EDukeFlags4) + // these get stored as user flags inside the texture manager. enum { diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index bd798ec67..2a33b8102 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -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) { diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index a9a7f73ee..226d49d41 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -318,6 +318,7 @@ void DDukeActor::Serialize(FSerializer& arc) ("flags1", flags1) ("flags2", flags2) ("flags3", flags3) + ("flags4", flags4) ("curmove", curMove) ("curaction", curAction) ("curai", curAI) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index f6b8e10b8..ae364e7b5 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -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(); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index a896dac3f..e3e9ad9b8 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -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(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); diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index f3692e905..ad7db2119 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -653,7 +653,7 @@ void spawneffector(DDukeActor* actor, TArray* 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); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 8d1eefb97..41ee7fa28 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -105,6 +105,7 @@ public: EDukeFlags1 flags1; EDukeFlags2 flags2; EDukeFlags3 flags3; + EDukeFlags4 flags4; TObjPtr temp_actor, seek_actor; TArray uservars; diff --git a/wadsrc/static/zscript/games/duke/actors/dukeenemies/drone.zs b/wadsrc/static/zscript/games/duke/actors/dukeenemies/drone.zs index bfc7ecc74..f7964597d 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeenemies/drone.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeenemies/drone.zs @@ -13,6 +13,7 @@ class DukeDrone : DukeActor +QUICKALTERANG; +NOJIBS; +NOHITJIBS; + +NOSHOTGUNBLOOD; falladjustz 0; floating_floordist 30; floating_ceilingdist 50; diff --git a/wadsrc/static/zscript/games/duke/actors/dukeenemies/rotategun.zs b/wadsrc/static/zscript/games/duke/actors/dukeenemies/rotategun.zs index 661ddc7d9..32239c54a 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeenemies/rotategun.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeenemies/rotategun.zs @@ -15,6 +15,7 @@ class DukeRotateGun : DukeActor +NOVERTICALMOVE; +MOVE_NOPLAYERINTERACT; +NOHITJIBS; + +NOSHOTGUNBLOOD; sparkoffset -8; aimoffset 32; diff --git a/wadsrc/static/zscript/games/duke/actors/dukeenemies/turret.zs b/wadsrc/static/zscript/games/duke/actors/dukeenemies/turret.zs index 0c436d390..86f5ce14e 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeenemies/turret.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeenemies/turret.zs @@ -10,6 +10,7 @@ class DukeTurret : DukeActor +KILLCOUNT; +NOVERTICALMOVE; +NOHITJIBS; + +NOSHOTGUNBLOOD; aimoffset 32; } diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs index c5ed1dc18..9f0c4d5b6 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/rpg.zs @@ -18,6 +18,7 @@ class DukeRPG : DukeProjectile +DOUBLEDMGTHRUST; +NOFLOORPAL; +BREAKMIRRORS; + +DOUBLEHITDAMAGE; DukeProjectile.SpawnSound "RPG_SHOOT"; } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckenemies/cow.zs b/wadsrc/static/zscript/games/duke/actors/redneckenemies/cow.zs index 16d14b220..07c912b5c 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckenemies/cow.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckenemies/cow.zs @@ -6,6 +6,7 @@ class RedneckCow : DukeActor { pic "COW"; +BADGUY; + +NODAMAGETURN; Strength COWSTRENGTH; } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckenemies/mosquito.zs b/wadsrc/static/zscript/games/duke/actors/redneckenemies/mosquito.zs index 33d813beb..30d8c9060 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckenemies/mosquito.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckenemies/mosquito.zs @@ -12,6 +12,7 @@ class RedneckMosquito : DukeActor +QUICKALTERANG; +NOJIBS; +NOHITJIBS; + +NOSHOTGUNBLOOD; falladjustz 0; floating_floordist 30; floating_ceilingdist 50; diff --git a/wadsrc/static/zscript/games/duke/actors/redneckweapons/boatcannon.zs b/wadsrc/static/zscript/games/duke/actors/redneckweapons/boatcannon.zs index c6bd3f554..8b8bcdf31 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckweapons/boatcannon.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckweapons/boatcannon.zs @@ -11,6 +11,7 @@ class RedneckBoatGrenade : RedneckDynamiteArrow // RRRA only pic "BOATGRENADE"; -DOUBLEDMGTHRUST; -ALWAYSROTATE2; + -DOUBLEHITDAMAGE; DukeProjectile.SpawnSound "MORTAR"; } diff --git a/wadsrc/static/zscript/games/duke/actors/redneckweapons/ripsaw.zs b/wadsrc/static/zscript/games/duke/actors/redneckweapons/ripsaw.zs index 32fb94c74..3b694a161 100644 --- a/wadsrc/static/zscript/games/duke/actors/redneckweapons/ripsaw.zs +++ b/wadsrc/static/zscript/games/duke/actors/redneckweapons/ripsaw.zs @@ -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; diff --git a/wadsrc/static/zscript/games/duke/actors/worldtour/firefly.zs b/wadsrc/static/zscript/games/duke/actors/worldtour/firefly.zs index 4eeb54fa5..36c2496a8 100644 --- a/wadsrc/static/zscript/games/duke/actors/worldtour/firefly.zs +++ b/wadsrc/static/zscript/games/duke/actors/worldtour/firefly.zs @@ -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; } diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 586ff7d7e..da9c20398 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -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);