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

◆ SelectStoreCartridge()

static Magazine SelectStoreCartridge ( DayZPlayer player,
Weapon_Base weapon,
int muzzleIndex,
Magazine exclude_mag,
float damage,
string magTypeName )
static

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

204 {
205 if (damage < 1.0)
206 {
207 // find suitable heap / mag (but not the excluded one)
208 ref array<Magazine> mags = new array<Magazine>;
209 if (DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, mags))
210 {
211 int sz = mags.Count();
212 for (int i = 0; i < sz; ++i)
213 {
214 Magazine mag_i = mags.Get(i);
215 if (mag_i != exclude_mag && mag_i.CanAddCartridges(1))
216 {
217 return mag_i;
218 }
219 }
220 }
221
222 // create a new one in inventory
224 if (player.GetInventory().FindFirstFreeLocationForNewEntity(magTypeName, FindInventoryLocationType.ANY, inv_loc))
225 {
226 EntityAI eai_inv = SpawnEntity(magTypeName, inv_loc, ECE_IN_INVENTORY, RF_DEFAULT);
227 if (eai_inv && eai_inv.IsInherited(Magazine))
228 {
229 Magazine mag_inv;
230 if (Class.CastTo(mag_inv, eai_inv))
231 {
232 mag_inv.ServerSetAmmoCount(0);
233 return mag_inv;
234 }
235 }
236 }
237 }
238
239 vector pos = player.GetPosition();
240 EntityAI eai_gnd = player.SpawnEntityOnGroundPos(magTypeName, pos);
241 if (eai_gnd && eai_gnd.IsInherited(Magazine))
242 {
243 Magazine mag_gnd;
244 if (Class.CastTo(mag_gnd, eai_gnd))
245 {
246 mag_gnd.ServerSetAmmoCount(0);
247 return mag_gnd;
248 }
249 }
250
251 return NULL;
252 }
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
void DayZPlayerUtils()
cannot be instantiated
Определения DayZPlayerUtils.c:465
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
InventoryLocation.
Определения InventoryLocation.c:29
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo(), DayZPlayerUtils(), ECE_IN_INVENTORY, RF_DEFAULT и SpawnEntity().