Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AISetStance.c
Go to the documentation of this file.
1
4{
5 // Inputs
6 protected static const string STANCE_PORT = "Stance";
7
8 protected CharacterControllerComponent m_CharacterController;
9 protected SCR_AICharacterSettingsComponent m_SettingsComp;
10
11 [Attribute("0", UIWidgets.ComboBox, "Desired character stance", "", ParamEnumArray.FromEnum(ECharacterStance) )]
13
14 //------------------------------------------------------------------------------------------------
15 override void OnInit(AIAgent owner)
16 {
17 super.OnInit(owner);
18
19 m_SettingsComp = SCR_AICharacterSettingsComponent.Cast(owner.FindComponent(SCR_AICharacterSettingsComponent));
20
21 IEntity myEntity = owner.GetControlledEntity();
22 if(myEntity)
23 {
24 m_CharacterController = CharacterControllerComponent.Cast(owner.GetControlledEntity().FindComponent(CharacterControllerComponent));
26 NodeError(this, owner, "Can't find CharacterControllerComponent.");
27 }
28 }
29
30 //------------------------------------------------------------------------------------------------
31 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
32 {
34 return ENodeResult.FAIL;
35
36 ECharacterStance stance;
37
38 if(!GetVariableIn(STANCE_PORT, stance))
39 stance = m_eStance;
40
41 // Stance is first limited by this character's group
42 AIGroup group = owner.GetParentGroup();
43 if (group)
44 {
45 SCR_AIGroupInfoComponent groupInfoComp = SCR_AIGroupInfoComponent.Cast(group.FindComponent(SCR_AIGroupInfoComponent));
46 if (groupInfoComp)
47 stance = groupInfoComp.GetAllowedStance(stance);
48 }
49
50 // Check if stance is restricted by settings
51 SCR_AICharacterStanceSettingBase stanceSetting = null;
54
55 if (stanceSetting)
56 stance = stanceSetting.GetStance(stance);
57
59
60 return ENodeResult.SUCCESS;
61 }
62
63 //------------------------------------------------------------------------------------------------
64 static override bool VisibleInPalette() {return true;}
65
66 //------------------------------------------------------------------------------------------------
67 protected static ref TStringArray s_aVarsIn = {
69 };
70 override array<string> GetVariablesIn()
71 {
72 return s_aVarsIn;
73 }
74
75 //------------------------------------------------------------------------------------------------
76 override string GetNodeMiddleText()
77 {
78 string s;
79 s = s + string.Format("m_eStance: %1\n", typename.EnumToString(ECharacterStance, m_eStance));
80 return s;
81 }
82
83 //------------------------------------------------------------------------------------------------
84 override static string GetOnHoverDescription()
85 {
86 return "Sets stance of character. Also checks restriction from group info component, and from settings component.";
87 }
88};
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition NodeError.c:3
proto bool GetVariableIn(string name, out void val)
static const string STANCE_PORT
CharacterControllerComponent m_CharacterController
override string GetNodeMiddleText()
override array< string > GetVariablesIn()
static ref TStringArray s_aVarsIn
ECharacterStance m_eStance
static override string GetOnHoverDescription()
SCR_AICharacterSettingsComponent m_SettingsComp
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
override void OnInit(AIAgent owner)
static override bool VisibleInPalette()
ENodeResult
Definition ENodeResult.c:13
ECharacterStance
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385