Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
aitargetcallbacksplayer.c
Go to the documentation of this file.
2 {
4  {
5  m_Player = pPlayer;
6 
7  m_iHeadBoneIndex = m_Player.GetBoneIndexByName("Head");
8  m_iChestBoneIndex = m_Player.GetBoneIndexByName("Spine3");
9  }
10 
11  override vector GetHeadPositionWS()
12  {
13  if (m_iHeadBoneIndex != -1)
14  return m_Player.GetBonePositionWS(m_iHeadBoneIndex);
15  else
16  return m_Player.GetPosition() + "0 1.7 0";
17  }
18 
19  override vector GetVisionPointPositionWS(EntityAI pApplicant)
20  {
21  DayZInfected infected = DayZInfected.Cast(pApplicant);
22  if (infected)
23  {
24  DayZInfectedInputController ic = infected.GetInputController();
25  if (ic)
26  {
27  int mindState = ic.GetMindState();
28  if (mindState >= DayZInfectedConstants.MINDSTATE_ALERTED)
29  {
30  return GetHeadPositionWS();
31  }
32  else
33  {
34  if (m_iChestBoneIndex != -1)
35  return m_Player.GetBonePositionWS(m_iChestBoneIndex);
36  }
37  }
38  }
39 
40  return m_Player.GetPosition() + "0 1 0";
41  }
42 
43  override float GetMaxVisionRangeModifier(EntityAI pApplicant)
44  {
46  m_Player.GetMovementState(state);
47 
48  float mod = 1.0;
49  float speedCoef = PlayerConstants.AI_VISIBILITY_RUN;
50  float stanceCoef = PlayerConstants.AI_VISIBILITY_STANDING;
51  float playerVisCoef = 1.0; //Use disabled since 1.12
52 
54  switch (AITargetCallbacksPlayer.StanceToMovementIdxTranslation(state))
55  {
56  case DayZPlayerConstants.MOVEMENTIDX_WALK:
57  speedCoef = PlayerConstants.AI_VISIBILITY_WALK;
58  break;
59 
60  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
61  speedCoef = PlayerConstants.AI_VISIBILITY_IDLE;
62  break;
63  }
64 
66  switch (state.m_iStanceIdx)
67  {
68  case DayZPlayerConstants.STANCEIDX_CROUCH:
69  case DayZPlayerConstants.STANCEIDX_RAISEDCROUCH:
70  stanceCoef = PlayerConstants.AI_VISIBILITY_CROUCH;
71  break;
72 
73  case DayZPlayerConstants.STANCEIDX_PRONE:
74  case DayZPlayerConstants.STANCEIDX_RAISEDPRONE:
75  stanceCoef = PlayerConstants.AI_VISIBILITY_PRONE;
76  break;
77  }
78 
80  mod = (speedCoef + stanceCoef) / 2;
81 
82  return mod;
83  }
84 
87  static int StanceToMovementIdxTranslation(HumanMovementState pState)
88  {
89  int movementSpeed = 0;
90 
91  switch (pState.m_iStanceIdx)
92  {
93  case DayZPlayerConstants.STANCEIDX_CROUCH:
94  switch (pState.m_iMovement)
95  {
96  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
97  movementSpeed = DayZPlayerConstants.MOVEMENTIDX_IDLE;
98  break;
99 
100  case DayZPlayerConstants.MOVEMENTIDX_WALK:
101  case DayZPlayerConstants.MOVEMENTIDX_RUN:
102  movementSpeed = DayZPlayerConstants.MOVEMENTIDX_WALK;
103  break;
104 
105  case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
106  movementSpeed = DayZPlayerConstants.MOVEMENTIDX_CROUCH_RUN;
107  break;
108  }
109  break;
110 
111  case DayZPlayerConstants.STANCEIDX_PRONE:
112  switch (pState.m_iMovement)
113  {
114  case DayZPlayerConstants.MOVEMENTIDX_IDLE:
115  movementSpeed = DayZPlayerConstants.MOVEMENTIDX_IDLE;
116  break;
117 
118  default:
119  movementSpeed = DayZPlayerConstants.MOVEMENTIDX_WALK;
120  break;
121  }
122  break;
123 
124  default:
125  movementSpeed = pState.m_iMovement;
126  }
127 
128  return movementSpeed;
129  }
130 
131  private PlayerBase m_Player;
132  private int m_iHeadBoneIndex;
133  private int m_iChestBoneIndex;
134 }
DayZInfectedInputController
Definition: dayzinfectedinputcontroller.c:1
DayZInfected
Definition: zombiebase.c:1
HumanMovementState
Definition: human.c:1125
PlayerBase
Definition: playerbaseclient.c:1
PlayerConstants
Definition: playerconstants.c:1
vector
Definition: enconvert.c:105
AITargetCallbacks
Definition: aitarget_callbacks.c:8
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
DayZInfectedConstants
DayZInfectedConstants
Definition: dayzinfected.c:1
AITargetCallbacksPlayer
Definition: aitargetcallbacksplayer.c:1
EntityAI
Definition: building.c:5