DayZ 1.24
Loading...
Searching...
No Matches
ActionRestrainTarget.c
Go to the documentation of this file.
2{
3 const float DEFAULT_RESTRAIN_TIME = 2;
4
5 override void CreateActionComponent()
6 {
8
9 if (m_ActionData.m_MainItem.ConfigIsExisting("RestrainTime"))
10 time = m_ActionData.m_MainItem.ConfigGetFloat("RestrainTime");
11
12 if (m_ActionData.m_Player.IsQuickRestrain())
14
16 }
17};
18
20{
22 {
24 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_RESTRAINTARGET;
25 m_FullBody = true;
26 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
28 m_Text = "#restrain";
29 }
30
36
37 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
38 {
39 PlayerBase other_player = PlayerBase.Cast(target.GetObject());
40 if (!other_player)
41 return false;
42 if (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
43 return other_player.CanBeRestrained();
44 else
45 return !other_player.IsRestrained();
46
47 }
48
50 {
51 if (player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE))
52 return DayZPlayerConstants.STANCEMASK_CROUCH;
53 else
54 return DayZPlayerConstants.STANCEMASK_ERECT;
55 }
56
58 {
59 PlayerBase target_player = PlayerBase.Cast(action_data.m_Target.GetObject());
60
61 if (GetGame().IsServer() && GetGame().IsMultiplayer())
62 {
63 if (target_player.IsSurrendered() || !target_player.CanBeRestrained())
64 return false;
65 }
66 if (GetGame().IsServer())
67 {
69
70 if (callback.GetActionComponentProgress() > 0.75 && !target_player.IsRestrainPrelocked())
71 target_player.SetRestrainPrelocked(true);
72
73 return !GetGame().GetMission().IsPlayerDisconnecting(target_player);
74
75 }
76 return true;
77 }
78
80 {
81 PlayerBase target_player = PlayerBase.Cast(action_data.m_Target.GetObject());
82 if (target_player.IsSurrendered())
83 {
85 target_player.EndSurrenderRequest(sdr);
86 }
87 else if (target_player.IsEmotePlaying())
88 target_player.m_EmoteManager.ServerRequestEmoteCancel();
89
90 target_player.SetRestrainStarted(true);
91 }
92
94 {
95 PlayerBase target_player = PlayerBase.Cast(action_data.m_Target.GetObject());
96 if (target_player)
97 {
98 target_player.SetRestrainStarted(false);
99 target_player.SetRestrainPrelocked(false);
100 }
101 }
102
104 {
105 PlayerBase target_player = PlayerBase.Cast(action_data.m_Target.GetObject());
107
108 if (CanReceiveAction(action_data.m_Target) && !target_player.IsRestrained())
109 {
110 EntityAI item_in_hands_target = target_player.GetHumanInventory().GetEntityInHands();
111 EntityAI item_in_hands_source = source_player.GetHumanInventory().GetEntityInHands();
112
114 {
115 Error("Restraining target failed, nothing in hands");
116 return;
117 }
118
119 string new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
121 {
122 Print("Restraining player with item in hands, first drop & then restrain");
123
125 MiscGameplayFunctions.TurnItemInHandsIntoItemEx(target_player, lambda2);
126 }
127 else
128 {
129 Print("Restraining player with empty hands");
131 source_player.LocalReplaceItemInHandsWithNewElsewhere(lambda);
132 }
133
134 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
135 }
136 }
137
139 {
140 super.OnFinishProgressClient(action_data);
141
142 GetGame().GetAnalyticsClient().OnActionRestrain();
143 }
144};
145
147{
149 ExplosivesBase m_PairedExplosive;
150
155
157 {
158 super.OnSuccess(new_item);
159
161 {
162 m_PairedExplosive.UnpairRemote();
164 ib.PairWithDevice(m_PairedExplosive);
165 m_PairedExplosive.Arm();
166 }
167
168 // as soon as previous op is finish, start another one
169 EntityAI item_in_hands_source = m_SourcePlayer.GetHumanInventory().GetEntityInHands();
171 {
172 string new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
174 if (m_SourcePlayer)
175 m_SourcePlayer.LocalReplaceItemInHandsWithNewElsewhere(lambda);
176 else
177 Error("ChainedDropAndRestrainLambda: missing source player!");
178 }
179 else
180 Error("ChainedDropAndRestrainLambda: missing source item in hands!");
181 }
182
184 {
185 super.CopyOldPropertiesToNew(old_item, new_item);
187 if (trigger)
188 m_PairedExplosive = ExplosivesBase.Cast(trigger.GetControlledDevice());
189 }
190}
191
192
194{
196
205
207 {
208 super.OnSuccess(new_item);
209
210 m_TargetPlayer.SetRestrained(true);
211 m_TargetPlayer.OnItemInHandsChanged();
212 }
213};
214
216{
217 override void End()
218 {
219
220 }
221}
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
bool CanReceiveAction(ActionTarget target)
Definition ActionBase.c:594
int m_StanceMask
Definition ActionBase.c:53
void RestrainTargetPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
ChainedDropAndRestrainLambda m_TargetPlayer
DayZPlayer m_Player
Definition Hand_Events.c:42
ActionData m_ActionData
PlayerBase m_Player
Definition ActionBase.c:33
ref CABase m_ActionComponent
Definition ActionBase.c:30
ItemBase m_MainItem
Definition ActionBase.c:28
override void CreateActionComponent()
override bool ActionConditionContinue(ActionData action_data)
override void OnStartServer(ActionData action_data)
override void OnFinishProgressServer(ActionData action_data)
override int GetStanceMask(PlayerBase player)
override void CreateConditionComponents()
override void OnEndServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressClient(ActionData action_data)
Definition CCTMan.c:2
void ChainedDropAndRestrainLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false, PlayerBase src_player=null)
override void OnSuccess(EntityAI new_item)
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
InventoryLocation.
override void End()
override void OnSuccess(EntityAI new_item)
const float DEFAULT
DayZPlayerInstanceType
defined in C++
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
const float DEBUG_QUICK_UNRESTRAIN_TIME
Definition constants.c:598