add a few commonly-used gzdoom-specific properties to the dehacked parser

This commit is contained in:
Xaser Acheron 2025-04-29 01:21:53 -05:00 committed by Ricardo Luís Vaz Silva
parent fc470b4f7c
commit 16dffcbbf0
2 changed files with 69 additions and 3 deletions

View file

@ -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];

View file

@ -480,6 +480,9 @@ xx(PowerupType)
xx(PlayerPawn)
xx(RipSound)
xx(Archvile)
xx(Obituary)
xx(HitObituary)
xx(SelfObituary)
xx(ResolveState)