DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл ActionSkinning.c

См. исходные тексты.

Структуры данных

class  ActionSkinningCB
 

Функции

ActionSkinningCB ActionContinuousBaseCB ActionSkinning ()
 
override void CreateActionComponent ()
 
override void CreateConditionComponents ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override void OnFinishProgressServer (ActionData action_data)
 
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)
 
vector GetRandomPos (vector body_pos)
 

Функции

◆ ActionCondition()

override bool ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
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
Definition Building.c:6
Definition ObjectTyped.c:2
Definition EntityAI.c:95
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo().

◆ ActionSkinning()

32 {
33 m_CallbackClass = ActionSkinningCB;
34 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
35
36 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ANIMALSKINNING;
37 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
38 m_FullBody = true;
39 m_Text = "#skin";
40 }
int m_CommandUID
Definition ActionBase.c:31
int m_StanceMask
Definition ActionBase.c:33
Definition ActionSkinning.c:22
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602

Используется в ActionConstructor::RegisterActions(), ToolBase::SetActions(), Crowbar::SetActions(), HandSaw::SetActions(), HayHook::SetActions(), Iceaxe::SetActions(), Inventory_Base::SetActions() и ItemBase::SetActions().

◆ CreateActionComponent()

override void CreateActionComponent ( )
32 {
33 m_CallbackClass = ActionSkinningCB;
34 m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
35

Перекрестные ссылки m_CommandUID и m_StanceMask.

◆ CreateConditionComponents()

override void CreateConditionComponents ( )
43 {
44 m_ConditionItem = new CCINonRuined();
45 m_ConditionTarget = new CCTCursorNoRuinCheck();
46 }
Definition CCINonRuined.c:2
Definition CCTCursorNoRuinCheck.c:2

◆ CreateOrgan()

ItemBase CreateOrgan ( PlayerBase player,
vector body_pos,
string item_to_spawn,
string cfg_skinning_organ_class,
ItemBase tool )
91 {
92 // Create item from config
95 MiscGameplayFunctions.GetHeadBonePos(player,posHead);
98
99 // Check if skinning is configured for this body
100 if (!added_item)
101 return null;
102
103 // Set item's quantity from config, if it's defined there.
104 float item_quantity = 0;
107
108 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMax", quant_min_max);
109 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMaxCoef", quant_min_max_coef);
110
111 // Read config for quantity value
112 if (quant_min_max.Count() > 0)
113 {
114 float soft_skill_manipulated_value = (quant_min_max.Get(0)+ quant_min_max.Get(1)) / 2;
116 }
117
118 if (quant_min_max_coef.Count() > 0)
119 {
120 float coef = Math.RandomFloat(quant_min_max_coef.Get(0), quant_min_max_coef.Get(1));
121 item_quantity = added_item.GetQuantityMax() * coef;
122 }
123
124 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantity") > 0)
125 item_quantity = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantity");
126
127 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef") > 0)
128 {
129 float coef2 = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
130 item_quantity = added_item.GetQuantityMax() * coef2;
131 }
132
133 if (item_quantity > 0)
134 {
136 added_item.SetQuantity(item_quantity, false);
137 }
138
139 // Transfer tool's damage to the item's condition
140 float item_apply_tool_damage_coef = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "transferToolDamageCoef");
141
143 {
144 float tool_dmg_coef = 1 - tool.GetHealth01();
146 added_item.DecreaseHealthCoef(organ_dmg_coef);
147 }
148
149 added_item.InsertAgent(eAgents.SALMONELLA, 1);
150 return added_item;
151 }
const int ECE_PLACE_ON_SURFACE
Definition CentralEconomy.c:37
DayZGame g_Game
Definition DayZGame.c:3815
eAgents
Definition EAgents.c:3
Definition InventoryItem.c:731
Definition EnMath.c:7
Definition ActionConstants.c:120
const float NARROW
Definition ActionConstants.c:122
Definition EnConvert.c:106
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].

Перекрестные ссылки Class::CastTo(), ECE_PLACE_ON_SURFACE, g_Game, GetGame(), UAItemsSpreadRadius::NARROW, Math::RandomFloat() и Math::Round().

Используется в SpawnItems().

◆ DropInventoryItems()

