DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionCloseDoors.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 = "#close";
10 }
11
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.IsDoorOpen(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 building.CloseDoor(doorIndex);
51 }
52 }
53 }
54
55 override void OnEndServer(ActionData action_data)
56 {
57 m_NoisePar = new NoiseParams();
58 m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
60 if (noise)
61 {
62 if (action_data.m_Player)
63 noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar);
64 }
65 }
66}
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected bool IsBuilding(ActionTarget target)
Definition ActionBase.c:917
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition ActionBase.c:927
protected string m_Text
Definition ActionBase.c:49
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
class NoiseSystem NoiseParams()
Definition Noise.c:15
override void OnEndServer(ActionData action_data)
ref NoiseParams m_NoisePar
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnStartServer(ActionData action_data)
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
proto native NoiseSystem GetNoiseSystem()
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto void AddNoisePos(EntityAI source_entity, vector pos, NoiseParams noise_params, float external_strenght_multiplier=1.0)
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.