Dayz Explorer 1.28.160049
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
45 protected int TranslateLockSelectionIntoDoorIdx(ActionTarget target)
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};
int TranslateLockSelectionIntoDoorIdx(ActionTarget target)
Returns door idx.
Super root of all classes in Enforce script.
Definition enscript.c:11