From bca8d01ab3e5a4a64bbfa24af9bfbfd4b169993d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Jun 2021 01:34:14 +0200 Subject: [PATCH] - MBF21: infighting groups. --- src/gamedata/d_dehacked.cpp | 36 ++++++++++++++++++--------- src/gamedata/info.h | 3 +++ src/playsim/p_interaction.cpp | 14 ++++++++--- src/scripting/thingdef_properties.cpp | 13 ++++++++++ wadsrc/static/zscript/actors/actor.zs | 5 ++++ 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index f2d48939b..3e9011b2a 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -949,20 +949,32 @@ static int PatchThing (int thingy) hadStyle = true; } } + else if (linelen == 12 && stricmp(Line1, "No Ice Death") == 0) + { + if (val) + { + info->flags4 |= MF4_NOICEDEATH; + } + else + { + info->flags4 &= ~MF4_NOICEDEATH; + } + } + else if (linelen == 16 && stricmp(Line1, "infighting group") == 0) + { + stripwhite(Line2); + int grp = atoi(Line2); + if (grp < 0) + { + Printf("Infighting groups must be >= 0 (check your dehacked)\n"); + grp = 0; + } + type->ActorInfo()->infighting_group = grp; + } + else if (linelen > 6) { - if (linelen == 12 && stricmp (Line1, "No Ice Death") == 0) - { - if (val) - { - info->flags4 |= MF4_NOICEDEATH; - } - else - { - info->flags4 &= ~MF4_NOICEDEATH; - } - } - else if (stricmp (Line1 + linelen - 6, " frame") == 0) + if (stricmp (Line1 + linelen - 6, " frame") == 0) { FState *state = FindState (val); diff --git a/src/gamedata/info.h b/src/gamedata/info.h index ba2bbb335..0d2eadac4 100644 --- a/src/gamedata/info.h +++ b/src/gamedata/info.h @@ -245,6 +245,9 @@ struct FActorInfo uint16_t SpawnID = 0; uint16_t ConversationID = 0; int16_t DoomEdNum = -1; + int infighting_group = 0; + int projectile_group = 0; + int splash_group = 0; FStateLabels *StateList = nullptr; DmgFactors DamageFactors; diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index 0e1b87611..a054b763c 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -1600,13 +1600,13 @@ bool AActor::OkayToSwitchTarget(AActor *other) if (!(other->flags & MF_SHOOTABLE)) return false; // Don't attack things that can't be hurt - if ((flags4 & MF4_NOTARGETSWITCH) && target != NULL) + if ((flags4 & MF4_NOTARGETSWITCH) && target != nullptr) return false; // Don't switch target if not allowed - if ((master != NULL && other->IsA(master->GetClass())) || // don't attack your master (or others of its type) - (other->master != NULL && IsA(other->master->GetClass()))) // don't attack your minion (or those of others of your type) + if ((master != nullptr && other->IsA(master->GetClass())) || // don't attack your master (or others of its type) + (other->master != nullptr && IsA(other->master->GetClass()))) // don't attack your minion (or those of others of your type) { - if (!IsHostile (other) && // allow target switch if other is considered hostile + if (!IsHostile(other) && // allow target switch if other is considered hostile (other->tid != TIDtoHate || TIDtoHate == 0) && // or has the tid we hate other->TIDtoHate == TIDtoHate) // or has different hate information { @@ -1614,6 +1614,12 @@ bool AActor::OkayToSwitchTarget(AActor *other) } } + // MBF21 support. + auto mygroup = GetClass()->ActorInfo()->infighting_group; + auto othergroup = other->GetClass()->ActorInfo()->infighting_group; + if (mygroup != 0 && mygroup == othergroup) + return false; + if ((flags7 & MF7_NOINFIGHTSPECIES) && GetSpecies() == other->GetSpecies()) return false; // Don't fight own species. diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index d92e0a734..2120ae97b 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -1025,6 +1025,19 @@ DEFINE_PROPERTY(designatedteam, I, Actor) defaults->DesignatedTeam = val; } +//========================================================================== +// MBF21 +//========================================================================== +DEFINE_PROPERTY(infightinggroup, I, Actor) +{ + PROP_INT_PARM(i, 0); + if (i < 0) + { + I_Error("Infighting groups must be >= 0."); + } + info->ActorInfo()->infighting_group = i; +} + //========================================================================== // [BB] //========================================================================== diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 2af204a71..508a5b20a 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -266,6 +266,11 @@ class Actor : Thinker native meta Name MissileName; meta double FastSpeed; // speed in fast mode + // todo: implement access to native meta properties. + // native meta int infighting_group; + // native meta int projectile_group; + // native meta int splash_group; + Property prefix: none; Property Obituary: Obituary; Property HitObituary: HitObituary;