Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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  {
14  m_ConditionItem = new CCINone();
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  return building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked());
41 
42  }
43  }
44 
45  return false;
46  }
47 
48  override void OnStartServer(ActionData action_data)
49  {
50  Building building;
51  if (Class.CastTo(building, action_data.m_Target.GetObject()))
52  {
53  int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
54  if (doorIndex != -1)
55  {
56  if (building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked()))
57  {
58  building.OpenDoor(doorIndex);
59  }
60  }
61  }
62  }
63 
64  override void OnEndServer(ActionData action_data)
65  {
66  m_NoisePar = new NoiseParams();
67  m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
68  NoiseSystem noise = GetGame().GetNoiseSystem();
69  if (noise)
70  {
71  if (action_data.m_Player)
72  noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar);
73  }
74  }
75 }
76 
78 {
79  override bool CheckIfDoorIsLocked()
80  {
81  return false;
82  }
83 
84  override void OnEndServer(ActionData action_data)
85  {
87  //super.OnEndServer(action_data);
88  }
89 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionLockedDoors
Definition: actionlockeddoors.c:1
ActionOpenDoors
Definition: actionopendoors.c:1
CCINone
Definition: ccinone.c:1
UAMaxDistances
Definition: actionconstants.c:104
OnEndServer
override void OnEndServer(ActionData action_data)
Definition: actionopendoors.c:63
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
CheckIfDoorIsLocked
ActionOpenDoors ActionInteractBase CheckIfDoorIsLocked()
Definition: actionopendoors.c:79
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