Faction Test 100.10.0.0

This commit is contained in:
Markus Isberg
2022-12-07 17:46:02 +02:00
parent de250b4a64
commit e0c3754621
19 changed files with 147 additions and 62 deletions
@@ -692,7 +692,7 @@ namespace Barotrauma
//if the attacker has the same targeting tag as the character we're protecting, we can't change the TargetState
//otherwise e.g. a pet that's set to follow humans would start attacking all humans (and other pets, since they're considered part of the same group) when a hostile human attacks it
//TODO: a way for pets to differentiate hostile and friendly humans?
if (attacker?.AiTarget != null && targetCharacter.SpeciesName != GetTargetingTag(attacker.AiTarget))
if (attacker?.AiTarget != null && targetCharacter.SpeciesName != GetTargetingTag(attacker.AiTarget) && !attacker.IsFriendly(targetCharacter))
{
// Attack the character that attacked the target we are protecting
ChangeTargetState(attacker, AIState.Attack, selectedTargetingParams.Priority * 2);
@@ -3729,7 +3729,7 @@ namespace Barotrauma
// When the monsters attack the player sub, they wall hack so that they can be more aggressive.
// Pets should always check the visibility, unless the pet and the target are both outside the submarine -> shouldn't target when they can't perceive (= no wall hack)
checkVisibility =
Character.IsPet && (Character.Submarine == null) != (target.Entity.Submarine == null) ||
Character.IsPet && (Character.Submarine != null || target.Entity.Submarine != null) ||
target.Entity.Submarine != null && target.Entity.Submarine == Character.Submarine && target.Entity.Submarine.TeamID == CharacterTeamType.None;
}
if (dist > 0)
@@ -238,6 +238,15 @@ namespace Barotrauma
}
}
public bool IsInTargetSlot(Item item)
{
if (container?.Inventory is ItemInventory inventory && TargetSlot is not null)
{
return inventory.IsInSlot(item, (int)TargetSlot);
}
return false;
}
public override void Reset()
{
base.Reset();
@@ -115,6 +115,8 @@ namespace Barotrauma
{
objective.TargetSlot = container.FindSuitableSubContainerIndex(OXYGEN_SOURCE);
}
// Only remove the oxygen source being replaced
objective.RemoveExistingPredicate = i => objective.IsInTargetSlot(i);
return objective;
},
onAbandon: () =>