DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionUnrestrainTarget.c
Go to the documentation of this file.
2{
3 const float DEFAULT_UNRESTRAIN_TIME = 2;
4
5 override void CreateActionComponent()
6 {
7 float time = ObtainUnrestrainTime();
8
9 if( time <=0 )
10 {
12 }
13
14 if( m_ActionData.m_Player.IsQuickRestrain() )
15 {
17 }
18
20 }
21
23 {
24 PlayerBase target_player = PlayerBase.Cast(m_ActionData.m_Target.GetObject());
25 PlayerBase source_player = m_ActionData.m_Player;
26
27 if (target_player.IsRestrained())
28 {
29 EntityAI item_in_hands_source = source_player.GetItemInHands();
30
31 ItemBase item_in_hands_target = target_player.GetItemInHands();
32
34 item_in_hands_target.ConfigGetTextArray( "CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING );
35
36 string item_in_hands_name = item_in_hands_source.GetType();
37
38 for(int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
39 {
40 if((i % 2) == 0)
41 {
43 if( GetGame().IsKindOf(item_in_hands_name, class_name) )
44 {
45 float value = CachedObjectsArrays.ARRAY_STRING.Get(i+1).ToFloat();
46 return value;
47 }
48 }
49 }
50 }
51 return -1;
52 }
53};
54
56{
58 {
60 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_UNRESTRAINTARGET;
61 m_FullBody = true;
62 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
64 m_Text = "#unrestrain";
65 }
66
68 {
71 }
72
73 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
74 {
75 PlayerBase other_player = PlayerBase.Cast(target.GetObject());
76 EntityAI item_in_hands_source = player.GetItemInHands();
77
78 if( other_player.IsRestrained() )
79 {
80 //Print("is restrained");
81 EntityAI item_in_hands_target = other_player.GetItemInHands();
82
84
85 if( item_in_hands_target )
86 {
87 item_in_hands_target.ConfigGetTextArray( "CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING );
88
89 string item_in_hands_name = item_in_hands_source.GetType();
90
91 for(int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
92 {
93 if((i % 2) == 0)
94 {
96 if( GetGame().IsKindOf(item_in_hands_name, class_name) )
97 {
98 return true;
99 }
100 }
101 }
102 }
103 }
104 return false;
105 }
106
107 override void OnFinishProgressServer( ActionData action_data )
108 {
109 PlayerBase player_target = PlayerBase.Cast(action_data.m_Target.GetObject());
110 PlayerBase player_source = PlayerBase.Cast(action_data.m_Player);
111
112 if (CanReceiveAction(action_data.m_Target) && player_target.IsRestrained())
113 {
114 EntityAI unrestraining_tool = action_data.m_MainItem;
115 EntityAI restraining_item = player_target.GetItemInHands();
116
117 player_target.SetRestrained(false);
118
119
120 //Damage applied to tool
122
123 restraining_item.ConfigGetTextArray( "CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING );
124 restraining_item.ConfigGetFloatArray( "CanBeUnrestrainedByDMG", CachedObjectsArrays.ARRAY_FLOAT );
125
126 string item_in_hands_name = unrestraining_tool.GetType();
127 float damageToTool = 0;
128
129 for(int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
130 {
132 if( GetGame().IsKindOf(item_in_hands_name, class_name) )
133 {
134 damageToTool = CachedObjectsArrays.ARRAY_FLOAT.Get(i/2);
135 break;
136 }
137 }
138
139 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, damageToTool);
140 //---------------------------
141
142 MiscGameplayFunctions.TransformRestrainItem(restraining_item, unrestraining_tool, player_source, player_target);
143
144 action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
145 }
146 }
147};
148
149class ReplaceAndDestroyLambda : TurnItemIntoItemLambdaAnimSysNotifyLambda
150{
153 bool m_Drop;
154
155 void ReplaceAndDestroyLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy = false)
156 {
157 m_TargetPlayer = player;
158 m_Destroy = destroy;
159 m_OldItem = old_item;
160 }
161
162 override void OnSuccess(EntityAI new_item)
163 {
164 super.OnSuccess(new_item);
165
166 if ( m_Destroy )
167 {
168 new_item.SetHealth("","",0);
169 }
170 }
171};
172
174{
175 void ReplaceAndDestroyLambdaEx(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy = false, bool enableDrop = true)
176 {
177 m_Drop = enableDrop;
178 }
179
180 override protected EntityAI CreateNewEntity()
181 {
182 EntityAI newItem = super.CreateNewEntity();
183
184 if (!newItem && m_Drop)
185 {
186 newItem = EntityAI.Cast(GetGame().CreateObjectEx(m_NewItemType, m_TargetPlayer.GetPosition(), ECE_PLACE_ON_SURFACE|ECE_LOCAL));
187 }
188
189 return newItem;
190 }
191};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool CanReceiveAction(ActionTarget target)
Definition ActionBase.c:637
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
const int ECE_LOCAL
const int ECE_PLACE_ON_SURFACE
class OptionSelectorMultistate extends OptionSelector class_name
protected ActionData m_ActionData
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnFinishProgressServer(ActionData action_data)
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition CCTMan.c:2
static ref TStringArray ARRAY_STRING
static ref TFloatArray ARRAY_FLOAT
void ReplaceAndDestroyLambdaEx(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false, bool enableDrop=true)
override protected EntityAI CreateNewEntity()
override void OnSuccess(EntityAI new_item)
void ReplaceAndDestroyLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false)
const float DEFAULT
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
const float DEBUG_QUICK_UNRESTRAIN_TIME
Definition constants.c:583