27 objForTitle = m_Agent;
29 objForTitle = m_Entity;
38 SCR_AIInfoBaseComponent baseInfoComp;
40 SCR_AIGroupInfoComponent groupInfoComp;
42 SCR_MailboxComponent mailboxComp;
43 PerceptionComponent perception;
45 SCR_AIBaseUtilityComponent utilityComp;
46 SCR_AIUtilityComponent unitUtilityComp;
47 SCR_AICombatComponent combatComp;
48 SCR_AISettingsBaseComponent settingsComp;
50 if (!m_Agent && !m_Group && !m_Entity)
52 DbgUI.Text(
"The target doesn't exist!");
58 DbgUI.Text(agentName);
62 baseInfoComp = SCR_AIInfoBaseComponent.Cast(m_Agent.FindComponent(SCR_AIInfoBaseComponent));
64 groupInfoComp = SCR_AIGroupInfoComponent.Cast(baseInfoComp);
65 mailboxComp = SCR_MailboxComponent.Cast(m_Agent.FindComponent(SCR_MailboxComponent));
66 utilityComp = SCR_AIBaseUtilityComponent.Cast(m_Agent.FindComponent(SCR_AIBaseUtilityComponent));
68 unitUtilityComp = SCR_AIUtilityComponent.Cast(utilityComp);
69 settingsComp = SCR_AISettingsBaseComponent.Cast(m_Agent.FindComponent(SCR_AISettingsBaseComponent));
75 combatComp = SCR_AICombatComponent.Cast(m_Entity.FindComponent(SCR_AICombatComponent));
76 perception = PerceptionComponent.Cast(m_Entity.FindComponent(PerceptionComponent));
81 DbgUI.Text(
string.Format(
"LOD: %1", m_Agent.GetLOD()));
87 string strUnitBusy =
string.Format(
"Unit Busy: %1",
typename.EnumToString(EUnitAIState, infoComp.
GetAIState()));
88 DbgUI.Text(strUnitState);
89 DbgUI.Text(strUnitRoles);
90 DbgUI.Text(strUnitBusy);
92 else if (groupInfoComp)
94 DbgUI.Text(
string.Format(
"Control Mode: %1",
typename.EnumToString(EGroupControlMode, groupInfoComp.GetGroupControlMode())));
99 BaseTarget currentEnemy = combatComp.GetCurrentTarget();
100 DbgUI.Text(
string.Format(
"Enemy: %1", currentEnemy.ToString()));
105 int nRxMessages = mailboxComp.GetMessageCount();
106 int nRxOrders = mailboxComp.GetOrderCount();
107 int nRxDangers = m_Agent.GetDangerEventsCount();
108 DbgUI.Text(
string.Format(
"Mailbox Queue: Msg: %1, Order: %2, Dngr: %3", nRxMessages, nRxOrders, nRxDangers));
117 EAIThreatState threatState = unitUtilityComp.m_ThreatSystem.GetState();
118 DbgUI.Text(
string.Format(
"Threat: %1 %2", unitUtilityComp.m_ThreatSystem.GetThreatMeasure().ToString(6, 3),
typename.EnumToString(EAIThreatState, threatState)));
121 AIActionBase currentAction = utilityComp.GetCurrentAction();
123 DbgUI.Text(
"Current Action: null");
126 DbgUI.Text(
"Current Action:");
127 float actionPriority = currentAction.Evaluate();
128 string currentActionStr =
string.Format(
" > %1 %2", actionPriority.ToString(5, 1), currentAction.Type().ToString());
129 DbgUI.Text(currentActionStr);
133 array<string> spinnerStrings = {
"[|]",
"[/]",
"[-]",
"[\\]"};
134 string strSpinner = spinnerStrings[utilityComp.DiagGetCounter() % spinnerStrings.Count()];
136 DbgUI.Text(
string.Format(
"%1 Actions:", strSpinner));
137 array<ref AIActionBase> allActions = {};
138 utilityComp.GetActions(allActions);
142 DbgUI.Text(actionStr);
147 array<AIActionBase> subactions = {};
152 DbgUI.Text(subactionStr);
160 if (groupUtilityComp)
164 DbgUI.Text(
string.Format(
"Combat Mode External: %1",
167 DbgUI.Text(
string.Format(
"Combat Mode Actual: %1",
171 bool showUsableVehicles;
172 DbgUI.Check(
"Show group usable vehicles", showUsableVehicles);
173 if (showUsableVehicles)
182 int dumpDbgMsgsDuration;
184 DbgUI.Text(
"Dump Debug Messages:");
186 DbgUI.Combo(
"Age", dumpDbgMsgsDuration, {
"All",
"120 sec",
"30 sec",
"5 sec"});
188 int dbgMsgTypeSelection;
189 array<string> dbgMsgTypeNames = {};
191 dbgMsgTypeNames.InsertAt(
"All", 0);
193 DbgUI.Combo(
"Type", dbgMsgTypeSelection, dbgMsgTypeNames);
194 dbgMsgType = dbgMsgTypeSelection - 1;
195 bool useDbgMsgTypeFilter = dbgMsgTypeSelection != 0;
198 bool dumpMsgs =
DbgUI.Button(
"Dump");
202 int msgAgeThresholdMs;
203 switch (dumpDbgMsgsDuration)
205 case 0: msgAgeThresholdMs = -1;
break;
206 case 1: msgAgeThresholdMs = 120*1000;
break;
207 case 2: msgAgeThresholdMs = 30*1000;
break;
208 case 3: msgAgeThresholdMs = 5*1000;
break;
211 baseInfoComp.DumpDebugMessages(useTypeFilter: useDbgMsgTypeFilter, msgTypeFilter: dbgMsgType, ageThresholdMs: msgAgeThresholdMs);
219 DbgUI.Text(
"Breakpoint At:");
221 bool rqBreak =
DbgUI.Button(
"Utility Comp.");
222 if (rqBreak && utilityComp)
224 utilityComp.DiagSetBreakpoint();
232 DbgUI.Check(
"Show Settings", showSettings);
240 bool showPerceivable;
241 DbgUI.Check(
"Show Perceivable", showPerceivable);
249 if (perception && combatComp)
259 if (unitUtilityComp && unitUtilityComp.m_CombatMoveState)
261 bool showCombatMoveState;
262 DbgUI.Check(
"Show combat move state", showCombatMoveState);
263 if (showCombatMoveState)
275 bool locate =
DbgUI.Button(
"Locate");
278 array<string> locateTexts = {
"I am here!",
"Look at me!",
"Hey! Look here!",
"Here I am!"};
281 ent = m_Agent.GetControlledEntity();
290 if (m_Agent && !m_Group)
293 bool forceDeath =
DbgUI.Button(
"Kill");
296 CharacterControllerComponent cntrlComp = CharacterControllerComponent.Cast(m_Entity.FindComponent(CharacterControllerComponent));
298 cntrlComp.ForceDeath();
332 DbgUI.Check(
" Show Unknown", showUnknown);
333 DbgUI.Check(
" Show Friendly", showFriendly);
334 DbgUI.Check(
" Show Enemy", showEnemy);
337 array<ETargetCategory> targetCategories = {};
348 FactionAffiliationComponent myFactionComp = FactionAffiliationComponent.Cast(myEntity.
FindComponent(FactionAffiliationComponent));
349 Faction myFaction = myFactionComp.GetAffiliatedFaction();
351 BaseTarget selectedTarget = combatComponent.GetCurrentTarget();
353 DbgUI.Text(
"[ID Category TimeSinceSeen Dngr Type (Exp TraceFraction) (Detect Ident Sound)]");
355 array<BaseTarget> targets = {};
360 perception.GetTargetsList(targets, targetCategory);
361 foreach (
int i,
BaseTarget baseTarget : targets)
363 IEntity targetEntity = baseTarget.GetTargetEntity();
398 string strTimeSinceSeenOrDetected =
string.Format(
"(%1 %2)",
399 baseTarget.GetTimeSinceSeen().ToString(4, 1),
400 baseTarget.GetTimeSinceDetected().ToString(4, 1));
402 if (baseTarget.IsEndangering())
403 strState = strState +
"DNGR ";
404 if (baseTarget.IsDisarmed())
405 strState = strState +
"DISARMED ";
407 array<string> substrings = {};
409 string strPrefabName =
string.Empty;
410 if (!prefabName.IsEmpty())
412 prefabName.Split(
"/", substrings,
true);
413 if (!substrings.IsEmpty())
414 strPrefabName = substrings[substrings.Count()-1];
417 string strSelected =
" ";
418 if (selectedTarget == baseTarget)
421 string strDistance =
vector.Distance(myPos, targetEntity.
GetOrigin()).ToString(5, 2);
423 string strType =
typename.EnumToString(
EAIUnitType, baseTarget.GetUnitType());
425 float recognitionDetect;
426 float recognitionIdentify;
427 baseTarget.GetAccumulatedRecognition(recognitionDetect, recognitionIdentify);
430 float emittedSoundPower = baseTarget.GetPerceivableComponent().GetSoundPower();
431 float targetDistance = baseTarget.GetDistance();
432 float observedSoundIntensity = -999;
433 if (targetDistance != 0)
434 observedSoundIntensity = emittedSoundPower / (4.0 *
Math.PI * targetDistance * targetDistance);
435 string strSoundIntensity;
436 if (observedSoundIntensity != 0)
437 strSoundIntensity =
string.Format(
"%1 dB", (10*
Math.Log10(observedSoundIntensity/1e-12)).ToString(5,1));
439 strSoundIntensity =
"-inf dB";
441 string strExposure =
string.Format(
"(%1 %2) ", baseTarget.GetExposure().ToString(3,2), baseTarget.GetTraceFraction().ToString(3, 2));
443 string strRecognition =
string.Format(
"(%1 %2 %3)", recognitionDetect.ToString(3, 2), recognitionIdentify.ToString(3, 2), strSoundIntensity);
445 string str =
string.Format(
"%1 %2 %3 %4s %5 %6 %7 %8",
449 strTimeSinceSeenOrDetected,
458 bool showRecognition =
false;
459 DbgUI.Check(
string.Format(
"%1 Recognition", targetId), showRecognition);
463 DbgUI.Text(
string.Format(
"%1 Exp: %2, Rec: Detect: %3 Identify: %4",
464 targetId, baseTarget.GetExposure().ToString(3, 2), recognitionDetect.ToString(3, 2), recognitionIdentify.ToString(3, 2)));
466 const int plotWidth = 200;
467 const int plotHeight = 150;
469 DbgUI.PlotLive(
string.Format(
"%1 Detection", targetId), plotWidth, plotHeight, recognitionDetect, 300);
470 DbgUI.PlotLive(
string.Format(
"%1 Identification", targetId), plotWidth, plotHeight, recognitionIdentify, 300);
480 DbgUI.Text(
"Recognition Factors:");
481 DbgUI.Text(
string.Format(
" Visual: %1", p.GetVisualRecognitionFactor()));
482 DbgUI.Text(
string.Format(
" Illumination: %1", p.GetIlluminationFactor()));
484 float soundPower = p.GetSoundPower();
485 string soundPowerStr;
487 soundPowerStr =
"- Inf";
489 soundPowerStr =
string.Format(
"%1", 10*
Math.Log10(soundPower/1e-12));
490 DbgUI.Text(
string.Format(
" Sound pwr: %1 dB", soundPowerStr));
492 DbgUI.Text(
string.Format(
"Est. visual size: %1", p.GetEstimatedVisualSize()));
493 DbgUI.Text(
string.Format(
"Ambient LV: %1", p.GetAmbientLV()));
495 FactionAffiliationComponent factionComp = p.GetFactionAffiliationComponent();
498 DbgUI.Text(
string.Format(
"Faction: %1, Override: %2, Final: %3",
504 FactionManager fm =
GetGame().GetFactionManager();
507 DbgUI.Text(
"SetPerceivedFactionOverride: ");
510 if (
DbgUI.Button(
"Reset"))
511 p.SetPerceivedFactionOverride(null);
515 int factionCount = fm.GetFactionsCount();
516 for (
int i = 0; i < factionCount; i++)
518 Faction f = fm.GetFactionByIndex(i);
519 if (
DbgUI.Button(f.GetFactionKey()))
521 p.SetPerceivedFactionOverride(f);
523 if (i != factionCount-1)
609 string company, platoon, squad, character, format, returnString;
610 m_Group.GetCallsigns(company, platoon, squad, character, format);
611 returnString.Format(format, company, platoon, squad, character);
618 SCR_CallsignCharacterComponent callsignComp = SCR_CallsignCharacterComponent.Cast(m_Agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
620 FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(m_Agent.GetControlledEntity().FindComponent(FactionAffiliationComponent));
626 string faction =
GetFactionKey(factionComp.GetAffiliatedFaction());
627 str = str +
string.Format(
"[%1] ", faction);
632 string company, platoon, squad, character, format;
633 bool setCallsign = callsignComp.GetCallsignNames(company, platoon, squad, character, format);
636 string callsign =
WidgetManager.Translate(format, company, platoon, squad, character);
637 str = str +
string.Format(
" %1", callsign);