DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionOpenDoors.c
Go to the documentation of this file.
2{
4
6 {
7 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
8 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
9 m_Text = "#open";
10 }
11
13 {
16 }
17
18 protected bool CheckIfDoorIsLocked()
19 {
20 return true;
21 }
22
23 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
24 {
25 if (!target)
26 return false;
27
28 if (!IsBuilding(target))
29 return false;
30
31 Building building;
32 if (Class.CastTo(building, target.GetObject()))
33 {
34 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
35 if (doorIndex != -1)
36 {
37 if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
38 return false;
39
40 if (building.IsDoorOpen(doorIndex))
41 return false;
42
44 {
45 if (building.IsDoorLocked(doorIndex))
46 return false;
47 }
48 else
49 {
50 if (!building.IsDoorLocked(doorIndex))
51 return false;
52 }
53
54 return true;
55 }
56 }
57
58 return false;
59 }
60
61 override void OnStartServer(ActionData action_data)
62 {
63 Building building;
64 if (Class.CastTo(building, action_data.m_Target.GetObject()))
65 {
66 int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
67 if (doorIndex != -1)
68 {
69 building.OpenDoor(doorIndex);
70 }
71 }
72 }
73
74 override void OnEndServer(ActionData action_data)
75 {
76 m_NoisePar = new NoiseParams();
77 m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
79 if (noise)
80 {
81 if (action_data.m_Player)
82 noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar);
83 }
84 }
85}
86
87class ActionLockedDoors : ActionOpenDoors
88{
89 override bool CheckIfDoorIsLocked()
90 {
91 return false;
92 }
93
94 override void OnEndServer(ActionData action_data)
95 {
97 //super.OnEndServer(action_data);
98 }
99};
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected bool IsBuilding(ActionTarget target)
Definition ActionBase.c:917
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition ActionBase.c:927
protected string m_Text
Definition ActionBase.c:49
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
class NoiseSystem NoiseParams()
Definition Noise.c:15
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnEndServer(ActionData action_data)
ref NoiseParams m_NoisePar
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
protected bool CheckIfDoorIsLocked()
override void OnStartServer(ActionData action_data)
proto native NoiseSystem GetNoiseSystem()
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto void AddNoisePos(EntityAI source_entity, vector pos, NoiseParams noise_params, float external_strenght_multiplier=1.0)
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.