Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AICinematicLookAt.c
Go to the documentation of this file.
1
3{
4 protected SlotManagerComponent m_SlotManager;
10 protected vector m_vLook[4];
11 protected vector m_vLookEnd[4];
16
17 //-------------------------------------------------------------------------------------------
18 protected override void OnInit(AIAgent owner)
19 {
20 m_SlotManager = SlotManagerComponent.Cast(owner.GetControlledEntity().FindComponent(SlotManagerComponent));
21
22 if (m_SlotManager)
23 {
24 m_PointOfViewStart = m_SlotManager.GetSlotByName("PointOfViewStart");
25 m_PointOfViewEnd = m_SlotManager.GetSlotByName("PointOfViewEnd");
26 }
27
28 m_CharacterAnimation = CharacterAnimationComponent.Cast(owner.GetControlledEntity().FindComponent(CharacterAnimationComponent));
29
31 m_LookAtVariable = m_CharacterAnimation.BindVariableBool("Look");
32
33 m_ControllerComponent = SCR_CharacterControllerComponent.Cast(owner.GetControlledEntity().FindComponent(SCR_CharacterControllerComponent));
34 }
35
36
37 //-------------------------------------------------------------------------------------------
38 protected override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
39 {
41 return ENodeResult.FAIL;
42
43 if (!m_ControllerComponent.IsLoitering())
44 return ENodeResult.FAIL;
45
46 m_Player = ChimeraCharacter.Cast(EntityUtils.GetPlayer());
47
48 if (!m_Player)
49 return ENodeResult.FAIL;
50
51 m_Player.GetTransform(m_vPlayerPosition);
52
53 // Compute lookAt region origin
55 m_PointOfViewStart.GetWorldTransform(m_vLook);
56
58 m_PointOfViewEnd.GetWorldTransform(m_vLookEnd);
59
60 m_vLookAxis = vector.Direction(m_vLook[3], m_vLookEnd[3]);
61 m_vLookAxis.Normalize();
62
63 if (Math3D.IntersectionSphereCone(m_vPlayerPosition[3], 1, m_vLook[3], m_vLookAxis, 1.1))
64 {
65 m_vPlayerHeadPosition = m_Player.EyePosition();
66
67 m_CharacterAnimation.SetIKTarget("HeadLook", "HeadLook", owner.GetControlledEntity().CoordToLocal(m_vPlayerHeadPosition), {0, 0, 0});
68
70 m_CharacterAnimation.SetVariableBool(m_LookAtVariable, true);
71 }
72 else
73 {
75 m_CharacterAnimation.SetVariableBool(m_LookAtVariable, false);
76 }
77
78 return ENodeResult.RUNNING;
79 }
80
81 //-------------------------------------------------------------------------------------------
82 static override bool VisibleInPalette()
83 {
84 return true;
85 }
86
87};
int TAnimGraphVariable
Definition ECommandIDs.c:2
Adds ability to attach an object to a slot.
Base class for tasks which return some target from combat component.
SCR_CharacterControllerComponent m_ControllerComponent
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
TAnimGraphVariable m_LookAtVariable
SlotManagerComponent m_SlotManager
EntitySlotInfo m_PointOfViewStart
static override bool VisibleInPalette()
override void OnInit(AIAgent owner)
CharacterAnimationComponent m_CharacterAnimation
ENodeResult
Definition ENodeResult.c:13