void DropInventoryItems ( PlayerBase body,
float newLifetime )
235 {
237 body.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
238 foreach (EntityAI child : children)
239 {
240 if (child)
241 {
242 child.SetLifetime(newLifetime);
243 body.GetInventory().DropEntity(InventoryMode.SERVER, body, child);
244 }
245 }
246 }
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

Используется в HandlePlayerBody().

◆ GetRandomPos()

vector GetRandomPos ( vector body_pos)
341 {
342 return body_pos + Vector(Math.RandomFloat01() - 0.5, 0, Math.RandomFloat01() - 0.5);
343 }
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

Перекрестные ссылки Math::RandomFloat01() и Vector().

◆ HandlePlayerBody()

void HandlePlayerBody ( ActionData action_data)

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

170 {
172 if (Class.CastTo(body,action_data.m_Target.GetObject()))
173 {
174 if (body.IsRestrained() && body.GetHumanInventory().GetEntityInHands())
175 MiscGameplayFunctions.TransformRestrainItem(body.GetHumanInventory().GetEntityInHands(), null, action_data.m_Player, body);
176
177 //Remove splint if target is wearing one
178 if (body.IsWearingSplint())
179 {
180 EntityAI entity = action_data.m_Player.SpawnEntityOnGroundOnCursorDir("Splint", 0.5);
182 EntityAI attachment = body.GetItemOnSlot("Splint_Right");
183 if (attachment && attachment.GetType() == "Splint_Applied")
184 {
185 if (newItem)
186 {
187 MiscGameplayFunctions.TransferItemProperties(attachment, newItem);
188 //Lower health level of splint after use
189 if (newItem.GetHealthLevel() < 4)
190 {
191 int newDmgLevel = newItem.GetHealthLevel() + 1;
192 float max = newItem.GetMaxHealth("", "");
193
194 switch (newDmgLevel)
195 {
198 break;
199
201 newItem.SetHealth("", "", max * GameConstants.DAMAGE_DAMAGED_VALUE);
202 break;
203
205 newItem.SetHealth("", "", max * GameConstants.DAMAGE_WORN_VALUE);
206 break;
207
209 newItem.SetHealth("", "", max * GameConstants.DAMAGE_RUINED_VALUE);
210 break;
211
212 default:
213 break;
214 }
215 }
216 }
217
218 attachment.Delete();
219 }
220 }
221
223 if (GetCEApi())
224 {
225 deadBodyLifetime = GetCEApi().GetCEGlobalInt("CleanupLifetimeDeadPlayer");
226 if (deadBodyLifetime <= 0)
227 deadBodyLifetime = 3600;
228 }
229
231 }
232 }
void DropInventoryItems(PlayerBase body, float newLifetime)
Definition ActionSkinning.c:234
proto native CEApi GetCEApi()
Get the CE API.
Definition constants.c:638
Definition PlayerBaseClient.c:2
const float DAMAGE_RUINED_VALUE
Definition constants.c:823
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:821
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:822
const float DAMAGE_WORN_VALUE
Definition constants.c:820
const int STATE_RUINED
Definition constants.c:807
const int STATE_BADLY_DAMAGED
Definition constants.c:808
const int STATE_DAMAGED
Definition constants.c:809
const int STATE_WORN
Definition constants.c:810

Перекрестные ссылки 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 и GameConstants::STATE_WORN.

Используется в OnFinishProgressServer().

◆ OnFinishProgressClient()

override void OnFinishProgressClient ( ActionData action_data)
154 {
155 super.OnFinishProgressClient(action_data);
156
157 if (action_data.m_Target)
158 {
159 Object target_obj = action_data.m_Target.GetObject();
160
161 if (target_obj.IsKindOf("Animal_CapreolusCapreolus") || target_obj.IsKindOf("Animal_CapreolusCapreolusF") || target_obj.IsKindOf("Animal_CervusElaphus") || target_obj.IsKindOf("Animal_CervusElaphusF"))
162 {
163 GetGame().GetAnalyticsClient().OnActionFinishedGutDeer();
164 }
165 }
166 }

Перекрестные ссылки GetGame().

◆ OnFinishProgressServer()

