Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
actionunlockcontainerdoor.c
Go to the documentation of this file.
2{
3 //custom condition, wrong key unlock attempt is allowed
4 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
5 {
6 ContainerLockedBase shipCont;
7 if (Class.CastTo(shipCont, target.GetObject()))
8 {
9 int doorIndex = TranslateLockSelectionIntoDoorIdx(target);
10 if (doorIndex != -1)
11 return shipCont.IsDoorLocked(doorIndex);
12 }
13 return false;
14 }
15
16 override void OnFinishProgressServer( ActionData action_data )
17 {
19 ContainerLockedBase shipCont = ContainerLockedBase.Cast(action_data.m_Target.GetObject());
20 if (shipCont && key && ((shipCont.GetLockCompatibilityType(shipCont.GetDoorIndex(action_data.m_Target.GetComponentIndex())) & key.GetKeyCompatibilityType()) == 0))
21 {
22 key.DestroyKeyServer();
23 }
24 else
25 {
26 UnlockDoor(action_data.m_Target);
27 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
28 }
29 }
30
31 override protected void UnlockDoor(ActionTarget target)
32 {
33 Building building;
34 if (Class.CastTo(building, target.GetObject()))
35 {
36 int doorIndex = TranslateLockSelectionIntoDoorIdx(target);
37 if (doorIndex != -1)
38 {
39 building.UnlockDoor(doorIndex,false);
40 }
41 }
42 }
43
46 {
47 //side1_lock
48 ContainerLockedBase shipCont;
49 if (Class.CastTo(shipCont, target.GetObject()))
50 {
51 string selectionName = shipCont.GetActionComponentName( target.GetComponentIndex() );
52
53 if (selectionName.Contains("_lock"))
54 return (selectionName.Substring(4,1).ToInt() - 1);
55 }
56
57 return -1;
58 }
59};
ActionBase ActionData
Definition actionbase.c:30
class ActionTargets ActionTarget
override void OnFinishProgressServer(ActionData action_data)
int TranslateLockSelectionIntoDoorIdx(ActionTarget target)
Returns door idx.
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
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
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native int ToInt()
Converts string to integer.
bool Contains(string sample)
Returns true if sample is substring of string.
Definition enstring.c:286