Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionopendoors.c
Go to the documentation of this file.
2{
3 ref NoiseParams m_NoisePar;
4
5 void ActionOpenDoors()
6 {
7 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
8 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
9 m_Text = "#open";
10 }
11
12 override void CreateConditionComponents()
13 {
16 }
17
18 protected bool CheckIfDoorIsLocked()
19 {
20 return true;
21 }
22
23 protected bool CreatesNoise()
24 {
25 return true;
26 }
27
28 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
29 {
30 if (!target)
31 return false;
32
33 if (!IsBuilding(target))
34 return false;
35
36 Building building;
37 if (Class.CastTo(building, target.GetObject()))
38 {
39 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
40 if (doorIndex != -1)
41 {
42 if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
43 return false;
44
45 return building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked());
46
47 }
48 }
49
50 return false;
51 }
52
53 override void OnStartServer(ActionData action_data)
54 {
55 super.OnStartServer(action_data);
56
57 Building building;
58 if (Class.CastTo(building, action_data.m_Target.GetObject()))
59 {
60 int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
61 if (doorIndex != -1)
62 {
63 if (building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked()))
64 {
65 building.OpenDoor(doorIndex);
66 }
67 }
68 }
69 }
70
71 override void OnEndServer(ActionData action_data)
72 {
73 super.OnEndServer(action_data);
74
75 m_NoisePar = new NoiseParams();
76 m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
77 NoiseSystem noise = GetGame().GetNoiseSystem();
78 if (noise && CreatesNoise())
79 {
80 if (action_data.m_Player)
81 noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
82 }
83 }
84
85 override bool IsLockTargetOnUse()
86 {
87 return false;
88 }
89}
90
92{
93 override bool CheckIfDoorIsLocked()
94 {
95 return false;
96 }
97
98 override protected bool CreatesNoise()
99 {
100 return false;
101 }
102};
ref NoiseParams m_NoisePar
bool CreatesNoise()
ActionOpenDoors ActionInteractBase CheckIfDoorIsLocked()
int m_StanceMask
Definition actionbase.c:62
bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
bool IsBuilding(ActionTarget target)
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
override void OnEndServer(ActionData action_data)
override bool IsLockTargetOnUse()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnStartServer(ActionData action_data)
Super root of all classes in Enforce script.
Definition enscript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
class NoiseSystem NoiseParams()
Definition noise.c:15