Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIFindSmartActions.c
Go to the documentation of this file.
2{
3 static const string PORT_CENTER_OF_SEARCH = "OriginIn";
4 static const string PORT_RADIUS = "RadiusIn";
5 static const string PORT_SA_NUMBER = "SmartActionNumber";
6 static const string PORT_SA_FOUND = "SmartActionsFound";
7 static const string PORT_SA_TAGS = "SmartActionTags";
8
11
12 //------------------------------------------------------------------------------------------------
13 static override bool VisibleInPalette() {return true;}
14
15 //------------------------------------------------------------------------------------------------
16 override void OnInit(AIAgent owner)
17 {
18 ChimeraWorld myWorld = ChimeraWorld.CastFrom(GetGame().GetWorld());
19 if (myWorld)
21 m_groupOwner = SCR_AIGroup.Cast(owner);
22 if (!m_groupOwner)
23 {
24 m_groupOwner = SCR_AIGroup.Cast(owner.GetParentGroup());
25 if (!m_groupOwner)
26 NodeError(this, owner, "Node is not run on SCR_AIGroup agent or owner is not member of SCR_AIGroup!");
27 }
28 }
29
30 //------------------------------------------------------------------------------------------------
31 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
32 {
34 return ENodeResult.FAIL;
35
36 vector center;
37 GetVariableIn(PORT_CENTER_OF_SEARCH, center);
38 float radius;
39 GetVariableIn(PORT_RADIUS, radius);
40 ref array<string> aTags = {};
41 GetVariableIn(PORT_SA_TAGS, aTags);
42
43 ref array<AISmartActionComponent> outSmartActions = {};
44 int numSAFound;
45 numSAFound = m_AISmartActionSystem.FindSmartActions(outSmartActions, center, radius, aTags, EAIFindSmartAction_TagTest.InOrder);
46 if (numSAFound > 0)
47 {
48 SetVariableOut(PORT_SA_NUMBER,numSAFound);
49 m_groupOwner.AllocateSmartActions(outSmartActions);
50 }
51 SetVariableOut(PORT_SA_FOUND, numSAFound > 0);
52 return ENodeResult.SUCCESS;
53 }
54
55 //------------------------------------------------------------------------------------------------
56 protected static ref TStringArray s_aVarsOut = {
57 PORT_SA_NUMBER,
58 PORT_SA_FOUND
59 };
61 {
62 return s_aVarsOut;
63 }
64
65 //------------------------------------------------------------------------------------------------
66 protected static ref TStringArray s_aVarsIn = {
67 PORT_CENTER_OF_SEARCH,
68 PORT_RADIUS,
69 PORT_SA_TAGS
70 };
72 {
73 return s_aVarsIn;
74 }
75
76 //------------------------------------------------------------------------------------------------
77 static override string GetOnHoverDescription()
78 {
79 return "FindSmartActions: finds all smart actions of given tags within center and radius. Caches result to group properties.";
80 }
81};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.
Definition NodeError.c:3
proto void SetVariableOut(string name, void val)
proto bool GetVariableIn(string name, out void val)
static ref TStringArray s_aVarsIn
override void OnInit(AIAgent owner)
override TStringArray GetVariablesIn()
static override string GetOnHoverDescription()
static override bool VisibleInPalette()
static ref TStringArray s_aVarsOut
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
AISmartActionSystem m_AISmartActionSystem
override TStringArray GetVariablesOut()
ENodeResult
Definition ENodeResult.c:13
array< string > TStringArray
Definition Types.c:385