warvulture
This commit is contained in:
parent
4b95e705e7
commit
ee5a2e2e7b
12 changed files with 314 additions and 76 deletions
|
|
@ -111,4 +111,31 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IsEnemy is not the only way a mob picks the player, and the other way ignores it
|
||||
// completely. BaseAI.FindEnemy() walks every character asking IsEnemy - which both truce
|
||||
// patches above answer - but when that walk comes up empty and the creature HuntPlayer()s,
|
||||
// it falls through to Player.GetClosestPlayer(transform.position, 200f) and returns whoever
|
||||
// it finds, without asking anything about factions.
|
||||
//
|
||||
// That fall-through is why the Black Forest truce looked broken to the Trol's testers:
|
||||
// MonsterAI.UpdateAI turns hunting on for every IsEventCreature() while an event is running,
|
||||
// and the events that reach a Trol are "the forest is moving" (Greydwarves), "you are being
|
||||
// hunted" (Trolls) and the Fuling army - the exact three they named. Anything a SpawnSystem
|
||||
// entry or a TriggerSpawner flags with huntPlayer arrives by the same door.
|
||||
//
|
||||
// Filtering the RESULT rather than restating the rule keeps one source of truth: the public
|
||||
// instance IsEnemy(Character) calls the static overload both postfixes above hook, so this
|
||||
// honours whatever the faction sets and RaceHostilityManager's per-race lists already agree
|
||||
// on. Retaliation is untouched - a mob the player hits is targeted through
|
||||
// BaseAI.OnDamaged/SetTarget, which never goes near FindEnemy.
|
||||
[HarmonyPatch(typeof(BaseAI), "FindEnemy")]
|
||||
public static class FactionHuntPlayerPatch
|
||||
{
|
||||
public static void Postfix(BaseAI __instance, ref Character __result)
|
||||
{
|
||||
if (__result == null || !__result.IsPlayer()) return;
|
||||
if (!__instance.IsEnemy(__result)) __result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue