DayZ 1.24
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 {
8
9 if (time <= 0)
11
12 if (m_ActionData.m_Player.IsQuickRestrain())
14
16 }
17
19 {
22
23 if (target_player.IsRestrained())
24 {
26
28
30 item_in_hands_target.ConfigGetTextArray("CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING);
31
33
34 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
35 {
36 if ((i % 2) == 0)
37 {
39 if (GetGame().IsKindOf(item_in_hands_name, class_name))
40 {
41 float value = CachedObjectsArrays.ARRAY_STRING.Get(i + 1).ToFloat();
42 return value;
43 }
44 }
45 }
46 }
47 return -1;
48 }
49};
50
52{
54 {
56 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_UNRESTRAINTARGET;
57 m_FullBody = true;
58 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
60 m_Text = "#unrestrain";
61 }
62
68
69 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
70 {
71 PlayerBase other_player = PlayerBase.Cast(target.GetObject());
72 EntityAI item_in_hands_source = player.GetItemInHands();
73
74 if (other_player.IsRestrained())
75 {
76 //Print("is restrained");
78
80
82 {
83 item_in_hands_target.ConfigGetTextArray("CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING);
84
86
87 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
88 {
89 if ((i % 2) == 0)
90 {
92 if (GetGame().IsKindOf(item_in_hands_name, class_name))
93 return true;
94 }
95 }
96 }
97 }
98 return false;
99 }
100
102 {
103 PlayerBase player_target = PlayerBase.Cast(action_data.m_Target.GetObject());
105
106 if (CanReceiveAction(action_data.m_Target) && player_target.IsRestrained())
107 {
109 EntityAI restraining_item = player_target.GetItemInHands();
110
111 player_target.SetRestrained(false);
112
113
114 //Damage applied to tool
116
117 restraining_item.ConfigGetTextArray("CanBeUnrestrainedBy", CachedObjectsArrays.ARRAY_STRING);
118 restraining_item.ConfigGetFloatArray("CanBeUnrestrainedByDMG", CachedObjectsArrays.ARRAY_FLOAT);
119
120 string item_in_hands_name = unrestraining_tool.GetType();
121 float damageToTool = 0;
122
123 for (int i = 0; i < CachedObjectsArrays.ARRAY_STRING.Count(); i++)
124 {
126 if (GetGame().IsKindOf(item_in_hands_name, class_name))
127 {
129 break;
130 }
131 }
132
133 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, damageToTool);
134 //---------------------------
135
137
138 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
139 }
140 }
141};
142
143class ReplaceAndDestroyLambda : TurnItemIntoItemLambdaAnimSysNotifyLambda
144{
147 bool m_Drop;
148
150 {
153 m_OldItem = old_item;
154 }
155
157 {
158 super.OnSuccess(new_item);
159
160 if (m_Destroy)
161 new_item.SetHealth("", "", 0);
162 }
163};
164
166{
168 {
170 }
171
172 override protected EntityAI CreateNewEntity()
173 {
174 EntityAI newItem = super.CreateNewEntity();
175
176 if (!newItem && m_Drop)
177 newItem = EntityAI.Cast(GetGame().CreateObjectEx(m_NewItemType, m_TargetPlayer.GetPosition(), ECE_PLACE_ON_SURFACE | ECE_LOCAL));
178
179 return newItem;
180 }
181};
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
const int ECE_LOCAL
const int ECE_PLACE_ON_SURFACE
class OptionSelectorMultistate extends OptionSelector class_name
ActionData m_ActionData
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
ref CABase m_ActionComponent
Definition ActionBase.c:30
override void OnFinishProgressServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
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 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:597
proto native CGame GetGame()
const float DEBUG_QUICK_UNRESTRAIN_TIME
Definition constants.c:598