3 const float DEFAULT_RESTRAIN_TIME = 2;
5 override void CreateActionComponent()
7 float time = DEFAULT_RESTRAIN_TIME;
9 if ( m_ActionData.m_MainItem.ConfigIsExisting(
"RestrainTime") )
11 time = m_ActionData.m_MainItem.ConfigGetFloat(
"RestrainTime");
14 if ( m_ActionData.m_Player.IsQuickRestrain() )
35 override void CreateConditionComponents()
48 return other_player.CanBeRestrained();
52 return !other_player.IsRestrained();
65 override bool ActionConditionContinue(
ActionData action_data)
71 if ( target_player.IsSurrendered() || !target_player.CanBeRestrained() )
80 if ( callback.GetActionComponentProgress() > 0.75 && !target_player.IsRestrainPrelocked() )
82 target_player.SetRestrainPrelocked(
true);
85 return !
GetGame().GetMission().IsPlayerDisconnecting(target_player);
91 override void OnStartServer(
ActionData action_data)
94 if ( target_player.IsSurrendered() )
96 SurrenderDataRestrain sdr =
new SurrenderDataRestrain;
97 target_player.EndSurrenderRequest(sdr);
99 else if ( target_player.IsEmotePlaying() )
101 target_player.m_EmoteManager.ServerRequestEmoteCancel();
104 target_player.SetRestrainStarted(
true);
107 override void OnEndServer(
ActionData action_data)
112 target_player.SetRestrainStarted(
false);
113 target_player.SetRestrainPrelocked(
false);
117 override void OnFinishProgressServer(
ActionData action_data )
122 if (
CanReceiveAction(action_data.m_Target) && !target_player.IsRestrained())
124 EntityAI item_in_hands_target = target_player.GetHumanInventory().GetEntityInHands();
125 EntityAI item_in_hands_source = source_player.GetHumanInventory().GetEntityInHands();
127 if ( !item_in_hands_source )
129 Error(
"Restraining target failed, nothing in hands");
133 string new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
134 if (item_in_hands_target)
136 Print(
"Restraining player with item in hands, first drop & then restrain");
139 MiscGameplayFunctions.TurnItemInHandsIntoItemEx(target_player, lambda2);
143 Print(
"Restraining player with empty hands");
145 source_player.LocalReplaceItemInHandsWithNewElsewhere(lambda);
152 override void OnFinishProgressClient(
ActionData action_data )
154 super.OnFinishProgressClient( action_data );
156 GetGame().GetAnalyticsClient().OnActionRestrain();
167 m_SourcePlayer = src_player;
170 override void OnSuccess(
EntityAI new_item)
172 super.OnSuccess(new_item);
174 if (m_PairedExplosive)
176 m_PairedExplosive.UnpairRemote();
178 ib.PairWithDevice(m_PairedExplosive);
179 m_PairedExplosive.Arm();
183 EntityAI item_in_hands_source = m_SourcePlayer.GetHumanInventory().GetEntityInHands();
184 if (item_in_hands_source)
186 string new_item_name = MiscGameplayFunctions.ObtainRestrainItemTargetClassname(item_in_hands_source);
189 m_SourcePlayer.LocalReplaceItemInHandsWithNewElsewhere(lambda);
191 Error(
"ChainedDropAndRestrainLambda: missing source player!");
195 Error(
"ChainedDropAndRestrainLambda: missing source item in hands!");
199 override void CopyOldPropertiesToNew (notnull
EntityAI old_item,
EntityAI new_item)
201 super.CopyOldPropertiesToNew(old_item, new_item);
204 m_PairedExplosive =
ExplosivesBase.Cast(trigger.GetControlledDevice());
219 OverrideNewLocation(targetHnd);
224 super.OnSuccess(new_item);