Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionclosedoors.c
Go to the documentation of this file.
2 {
3  ref NoiseParams m_NoisePar;
4 
5  void ActionCloseDoors()
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  {
14  m_ConditionItem = new CCINone();
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  Building building;
45  if (Class.CastTo(building, action_data.m_Target.GetObject()))
46  {
47  int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
48  if (doorIndex != -1)
49  {
50  if (building.CanDoorBeClosed(doorIndex))
51  {
52  building.CloseDoor(doorIndex);
53  }
54 
55  }
56  }
57  }
58 
59  override void OnEndServer(ActionData action_data)
60  {
61  m_NoisePar = new NoiseParams();
62  m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
63  NoiseSystem noise = GetGame().GetNoiseSystem();
64  if (noise)
65  {
66  if (action_data.m_Player)
67  noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar);
68  }
69  }
70 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
CCINone
Definition: ccinone.c:1
UAMaxDistances
Definition: actionconstants.c:104
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
NoiseParams
class ObjectSpawnerHandler NoiseParams
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
m_NoisePar
ref NoiseParams m_NoisePar
Definition: actionopendoors.c:2
CCTCursor
Definition: cctcursor.c:1
IsInReach
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition: actionbase.c:928
NoiseSystem
Definition: noise.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
IsBuilding
protected bool IsBuilding(ActionTarget target)
Definition: actionbase.c:918
ActionCloseDoors
Definition: actionclosedoors.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53