override void OnFinishProgressServer ( ActionData action_data)
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 {
80 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().ObjectDelete,body);
81 }
82
83 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, UADamageApplied.SKINNING);
84
86 moduleLifespan.UpdateBloodyHandsVisibility(action_data.m_Player, true);
87 }
void SpawnItems(ActionData action_data)
Definition ActionSkinning.c:248
void HandlePlayerBody(ActionData action_data)
This section drops all clothes (and attachments) from the dead player before deleting their body.
Definition ActionSkinning.c:169
void PluginLifespan()
Definition PluginLifespan.c:45
PluginBase GetPlugin(typename plugin_type)
Definition PluginManager.c:316
Definition AmmunitionPiles.c:84
Definition ActionConstants.c:142
const float SKINNING
Definition ActionConstants.c:148
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8

Перекрестные ссылки CALL_CATEGORY_SYSTEM, GetGame(), GetPlugin(), HandlePlayerBody(), PluginLifespan(), UADamageApplied::SKINNING и SpawnItems().

◆ SpawnItems()

void SpawnItems ( ActionData action_data)
249 {
250 EntityAI body = EntityAI.Cast(action_data.m_Target.GetObject());
251
252 // Get config path to the animal
253 string cfg_animal_class_path = "cfgVehicles " + body.GetType() + " " + "Skinning ";
254 vector bodyPosition = body.GetPosition();
255
256 if (!g_Game.ConfigIsExisting(cfg_animal_class_path))
257 {
258 Debug.Log("Failed to find class 'Skinning' in the config of: " + body.GetType());
259 return;
260 }
261
262 // Getting item type from the config
263 int child_count = g_Game.ConfigGetChildrenCount(cfg_animal_class_path);
264
265 string item_to_spawn;
267 // Parsing of the 'Skinning' class in the config of the dead body
268 for (int i1 = 0; i1 < child_count; i1++)
269 {
270 // To make configuration as convenient as possible, all classes are parsed and parameters are read
271 g_Game.ConfigGetChildName(cfg_animal_class_path, i1, cfg_skinning_organ_class); // out cfg_skinning_organ_class
273 g_Game.ConfigGetText(cfg_skinning_organ_class + "item", item_to_spawn); // out item_to_spawn
274
275 if (item_to_spawn != "") // Makes sure to ignore incompatible parameters in the Skinning class of the agent
276 {
277 // Spawning items in action_data.m_Player's inventory
278 int item_count = g_Game.ConfigGetInt(cfg_skinning_organ_class + "count");
279
282 float zoneDmg = 0;
283
284 GetGame().ConfigGetTextArray(cfg_skinning_organ_class + "itemZones", itemZones);
285 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "countByZone", itemCount);
286
287 if (itemCount.Count() > 0)
288 {
289 item_count = 0;
290 for (int z = 0; z < itemZones.Count(); z++)
291 {
292 zoneDmg = body.GetHealth01(itemZones[z], "Health");
293 zoneDmg *= itemCount[z]; //just re-using variable
295 }
296 }
297
298 for (int i2 = 0; i2 < item_count; i2++)
299 {
301
302 //Damage pelts based on the average values on itemZones
303 //It only works if the "quantityCoef" in the config is more than 0
304 float qtCoeff = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
305 if (qtCoeff > 0)
306 {
307 float avgDmgZones = 0;
308 for (int c2 = 0; c2 < itemZones.Count(); c2++)
309 {
310 avgDmgZones += body.GetHealth01(itemZones[c2], "Health");
311 }
312
313 avgDmgZones = avgDmgZones/itemZones.Count(); // Evaluate the average Health
314
315 if (spawn_result)
316 spawn_result.SetHealth01("","", avgDmgZones);
317 }
318
319 // inherit temperature
320 if (body.CanHaveTemperature() && spawn_result.CanHaveTemperature())
321 {
322 spawn_result.SetTemperatureDirect(body.GetTemperature());
323 spawn_result.SetFrozen(body.GetIsFrozen());
324 }
325
326 // handle fat/guts from human bodies
327 if ((item_to_spawn == "Lard") || (item_to_spawn == "Guts"))
328 {
329 if (body.IsKindOf("SurvivorBase"))
330 {
331 spawn_result.InsertAgent(eAgents.BRAIN, 1);
332 }
333 }
334 }
335 }
336 }
337 }
ItemBase CreateOrgan(PlayerBase player, vector body_pos, string item_to_spawn, string cfg_skinning_organ_class, ItemBase tool)
Definition ActionSkinning.c:90
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:136
static proto float Floor(float f)
Returns floor of value.

Перекрестные ссылки CreateOrgan(), Math::Floor(), g_Game, GetGame() и Debug::Log().

Используется в OnFinishProgressServer().