DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ CreateOrgan()

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

См. определение в файле ActionSkinning.c строка 91

92 {
93 // Create item from config
94 ItemBase added_item;
95 vector posHead = MiscGameplayFunctions.GetPlayerHeadPosition(player);
96 vector posRandom = MiscGameplayFunctions.GetRandomizedPositionVerified(posHead,body_pos,UAItemsSpreadRadius.NARROW,player);
97 Class.CastTo(added_item, g_Game.CreateObjectEx(item_to_spawn, posRandom, ECE_PLACE_ON_SURFACE));
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;
105 array<float> quant_min_max = new array<float>;
106 array<float> quant_min_max_coef = new array<float>;
107
108 g_Game.ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMax", quant_min_max);
109 g_Game.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;
115 item_quantity = Math.RandomFloat(soft_skill_manipulated_value, quant_min_max.Get(1));
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 (g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantity") > 0)
125 item_quantity = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantity");
126
127 if (g_Game.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 {
135 item_quantity = Math.Round(item_quantity);
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 = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "transferToolDamageCoef");
141
142 if (item_apply_tool_damage_coef > 0)
143 {
144 float tool_dmg_coef = 1 - tool.GetHealth01();
145 float organ_dmg_coef = tool_dmg_coef * item_apply_tool_damage_coef;
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
Определения CentralEconomy.c:38
DayZGame g_Game
Определения DayZGame.c:4074
eAgents
Определения EAgents.c:3
Super root of all classes in Enforce script.
Определения EnScript.c:11
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfBricks.c:64
Определения EnMath.c:7
const float NARROW
Определения ActionConstants.c:130
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:119
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
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, UAItemsSpreadRadius::NARROW, Math::RandomFloat(), Math::Round() и ItemBase::SetQuantity().

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