DayZ 1.24
Loading...
Searching...
No Matches
ActionSkinning.c File Reference

Go to the source code of this file.

Classes

class  ActionSkinningCB
 

Functions

ActionSkinningCB ActionContinuousBaseCB ActionSkinning ()
 
override void CreateActionComponent ()
 
override void CreateConditionComponents ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override void OnFinishProgressServer (ActionData action_data)
 
vector GetRandomPos (vector body_pos)
 
ItemBase CreateOrgan (PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
 
override void OnFinishProgressClient (ActionData action_data)
 
void HandlePlayerBody (ActionData action_data)
 This section drops all clothes (and attachments) from the dead player before deleting their body.
 
void DropInventoryItems (PlayerBase body, float newLifetime)
 
void SpawnItems (ActionData action_data)
 

Function Documentation

◆ ActionCondition()

override bool ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )

Definition at line 48 of file ActionSkinning.c.

49 {
50 Object targetObject = target.GetObject();
51
52 if (targetObject.CanBeSkinned() && !targetObject.IsAlive())
53 {
55 if (Class.CastTo(target_EAI, targetObject) && target_EAI.CanBeSkinnedWith(item))
56 return true;
57 }
58
59 return false;
60 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo().

◆ ActionSkinning()

Definition at line 1 of file ActionSkinning.c.

32 {
33 m_CallbackClass = ActionSkinningCB;
35
36 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ANIMALSKINNING;
37 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
38 m_FullBody = true;
39 m_Text = "#skin";
40 }
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
float m_SpecialtyWeight
Definition ActionBase.c:68
int m_StanceMask
Definition ActionBase.c:53
const float PRECISE_MEDIUM
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

Referenced by ActionConstructor::RegisterActions(), ToolBase::SetActions(), Crowbar::SetActions(), HandSaw::SetActions(), HayHook::SetActions(), Iceaxe::SetActions(), Inventory_Base::SetActions(), and ItemBase::SetActions().

◆ CreateActionComponent()

override void ActionSkinning::CreateActionComponent ( )

◆ CreateConditionComponents()

override void CreateConditionComponents ( )

Definition at line 42 of file ActionSkinning.c.

43 {
46 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ CreateOrgan()

ItemBase CreateOrgan ( PlayerBase player,
vector body_pos,
string item_to_spawn,
string cfg_skinning_organ_class,
ItemBase tool )

Definition at line 94 of file ActionSkinning.c.

95 {
96 // Create item from config
100
101 // Check if skinning is configured for this body
102 if (!added_item)
103 return null;
104
105 // Set randomized position
106 added_item.PlaceOnSurface();
107
108 // Set item's quantity from config, if it's defined there.
109 float item_quantity = 0;
112
113 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMax", quant_min_max);
114 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMaxCoef", quant_min_max_coef);
115
116
117 // Read config for quantity value
118 if (quant_min_max.Count() > 0)
119 {
120 float soft_skill_manipulated_value = (quant_min_max.Get(0) + quant_min_max.Get(1)) / 2;
121 float min_quantity = player.GetSoftSkillsManager().AddSpecialtyBonus(soft_skill_manipulated_value, this.GetSpecialtyWeight());
122 item_quantity = Math.RandomFloat(min_quantity, quant_min_max.Get(1));
123 }
124
125 if (quant_min_max_coef.Count() > 0)
126 {
127 float coef = Math.RandomFloat(quant_min_max_coef.Get(0), quant_min_max_coef.Get(1));
128 item_quantity = added_item.GetQuantityMax() * coef;
129 }
130
131 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantity") > 0)
132 item_quantity = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantity");
133
134 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef") > 0)
135 {
136 float coef2 = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
137 item_quantity = added_item.GetQuantityMax() * coef2;
138 }
139
140 if (item_quantity > 0)
141 {
143 added_item.SetQuantity(item_quantity, false);
144 }
145
146 // Transfer tool's damage to the item's condition
147 float item_apply_tool_damage_coef = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "transferToolDamageCoef");
148
150 {
151 float tool_dmg_coef = 1 - tool.GetHealth01();
153 added_item.DecreaseHealthCoef(organ_dmg_coef);
154 }
155
156 added_item.InsertAgent(eAgents.SALMONELLA, 1);
157 return added_item;
158 }
float GetSpecialtyWeight()
Definition ActionBase.c:967
vector GetRandomPos(vector body_pos)
const int ECE_PLACE_ON_SURFACE
DayZGame g_Game
Definition DayZGame.c:3528
eAgents
Definition EAgents.c:3
Definition EnMath.c:7
proto native CGame GetGame()
static proto float Round(float f)
Returns mathematical round of value.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].

