Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
actionunlockdoors.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
5 m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.UNLOCK);
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_Text = "#unlock";
20 }
21
27
28 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
29 {
30 if( !IsBuilding(target) ) return false;
31 if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
32
33 Building building;
34 ToolBase tool;
35 if (Class.CastTo(building, target.GetObject())&& Class.CastTo(tool, item))
36 {
37 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
38 if (doorIndex != -1 && tool.GetKeyCompatibilityType() & building.GetLockCompatibilityType(doorIndex))
39 return building.IsDoorLocked(doorIndex);
40 }
41 return false;
42 }
43
44 protected void UnlockDoor(ActionTarget target)
45 {
46 Building building;
47
48 if ( Class.CastTo(building, target.GetObject()) )
49 {
50 int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
51 if ( doorIndex != -1 )
52 {
53 building.UnlockDoor(doorIndex);
54 }
55 }
56 }
57
58 override void OnFinishProgressServer( ActionData action_data )
59 {
60 UnlockDoor(action_data.m_Target);
61
62 //Damage the Lockpick
63 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
64
65 }
66
67 override bool IsLockTargetOnUse()
68 {
69 return false;
70 }
71};
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
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 UnlockDoor(ActionTarget target)
override void CreateConditionComponents()
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 bool IsDoorLocked(int index)
When the door is locked.
int GetLockCompatibilityType(int doorIdx)
Which door is compatible with which key (door idx supplied).
Definition building.c:167
proto native void UnlockDoor(int index, bool animate=true)
Unlocks the door if locked, AJAR animation optional.
Super root of all classes in Enforce script.
Definition enscript.c:11
const float DEFAULT
const float UNLOCK
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.