Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionclosedoors.c
Go to the documentation of this file.
2{
3 ref NoiseParams m_NoisePar;
4
6 {
7 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
8 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
9 m_Text = "#close";
10 }
11
12 override void CreateConditionComponents()
13 {
16 }
17
18 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
19 {
20 if (!target)
21 return false;
22
23 if (!IsBuilding(target))
24 return false;
25
26 Building building;
27 if (Class.CastTo(building, target.GetObject()))
28 {
29 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
30 if (doorIndex != -1)
31 {
32 if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
33 return false;
34
35 return building.CanDoorBeClosed(doorIndex);
36 }
37 }
38
39 return false;
40 }
41
42 override void OnStartServer(ActionData action_data)
43 {
44 super.OnStartServer(action_data);
45
46 Building building;
47 if (Class.CastTo(building, action_data.m_Target.GetObject()))
48 {
49 int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
50 if (doorIndex != -1)
51 {
52 if (building.CanDoorBeClosed(doorIndex))
53 {
54 building.CloseDoor(doorIndex);
55 }
56 }
57 }
58 }
59
60 override void OnEndServer(ActionData action_data)
61 {
62 super.OnEndServer(action_data);
63
64 m_NoisePar = new NoiseParams();
65 m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
66 NoiseSystem noise = GetGame().GetNoiseSystem();
67 if (noise)
68 {
69 if (action_data.m_Player)
70 noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
71 }
72 }
73
74 override bool IsLockTargetOnUse()
75 {
76 return false;
77 }
78}
ref NoiseParams m_NoisePar
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
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