DayZ 1.24
Loading...
Searching...
No Matches
ActionLockAttachment.c
Go to the documentation of this file.
1//Transfer locktypes from BasicDefines.hpp here. This is mostly for readability
2//NONE must be 0 as it is actively used below
4{
5 NONE = 0,
6 LOCK_SCREW = 1,
7 LOCK_BOLT = 2,
8 LOCK_NUT = 3,
9 LOCK_WIRE = 4
10}
11
13{
14 override void CreateActionComponent()
15 {
16 m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.BASEBUILDING_REPAIR_FAST);
17 }
18};
21{
22 private const string LOCK_VERSION = "#widget_lock";
23 private const string UNLOCK_VERSION = "#widget_unlock";
24 private string m_Name = LOCK_VERSION;
25
35
37 {
38 ItemBase target_IB = ItemBase.Cast(target.GetObject());
39 if (target_IB.IsLockedInSlot())
41 else if (target_IB.IsAlive())
43 else
44 m_Text = "";
45 }
46
52
53 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
54 {
55 if (!target)
56 return false;
57
58 EntityAI parent_EAI = EntityAI.Cast(target.GetParent());
59 ItemBase target_IB = ItemBase.Cast(target.GetObject());
60
61 array<int> compLock = item.m_CompatibleLocks;
62 int targetType = eLockTypes.NONE;
63
64 if (target_IB && parent_EAI)
65 {
66 //CAR DOOR HANDLING
67 //I don't really like this, but sometimes specifics have to be handled in generics
69 if (targetDoor)
70 {
72 bool isPresent = targetDoor.GetInventory().GetCurrentInventoryLocation(loc);
73
74 if (!isPresent || loc.GetSlot() == -1)
75 return false;
76
77 string slotName = InventorySlots.GetSlotName(loc.GetSlot());
79 return false;
80 }
81 //END OF CAR DOOR SPECIFICS
82
83
84 if (target_IB.IsLockedInSlot())
86 else if (target_IB.IsAlive())
88 else if (!target_IB.IsLockedInSlot())
89 return false;
90
91 targetType = target_IB.GetLockType();
92
93 for (int i = 0; i < compLock.Count(); i++)
94 {
95 if (targetType == compLock[i] && targetType != eLockTypes.NONE)
96 return true;
97 }
98 }
99 return false;
100 }
101
103 {
104 super.OnStartAnimationLoop(action_data);
105
106 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
107 {
108 ItemBase target_IB = ItemBase.Cast(action_data.m_Target.GetObject());
109 Param2<bool, string> play = new Param2<bool, string>(true, action_data.m_MainItem.GetLockSoundSet());
110 GetGame().RPCSingleParam(target_IB, ERPCs.RPC_SOUND_LOCK_ATTACH, play, true);
111 }
112 }
113
115 {
116 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
117 {
118 ItemBase target_IB = ItemBase.Cast(action_data.m_Target.GetObject());
119 Param2<bool, string> play = new Param2<bool, string>(false, action_data.m_MainItem.GetLockSoundSet());
120 GetGame().RPCSingleParam(target_IB, ERPCs.RPC_SOUND_LOCK_ATTACH, play, true);
121 }
122 }
123
125 {
126 super.OnEndAnimationLoop(action_data);
127
128 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
129 {
130 ItemBase target_IB = ItemBase.Cast(action_data.m_Target.GetObject());
131 Param2<bool, string> play = new Param2<bool, string>(false, action_data.m_MainItem.GetLockSoundSet());
132 GetGame().RPCSingleParam(target_IB, ERPCs.RPC_SOUND_LOCK_ATTACH, play, true);
133 }
134 }
135
137 {
138 ItemBase target_IB = ItemBase.Cast(action_data.m_Target.GetObject());
139
140 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 5);
141
142 if (target_IB.IsLockedInSlot())
143 {
144 target_IB.UnlockFromParent();
145 return;
146 }
147
148 target_IB.LockToParent();
149 }
150}
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
ActionEmptyMagazine CreateActionComponent
CarDoorState
Definition CarScript.c:2
PlayerSpawnPreset slotName
ERPCs
Definition ERPCs.c:2
override void CreateConditionComponents()
override void OnStartAnimationLoop(ActionData action_data)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressServer(ActionData action_data)
override void OnEnd(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnEndAnimationLoop(ActionData action_data)
override int GetCarDoorsState(string slotType)
InventoryLocation.
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
const float SMALL
const float BASEBUILDING_REPAIR_FAST
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()