DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Bot_MoveForward.c
См. документацию.
1#ifdef ROBOCLIENT
2class BotMoveForward extends BotStateBase
3{
4 private bool m_FirstTime = true;
5 private bool m_PrevIsClimbing = false;
6 private float m_PrevMaxClimbDist = 0;
7
8 void BotMoveForward(Bot bot = NULL, BotStateBase parent = NULL)
9 {
10 }
11
12 //copied from DayZPlayerImplementJumpClimb
13 private int GetClimbType(float pHeight)
14 {
15 int climbType = -1;
16 if (pHeight < 1.1)
17 climbType = 0;
18 else if (pHeight >= 1.1 && pHeight < 1.7)
19 climbType = 1;
20 else if (pHeight >= 1.7 && pHeight < 2.75)
21 climbType = 2;
22
23 return climbType;
24 }
25
26 override void OnEntry (BotEventBase e)
27 {
28 super.OnEntry(e);
29 m_PrevMaxClimbDist = m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance;
30 GetUApi().GetInputByID(UAMoveForward).ForceEnable(true);
31 }
32
33 override void OnExit (BotEventBase e)
34 {
35 super.OnExit(e);
36
37 GetUApi().GetInputByID(UAMoveForward).ForceEnable(false);
38 }
39
40 override void OnUpdate (float dt)
41 {
42 bool isClimbing = m_Bot.m_Owner.IsClimbing();
43 if (!isClimbing)
44 {
45 DayZPlayer player = g_Game.GetPlayer();
46 vector m_OwnerPosition = m_Owner.GetPosition();
47 vector m_WaterPositionCheck = m_OwnerPosition + m_Owner.GetDirection() * 3;
48 if (m_PrevIsClimbing)
49 {
50 m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance = m_PrevMaxClimbDist;
51 }
52 else if (GetGame().SurfaceIsSea(m_WaterPositionCheck[0], m_WaterPositionCheck[2]))
53 {
54
55 m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance = m_PrevMaxClimbDist;
56 m_Bot.ProcessEvent(m_Bot.__Obst__);
57 }
58
59 const vector raycastHeight = "0 0.75 0"; //raycast from a higher point
60 const float startPosOffset = 0.1; //offset bc issues with climbing
61 const float raycastDist = 0.8;
62 const float raycastSphereRadius = 0.3;
63 vector startPos = m_OwnerPosition + raycastHeight + startPosOffset * m_Owner.GetDirection();
64 vector endPos = m_OwnerPosition + raycastHeight + raycastDist * m_Owner.GetDirection();
65 vector hitPosition, hitNormal;
66 float hitFraction;
67 Object hitObject = null;
68
70 bool hit = DayZPhysics.SphereCastBullet(startPos, endPos, raycastSphereRadius, collisionMask, m_Owner, hitObject, hitPosition, hitNormal, hitFraction);
71 if (hit)
72 {
73 m_PrevMaxClimbDist = m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance;
74 m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance = 2.5;
75 SHumanCommandClimbResult climbRes = new SHumanCommandClimbResult();
76 HumanCommandClimb.DoPerformClimbTest(player, climbRes, 0);
77 int climbType = GetClimbType(climbRes.m_fClimbHeight);
78
79 if ((climbRes.m_bIsClimb || climbRes.m_bIsClimbOver) && m_Owner.CanClimb(climbType, climbRes))
80 {
81#ifdef INPUT_OVERRIDE
82 player.GetInputInterface().SyncedOverride_ID(UAGetOver, 1, OverrideInputType.PRESS, true);
83#endif
84 }
85 else
86 {
87 m_Owner.GetDayZPlayerType().CommandClimbSettingsW().m_fFwMaxDistance = m_PrevMaxClimbDist;
88 m_Bot.ProcessEvent(m_Bot.__Obst__);
89 }
90 }
91 }
92 m_PrevIsClimbing = isClimbing;
93 super.OnUpdate(dt);
94 }
95}
96#endif
DayZGame g_Game
Определения DayZGame.c:4074
PhxInteractionLayers
Определения DayZPhysics.c:2
float hitFraction
Определения DustKickupEffects.c:23
HandStateEquipped OnEntry
Определения WeaponChambering.c:292
enum ProcessDirectDamageFlags m_Owner
vector m_OwnerPosition
The owner performing the snap callback.
Определения Object.c:12
proto native UAInputAPI GetUApi()
class WeaponChambering_Chamber_OnEntry extends WeaponChambering_Base OnExit
Определения WeaponChambering.c:352
override void OnEntry(HandEventBase e)
Определения Hand_States.c:34
proto native void ForceEnable(bool bEnable)
proto native UAInput GetInputByID(int iID)
returns list of all bindable (i.e. visible) inputs from the active group ('core' by default)
override void OnExit(WeaponEventBase e)
Определения WeaponChambering.c:439
class LOD Object
DayZGame GetGame()
Определения gameplay.c:636
proto native void OnUpdate()
Определения 3_Game/DayZ/tools/tools.c:349
void HumanCommandClimb()
Определения human.c:837