14 void SetTransferParams(
bool transfer_agents =
true,
bool transfer_variables =
true,
bool transfer_health =
true,
bool exclude_quantity =
false,
float quantity_override = -1)
25 super.CopyOldPropertiesToNew(old_item, new_item);
30 MiscGameplayFunctions.TransferInventory(old_item, new_item,
m_Player);
41 Debug.
LogError(
"TurnItemIntoItemLambda: failed to create new item",
"static");
56 m_OldItem.ConfigGetTextArray(
"ChangeInventorySlot",inventory_slots);
57 if (inventory_slots.Count() < 1)
60 attach_types.Insert(
m_OldItem.ConfigGetString(
"ChangeIntoOnAttach"));
64 inventory_slots_idx.Clear();
65 for (
int i = 0; i < inventory_slots.Count(); ++i)
69 m_OldItem.ConfigGetTextArray(
"ChangeIntoOnAttach",attach_types);
73 str = attach_types.
Get(inventory_slots_idx.Find(idx));
83 super.OnSuccess(new_item);
86 m_Player.GetItemAccessor().OnItemInHandsChanged();
95 super.OnSuccess(new_item);
98 m_Player.GetItemAccessor().OnItemInHandsChanged();
103class TurnItemIntoItemLambdaRestrainLambda
extends TurnItemIntoItemLambdaAnimSysNotifyLambda
107 super.OnSuccess(new_item);
126 super.CopyOldPropertiesToNew(old_item, new_item);
132 int count = children.Count();
133 for (
int i = 0; i < count; ++i)
139 child.GetInventory().GetCurrentInventoryLocation(child_src);
152 m_Player.LocalTakeToDst(child_src, child_dst);
154 g_Game.RemoteObjectTreeCreate(child);
172 if (new_item_type !=
string.
Empty)
173 Error(
"MoveEquipAndDestroyRootLambda expects new_item_type to be empty");
178 super.RemoveNetworkObjectInfo();
183 super.UndoRemoveNetworkObjectInfo();
190 super.CopyOldPropertiesToNew(old_item, new_item);
197 super.CreateNetworkObjectInfo(new_item);
213class MiscGameplayFunctions
216 static float Truncate(
float value,
int decimals = 2)
229 int multiplier =
Math.
Pow(10,decimals);
238 return MiscGameplayFunctions.TruncateToS(value[0],decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[1],decimals) +delimiter + MiscGameplayFunctions.TruncateToS(value[2],decimals);
243 return string.
Format(
"#(argb,8,8,3)color(%1,CO)",
string.Format(
"%1,%2,%3,%4", r, g, b, a));
247 static string ValueToBar(
float value,
string bar =
"[----------]",
string mark =
"x")
249 int length = bar.
Length() - 2;
250 float index =
Math.
Lerp(0,length, value);
260 int length_first = pos+1;
261 int length_base = base.
Length();
262 int length_second = length_base - length_first;
263 string first = base.
Substring(0,length_first);
264 string second = base.
Substring(pos+1,length_second);
265 return first + insert + second;
273 if (transfer_agents && target_ib)
274 target_ib.TransferAgents(source.GetAgents());
276 if (transfer_variables)
277 MiscGameplayFunctions.TransferEntityVariables(source, target, exclude_quantity);
290 if (exclude_quantity)
292 int maskOriginal = source.m_VariablesMask;
294 target.TransferVariablesFloat(source.GetVariablesFloat());
295 source.m_VariablesMask = maskOriginal;
299 target.TransferVariablesFloat(source.GetVariablesFloat());
302 if (source.IsMagazine() && target.IsMagazine())
304 Magazine source_mag = Magazine.Cast(source);
305 Magazine target_mag = Magazine.Cast(target);
307 target_mag.ServerSetAmmoCount(source_mag.GetAmmoCount());
310 if (source.IsWeapon() && target.IsWeapon())
315 target_wpn.CopyWeaponStateFrom(source_wpn);
318 if (source.HasEnergyManager() && target.HasEnergyManager())
350 int count = children.Count();
351 for (
int i = 0; i < count; ++i)
357 child.GetInventory().GetCurrentInventoryLocation( child_src );
360 child_dst.
Copy( child_src );
368 targetItem.GetInventory().TakeToDst(
InventoryMode.LOCAL, child_src, child_dst);
377 player.LocalDropEntity(child);
378 g_Game.RemoteObjectTreeCreate(child);
389 if (!healthTypes || healthTypes.Count() == 0)
390 HPTypes.Insert(
"Health");
392 HPTypes.Copy(healthTypes);
394 if (transferZoneDamage)
398 source.GetDamageZones(zonesSrc);
399 target.GetDamageZones(zonesTgt);
401 foreach (
string zone : zonesSrc)
403 if (zonesTgt.Find(zone) == -1)
406 foreach (
string health : HPTypes)
408 target.SetHealth01(zone,health,source.GetHealth01(zone,health));
413 foreach (
string gHealth : HPTypes)
415 target.SetHealth01(
"",gHealth,source.GetHealth01(
"",gHealth));
426 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
430 if (magazine.GetAmmoCount() <= 5)
432 magazine.ServerSetAmmoMax();
438 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
442 if (magazine.GetAmmoCount() <= 5)
444 magazine.LocalSetAmmoMax();
461 player.ServerReplaceItemWithNew(lambda);
471 player.ServerReplaceItemInHandsWithNew(lambda);
487 maxStackSize =
g_Game.ConfigGetInt(
"cfgVehicles " + itemName +
" varStackMax");
488 if( maxStackSize < 1)
489 maxStackSize =
g_Game.ConfigGetInt(
"cfgVehicles " + itemName +
" varQuantityMax");
490 if( maxStackSize < 1)
493 int fullPilesCount =
Math.
Floor(quantity/maxStackSize);
494 int rest = quantity - (fullPilesCount * maxStackSize);
496 for (
int i = 0; i < fullPilesCount; ++i)
508 pile.SetHealth(health);
515 itemPiles.Insert(pile);
530 pile.SetHealth(health);
537 itemPiles.Insert(pile);
547 float max_stack_size;
551 max_stack_size =
g_Game.ConfigGetInt(
"cfgVehicles " + item_name +
" varStackMax");
552 if( max_stack_size < 1)
553 max_stack_size =
g_Game.ConfigGetInt(
"cfgVehicles " + item_name +
" varQuantityMax");
554 if( max_stack_size < 1)
557 int full_piles_count =
Math.
Floor(quantity/max_stack_size);
558 int rest = quantity - (full_piles_count*max_stack_size);
561 for (
int i = 0; i < full_piles_count; ++i)
563 randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
566 pile.SetHealth(health);
567 item_piles.Insert(pile);
572 randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
575 pile.SetHealth(health);
576 item_piles.Insert(pile);
588 stack_size =
g_Game.ConfigGetInt(
"cfgMagazines " + item_name +
" count");
590 int piles_count =
Math.
Floor(quantity/stack_size);
591 int rest = quantity - (piles_count*stack_size);
593 for (
int i = 0; i < piles_count; ++i)
596 pile.ServerSetAmmoCount(stack_size);
602 pile.ServerSetAmmoCount(rest);
616 stack_size =
g_Game.ConfigGetInt(
"cfgMagazines " + item_name +
" count");
618 int piles_count =
Math.
Floor(quantity/stack_size);
619 int rest = quantity - (piles_count*stack_size);
622 for (
int i = 0; i < piles_count; ++i)
624 randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
626 pile.ServerSetAmmoCount(stack_size);
632 randomizedPos = MiscGameplayFunctions.GetRandomizedPositionVerified(starPos,targetPos,radius,ignoreObjectCollison);
634 pile.ServerSetAmmoCount(rest);
647 if (!
g_Game.ConfigGetText(
"cfgAmmo " + bullet_type +
" spawnPileType", item_name))
650 stack_size =
g_Game.ConfigGetInt(
"cfgMagazines " + item_name +
" count");
654 int piles_count =
Math.
Floor(quantity/stack_size);
655 int rest = quantity - (piles_count*stack_size);
657 for (
int i = 0; i < piles_count; ++i)
660 pile.ServerSetAmmoCount(stack_size);
667 pile.ServerSetAmmoCount(rest);
680 if (!
g_Game.ConfigGetText(
"cfgAmmo " + bullet_type +
" spawnPileType", item_name))
689 float health_normalized = health / 100;
720 cfg_path = cfg_path +
" "+
class_name+
" DamageSystem GlobalHealth " + health_type +
" hitpoints";
721 max_health =
g_Game.ConfigGetFloat(cfg_path);
728 vector usti_hlavne_position = weapon.GetSelectionPositionMS(
"usti hlavne" );
729 vector konec_hlavne_position = weapon.GetSelectionPositionMS(
"konec hlavne" );
730 vector end_point = weapon.ModelToWorld(usti_hlavne_position);
731 vector begin_point = weapon.ModelToWorld(konec_hlavne_position);
733 int contact_component;
735 vector aim_point = end_point - begin_point;
737 aim_point = aim_point + end_point;
739 if (
DayZPhysics.
RaycastRV(begin_point, aim_point,
position, contact_dir, contact_component, null, null, null,
false,
false, ObjIntersectFire))
747 int headBoneIdx = player.GetBoneIndexByName(
"Head");
748 if ( headBoneIdx == -1 )
749 { pos = player.GetPosition()[1] + 1.6; }
751 { pos = player.GetBonePositionWS(headBoneIdx); }
779 vector playerPosition = player.GetPosition();
782 playerPosition[1] + headHeight,
810 switch (movement_speed)
833 switch (movement_speed)
855 return entity.ConfigGetString(
"OnRestrainChange");
865 type = tool.ConfigGetBool(
"RestrainUnlockType");
867 string new_item_name = current_item.ConfigGetString(
"OnRestrainChange");
869 if ( new_item_name !=
"" )
873 if (!player_target.IsAlive() || destroy)
879 MiscGameplayFunctions.TurnItemIntoItemEx(player_target,
new ReplaceAndDestroyLambdaEx(current_item, new_item_name, player_target, type));
884 MiscGameplayFunctions.TurnItemIntoItemEx(player_target,
new ReplaceAndDestroyLambdaEx(current_item, new_item_name, player_target, type));
889 Error(
"current_item:" +current_item+
", tool:" +tool +
". No value for 'OnRestrainChange' config parameter");
895 return (value >= from) && (value <= to);
903 vector player_dir = player.GetDirection();
904 vector to_target_dir = target_pos - player.GetPosition();
907 to_target_dir[1] = 0;
912 float cos_fi =
vector.
Dot(player_dir, to_target_dir);
913 vector cross = player_dir * to_target_dir;
921 if( (dir <= cone_angle && dir >= -cone_angle) ||
Math.
AbsFloat(dir) == 90 )
932 int max_length = 512;
933 string output = input;
944 if (player && targetEnt && memPointEndName !=
"" && targetEnt.MemoryPointExists(memPointEndName) && memPointStartName !=
"" && targetEnt.MemoryPointExists(memPointStartName))
946 vector memPointEndPos = targetEnt.ModelToWorld(targetEnt.GetMemoryPointPos(memPointEndName));
947 vector memPointStartPos = targetEnt.ModelToWorld(targetEnt.GetMemoryPointPos(memPointStartName));
948 vector playerPosition = player.GetPosition();
949 vector playerHeadPos = MiscGameplayFunctions.GetPlayerHeadPosition(player);
973 float angleRad =
Math.
Acos(dir1 * dir2);
978 return angleRad > toleranceAngle;
984 if (
Class.
CastTo(ent,target.GetObject()) && ent.CanUseConstruction())
988 if (construction &&
BuildCondition(player, target, item,
false, constraction_index))
1004 if (player.IsPlacingLocal() || player.IsPlacingServer())
1008 checkData.m_PartName = partName;
1010 return !construction.IsCollidingEx(checkData);
1019 if (ent && ent.CanUseConstruction())
1043 if (camera_check && !
GetGame().IsDedicatedServer())
1049 return !player.GetInputController().CameraIsFreeLook();
1059 entity.GetCollisionBox(minMax);
1063 float from_override = entity.HeightStartCheckOverride();
1064 if (from_override > 0.0)
1066 size[1] = from_override;
1070 size[1] = minMax[1][1] - minMax[0][1];
1073 from = entity.GetPosition() + size;
1074 if ( entity.HeightCheckOverride() > 0 )
1076 to = entity.GetPosition() +
Vector(0, entity.HeightCheckOverride(), 0);
1080 vector ceiling =
"0 0 0";
1081 ceiling[1] = height;
1082 to = from + ceiling;
1100 int contact_component;
1102 return DayZPhysics.
RaycastRV(from, to, contact_pos, contact_dir, contact_component, NULL, NULL, entity,
false,
false, geometry,0.25);
1114 int contactComponent;
1115 set<Object> objects =
new set<Object>;
1117 if (
DayZPhysics.
RaycastRV(from, to, contactPos, contactDir, contactComponent, objects, NULL, entity,
false,
false, geometry, 0.25))
1119 for (
int i = 0; i < objects.Count(); ++i)
1121 Object obj = objects.Get(i);
1125 if (excludedTypes && excludedTypes.Count())
1127 foreach (
typename excludedType: excludedTypes)
1129 if (obj.IsInherited(excludedType))
1146 float steam_offset = 0;
1150 particle_pos = parent.GetPosition();
1152 if ( parent.IsInherited( PortableGasStove ) )
1168 else if ( fireplace.IsFireplaceIndoor() )
1170 steam_offset = 0.45;
1179 particle_pos[1] = particle_pos[1] + steam_offset;
1181 return particle_pos;
1188 vector randomPos =
Vector(targetPos[0] + (
Math.
Cos(angle) * usedRadius), targetPos[1], targetPos[2] + (
Math.
Sin(angle) * usedRadius));
1197 params.
type = ObjIntersectIFire;
1202 ret = results[0].pos;
1203 ret[1] = targetPos[1];
1210 vector playerPosition = player.GetPosition();
1211 vector playerHeadPos = MiscGameplayFunctions.GetPlayerHeadPosition(
PlayerBase.Cast(player));
1212 vector targetPos = playerPosition + (player.GetDirection() * distance);
1224 vector direction = ib.GetDirection();
1228 if (direction[0] < 0)
1235 int count = items.Count();
1236 for (
int i = 0; i < count; ++i )
1238 item = items.Get(i);
1253 vector rotation_matrix[3];
1257 parent.GetCollisionBox(minmax);
1267 if (parentInventory)
1270 for (i = 0; i < count; ++i)
1281 for (i = 0; i < count; ++i)
1283 ents.Insert(parentCargo.
GetItem(i));
1300 if ( !
g_Game.IsMultiplayer() )
1305 if (CastTo(entityIB, entity))
1312 for (
int l = 0; l < entityIB.GetQuantity(); ++l)
1318 MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
1319 entityIB.AddQuantity( -1 );
1321 new_item.ThrowPhysically(null, force,
false);
1327 float stackable = entityIB.GetTargetQuantityMax();
1328 if ( !(stackable == 0 || stackable >= entityIB.GetQuantity()) )
1330 while (entityIB.GetQuantity() > stackable)
1336 ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx( spltDst );
1337 splitItem.ThrowPhysically(null, force,
false);
1344 entityInventory.
TakeToDst(invMode, src, dst);
1345 entityIB.ThrowPhysically(null, force,
false);
1350 entityInventory.
DropEntity(invMode, entity.GetHierarchyRoot(), entity);
1360 float heatIsolation = pItem.GetHeatIsolation();
1361 float itemHealthLabel = pItem.GetHealthLevel();
1362 float itemWetness = pItem.GetWet();
1387 switch (itemHealthLabel)
1411 heatIsolation *= healthFactor;
1412 heatIsolation *= wetFactor;
1414 return heatIsolation;
1419 if (!obstructingObjects)
1422 for (
int i = 0; i < potentiallyObstructingObjects.Count(); ++i )
1424 Object obj = potentiallyObstructingObjects[i];
1425 if ( obj && ( obj.CanObstruct() || obj.CanProxyObstruct() ) )
1426 obstructingObjects.Insert(obj);
1432 return obj.IsTransport() || obj.CanUseConstruction();
1439 vicinityObjects.Copy(objects);
1444 int mCount = vicinityObjects.Count();
1446 if (!filteredObjects)
1450 if ( doDistanceCheck )
1452 for ( i = vicinityObjects.Count() - 1; i >= 0; --i )
1454 Object obj = vicinityObjects[i];
1456 vicinityObjects.Remove(i);
1464 float distance, dist1, dist2;
1466 for ( i = 0; i < obstructingObjects.Count(); ++i )
1468 distance =
vector.
DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
1469 distanceHelper.Insert(distance);
1472 distanceHelperUnsorted.Copy(distanceHelper);
1473 distanceHelper.Sort();
1475 for ( i = distanceHelper.Count() - 1; i >= 0; --i )
1476 sortedObstructingObjects.Insert(obstructingObjects[distanceHelperUnsorted.Find(distanceHelper[i])]);
1486 for ( i = 0; i < sortedObstructingObjects.Count(); ++i )
1488 Object obstrObj = sortedObstructingObjects[i];
1489 vector worldPos = obstrObj.GetWorldPosition();
1492 if ( obstrObj.GetCollisionBox(minMax) )
1496 max = max * (obstrObj.GetOrientation() * range);
1498 vector center, dx, dy, dz, half;
1499 center = (min + max) * 0.5;
1500 dz = obstrObj.GetOrientation();
1503 half = (max - min) * 0.5;
1509 for ( j = vicinityObjects.Count() - 1; j >= 0; --j )
1511 Object vicObj = vicinityObjects[j];
1514 vector d = vicObj.GetWorldPosition() - worldPos + center;
1517 group.Insert(vicObj);
1518 vicinityObjects.Remove(j);
1523 if ( group.Count() > 0 )
1524 tempGroups.Insert(group);
1529 for ( i = 0; i < tempGroups.Count(); ++i )
1539 foreach (
Object filteredObject : objectGroup)
1542 filteredObjects.Insert(filteredObject);
1553 for (
int i = 0; i < objects.Count(); )
1555 Object obj1 = objects[i];
1560 for (
int j = objects.Count() - 1; j > i; --j )
1562 Object obj2 = objects[j];
1565 vector start = obj1.GetWorldPosition();
1566 vector end = obj2.GetWorldPosition();
1569 if ( distance < squaredDistanceDelta )
1576 objectGroups.Insert(group);
1587 vector rayStart = MiscGameplayFunctions.GetPlayerHeadPosition(player);
1599 if (doDistanceCheck &&
vector.
DistanceSq(player.GetPosition(), distanceCheckPos) > maxDist * maxDist)
1602 cache.ObjectCenterPos =
object.GetCenter();
1609 if (
object.CanProxyObstruct())
1613 if (cache.HitProxyObjects)
1615 if (cache.HitProxyObjects.Count() > 0)
1617 if (cache.HitProxyObjects[0].hierLevel > 0)
1620 if (!cache.HitProxyObjects[0].parent.IsMan())
1622 if (cache.HitProxyObjects[0].parent)
1626 if (proxyInventory && proxyInventory.
GetCargo())
1639 for (
int m = 0; m < cache.HitObjects.Count(); ++m)
1641 Object hit_object = cache.HitObjects.Get(m);
1643 if ( hit_object.CanObstruct() )
1670 if (geometryTypeOverride != -1)
1671 rayInput.
type = geometryTypeOverride;
1676 if (cache.HitProxyObjects)
1678 count = cache.HitProxyObjects.Count();
1680 for (i = 0; i < count; ++i)
1682 if (cache.HitProxyObjects[i].hierLevel > 0)
1684 parent = cache.HitProxyObjects[i].parent;
1685 if (parent && !parent.IsMan() && parent.CanProxyObstruct())
1687 if (parent !=
object || (parent ==
object &&
object.CanProxyObstructSelf()))
1695 int geometry = ObjIntersectFire;
1696 if (geometryTypeOverride != -1)
1697 geometry = geometryTypeOverride;
1698 DayZPhysics.
RaycastRV(cache.RaycastStart, cache.ObjectCenterPos, cache.ObjectContactPos, cache.ObjectContactDir, cache.ContactComponent, cache.HitObjects,
object,
g_Game.GetPlayer(),
false,
false, geometry, 0.0,
CollisionFlags.ALLOBJECTS);
1699 count = cache.HitObjects.Count();
1700 for (i = 0; i < count; ++i)
1702 if (cache.HitObjects[i].CanObstruct())
1714 float adjustedDamage;
1716 g_Game.SurfaceUnderObject(player, surfaceType, liquidType);
1718 if (modifierSurface == 0)
1719 modifierSurface = 1;
1721 if (player.GetInColdArea())
1722 adjustedDamage = baseDamage * (modifierSurface +
g_Game.GetMission().GetWorldData().GetColdAreaToolDamageModifier());
1724 adjustedDamage = baseDamage * modifierSurface;
1732 item.DecreaseHealth(dmg,
false);
1744 return val / maxVal;
1747 static float Bobbing(
float period,
float amplitude,
float elapsedTime)
1753 elapsedTime /= period;
1756 cycle += elapsedTime;
1758 cycle =
Math.
Sin(cycle) * amplitude;
1771 EntityAI entity = player.GetInventory().CreateInInventory(
"Splint");
1773 entity = player.SpawnEntityOnGroundOnCursorDir(
"Splint", 0.5);
1777 Class.
CastTo(attachment, player.GetItemOnSlot(
"Splint_Right"));
1778 if ( attachment && attachment.GetType() ==
"Splint_Applied" )
1782 MiscGameplayFunctions.TransferItemProperties(attachment,new_item);
1787 if (new_item.GetHealthLevel() < 4)
1789 int newDmgLevel = new_item.GetHealthLevel() + 1;
1791 float max = new_item.GetMaxHealth(
"",
"");
1793 switch ( newDmgLevel )
1818 attachment.Delete();
1825 if( player.GetSimulationTimeStamp() < 20 && !player.IsPersistentFlag(
PersistentFlag.AREA_PRESENCE) )
1830 vector player_pos = player.GetPosition();
1831 vector closest_safe_pos = MiscGameplayFunctions.GetClosestSafePos(player_pos, safe_positions);
1833 if (player_pos!=closest_safe_pos)
1835 closest_safe_pos[1] =
g_Game.SurfaceY(closest_safe_pos[0], closest_safe_pos[2]);
1837 player.SetPosition( closest_safe_pos );
1839 g_Game.RPCSingleParam(player,
ERPCs.RPC_WARNING_TELEPORT, null,
true, player.GetIdentity());
1841 PluginAdminLog adminLog = PluginAdminLog.Cast(
GetPlugin(PluginAdminLog));
1843 adminLog.PlayerTeleportedLog(player,player_pos,closest_safe_pos,
"Unwillingly spawning in contaminated area.");
1852 vector closest_pos = to_pos;
1853 float smallest_dist =
float.MAX;
1862 if ( dist < smallest_dist)
1864 smallest_dist = dist;
1874 vector playerPos = player.GetPosition();
1875 if (playerPos != safePos)
1877 player.SetPosition(safePos);
1878 g_Game.RPCSingleParam(player,
ERPCs.RPC_WARNING_TELEPORT, null,
true, player.GetIdentity());
1893 noise.
AddNoiseTarget(source.GetPosition(), lifeTime, noiseParams);
1900 float minValue = 0.0;
1901 for (
int i = 0; i < pArray.Count(); ++i)
1903 if (minValue == 0 || pArray.Get(i) < minValue)
1905 minValue = pArray.Get(i);
1914 float maxValue = 0.0;
1915 for (
int i = 0; i < pArray.Count(); ++i)
1917 if (maxValue == 0 || pArray.Get(i) > maxValue)
1919 maxValue = pArray.Get(i);
1928 return g_Game.ConfigGetTextOut(
"CfgVehicles " + type +
" displayName");
1933 if (pSelection.Count() == 0 || pCompName.
Length() == 0)
1938 for (
int i = 0; i < pSelection.Count(); ++i)
1941 if (pSelection[i] && pSelection[i].
GetName() == pCompName)
1952 if (!MiscGameplayFunctions.IsComponentInSelection(pSelection, pCompName))
1957 for (
int i = 0; i < pSelection.Count(); ++i)
1960 if (pSelection[i] && pSelection[i].
GetName() == pCompName)
1971 if (listOfTypenames.Count() > 0)
1976 Object childToRemove = child;
1977 child =
Object.Cast(child.GetSibling());
1979 if (childToRemove.IsAnyInherited(listOfTypenames))
1981 vector pos = parent.GetPosition();
1982 parent.RemoveChild(childToRemove,
false);
1987 childToRemove.SetTransform(m4);
1988 childToRemove.PlaceOnSurface();
1996 if (listOfTypenames.Count() > 0)
2001 Object childToRemove = child;
2002 child =
Object.Cast(child.GetSibling());
2004 if (childToRemove.IsAnyInherited(listOfTypenames))
2006 parent.RemoveChild(childToRemove,
false);
2007 childToRemove.Delete();
2019 outputObjects.Insert(child);
2028 if (parent.GetLiquidType() != 0 && parent.GetQuantityNormalized() > liquidQuantityThresholdPercentage && !parent.GetIsFrozen())
2037 g_Game.GetWeather().GetWindMagnitude().GetLimits(windMin, windMax);
2038 float snowfall =
g_Game.GetWeather().GetSnowfall().GetActual();
2039 float value = snowfall +
g_Game.GetWeather().GetWindMagnitude().GetActual() / windMax;
2047 obj.GetActionComponentNameList(compIdx, compNames);
2048 foreach (
string selection : compNames)
2050 if (selection.Contains(selName))
2060 [
Obsolete(
"Obsolete collision checking method, use the other 'ComplexBuildCollideCheckClient'")]
2066 [
Obsolete(
"Obsolete collision checking method, use the other 'BuildCondition'")]
2072 [
Obsolete(
"Use MiscGameplayFunctions.GenerateAINoiseAtPositionEx instead!")]
2094 old_item.GetTransform(mtx);
2096 player.GetTransform(mtx);
2098 OverrideNewLocation(gnd);
2103 super.RemoveOldItemFromLocation();
2104 m_Player.GetHumanInventory().OnEntityInHandsDestroyed(m_OldLocation);
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
override void OnSuccess(EntityAI new_item)
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
const int ECE_PLACE_ON_SURFACE
const int ECE_UPDATEPATHGRAPH
const int ECE_CREATEPHYSICS
void ConstructionBase(EntityAI parent)
void CollisionCheckData()
proto native int GetComponentIndex()
InventoryLocationType
types of Inventory Location
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
ref array< ref RaycastRVResult > HitProxyObjects
static bool CanIgnoreDistanceCheck(Object obj)
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda RaycastStart
static void TransferEntityVariables(EntityAI source, EntityAI target, bool exclude_quantity=false)
static vector TruncateVec(vector value, int decimals=2)
truncate float to specified precision
static string ObtainRestrainItemTargetClassname(notnull EntityAI entity)
static bool GenericDirectionalCheck(vector dir1, vector dir2, float toleranceAngle)
just compares the angle
static void GetAttachedChildren(IEntity parent, array< IEntity > outputObjects)
Fills the provided array with all children entities in hierarchy of this entity.
static vector GetRandomizedPositionVerifiedPlayer(Man player, float distance, float radius, Object ignore)
static void TransferEntityHealth(EntityAI source, EntityAI target, array< string > healthTypes=null, bool transferZoneDamage=true)
static void DealAbsoluteDmg(ItemBase item, float dmg)
static void TransferItemVariables(ItemBase source, ItemBase target, bool exclude_quantity=false)
DEPRECATED.
static float GetCombinedSnowfallWindValue()
static bool TeleportPlayerToSafeLocation3D(notnull PlayerBase player, vector safePos)
'stupider' teleport method, does not touch flag management. Applies Y from the position as well!
static float Bobbing(float period, float amplitude, float elapsedTime)
static bool MemPointDirectionalCheck(PlayerBase player, EntityAI targetEnt, string memPointStartName, string memPointEndName, float toleranceAngle=Math.PI_HALF)
static bool IsPlayerOrientedTowardPos(notnull DayZPlayerImplement player, vector target_pos, float cone_angle)
Check if player direction(based on cone of defined angle) is oriented to target position.
static void RemoveAllAttachedChildrenByTypename(notnull EntityAI parent, array< typename > listOfTypenames)
static void TurnItemIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
static void DropAllItemsInInventoryInBounds(ItemBase ib, vector halfExtents)
static vector GetSteamPosition(EntityAI parent)
static void GenerateAINoiseAtPosition(vector position, float lifeTime, NoiseParams noiseParams)
static vector GetRandomizedPosition(vector targetPos, float radius)
static void DealEvinronmentAdjustedDmg(ItemBase item, PlayerBase player, float baseDamage)
static array< Magazine > CreateMagazinePilesFromBulletDispersed(string bullet_type, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
static array< ItemBase > CreateItemBasePilesEx(string itemName, vector groundPosition, float quantity, float health, bool floatySpawn=false, bool throwAfterSpawn=false)
enum ThrowEntityFlags Truncate(float value, int decimals=2)
truncate float to specified precision
static vector GetClosestSafePos(vector to_pos, notnull array< ref array< float > > positions)
static void FilterObstructedObjectsByGrouping(vector origin, float range, float distanceDelta, array< Object > objects, array< Object > obstructingObjects, out array< Object > filteredObjects, bool doDistanceCheck=false, bool checkIfDistanceCanBeIgnored=false, float maxDist=0)
group objects that are close to each other together
static int GetHealthLevelForAmmo(string class_name, float health)
ref set< Object > HitObjects
void MoveEquipToExistingItemAndDestroyOldRootLambda(EntityAI old_item, string new_item_type, PlayerBase player, EntityAI new_item)
static void TurnItemInHandsIntoItem(notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
static float GetTypeMaxGlobalHealth(string class_name, string health_type="Health")
static float Normalize(int val, int maxVal)
static string TruncateVecToS(vector value, int decimals=2, string delimiter=" ")
static float GetPlayerHeadHeight(notnull PlayerBase player)
Returns approximated height(from terrain) of head in WS which takes the player's stance into account ...
static string TruncateToS(float value, int decimals=2)
truncate float to specified precision, output as string
static void GenerateAINoiseAtPositionEx(notnull Object source, float lifeTime, NoiseParams noiseParams)
static void DeleteAttachedChildrenByTypename(notnull EntityAI parent, array< typename > listOfTypenames)
static bool BuildCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check, int constraction_index)
static void TurnItemInHandsIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
static TransferInventoryResult TransferInventory(EntityAI sourceItem, EntityAI targetItem, PlayerBase player)
static string GetItemDisplayName(string type)
static void TransformRestrainItem(EntityAI current_item, EntityAI tool, PlayerBase player_source, PlayerBase player_target, bool destroy=false)
static vector GetHeadingVector(notnull PlayerBase player)
static array< Magazine > CreateMagazinePilesFromBullet(string bullet_type, vector ground_position, float quantity, float health)
static bool IsValueInRange(float value, float from, float to)
static string SanitizeString(string input)
static bool IsComponentInSelection(array< Selection > pSelection, string pCompName)
static void GetHeadBonePos(notnull PlayerBase player, out vector pos)
static bool GetProjectedCursorPos3d(out vector position, Weapon_Base weapon)
static float GetEnergyMetabolicSpeed(int movement_speed)
static bool IsObjectObstructedFilter(Object object, IsObjectObstructedCache cache, PlayerBase player)
static bool ComplexBuildCollideCheckClient(PlayerBase player, ActionTarget target, ItemBase item, int constraction_index)
static void IsUnderRoofFromToCalculation(EntityAI entity, out vector from, out vector to, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST)
static bool IsUnderRoof(EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST)
static vector GetPlayerHeadPosition(notnull PlayerBase player)
Returns approximated position of head in WS which takes the player's stance into account Preferred me...
static bool ComponentIdxContainsSelection(Object obj, int compIdx, string selName)
static float GetHeadingAngle(notnull DayZPlayerImplement player)
static bool IsObjectObstructed(Object object, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
static void ThrowEntityFromInventory(notnull EntityAI entity, vector position, float direction[4], vector force, int flags)
static void RemoveSplint(PlayerBase player)
static array< ItemBase > CreateItemBasePilesDispersed(string item_name, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
creation method using raycast-dispersed positioning; ECE_TRACE not used as a result
static bool IsObjectObstructedProxy(Object object, IsObjectObstructedCache cache, PlayerBase player)
static float GetWaterMetabolicSpeed(int movement_speed)
static bool IsObjectObstructedFilterEx(Object object, IsObjectObstructedCache cache, PlayerBase player, int geometryTypeOverride=-1)
groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometr...
static bool IsUnder(EntityAI entity, array< typename > excludedTypes, out Object hitObj, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry=ObjIntersectIFire)
static void ThrowAllItemsInInventoryEx(notnull EntityAI parent, int flags, vector force)
static vector GetRandomizedPositionVerified(vector startPos, vector targetPos, float radius, Object ignore=null)
static void UnlimitedAmmoDebugCheck(Weapon_Base weapon)
static string ValueToBar(float value, string bar="[----------]", string mark="x")
Produces ACII "progress bar" based on an 0..1 'value' input.
static bool IsObjectObstructedEx(Object object, IsObjectObstructedCache cache, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
static void SplitArrayIntoGroupsByDistance(array< Object > objects, array< ref array< Object > > objectGroups, float squaredDistanceDelta)
static string InsertAtPos(string base, string insert, int pos)
Insert 'insert' behind index 'pos' of the 'base' string.
static void TransferItemProperties(EntityAI source, notnull EntityAI target, bool transfer_agents=true, bool transfer_variables=true, bool transfer_health=true, bool exclude_quantity=false)
will transform variables, agents and other local scripted properties as well as any relevant non-scri...
static float GetCurrentItemHeatIsolation(ItemBase pItem)
static array< Magazine > CreateMagazinePilesDispersed(string item_name, vector starPos, vector targetPos, float radius, float quantity, float health, Object ignoreObjectCollison)
creation method using raycast-dispersed positioning; ECE_TRACE not used as a result
static float FModulus(float x, float y)
static array< Magazine > CreateMagazinePiles(string item_name, vector ground_position, float quantity, float health)
static bool IsUnderRoofEx(EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry=ObjIntersectView)
static void TeleportCheck(notnull PlayerBase player, notnull array< ref array< float > > safe_positions)
checks if we should teleport the player to a safe location and if so, performs the teleportation
static void TurnItemIntoItem(notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
static void SoakItemInsideParentContainingLiquidAboveThreshold(notnull ItemBase item, notnull ItemBase parent, float liquidQuantityThresholdPercentage=0.05)
static void ThrowAllItemsInInventory(notnull EntityAI parent, int flags)
static void FilterObstructingObjects(array< Object > potentiallyObstructingObjects, out array< Object > obstructingObjects)
static array< ItemBase > CreateItemBasePiles(string item_name, vector ground_position, float quantity, float health, bool floaty_spawn=false)
Spawns multiple piles of stackable ItemBase objects on ground (intended for generic use)
class NoiseSystem NoiseParams()
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
override bool PerformRoofCheckForBase(string partName, PlayerBase player, out bool result)
override bool MustBeBuiltFromOutside()
static ref TFloatArray ARRAY_FLOAT
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
represents base for cargo storage for entities
Super root of all classes in Enforce script.
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
float GetEnergy()
Energy manager: Returns the amount of stored energy this device has.
void SetEnergy(float new_energy)
Energy manager: Sets stored energy for this device. It ignores the min/max limit!
bool IsSwitchedOn()
Energy manager: Returns state of the switch. Whenever the device is working or not does not matter....
ConstructionPart GetBuildPartHandsGenericAtIndex(int idx)
void SetTarget(Object target)
ConstructionPart GetBuildPartAtIndex(int idx)
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
void DestroyItemInCorpsesHandsAndCreateNewOnGndLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false)
override void RemoveOldItemFromLocation()
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
void DropEquipAndDestroyRootLambda(EntityAI old_item, string new_item_type, PlayerBase player)
void TransferFoodStage(notnull Edible_Base source)
override bool IsBaseFireplace()
override bool IsIndoorOven()
override bool IsBarrelWithHoles()
proto native EntityAI GetAttachmentFromIndex(int index)
static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
Finds a transformation for the item to be dropped to If the initial transforation overlaps with anoth...
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
move src to dst
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
bool DropEntityInBounds(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
script counterpart to engine's class Inventory
proto native void SetGround(EntityAI e, vector mat[4])
sets current inventory location type to Ground with transformation mat
proto native void SetParent(notnull EntityAI parent)
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
provides access to slot configuration
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
override bool CanBeSplit()
this one is a also bit special: it moves all items to already existing item and destroys the ex-root ...
proto void AddNoiseTarget(vector pos, float lifetime, NoiseParams noise_params, float external_strength_multiplier=1.0)
Will make a noise at that position which the AI will "see" for the duration of 'lifetime'.
static const float HEAD_HEIGHT_CROUCH
static const float METABOLIC_SPEED_WATER_BASAL
static const float HEAD_HEIGHT_ERECT
[seconds]
static const float METABOLIC_SPEED_WATER_WALK
static const float METABOLIC_SPEED_ENERGY_JOG
static const float HEAD_HEIGHT_PRONE
static const float METABOLIC_SPEED_WATER_JOG
static const float METABOLIC_SPEED_ENERGY_WALK
static const float METABOLIC_SPEED_WATER_SPRINT
static const float METABOLIC_SPEED_ENERGY_SPRINT
static const float METABOLIC_SPEED_ENERGY_BASAL
void ReplaceAndDestroyLambda(EntityAI old_item, string new_item_type, PlayerBase player, bool destroy=false)
override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
override void VerifyItemTypeBySlotType()
if attaching from att.slot to att.slot, skips the change to "ground" version. Allows for correct prop...
void TurnItemIntoItemLambda(EntityAI old_item, string new_item_type, PlayerBase player)
float m_quantity_override
void SetTransferParams(bool transfer_agents=true, bool transfer_variables=true, bool transfer_health=true, bool exclude_quantity=false, float quantity_override=-1)
void ReplaceItemWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
override void OnSuccess(EntityAI new_item)
void ReplaceItemWithNewLambdaBase(EntityAI old_item, string new_item_type)
void UndoRemoveNetworkObjectInfo()
void CreateNetworkObjectInfo(EntityAI new_item)
Step G. - create NetworkObjectInfo for new item.
ref InventoryLocation m_NewLocation
void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
Step E. copy properties from old object to the created one.
void RemoveNetworkObjectInfo()
Step C. - remove network part of the object @NOTE this operation does not delete the object,...
base class for transformation operations (creating one item from another)
static float GetParamFloat(string surface_name, string param_name)
override void OnSuccess(EntityAI new_item)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Aside
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
static const vector Forward
proto float Normalize()
Normalizes vector. Returns length.
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
DayZPlayerConstants
defined in C++
const int INDEX_NOT_FOUND
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
void Error(string err)
Messagebox with error message.
const float PROJECTED_CURSOR_DISTANCE
const float ROOF_CHECK_RAYCAST_DIST
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
class array< Class T > TStringArray
void Obsolete(string msg="")
proto native IEntity GetSibling()
Returns pointer to next child Entity on the same hierarchy.
proto native IEntity GetChildren()
Returns pointer to first child Entity in hierarchy.
const float ENVIRO_ISOLATION_WETFACTOR_SOAKED
const float ENVIRO_ISOLATION_WETFACTOR_WET
const float ENVIRO_ISOLATION_WETFACTOR_DAMP
const float ENVIRO_ISOLATION_WETFACTOR_DRENCHED
const float ENVIRO_ISOLATION_HEALTHFACTOR_RUINED
const float ENVIRO_ISOLATION_HEALTHFACTOR_DAMAGED
const float ENVIRO_ISOLATION_HEALTHFACTOR_WORN
const float ENVIRO_ISOLATION_WETFACTOR_DRY
impact of item wetness to the heat isolation
const float ENVIRO_ISOLATION_HEALTHFACTOR_PRISTINE
impact of item health (state) to the heat isolation
const float ENVIRO_ISOLATION_HEALTHFACTOR_B_DAMAGED
const float DAMAGE_BADLY_DAMAGED_VALUE
const float DAMAGE_RUINED_VALUE
const float DAMAGE_DAMAGED_VALUE
const float DAMAGE_WORN_VALUE
const int STATE_BADLY_DAMAGED
const int VARIABLE_QUANTITY
const float STATE_SOAKING_WET
const float STATE_DRENCHED
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static const float PI_HALF
static proto float ModFloat(float x, float y)
Returns the floating-point remainder of x/y rounded towards zero.
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
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].
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float Pow(float v, float power)
Return power of v ^ power.
static const float RAD2DEG
static proto float AbsFloat(float f)
Returns absolute value.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
@ NONE
body is not in simulation, nor in collision world
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)
proto native int Length()
Returns length of string.
proto string Get(int index)
Gets n-th character from string.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto int ToLower()
Changes string to lowercase. Returns length.