DayZ 1.27
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;
96 MiscGameplayFunctions.GetHeadBonePos(player,posHead);
97 vector posRandom = MiscGameplayFunctions.GetRandomizedPositionVerified(posHead,body_pos,UAItemsSpreadRadius.NARROW,player);
98 Class.CastTo(added_item, GetGame().CreateObjectEx(item_to_spawn, posRandom, ECE_PLACE_ON_SURFACE));
99
100 // Check if skinning is configured for this body
101 if (!added_item)
102 return null;
103
104 // Set item's quantity from config, if it's defined there.
105 float item_quantity = 0;
106 array<float> quant_min_max = new array<float>;
107 array<float> quant_min_max_coef = new array<float>;
108
109 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMax", quant_min_max);
110 GetGame().ConfigGetFloatArray(cfg_skinning_organ_class + "quantityMinMaxCoef", quant_min_max_coef);
111
112 // Read config for quantity value
113 if (quant_min_max.Count() > 0)
114 {
115 float soft_skill_manipulated_value = (quant_min_max.Get(0)+ quant_min_max.Get(1)) / 2;
116 item_quantity = Math.RandomFloat(soft_skill_manipulated_value, quant_min_max.Get(1));
117 }
118
119 if (quant_min_max_coef.Count() > 0)
120 {
121 float coef = Math.RandomFloat(quant_min_max_coef.Get(0), quant_min_max_coef.Get(1));
122 item_quantity = added_item.GetQuantityMax() * coef;
123 }
124
125 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantity") > 0)
126 item_quantity = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantity");
127
128 if (GetGame().ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef") > 0)
129 {
130 float coef2 = g_Game.ConfigGetFloat(cfg_skinning_organ_class + "quantityCoef");
131 item_quantity = added_item.GetQuantityMax() * coef2;
132 }
133
134 if (item_quantity > 0)
135 {
136 item_quantity = Math.Round(item_quantity);
137 added_item.SetQuantity(item_quantity, false);
138 }
139
140 // Transfer tool's damage to the item's condition
141 float item_apply_tool_damage_coef = GetGame().ConfigGetFloat(cfg_skinning_organ_class + "transferToolDamageCoef");
142
143 if (item_apply_tool_damage_coef > 0)
144 {
145 float tool_dmg_coef = 1 - tool.GetHealth01();
146 float organ_dmg_coef = tool_dmg_coef * item_apply_tool_damage_coef;
147 added_item.DecreaseHealthCoef(organ_dmg_coef);
148 }
149
150 added_item.InsertAgent(eAgents.SALMONELLA, 1);
151 return added_item;
152 }
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
DayZGame g_Game
Определения DayZGame.c:3868
eAgents
Определения EAgents.c:3
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
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)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
Определения EnMath.c:7
const float NARROW
Определения ActionConstants.c:127
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
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(), CGame::ConfigGetFloat(), CGame::ConfigGetFloatArray(), ECE_PLACE_ON_SURFACE, g_Game, GetGame(), UAItemsSpreadRadius::NARROW, Math::RandomFloat(), Math::Round() и ItemBase::SetQuantity().

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