References Class::CastTo(), ECE_PLACE_ON_SURFACE, g_Game, GetGame(), GetRandomPos(), GetSpecialtyWeight(), Math::RandomFloat(), and Math::Round().

Referenced by SpawnItems().

◆ DropInventoryItems()

void DropInventoryItems ( PlayerBase body,
float newLifetime )

Definition at line 239 of file ActionSkinning.c.

240 {
242 body.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
243 foreach (EntityAI child : children)
244 {
245 if (child)
246 {
247 child.SetLifetime(newLifetime);
248 body.GetInventory().DropEntity(InventoryMode.SERVER, body, child);
249 }
250 }
251 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6

Referenced by HandlePlayerBody().

◆ GetRandomPos()

vector GetRandomPos ( vector body_pos)

Definition at line 88 of file ActionSkinning.c.

89 {
90 return body_pos + Vector(Math.RandomFloat01() - 0.5, 0, Math.RandomFloat01() - 0.5);
91 }
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:126

References Math::RandomFloat01(), and Vector().

Referenced by CreateOrgan().

◆ HandlePlayerBody()

void HandlePlayerBody ( ActionData action_data)

This section drops all clothes (and attachments) from the dead player before deleting their body.

Definition at line 174 of file ActionSkinning.c.

175 {
177 if (Class.CastTo(body, action_data.m_Target.GetObject()))
178 {
179 if (body.IsRestrained() && body.GetHumanInventory().GetEntityInHands())
180 MiscGameplayFunctions.TransformRestrainItem(body.GetHumanInventory().GetEntityInHands(), null, action_data.m_Player, body);
181
182 //Remove splint if target is wearing one
183 if (body.IsWearingSplint())
184 {
185 EntityAI entity = action_data.m_Player.SpawnEntityOnGroundOnCursorDir("Splint", 0.5);
187 EntityAI attachment = body.GetItemOnSlot("Splint_Right");
188 if (attachment && attachment.GetType() == "Splint_Applied")
189 {
190 if (newItem)
191 {
192 MiscGameplayFunctions.TransferItemProperties(attachment, newItem);
193 //Lower health level of splint after use
194 if (newItem.GetHealthLevel() < 4)
195 {
196 int newDmgLevel = newItem.GetHealthLevel() + 1;
197 float max = newItem.GetMaxHealth("", "");
198
199 switch (newDmgLevel)
200 {
203 break;
204
206 newItem.SetHealth("", "", max * GameConstants.DAMAGE_DAMAGED_VALUE);
207 break;
208
210 newItem.SetHealth("", "", max * GameConstants.DAMAGE_WORN_VALUE);
211 break;
212
214 newItem.SetHealth("", "", max * GameConstants.DAMAGE_RUINED_VALUE);
215 break;
216
217 default:
218 break;
219 }
220 }
221 }
222
223 attachment.Delete();
224 }
225 }
226
228 if (GetCEApi())
229 {
230 deadBodyLifetime = GetCEApi().GetCEGlobalInt("CleanupLifetimeDeadPlayer");
231 if (deadBodyLifetime <= 0)
232 deadBodyLifetime = 3600;
233 }
234
236 }
237 }
void DropInventoryItems(PlayerBase body, float newLifetime)
proto native CEApi GetCEApi()
Get the CE API.
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:772
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const float DAMAGE_WORN_VALUE
Definition constants.c:770
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758

References Class::CastTo(), GameConstants::DAMAGE_BADLY_DAMAGED_VALUE, GameConstants::DAMAGE_DAMAGED_VALUE, GameConstants::DAMAGE_RUINED_VALUE, GameConstants::DAMAGE_WORN_VALUE, DropInventoryItems(), GetCEApi(), GameConstants::STATE_BADLY_DAMAGED, GameConstants::STATE_DAMAGED, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

Referenced by OnFinishProgressServer().

◆ OnFinishProgressClient()

override void OnFinishProgressClient ( ActionData action_data)

Definition at line 160 of file ActionSkinning.c.

161 {
162 super.OnFinishProgressClient(action_data);
163
164 if (action_data.m_Target)
165 {
166 Object target_obj = action_data.m_Target.GetObject();
167
168 if (target_obj.IsKindOf("Animal_CapreolusCapreolus") || target_obj.IsKindOf("Animal_CapreolusCapreolusF") || target_obj.IsKindOf("Animal_CervusElaphus") || target_obj.IsKindOf("Animal_CervusElaphusF"))
169 GetGame().GetAnalyticsClient().OnActionFinishedGutDeer();
170 }
171 }

References GetGame().

◆ OnFinishProgressServer()

override void OnFinishProgressServer ( ActionData action_data)

Definition at line 63 of file ActionSkinning.c.

64 {
65 super.OnFinishProgressServer(action_data);
66
67 Object targetObject = action_data.m_Target.GetObject();
68
69 // Mark the body as skinned to forbid another skinning action on it
71 body.SetAsSkinned();
72
73 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(body, {Bolt_Base});
74
77
78 if (body)
79 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().ObjectDelete, body);
80
81 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.SKINNING);
82
84 moduleLifespan.UpdateBloodyHandsVisibility(action_data.m_Player, true);
85 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
86 }
void SpawnItems(ActionData action_data)
void HandlePlayerBody(ActionData action_data)
This section drops all clothes (and attachments) from the dead player before deleting their body.
void PluginLifespan()
PluginBase GetPlugin(typename plugin_type)
const float SKINNING
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

