295 {
296 if (damage < 1.0)
297 {
300 if (
DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, magazines))
301 {
302 int healthLevel = -1;
303 float testHeatlh = 1 - damage;
304 foreach (Magazine magazine : magazines)
305 {
306 if (healthLevel == -1)
307 {
308 if (magazine.CanAddCartridges(1))
309 {
310 int numberOfHealthLevels = magazine.GetNumberOfHealthLevels();
311 for (int i = 1; i < numberOfHealthLevels; i++)
312 {
313 if (magazine.GetHealthLevelValue(i) < testHeatlh)
314 {
315 healthLevel = i - 1;
316 break;
317 }
318 }
319 }
320 }
321
322 if (magazine.GetHealthLevel() == healthLevel)
323 {
324 if (magazine.ServerStoreCartridge(damage, cartTypeName))
325 return true;
326 }
327 }
328 }
329
332 if (player.GetInventory().FindFirstFreeLocationForNewEntity(magTypeName,
FindInventoryLocationType.ANY, inventoryLocation))
333 {
335 if (entityInventory && entityInventory.IsInherited(Magazine))
336 {
337 Magazine magazineInventory;
338 if (
Class.
CastTo(magazineInventory, entityInventory))
339 {
340 magazineInventory.ServerSetAmmoCount(0);
341 magazineInventory.SetHealth("", "", (1 - damage) * magazineInventory.GetMaxHealth());
342 if (magazineInventory.ServerStoreCartridge(damage, cartTypeName))
343 return true;
344 }
345 }
346 }
347
349 if (CanDrop)
351 }
352
353 return false;
354 }
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
void DayZPlayerUtils()
cannot be instantiated
static bool HandleDropCartridge(DayZPlayer player, float damage, string cartTypeName, string magTypeName)
FindInventoryLocationType
flags for searching locations in inventory
Super root of all classes in Enforce script.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.