Page MenuHomeFeedback Tracker

AI operating mortar does not respect DisableLOD
Assigned, NormalPublic

Description

I believe the problems lies in SCR_AIStaticArtilleryBehavior.OnActionDeselected() which calls agent.AllowMaxLOD(). The function assumes that the AI was allowed max LOD before starting artillery behaviour. Instead it should check whether AI is allowed max LOD prior to start of behaviour, and then skip agent.AllowMaxLOD() in case it was not.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
AI Issues
Steps To Reproduce
  1. Add SlotAI with character to scene
  2. Add Mortar prefab + ammo to scene
  3. Add DisableLOD action to AI
  4. Add waypoints to make AI get in mortar and fire it somewhere repeatably
  5. Play scene and observe AI with binoculars from ~1km distance (so AI should disappear if max LOD allowed)

AI will spawn and be visible at first. If you look away for some time and back again the AI is no longer rendered.

Event Timeline

runekn created this task.Thu, May 22, 9:34 AM
runekn added a comment.EditedThu, May 22, 9:40 AM

As for fixing it myself, is there any current method for checking if an AIAgent is allowed max LOD? I don't see one in AIAgent.c, so my current workaround is a looped WaitAndExecute that just reapplies DisableLOD constantly.

runekn changed Category from General to AI Issues.Thu, May 22, 10:09 AM
Geez changed the task status from New to Assigned.Thu, May 22, 11:31 AM

My new workaround

modded class SCR_ChimeraAIAgent
{
	bool m_bPreventMaxLODActual = false;
}


[BaseContainerProps(), SCR_ContainerAIActionTitle()]
modded class SCR_ScenarioFrameworkAIActionDisableLOD
{
	override void OnActivate()
	{
		super.OnActivate();
		
		if (!m_bDisableLOD)
			return;
		
		array<AIAgent> agents = {};
		m_AIGroup.GetAgents(agents);
		m_AIGroup.m_bPreventMaxLODActual = true;
		
		foreach (AIAgent agent : agents)
		{
			SCR_ChimeraAIAgent chimeraAgent = SCR_ChimeraAIAgent.Cast(agent);
			if (chimeraAgent)
				chimeraAgent.m_bPreventMaxLODActual = true;
		}
	}
}


modded class SCR_AIStaticArtilleryBehavior
{
	override void OnActionDeselected()
	{
		AIAgent agent = m_Utility.GetOwner();
		
		SCR_ChimeraAIAgent chimeraAgent = SCR_ChimeraAIAgent.Cast(agent);
		if (chimeraAgent && chimeraAgent.m_bPreventMaxLODActual)
			return;
		
		agent.AllowMaxLOD();
	}
}