fix: Alfar drones and Sverm workers work instead of wandering
HandsToVanilla gave the tick to MonsterAI whenever BaseAI.FindClosestEnemy returned someone. Vanilla takes its first match at any distance and only checks maxDistance after that, so any wild creature in the loaded zones counted. The tamed MonsterAI then idled around and the work loop never ran. Check the distance ourselves.
This commit is contained in:
parent
bba81cbbf0
commit
3c81b8f130
2 changed files with 10 additions and 2 deletions
|
|
@ -270,7 +270,11 @@ namespace RacesOfValheim
|
|||
else if (Time.time >= m_nextFightScan)
|
||||
{
|
||||
m_nextFightScan = Time.time + FightScanInterval;
|
||||
if (BaseAI.FindClosestEnemy(m_character, transform.position, FightRange) != null)
|
||||
// FindClosestEnemy takes its first match at ANY distance (it only compares against
|
||||
// maxDistance once it holds one), so with a deer anywhere in the loaded zones it never
|
||||
// returned null and vanilla kept the tick: the worker idled about instead of working.
|
||||
Character enemy = BaseAI.FindClosestEnemy(m_character, transform.position, FightRange);
|
||||
if (enemy != null && Vector3.Distance(enemy.transform.position, transform.position) <= FightRange)
|
||||
{
|
||||
m_fightUntil = Time.time + FightLinger;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue