- MBF21: infighting groups.

This commit is contained in:
Christoph Oelckers 2021-06-29 01:34:14 +02:00
parent 9b4a4157b9
commit bca8d01ab3
5 changed files with 55 additions and 16 deletions

View file

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

View file

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

View file

@ -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.

View file

@ -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]
//==========================================================================

View file

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