Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIGetAnimationScriptParameters.c
Go to the documentation of this file.
2{
3 static const string PORT_ROOT_ENTITY = "RootEntity";
4 static const string PORT_POSITION = "AnimationPosition";
5 static const string PORT_DURATION = "AnimationDuration";
6 static const string PORT_DIRECTION = "AnimationDirection";
7 static const string PORT_ANIMATION_INDEX = "AnimationIndex";
8 static const string PORT_AGENT_SCRIPT = "AgentScript";
9
10 protected int m_iAnimationIndex;
11
12 //------------------------------------------------------------------------------------------------
13 override void OnInit(AIAgent owner)
14 {
16 }
17
18 //------------------------------------------------------------------------------------------------
19 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
20 {
21 SCR_AIAnimationScript agentScript;
22 IEntity rootEntity;
23 if (!GetVariableIn(PORT_AGENT_SCRIPT, agentScript) || !agentScript)
24 return NodeError(this, owner, "Missing script reference for this agent!");
25 if (!GetVariableIn(PORT_ROOT_ENTITY, rootEntity) || !rootEntity)
26 return NodeError(this, owner, "Missing root entity to find world position for animation!");
27
29 return ENodeResult.FAIL;
30
31 float duration = agentScript.GetAnimationDuration(m_iAnimationIndex);
32 if (duration < 0)
33 duration = int.MAX;
34
35 SetVariableOut(PORT_POSITION, agentScript.GetAnimationPosition(rootEntity, m_iAnimationIndex));
36 SetVariableOut(PORT_DURATION, duration);
37
38 vector mat[4];
39 agentScript.GetAnimationWorldTransform(rootEntity, m_iAnimationIndex, mat);
40 vector directionVector = vector.Forward.Multiply3(mat) + mat[3];
41
42 SetVariableOut(PORT_DIRECTION, directionVector);
43 SetVariableOut(PORT_ANIMATION_INDEX, m_iAnimationIndex);
44
46
47 return ENodeResult.SUCCESS;
48 }
49
50 //------------------------------------------------------------------------------------------------
51 protected static override bool VisibleInPalette() { return true; }
52
53 //------------------------------------------------------------------------------------------------
54 protected static ref TStringArray s_aVarsOut = {
55 PORT_POSITION,
56 PORT_DURATION,
57 PORT_DIRECTION,
58 PORT_ANIMATION_INDEX,
59 };
60
61 //------------------------------------------------------------------------------------------------
63 {
64 return s_aVarsOut;
65 }
66
67 protected static ref TStringArray s_aVarsIn = {
68 PORT_AGENT_SCRIPT,
69 PORT_ROOT_ENTITY
70 };
71
72 //------------------------------------------------------------------------------------------------
74 {
75 return s_aVarsIn;
76 }
77
78 //------------------------------------------------------------------------------------------------
79 static override string GetOnHoverDescription()
80 {
81 return "GetAnimationScriptParameters: Gets position, direction of FORWARD vector and duration of provided AIAnimationScript";
82 }
83};
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)
void GetAnimationWorldTransform(IEntity rootEntity, int animationIndex, out vector transform[4])
float GetAnimationDuration(int animationIndex)
vector GetAnimationPosition(IEntity rootEntity, int animationIndex)
bool IsAnimationIndexValid(int animationIndex)
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
ENodeResult
Definition ENodeResult.c:13
array< string > TStringArray
Definition Types.c:385