References CALL_CATEGORY_SYSTEM, GetGame(), GetPlugin(), HandlePlayerBody(), m_SpecialtyWeight, PluginLifespan(), UADamageApplied::SKINNING, and SpawnItems().

◆ SpawnItems()

void SpawnItems ( ActionData action_data)

Definition at line 253 of file ActionSkinning.c.

254 {
255 EntityAI body = EntityAI.Cast(action_data.m_Target.GetObject());
256
257 // Get config path to the animal
258 string cfg_animal_class_path = "cfgVehicles " + body.GetType() + " " + "Skinning ";
259 vector bodyPosition = body.GetPosition();
260
261 // Getting item type from the config
262 int child_count = g_Game.ConfigGetChildrenCount(cfg_animal_class_path);
263
264 string item_to_spawn;
266 // Parsing of the 'Skinning' class in the config of the dead body
267 for (int i1 = 0; i1 < child_count; i1++)
268 {
269 // To make configuration as convenient as possible, all classes are parsed and parameters are read
270 g_Game.ConfigGetChildName(cfg_animal_class_path, i1, cfg_skinning_organ_class); // out cfg_skinning_organ_class
272 g_Game.ConfigGetText(cfg_skinning_organ_class + "item", item_to_spawn); // out item_to_spawn
273
274 if (item_to_spawn != "") // Makes sure to ignore incompatible parameters in the Skinning class of the agent
275 {
276 // Spawning items in action_data.m_Player's inventory
277 int item_count = g_Game.ConfigGetInt(cfg_skinning_organ_class + "count");
278
281 float zoneDmg = 0;
282
283 GetGame().ConfigGetTextArray(cfg_skinning_organ_class + "itemZones", itemZones);
284 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "countByZone", itemCount);
285
286 if (itemCount.Count() > 0)
287 {
288 item_count = 0;
289 for (int z = 0; z < itemZones.Count(); z++)
290 {
291 zoneDmg = body.GetHealth01(itemZones[z], "Health");
292 zoneDmg *= itemCount[z]; //just re-using variable
294 }
295 }
296
297 for (int i2 = 0; i2 < item_count; i2++)
298 {
300
301 //Damage pelts based on the average values on itemZones
302 //It only works if the "quantityCoef" in the config is more than 0
303 float qtCoeff = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
304 if (qtCoeff > 0)
305 {
306 float avgDmgZones = 0;
307 for (int c2 = 0; c2 < itemZones.Count(); c2++)
308 avgDmgZones += body.GetHealth01(itemZones[c2], "Health");
309
310 avgDmgZones = avgDmgZones / itemZones.Count(); // Evaluate the average Health
311
312 if (spawn_result)
313 spawn_result.SetHealth01("", "", avgDmgZones);
314 }
315
316 // handle fat/guts from human bodies
317 if ((item_to_spawn == "Lard") || (item_to_spawn == "Guts"))
318 {
319 if (body.IsKindOf("SurvivorBase"))
320 spawn_result.InsertAgent(eAgents.BRAIN, 1);
321 }
322 }
323 }
324 }
325 }
ItemBase CreateOrgan(PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
static proto float Floor(float f)
Returns floor of value.

References CreateOrgan(), Math::Floor(), g_Game, and GetGame().

Referenced by OnFinishProgressServer().