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.GetHumanInventory().GetEntityInHands();
129 EntityAI item_in_hands_source = source_player.GetHumanInventory().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 {
146 source_player.LocalReplaceItemInHandsWithNewElsewhere(lambda);
147 }
148 }
149 }
void RestrainTargetPlayerLambda(EntityAI old_item, string new_item_type, PlayerBase player)
bool CanReceiveAction(ActionTarget target)
void Error(string err)
Messagebox with error message.