Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
actionlockdoors.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
5 m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.LOCK);
6 }
7};
8
10{
11 protected const float APPLIED_DMG = 6;
12
14 {
16 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
17 m_FullBody = true;
18 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
19 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_HIGH;
20 m_Text = "#lock_door";
21 }
22
28
29 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
30 {
31 if( !IsBuilding(target) ) return false;
32 if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
33
34 Building building;
35 ToolBase tool;
36 if (Class.CastTo(building, target.GetObject())&& Class.CastTo(tool, item))
37 {
38 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
39 if (doorIndex != -1 && tool.GetKeyCompatibilityType() & building.GetLockCompatibilityType(doorIndex))
40 return building.CanDoorBeLocked(doorIndex);
41 }
42 return false;
43 }
44
45 protected void LockDoor(ActionTarget target)
46 {
47 Building building;
48
49 if ( Class.CastTo(building, target.GetObject()) )
50 {
51 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
52 if ( doorIndex != -1 )
53 {
54 building.LockDoor(doorIndex);
55 }
56 }
57 }
58
59 override void OnFinishProgressServer( ActionData action_data )
60 {
61 LockDoor(action_data.m_Target);
62
63 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
64 }
65
66 override bool IsLockTargetOnUse()
67 {
68 return false;
69 }
70};
ActionBase ActionData
Definition actionbase.c:30
class ActionTargets ActionTarget
ActionData m_ActionData
bool m_FullBody
Definition actionbase.c:67
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
float m_SpecialtyWeight
Definition actionbase.c:83
ref CCTBase m_ConditionTarget
Definition actionbase.c:71
int m_StanceMask
Definition actionbase.c:68
override void CreateActionComponent()
override void OnFinishProgressServer(ActionData action_data)
void LockDoor(ActionTarget target)
override void CreateConditionComponents()
const float APPLIED_DMG
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool IsLockTargetOnUse()
proto native int GetDoorIndex(int componentIndex)
Gets the index of the door based on the view geometry component index.
proto native void LockDoor(int index, bool force=false)
Locks the door if not already locked, resets the door health. 'force = true' will close the door if o...
int GetLockCompatibilityType(int doorIdx)
Which door is compatible with which key (door idx supplied).
Definition building.c:167
bool CanDoorBeLocked(int doorIndex)
Check if the door is closed and if the door is unlocked.
Definition building.c:154
Super root of all classes in Enforce script.
Definition enscript.c:11
const float DEFAULT
const float LOCK
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.