From 16dffcbbf0823eaffed8212d1b4bc8c6e007035f Mon Sep 17 00:00:00 2001 From: Xaser Acheron Date: Tue, 29 Apr 2025 01:21:53 -0500 Subject: [PATCH] add a few commonly-used gzdoom-specific properties to the dehacked parser --- src/gamedata/d_dehacked.cpp | 69 +++++++++++++++++++++++++++++++++++-- src/namedef_custom.h | 3 ++ 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index 040735874f..1f6fc92c2c 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -1204,6 +1204,8 @@ static int PatchThing (int thingy, int flags) AActor *info; uint8_t dummy[sizeof(AActor)]; bool hadHeight = false; + bool hadProjHeight = false; + bool hadPhysHeight = false; bool hadTranslucency = false; bool hadStyle = false; FStateDefinitions statedef; @@ -1263,8 +1265,17 @@ static int PatchThing (int thingy, int flags) } else if (linelen == 6 && stricmp (Line1, "Height") == 0) { - info->Height = DEHToDouble(val); - info->projectilepassheight = 0; // needs to be disabled + // [XA] This is a bit more complex now, since projectilepassheight + // and "physical height" now both exist. if either of these are + // defined, then override the Height field accordingly. + if(!hadPhysHeight) + { + info->Height = DEHToDouble(val); + } + if(!hadProjHeight) + { + info->projectilepassheight = 0; // needs to be disabled + } hadHeight = true; } else if (linelen == 14 && stricmp (Line1, "Missile damage") == 0) @@ -1460,6 +1471,47 @@ static int PatchThing (int thingy, int flags) info->missilechancemult = DEHToDouble(val); } + // [XA] Fields for common GZDoom-specific values that + // are desirable to set in a cross-port DEHACKED mod. + // adding these prevents users from having to reimplement + // actors in zscript just to define these few fields. + else if (!stricmp(Line1, "Projectile pass height")) + { + info->projectilepassheight = DEHToDouble(val); + hadProjHeight = true; + } + else if (!stricmp(Line1, "Physical height")) + { + // [XA] This is a synonym for Height that is intended + // to be ignored in any ports that don't support + // projectilepassheight -- this is needed because + // other ports' "Height x" is actually equivalent + // to Zdoom's "ProjectilePassHeight x; Height y", + // i.e. the definition of the Height var is different. + info->Height = DEHToDouble(val); + hadPhysHeight = true; + } + else if (!stricmp(Line1, "Tag")) + { + stripwhite(Line2); + info->SetTag(Line2); + } + else if (!stricmp(Line1, "Obituary")) + { + stripwhite(Line2); + info->StringVar(NAME_Obituary) = Line2; + } + else if (!stricmp(Line1, "Melee obituary")) + { + stripwhite(Line2); + info->StringVar(NAME_HitObituary) = Line2; + } + else if (!stricmp(Line1, "Self obituary")) + { + stripwhite(Line2); + info->StringVar(NAME_SelfObituary) = Line2; + } + else if (linelen > 6) { if (stricmp (Line1 + linelen - 6, " frame") == 0) @@ -1728,12 +1780,23 @@ static int PatchThing (int thingy, int flags) else Printf (unknown_str, Line1, "Thing", thingy); } + // [XA] sanity check: to avoid ambiguity, an actor that defines + // ProjectilePassHeight must also define PhysicalHeight, and vice-versa. + if(hadPhysHeight && !hadProjHeight) + { + I_Error("Thing %d: DEHACKED actors that set 'Physical height' must also set 'Projectile pass height'\n", thingy); + } + else if(!hadPhysHeight && hadProjHeight) + { + I_Error("Thing %d: DEHACKED actors that set 'Projectile pass height' must also set 'Physical height'\n", thingy); + } + if (info != (AActor *)&dummy) { // Reset heights for things hanging from the ceiling that // don't specify a new height. if (info->flags & MF_SPAWNCEILING && - !hadHeight && + !hadHeight && !hadPhysHeight && thingy <= (int)OrgHeights.Size() && thingy > 0) { info->Height = OrgHeights[thingy - 1]; diff --git a/src/namedef_custom.h b/src/namedef_custom.h index dbf94dbafc..15b9d48d94 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -480,6 +480,9 @@ xx(PowerupType) xx(PlayerPawn) xx(RipSound) xx(Archvile) +xx(Obituary) +xx(HitObituary) +xx(SelfObituary) xx(ResolveState)