Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionrestraintarget.c
Go to the documentation of this file.
1
class
ActionRestrainTargetCB
:
ActionContinuousBaseCB
2
{
3
const
float
DEFAULT_RESTRAIN_TIME
= 2;
4
5
override
void
CreateActionComponent
()
6
{
7
float
time =
DEFAULT_RESTRAIN_TIME
;
8
9
if
(
m_ActionData
.m_MainItem.ConfigIsExisting(
"RestrainTime"
) )
10
{
11
time =
m_ActionData
.m_MainItem.ConfigGetFloat(
"RestrainTime"
);
12
}
13
14
if
(
m_ActionData
.m_Player.IsQuickRestrain() )
15
{
16
time =
DEBUG_QUICK_UNRESTRAIN_TIME
;
17
}
18
19
m_ActionData
.m_ActionComponent =
new
CAContinuousTime
(time);
20
}
21
};
22
23
class
ActionRestrainTarget
:
ActionContinuousBase
24
{
25
void
ActionRestrainTarget
()
26
{
27
m_CallbackClass
=
ActionRestrainTargetCB
;
28
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONFB_RESTRAINTARGET;
29
m_FullBody
=
true
;
30
m_StanceMask
=
DayZPlayerConstants
.STANCEMASK_ERECT |
DayZPlayerConstants
.STANCEMASK_CROUCH;
31
m_SpecialtyWeight
= UASoftSkillsWeight.PRECISE_LOW;
32
m_Text
=
"#restrain"
;
33
}
34
35
override
void
CreateConditionComponents
()
36
{
37
m_ConditionTarget
=
new
CCTMan
(
UAMaxDistances
.
DEFAULT
);
38
m_ConditionItem
=
new
CCINonRuined
;
39
}
40
41
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item )
42
{
43
PlayerBase
other_player =
PlayerBase
.Cast(target.GetObject());
44
if
(!other_player)
45
return
false
;
46
if
( player.GetInstanceType() ==
DayZPlayerInstanceType
.INSTANCETYPE_SERVER )
47
{
48
return
other_player.CanBeRestrained();
49
}
50
else
51
{
52
return
!other_player.IsRestrained();
53
}
54
55
}
56
57
override
int
GetStanceMask
(
PlayerBase
player)
58
{
59
if
( player.IsPlayerInStance(
DayZPlayerConstants
.STANCEMASK_CROUCH |
DayZPlayerConstants
.STANCEMASK_PRONE))
60
return
DayZPlayerConstants
.STANCEMASK_CROUCH;
61
else
62
return
DayZPlayerConstants
.STANCEMASK_ERECT;
63
}
64
65
override
bool
ActionConditionContinue
(
ActionData
action_data)
66
{
67
PlayerBase
target_player =
PlayerBase
.Cast(action_data.m_Target.GetObject());
68
69
if
(
g_Game
.IsServer() &&
g_Game
.IsMultiplayer() )
70
{
71
if
( target_player.IsSurrendered() || !target_player.CanBeRestrained() )
72
{
73
return
false
;
74
}
75
}
76
if
(
g_Game
.IsServer() )
77
{
78
ActionRestrainTargetCB
callback =
ActionRestrainTargetCB
.Cast(action_data.m_Callback);
79
80
if
( callback.
GetActionComponentProgress
() > 0.75 && !target_player.IsRestrainPrelocked() )
81
{
82
target_player.SetRestrainPrelocked(
true
);
83
}
84
85
return
!
g_Game
.GetMission().IsPlayerDisconnecting(target_player);
86
87
}
88
return
true
;
89
}
90
91
override
void
OnStartServer
(
ActionData
action_data)
92
{
93
super.OnStartServer(action_data);
94
95
PlayerBase
target_player =
PlayerBase
.Cast(action_data.m_Target.GetObject());
96
if
( target_player.IsSurrendered() )
97
{
98
SurrenderDataRestrain sdr =
new
SurrenderDataRestrain;
99
target_player.EndSurrenderRequest(sdr);
100
}
101
else
if
( target_player.IsEmotePlaying() )
102
{
103
target_player.m_EmoteManager.ServerRequestEmoteCancel();
104
}
105
106
target_player.SetRestrainStarted(
true
);
107
}
108
109
override
void
OnEndServer
(
ActionData
action_data)
110
{
111
super.OnEndServer(action_data);
112
113
PlayerBase
target_player =
PlayerBase
.Cast(action_data.m_Target.GetObject());
114
if
(target_player)
115
{
116
target_player.SetRestrainStarted(
false
);
117
target_player.SetRestrainPrelocked(
false
);
118
}
119
}
120
121
override
void
OnFinishProgressServer
(
ActionData
action_data )
122
{
123
PlayerBase
target_player =
PlayerBase
.Cast(action_data.m_Target.GetObject());
124
PlayerBase
source_player =
PlayerBase
.Cast(action_data.m_Player);
125
126
if
(
CanReceiveAction
(action_data.m_Target) && !target_player.IsRestrained())
127
{
128
EntityAI
item_in_hands_target = target_player.GetEntityInHands();
129
EntityAI
item_in_hands_source = source_player.GetEntityInHands();
130
131
if
( !item_in_hands_source )
132
{
133
Error
(
"Restraining target failed, nothing in hands"
);
134
return
;
135
}
136
137
string
new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
138
if
(item_in_hands_target)
139
{
140
ChainedDropAndRestrainLambda
lambda2 =
new
ChainedDropAndRestrainLambda
(item_in_hands_target, item_in_hands_target.GetType(), target_player,
false
, source_player);
141
MiscGameplayFunctions.TurnItemInHandsIntoItemEx(target_player, lambda2);
142
}
143
else
144
{
145
RestrainTargetPlayerLambda
lambda =
new
RestrainTargetPlayerLambda
(item_in_hands_source, new_item_name, target_player);
146
source_player.LocalReplaceItemInHandsWithNewElsewhere(lambda);
147
}
148
}
149
}
150
151
override
void
OnFinishProgressClient
(
ActionData
action_data )
152
{
153
super.OnFinishProgressClient( action_data );
154
155
g_Game
.GetAnalyticsClient().OnActionRestrain();
156
}
157
};
158
159
class
ChainedDropAndRestrainLambda
:
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda
160
{
161
PlayerBase
m_SourcePlayer
;
162
ExplosivesBase
m_PairedExplosive
;
163
164
void
ChainedDropAndRestrainLambda
(
EntityAI
old_item,
string
new_item_type,
PlayerBase
player,
bool
destroy =
false
,
PlayerBase
src_player = null)
165
{
166
m_SourcePlayer
= src_player;
167
}
168
169
override
void
OnSuccess
(
EntityAI
new_item)
170
{
171
super.OnSuccess(new_item);
172
173
if
(
m_PairedExplosive
)
174
{
175
m_PairedExplosive
.UnpairRemote();
176
ItemBase
ib =
ItemBase
.Cast(new_item);
177
ib.PairWithDevice(
m_PairedExplosive
);
178
m_PairedExplosive
.Arm();
179
}
180
181
// as soon as previous op is finish, start another one
182
EntityAI
item_in_hands_source =
m_SourcePlayer
.GetEntityInHands();
183
if
(item_in_hands_source)
184
{
185
string
new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
186
RestrainTargetPlayerLambda
lambda =
new
RestrainTargetPlayerLambda
(item_in_hands_source, new_item_name,
m_Player
);
187
if
(
m_SourcePlayer
)
188
m_SourcePlayer
.LocalReplaceItemInHandsWithNewElsewhere(lambda);
189
else
190
Error
(
"ChainedDropAndRestrainLambda: missing source player!"
);
191
}
192
else
193
{
194
Error
(
"ChainedDropAndRestrainLambda: missing source item in hands!"
);
195
}
196
}
197
198
override
void
CopyOldPropertiesToNew
(notnull
EntityAI
old_item,
EntityAI
new_item)
199
{
200
super.CopyOldPropertiesToNew(old_item, new_item);
201
RemoteDetonatorTrigger
trigger =
RemoteDetonatorTrigger
.Cast(old_item);
202
if
(trigger)
203
m_PairedExplosive
=
ExplosivesBase
.Cast(trigger.
GetControlledDevice
());
204
}
205
}
206
207
208
class
RestrainTargetPlayerLambda
:
TurnItemIntoItemLambda
209
{
210
PlayerBase
m_TargetPlayer
;
211
212
void
RestrainTargetPlayerLambda
(
EntityAI
old_item,
string
new_item_type,
PlayerBase
player)
213
{
214
m_TargetPlayer
= player;
215
216
InventoryLocation
targetHnd =
new
InventoryLocation
;
217
targetHnd.
SetHands
(
m_TargetPlayer
, null);
218
OverrideNewLocation(targetHnd);
219
}
220
221
override
void
OnSuccess
(
EntityAI
new_item)
222
{
223
super.OnSuccess(new_item);
224
225
m_TargetPlayer
.SetRestrained(
true
);
226
m_TargetPlayer
.OnItemInHandsChanged();
227
}
228
};
229
230
class
SurrenderDataRestrain
extends
SurrenderData
231
{
232
override
void
End
()
233
{
234
235
}
236
}
ActionData
ActionBase ActionData
Definition
actionbase.c:30
RestrainTargetPlayerLambda
void RestrainTargetPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition
actionrestraintarget.c:212
m_TargetPlayer
ChainedDropAndRestrainLambda m_TargetPlayer
ActionTarget
class ActionTargets ActionTarget
m_Player
map m_Player
ActionBaseCB::m_ActionData
ActionData m_ActionData
Definition
animatedactionbase.c:3
ActionBaseCB::GetActionComponentProgress
float GetActionComponentProgress()
Definition
animatedactionbase.c:119
ActionBase::m_FullBody
bool m_FullBody
Definition
actionbase.c:67
ActionBase::m_Text
string m_Text
Definition
actionbase.c:64
ActionBase::m_ConditionItem
ref CCIBase m_ConditionItem
Definition
actionbase.c:70
ActionBase::m_SpecialtyWeight
float m_SpecialtyWeight
Definition
actionbase.c:83
ActionBase::m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition
actionbase.c:71
ActionBase::CanReceiveAction
bool CanReceiveAction(ActionTarget target)
Definition
actionbase.c:805
ActionBase::m_StanceMask
int m_StanceMask
Definition
actionbase.c:68
ActionContinuousBaseCB
Definition
actioncontinuousbase.c:2
ActionContinuousBase::ActionContinuousBase
void ActionContinuousBase()
Definition
actioncontinuousbase.c:124
ActionRestrainTargetCB
Definition
actionrestraintarget.c:2
ActionRestrainTargetCB::CreateActionComponent
override void CreateActionComponent()
Definition
actionrestraintarget.c:5
ActionRestrainTargetCB::DEFAULT_RESTRAIN_TIME
const float DEFAULT_RESTRAIN_TIME
Definition
actionrestraintarget.c:3
ActionRestrainTarget::OnFinishProgressServer
override void OnFinishProgressServer(ActionData action_data)
Definition
actionrestraintarget.c:121
ActionRestrainTarget::ActionConditionContinue
override bool ActionConditionContinue(ActionData action_data)
Definition
actionrestraintarget.c:65
ActionRestrainTarget::OnEndServer
override void OnEndServer(ActionData action_data)
Definition
actionrestraintarget.c:109
ActionRestrainTarget::GetStanceMask
override int GetStanceMask(PlayerBase player)
Definition
actionrestraintarget.c:57
ActionRestrainTarget::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionrestraintarget.c:35
ActionRestrainTarget::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionrestraintarget.c:41
ActionRestrainTarget::OnFinishProgressClient
override void OnFinishProgressClient(ActionData action_data)
Definition
actionrestraintarget.c:151
ActionRestrainTarget::ActionRestrainTarget
void ActionRestrainTarget()
Definition
actionrestraintarget.c:25
ActionRestrainTarget::OnStartServer
override void OnStartServer(ActionData action_data)
Definition
actionrestraintarget.c:91
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
AnimatedActionBase::m_CallbackClass
m_CallbackClass
Definition
animatedactionbase.c:145
CAContinuousTime
Definition
cacontinuoustime.c:2
CCINonRuined
Definition
ccinonruined.c:2
CCTMan
Definition
cctman.c:2
ChainedDropAndRestrainLambda
Definition
actionrestraintarget.c:160
ChainedDropAndRestrainLambda::CopyOldPropertiesToNew
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Definition
actionrestraintarget.c:198
ChainedDropAndRestrainLambda::OnSuccess
override void OnSuccess(EntityAI new_item)
Definition
actionrestraintarget.c:169
ChainedDropAndRestrainLambda::m_PairedExplosive
ExplosivesBase m_PairedExplosive
Definition
actionrestraintarget.c:162
ChainedDropAndRestrainLambda::m_SourcePlayer
PlayerBase m_SourcePlayer
Definition
actionrestraintarget.c:161
ChainedDropAndRestrainLambda::ChainedDropAndRestrainLambda
void ChainedDropAndRestrainLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false, PlayerBase src_player=null)
Definition
actionrestraintarget.c:164
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda::DestroyItemInCorpsesHandsAndCreateNewOnGndLambda
void DestroyItemInCorpsesHandsAndCreateNewOnGndLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false)
Definition
miscgameplayfunctions.c:1915
EntityAI
Definition
inventoryitem.c:2
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::SetHands
proto native void SetHands(notnull EntityAI parent, EntityAI e)
ItemBase
Definition
inventoryitem.c:742
PlayerBase
Definition
playerbaseclient.c:2
RemoteDetonatorTrigger
Definition
remotedetonator.c:47
RemoteDetonatorTrigger::GetControlledDevice
EntityAI GetControlledDevice()
Definition
remotedetonator.c:150
SurrenderData
Definition
emotemanager.c:1425
SurrenderData::End
override void End()
Definition
actionrestraintarget.c:232
TurnItemIntoItemLambda
Definition
miscgameplayfunctions.c:92
TurnItemIntoItemLambda::OnSuccess
override void OnSuccess(EntityAI new_item)
Definition
miscgameplayfunctions.c:93
UAMaxDistances
Definition
actionconstants.c:110
UAMaxDistances::DEFAULT
const float DEFAULT
Definition
actionconstants.c:112
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition
dayzplayer.c:1071
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
ExplosivesBase
void ExplosivesBase()
Definition
explosivesbase.c:42
Error
void Error(string err)
Messagebox with error message.
Definition
endebug.c:90
DEBUG_QUICK_UNRESTRAIN_TIME
const float DEBUG_QUICK_UNRESTRAIN_TIME
\ misc
Definition
constants.c:650
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
continuous
actionrestraintarget.c
Generated by
1.17.0