Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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 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 = g_Game.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(g_Game.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};
ActionBase ActionData
Definition actionbase.c:30
bool CreatesNoise()
ActionOpenDoors ActionInteractBase CheckIfDoorIsLocked()
class ActionTargets ActionTarget
string m_Text
Definition actionbase.c:64
bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
bool IsBuilding(ActionTarget target)
ref CCIBase m_ConditionItem
Definition actionbase.c:70
ref CCTBase m_ConditionTarget
Definition actionbase.c:71
int m_StanceMask
Definition actionbase.c:68
override void OnEndServer(ActionData action_data)
ref NoiseParams m_NoisePar
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool IsLockTargetOnUse()
override void OnStartServer(ActionData action_data)
proto native int GetDoorIndex(int componentIndex)
Gets the index of the door based on the view geometry component index.
proto native void OpenDoor(int index)
Attempts to open the door.
bool CanDoorBeOpened(int doorIndex, bool checkIfLocked=false)
Definition building.c:130
Super root of all classes in Enforce script.
Definition enscript.c:11
static float GetNoiseReduction(Weather weather)
proto void AddNoisePos(EntityAI source_entity, vector pos, NoiseParams noise_params, float external_strenght_multiplier=1.0)
const float DEFAULT
DayZGame g_Game
Definition dayzgame.c:3942
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
class NoiseSystem NoiseParams()
Definition noise.c:15