DayZ 1.24
Loading...
Searching...
No Matches
MiscGameplayFunctions.c File Reference

Go to the source code of this file.

Classes

class  ReplaceItemWithNewLambda
 adds automatic QuickBar handling More...
 
class  TurnItemIntoItemLambda
 
class  DropEquipAndDestroyRootLambda
 this one is a bit special: it drops all items and destroys the ex-root of the hierarchy More...
 
class  DestroyItemInCorpsesHandsAndCreateNewOnGndLambda
 

Enumerations

enum  TransferInventoryResult { Ok , DroppedSome }
 
enum  ThrowEntityFlags
 

Functions

class TurnItemIntoItemLambdaAnimSysNotifyLambda extends TurnItemIntoItemLambda OnSuccess (EntityAI new_item)
 
void DropEquipAndDestroyRootLambda (EntityAI old_item, string new_item_type, PlayerBase player)
 
override void CopyOldPropertiesToNew (notnull EntityAI old_item, EntityAI new_item)
 
void MoveEquipToExistingItemAndDestroyOldRootLambda (EntityAI old_item, string new_item_type, PlayerBase player, EntityAI new_item)
 
void RemoveNetworkObjectInfo ()
 
void UndoRemoveNetworkObjectInfo ()
 
void CreateNetworkObjectInfo (EntityAI new_item)
 
enum ThrowEntityFlags Truncate (float value, int decimals=2)
 truncate float to specified precision
 
static string TruncateToS (float value, int decimals=2)
 truncate float to specified precision, output as string
 
static vector TruncateVec (vector value, int decimals=2)
 truncate float to specified precision
 
static string TruncateVecToS (vector value, int decimals=2, string delimiter=" ")
 
static string GetColorString (float r, float g, float b, float a)
 
static string ValueToBar (float value, string bar="[----------]", string mark="x")
 Produces ACII "progress bar" based on an 0..1 'value' input.
 
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 item' variables, agents and other local scripted properties as well as any relevant non-scripted properties like health
 
static void TransferItemVariables (ItemBase source, ItemBase target, bool exclude_quantity=false)
 
static TransferInventoryResult TransferInventory (EntityAI sourceItem, EntityAI targetItem, PlayerBase player)
 
static void UnlimitedAmmoDebugCheck (Weapon_Base weapon)
 
static void TurnItemIntoItem (notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
 
static void TurnItemIntoItemEx (notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
 
static void TurnItemInHandsIntoItem (notnull ItemBase old_item, string new_item_type, notnull PlayerBase player)
 
static void TurnItemInHandsIntoItemEx (notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)
 
static array< ItemBaseCreateItemBasePiles (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)
 
static array< MagazineCreateMagazinePiles (string item_name, vector ground_position, float quantity, float health)
 
static array< MagazineCreateMagazinePilesFromBullet (string bullet_type, vector ground_position, float quantity, float health)
 
static int GetHealthLevelForAmmo (string class_name, float health)
 
static float GetTypeMaxGlobalHealth (string class_name, string health_type="Health")
 
static bool GetProjectedCursorPos3d (out vector position, Weapon_Base weapon)
 
static void GetHeadBonePos (notnull PlayerBase player, out vector pos)
 
static vector GetHeadingVector (notnull PlayerBase player)
 
static float GetHeadingAngle (notnull DayZPlayerImplement player)
 
static float GetEnergyMetabolicSpeed (int movement_speed)
 
static float GetWaterMetabolicSpeed (int movement_speed)
 
static string ObtainRestrainItemTargetClassname (notnull EntityAI entity)
 
static void TransformRestrainItem (EntityAI current_item, EntityAI tool, PlayerBase player_source, PlayerBase player_target, bool destroy=false)
 
static bool IsValueInRange (float value, float from, float to)
 
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 string SanitizeString (string input)
 
static bool ComplexBuildCollideCheckClient (PlayerBase player, ActionTarget target, ItemBase item, string partName="")
 
static bool ComplexBuildCollideCheckClient (PlayerBase player, ActionTarget target, ItemBase item, int constraction_index)
 
static bool BuildCondition (PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)
 
static bool BuildCondition (PlayerBase player, ActionTarget target, ItemBase item, bool camera_check, 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 bool IsUnderRoofEx (EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry=ObjIntersectView)
 
static vector GetSteamPosition (EntityAI parent)
 
static void DropAllItemsInInventoryInBounds (ItemBase ib, vector halfExtents)
 
static void ThrowAllItemsInInventory (notnull EntityAI parent, int flags)
 
static void ThrowEntityFromInventory (notnull EntityAI entity, vector position, float direction[4], vector force, int flags)
 
static float GetCurrentItemHeatIsolation (ItemBase pItem)
 
static void FilterObstructingObjects (array< Object > potentiallyObstructingObjects, out array< Object > obstructingObjects)
 
static bool CanIgnoreDistanceCheck (Object obj)
 
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 void SplitArrayIntoGroupsByDistance (array< Object > objects, array< ref array< Object > > objectGroups, float squaredDistanceDelta)
 
static bool IsObjectObstructed (Object object, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
 
static bool IsObjectObstructedEx (Object object, IsObjectObstructedCache cache, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
 
static bool IsObjectObstructedProxy (Object object, IsObjectObstructedCache cache, PlayerBase player)
 
static bool IsObjectObstructedFilter (Object object, IsObjectObstructedCache cache, PlayerBase player)
 
static bool IsObjectObstructedFilterEx (Object object, IsObjectObstructedCache cache, PlayerBase player, int geometryTypeOverride=-1)
 groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometry override, if desired
 
static void DealAbsoluteDmg (ItemBase item, float dmg)
 
static float Normalize (int val, int maxVal)
 
static float Bobbing (float period, float amplitude, float elapsedTime)
 
static float FModulus (float x, float y)
 
static void RemoveSplint (PlayerBase player)
 
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 vector GetClosestSafePos (vector to_pos, notnull array< ref array< float > > positions)
 
static void GenerateAINoiseAtPosition (vector position, float lifeTime, NoiseParams noiseParams)
 
static float GetMinValue (array< float > pArray)
 
static float GetMaxValue (array< float > pArray)
 
static string GetItemDisplayName (string type)
 
static bool IsComponentInSelection (array< Selection > pSelection, string pCompName)
 
static int GetComponentIndex (array< Selection > pSelection, string pCompName)
 
static void RemoveAllAttachedChildrenByTypename (notnull EntityAI parent, array< typename > listOfTypenames)
 
static void GetAttachedChildren (IEntity parent, array< IEntity > outputObjects)
 Fills the provided array with all children entities in hierarchy of this entity.
 
static void SoakItemInsideParentContainingLiquidAboveThreshold (notnull ItemBase item, notnull ItemBase parent, float liquidQuantityThresholdPercentage=0.05)
 
void IsObjectObstructedCache (vector rayCastStart, int totalObjects)
 
void ClearCache ()
 

Variables

PlayerBase m_Player
 
EntityAI m_NewItem
 
 NONE = 0
 
 SPLIT = 1
 
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda RaycastStart = "0 0 0"
 
int TotalObjects = 0
 
vector ObjectCenterPos = "0 0 0"
 
vector ObjectContactPos = "0 0 0"
 
vector ObjectContactDir = "0 0 0"
 
int ContactComponent = -1
 
ref array< ref RaycastRVResultHitProxyObjects = new array<ref RaycastRVResult>
 
ref set< ObjectHitObjects = new set<Object>
 

Enumeration Type Documentation

◆ ThrowEntityFlags

Definition at line 197 of file MiscGameplayFunctions.c.

198{
199 NONE = 0,
200 SPLIT = 1, //< Splits the item when it has quantity, recommended to use when called on an attachment
201}

◆ TransferInventoryResult

Enumerator
Ok 
DroppedSome 

Definition at line 192 of file MiscGameplayFunctions.c.

193{
195};

Function Documentation

◆ Bobbing()

static float Bobbing ( float period,
float amplitude,
float elapsedTime )
staticprotected

Definition at line 1363 of file MiscGameplayFunctions.c.

1364 {
1365 //Prevent division by 0
1366 if (period == 0)
1367 period = 1;
1368
1369 elapsedTime /= period;
1370
1371 float cycle;
1372 cycle += elapsedTime;
1373 cycle = FModulus(cycle, 360);
1375
1376 return cycle;
1377 }
static float FModulus(float x, float y)
Definition EnMath.c:7
static proto float Sin(float angle)
Returns sinus of angle in radians.

References FModulus(), and Math::Sin().

◆ BuildCondition() [1/2]

static bool BuildCondition ( PlayerBase player,
ActionTarget target,
ItemBase item,
bool camera_check )
staticprotected

Definition at line 747 of file MiscGameplayFunctions.c.

748 {
749 return true;
750 }

Referenced by ComplexBuildCollideCheckClient().

◆ BuildCondition() [2/2]

static bool BuildCondition ( PlayerBase player,
ActionTarget target,
ItemBase item,
bool camera_check,
int constraction_index )
staticprotected

Definition at line 752 of file MiscGameplayFunctions.c.

753 {
754 Object targetObject = target.GetObject();
755 if (targetObject && targetObject.CanUseConstruction())
756 {
758 ConstructionActionData construction_action_data = player.GetConstructionActionData();
760
762 if (item)
764 else
766
767 //Debug
768 /*
769 if ( constrution_part )
770 {
771 Construction construction = base_building.GetConstruction();
772 construction.IsColliding( constrution_part.GetPartName() );
773 }
774 */
775
777 {
778 //camera and position checks
779 bool position_check = (base_building.MustBeBuiltFromOutside() && !base_building.IsPlayerInside(player, constrution_part.GetMainPartName())) || (!base_building.MustBeBuiltFromOutside() && base_building.IsPlayerInside(player, constrution_part.GetMainPartName()));
780 if (position_check && !player.GetInputController().CameraIsFreeLook())
781 {
782 //Camera check (client-only)
783 if (camera_check)
784 {
785 if (GetGame() && (!GetGame().IsDedicatedServer()))
786 return !base_building.IsFacingCamera(constrution_part.GetMainPartName());
787 }
788
789 return true;
790 }
791 }
792 }
793
794 return false;
795 }
proto native CGame GetGame()

References GetGame().

◆ CanIgnoreDistanceCheck()

static bool CanIgnoreDistanceCheck ( Object obj)
staticprotected

Definition at line 1068 of file MiscGameplayFunctions.c.

1069 {
1070 return obj.IsTransport() || obj.CanUseConstruction();
1071 }

Referenced by FilterObstructedObjectsByGrouping().

◆ ClearCache()

void ClearCache ( )
protected

Definition at line 1643 of file MiscGameplayFunctions.c.

1644 {
1645 ObjectCenterPos = "0 0 0";
1646 ObjectContactPos = "0 0 0";
1647 ObjectContactDir = "0 0 0";
1648 ContactComponent = -1;
1649 HitProxyObjects.Clear();
1650 HitObjects.Clear();
1651 }
ref array< ref RaycastRVResult > HitProxyObjects
vector ObjectContactDir
vector ObjectContactPos
vector ObjectCenterPos
ref set< Object > HitObjects
int ContactComponent

References ContactComponent, HitObjects, HitProxyObjects, ObjectCenterPos, ObjectContactDir, and ObjectContactPos.

◆ ComplexBuildCollideCheckClient() [1/2]

static bool ComplexBuildCollideCheckClient ( PlayerBase player,
ActionTarget target,
ItemBase item,
int constraction_index )
staticprotected

Definition at line 714 of file MiscGameplayFunctions.c.

715 {
717 if (base_building)
718 {
719 Construction construction = base_building.GetConstruction();
721 {
722 ConstructionActionData construction_action_data = player.GetConstructionActionData();
723 string partName;
724 if (item)
725 partName = construction_action_data.GetBuildPartAtIndex(constraction_index).GetPartName();
726 else
727 partName = construction_action_data.GetBuildPartNoToolAtIndex(constraction_index).GetPartName();
728 bool boo;
729 if (base_building.PerformRoofCheckForBase(partName, player, boo) && boo)
730 return false;
731 if (player.IsPlacingLocal() || player.IsPlacingServer())
732 return false;
733
734 /*float distance_root = vector.DistanceSq(target.GetCursorHitPos(), player.GetPosition());
735
736 if (!CfgGameplayHandler.GetDisableDistanceCheck() && distance_root < UAMaxDistances.BASEBUILDING_SHORT)
737 {
738 return false;
739 } */
740 return !construction.IsColliding(partName);
741 }
742 }
743 return false;
744 }
void Construction(BaseBuildingBase parent)
static bool BuildCondition(PlayerBase player, ActionTarget target, ItemBase item, bool camera_check)

References BuildCondition(), and Construction().

◆ ComplexBuildCollideCheckClient() [2/2]

static bool ComplexBuildCollideCheckClient ( PlayerBase player,
ActionTarget target,
ItemBase item,
string partName = "" )
staticprotected

Definition at line 709 of file MiscGameplayFunctions.c.

710 {
711 return true;
712 }

◆ CopyOldPropertiesToNew()

override void MoveEquipToExistingItemAndDestroyOldRootLambda::CopyOldPropertiesToNew ( notnull EntityAI old_item,
EntityAI new_item )

We don't care if a valid transform couldn't be found, we just want to preferably use it instead of placing on the old item

Definition at line 114 of file MiscGameplayFunctions.c.

115 {
116 super.CopyOldPropertiesToNew(old_item, new_item);
117
118 InventoryLocation understash_src = m_NewLocation; // m_NewLocation is a backup of original old_item's src before the operation started
119
121 old_item.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
122 int count = children.Count();
123 for (int i = 0; i < count; i++)
124 {
125 EntityAI child = children.Get(i);
126 if (child)
127 {
129 child.GetInventory().GetCurrentInventoryLocation(child_src);
130
132 //@TODO: modify _dst with place on gnd?
133
134 vector m4[4];
136
139
140 child_dst.SetGround(child, m4);
141
142 m_Player.LocalTakeToDst(child_src, child_dst);
143
144 GetGame().RemoteObjectTreeCreate(child); // this forces server to send CreateVehicle Message to client. This is needed for preserving the appearance of network operations on client (so that DeleteObject(old) arrives before CreateVehicle(new)). @NOTE: this does not delete the object on server, only it's network representation.
145 }
146 }
147 }
PlayerBase m_Player
script counterpart to engine's class Inventory
Definition Inventory.c:79
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...
InventoryLocation.
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:233

◆ CreateItemBasePiles()

static array< ItemBase > CreateItemBasePiles ( string item_name,
vector ground_position,
float quantity,
float health,
bool floaty_spawn = false )
staticprotected

Spawns multiple piles of stackable ItemBase objects on ground (intended for generic use)

Definition at line 409 of file MiscGameplayFunctions.c.

410 {
412 float max_stack_size;
414
416 max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varStackMax");
417 if (max_stack_size < 1)
418 max_stack_size = g_Game.ConfigGetInt("cfgVehicles " + item_name + " varQuantityMax");
419 if (max_stack_size < 1)
420 max_stack_size = 1;
421
424
425 for (int i = 0; i < full_piles_count; i++)
426 {
427 if (floaty_spawn)
429 else
431 pile.SetQuantity(max_stack_size);
432 pile.SetHealth(health);
433 item_piles.Insert(pile);
434 }
435 if (rest > 0)
436 {
437 if (floaty_spawn)
439 else
441 pile.SetQuantity(rest);
442 pile.SetHealth(health);
443 item_piles.Insert(pile);
444 }
445 return item_piles;
446 }
const int ECE_PLACE_ON_SURFACE
const int ECE_UPDATEPATHGRAPH
const int ECE_CREATEPHYSICS
DayZGame g_Game
Definition DayZGame.c:3528
static proto float Floor(float f)
Returns floor of value.

References ECE_CREATEPHYSICS, ECE_PLACE_ON_SURFACE, ECE_UPDATEPATHGRAPH, Math::Floor(), g_Game, and GetGame().

◆ CreateMagazinePiles()

static array< Magazine > CreateMagazinePiles ( string item_name,
vector ground_position,
float quantity,
float health )
staticprotected

Definition at line 448 of file MiscGameplayFunctions.c.

449 {
451 float stack_size;
453
455 stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
456
459
460 for (int i = 0; i < piles_count; i++)
461 {
463 pile.ServerSetAmmoCount(stack_size);
464 items.Insert(pile);
465 }
466 if (rest > 0)
467 {
469 pile.ServerSetAmmoCount(rest);
470 items.Insert(pile);
471 }
472 return items;
473 }

References ECE_PLACE_ON_SURFACE, Math::Floor(), g_Game, and GetGame().

◆ CreateMagazinePilesFromBullet()

static array< Magazine > CreateMagazinePilesFromBullet ( string bullet_type,
vector ground_position,
float quantity,
float health )
staticprotected

Definition at line 475 of file MiscGameplayFunctions.c.

476 {
479 float stack_size;
481 string item_name;
482 if (!g_Game.ConfigGetText("cfgAmmo " + bullet_type + " spawnPileType", item_name))
483 return items;
484
485 stack_size = g_Game.ConfigGetInt("cfgMagazines " + item_name + " count");
486
487 if (stack_size > 0)
488 {
491
492 for (int i = 0; i < piles_count; i++)
493 {
495 pile.ServerSetAmmoCount(stack_size);
496 items.Insert(pile);
497 }
498 if (rest > 0)
499 {
501 pile.ServerSetAmmoCount(rest);
502 items.Insert(pile);
503 }
504 }
505 return items;
506 }

References ECE_PLACE_ON_SURFACE, Math::Floor(), g_Game, and GetGame().

◆ CreateNetworkObjectInfo()

void CreateNetworkObjectInfo ( EntityAI new_item)
protected

Definition at line 185 of file MiscGameplayFunctions.c.

186 {
187 super.CreateNetworkObjectInfo(new_item);
188 GetGame().RemoteObjectTreeCreate(m_NewItem);
189 }
EntityAI m_NewItem

References GetGame(), and m_NewItem.

◆ DealAbsoluteDmg()

static void DealAbsoluteDmg ( ItemBase item,
float dmg )
staticprotected

Definition at line 1346 of file MiscGameplayFunctions.c.

1347 {
1348 item.DecreaseHealth(dmg, false);
1349 }

◆ DropAllItemsInInventoryInBounds()

static void DropAllItemsInInventoryInBounds ( ItemBase ib,
vector halfExtents )
staticprotected

Definition at line 886 of file MiscGameplayFunctions.c.

887 {
888 if (!GetGame().IsServer())
889 return;
891 ib.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, items);
892
893 vector direction = ib.GetDirection();
895
896 float angle = Math.Acos(dot);
897 if (direction[0] < 0)
898 angle = -angle;
899
900 float cos = Math.Cos(angle);
901 float sin = Math.Sin(angle);
902
904 int count = items.Count();
905 for (int i = 0; i < count; ++i)
906 {
907 item = items.Get(i);
908 if (item)
909 ib.GetInventory().DropEntityInBounds(InventoryMode.SERVER, ib, item, halfExtents, angle, cos, sin);
910 }
911 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static const vector Forward
Definition EnConvert.c:109
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Cos(float angle)
Returns cosinus of angle in radians.

References Math::Acos(), Math::Cos(), vector::Dot(), vector::Forward, GetGame(), and Math::Sin().

◆ DropEquipAndDestroyRootLambda()

void MoveEquipToExistingItemAndDestroyOldRootLambda::DropEquipAndDestroyRootLambda ( EntityAI old_item,
string new_item_type,
PlayerBase player )

Definition at line 109 of file MiscGameplayFunctions.c.

110 {
112 }

◆ FilterObstructedObjectsByGrouping()

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 )
staticprotected

group objects that are close to each other together

Definition at line 1074 of file MiscGameplayFunctions.c.

1075 {
1078
1079 int i = 0;
1080 int j = 0;
1081 int k = 0;
1082 int mCount = vicinityObjects.Count();
1083
1084 if (!filteredObjects)
1086
1087 // Remove objects that are too far from the player anyways
1088 if (doDistanceCheck)
1089 {
1090 for (i = vicinityObjects.Count() - 1; i >= 0; --i)
1091 {
1092 Object obj = vicinityObjects[i];
1093 if (obj && !CanIgnoreDistanceCheck(obj) && vector.DistanceSq(origin, obj.GetPosition()) > maxDist * maxDist)
1094 vicinityObjects.Remove(i);
1095 }
1096 }
1097
1098 // Sort obstructingObjects to have the furthest one first
1102 float distance, dist1, dist2;
1103
1104 for (i = 0; i < obstructingObjects.Count(); ++i)
1105 {
1106 distance = vector.DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
1107 distanceHelper.Insert(distance);
1108 }
1109
1111 distanceHelper.Sort();
1112
1113 for (i = distanceHelper.Count() - 1; i >= 0; --i)
1115
1119
1120 float cos = Math.Cos(90);
1121 float sin = Math.Sin(90);
1122
1123 // Iterate through sorted obstructingObjects
1124 for (i = 0; i < sortedObstructingObjects.Count(); ++i)
1125 {
1127 vector worldPos = obstrObj.GetWorldPosition();
1128 vector min, max;
1129 vector minMax[2];
1130 if (obstrObj.GetCollisionBox(minMax))
1131 {
1132 min = minMax[0];
1133 max = minMax[1];
1134 max = max * (obstrObj.GetOrientation() * range);
1135
1136 vector center, dx, dy, dz, half;
1137 center = (min + max) * 0.5;
1138 dz = obstrObj.GetOrientation();
1141 half = (max - min) * 0.5;
1143
1144 group = new array<Object>;
1145
1146 // Group objects within the above box
1147 for (j = vicinityObjects.Count() - 1; j >= 0; --j)
1148 {
1150 if (vicObj)
1151 {
1152 vector d = vicObj.GetWorldPosition() - worldPos + center;
1153 if (Math.AbsFloat(vector.Dot(d, dx)) <= half[0] && Math.AbsFloat(vector.Dot(d, dy)) <= half[1] && Math.AbsFloat(vector.Dot(d, dz)) <= half[2])
1154 {
1155 group.Insert(vicObj);
1156 vicinityObjects.Remove(j);
1157 }
1158 }
1159 }
1160
1161 if (group.Count() > 0)
1162 tempGroups.Insert(group);
1163 }
1164 }
1165
1166 // Go through the objects grouped by obstruction to split them by distance too
1167 for (i = 0; i < tempGroups.Count(); ++i)
1169
1170 // Split initial groups by distance
1172
1173 // Raycast accordingly to groups
1175 for (i = 0; i < objectGroups.Count(); ++i)
1176 {
1179
1181 filteredObjects.InsertAll(objectGroup);
1182
1183 cache.ClearCache();
1184 }
1185 }
static bool CanIgnoreDistanceCheck(Object obj)
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
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 proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Aside
Definition EnConvert.c:108
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Definition EnConvert.c:478
static const vector Up
Definition EnConvert.c:107
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float AbsFloat(float f)
Returns absolute value.

References Math::AbsFloat(), vector::Aside, CanIgnoreDistanceCheck(), Math::Cos(), vector::DistanceSq(), vector::Dot(), IsObjectObstructedCache(), IsObjectObstructedEx(), vector::RotateAroundZero(), Math::Sin(), SplitArrayIntoGroupsByDistance(), vector::Up, and Vector().

◆ FilterObstructingObjects()

static void FilterObstructingObjects ( array< Object > potentiallyObstructingObjects,
out array< Object > obstructingObjects )
staticprotected

Definition at line 1055 of file MiscGameplayFunctions.c.

1056 {
1057 if (!obstructingObjects)
1059
1060 for (int i = 0; i < potentiallyObstructingObjects.Count(); ++i)
1061 {
1063 if (obj && (obj.CanObstruct() || obj.CanProxyObstruct()))
1064 obstructingObjects.Insert(obj);
1065 }
1066 }

◆ FModulus()

static float FModulus ( float x,
float y )
staticprotected

Definition at line 1380 of file MiscGameplayFunctions.c.

1381 {
1382 return Math.ModFloat(x, y);
1383 }
Icon x
Icon y
static proto float ModFloat(float x, float y)
Returns the floating-point remainder of x/y rounded towards zero.

References Math::ModFloat(), x, and y.

Referenced by Bobbing().

◆ GenerateAINoiseAtPosition()

static void GenerateAINoiseAtPosition ( vector position,
float lifeTime,
NoiseParams noiseParams )
staticprotected

Definition at line 1484 of file MiscGameplayFunctions.c.

1485 {
1486 if (GetGame().IsServer())
1487 {
1488 NoiseSystem noise = GetGame().GetNoiseSystem();
1489 if (noise)
1490 noise.AddNoiseTarget(position, lifeTime, noiseParams);
1491 }
1492 }

References GetGame().

◆ GetAttachedChildren()

static void GetAttachedChildren ( IEntity parent,
array< IEntity > outputObjects )
staticprotected

Fills the provided array with all children entities in hierarchy of this entity.

Definition at line 1578 of file MiscGameplayFunctions.c.

1579 {
1580 IEntity child = parent.GetChildren();
1581 while (child)
1582 {
1583 outputObjects.Insert(child);
1584 child = child.GetSibling();
1585 }
1586 }
proto native IEntity GetChildren()
Returns pointer to first child Entity in hierarchy.

References IEntity::GetChildren().

◆ GetClosestSafePos()

static vector GetClosestSafePos ( vector to_pos,
notnull array< ref array< float > > positions )
staticprotected

Definition at line 1463 of file MiscGameplayFunctions.c.

1464 {
1466 float smallest_dist = float.MAX;
1467 foreach (array<float> pos: positions)
1468 {
1469 vector vpos = "0 0 0";
1470 vpos[0] = pos[0];
1471 vpos[2] = pos[1];
1472
1473 to_pos[1] = 0;
1474 float dist = vector.DistanceSq(to_pos, vpos);//2d dist sq
1475 if (dist < smallest_dist)
1476 {
1478 closest_pos = vpos;
1479 }
1480 }
1481 return closest_pos;
1482 }

References vector::DistanceSq().

◆ GetColorString()

static string GetColorString ( float r,
float g,
float b,
float a )
staticprotected

Definition at line 231 of file MiscGameplayFunctions.c.

232 {
233 return string.Format("#(argb,8,8,3)color(%1,CO)", string.Format("%1,%2,%3,%4", r, g, b, a));
234 }

References string::Format().

◆ GetComponentIndex()

static int GetComponentIndex ( array< Selection > pSelection,
string pCompName )
staticprotected

Definition at line 1538 of file MiscGameplayFunctions.c.

1539 {
1540 if (!MiscGameplayFunctions.IsComponentInSelection(pSelection, pCompName))
1541 return INDEX_NOT_FOUND;
1542
1543 for (int i = 0; i < pSelection.Count(); ++i)
1544 {
1545 pCompName.ToLower();
1546 if (pSelection[i] && pSelection[i].GetName() == pCompName)
1547 return i;
1548 }
1549
1550 return INDEX_NOT_FOUND;
1551 }
const int INDEX_NOT_FOUND
Definition gameplay.c:13
proto native owned string GetName()

References GetName(), and INDEX_NOT_FOUND.

◆ GetCurrentItemHeatIsolation()

static float GetCurrentItemHeatIsolation ( ItemBase pItem)
staticprotected

item heat isolation (from cfg)

item health (state)

item wetness

wet factor selection

health factor selection

apply factors

Definition at line 1003 of file MiscGameplayFunctions.c.

1004 {
1005 float wetFactor;
1006 float healthFactor;
1007
1008 float heatIsolation = pItem.GetHeatIsolation();
1009 float itemHealthLabel = pItem.GetHealthLevel();
1010 float itemWetness = pItem.GetWet();
1011
1023
1025 switch (itemHealthLabel)
1026 {
1029 break;
1030
1033 break;
1034
1037 break;
1038
1041 break;
1042
1045 break;
1046 }
1047
1051
1052 return heatIsolation;
1053 }
const float ENVIRO_ISOLATION_WETFACTOR_SOAKED
Definition constants.c:712
const float ENVIRO_ISOLATION_WETFACTOR_WET
Definition constants.c:711
const float ENVIRO_ISOLATION_WETFACTOR_DAMP
Definition constants.c:710
const float ENVIRO_ISOLATION_WETFACTOR_DRENCHED
Definition constants.c:713
const float ENVIRO_ISOLATION_HEALTHFACTOR_RUINED
Definition constants.c:719
const float ENVIRO_ISOLATION_HEALTHFACTOR_DAMAGED
Definition constants.c:717
const float ENVIRO_ISOLATION_HEALTHFACTOR_WORN
Definition constants.c:716
const float ENVIRO_ISOLATION_WETFACTOR_DRY
Heat buffer static timer tick (set for 2s enviro tick, 180s to 1.0)
Definition constants.c:709
const float ENVIRO_ISOLATION_HEALTHFACTOR_PRISTINE
impact of item health (state) to the heat isolation
Definition constants.c:715
const float ENVIRO_ISOLATION_HEALTHFACTOR_B_DAMAGED
Definition constants.c:718
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758
const int STATE_PRISTINE
Definition constants.c:761
const float STATE_DRY
Definition constants.c:785
const float STATE_DAMP
Definition constants.c:784
const float STATE_SOAKING_WET
Definition constants.c:782
const float STATE_DRENCHED
Definition constants.c:781
const float STATE_WET
Definition constants.c:783

References GameConstants::ENVIRO_ISOLATION_HEALTHFACTOR_B_DAMAGED, GameConstants::ENVIRO_ISOLATION_HEALTHFACTOR_DAMAGED, GameConstants::ENVIRO_ISOLATION_HEALTHFACTOR_PRISTINE, GameConstants::ENVIRO_ISOLATION_HEALTHFACTOR_RUINED, GameConstants::ENVIRO_ISOLATION_HEALTHFACTOR_WORN, GameConstants::ENVIRO_ISOLATION_WETFACTOR_DAMP, GameConstants::ENVIRO_ISOLATION_WETFACTOR_DRENCHED, GameConstants::ENVIRO_ISOLATION_WETFACTOR_DRY, GameConstants::ENVIRO_ISOLATION_WETFACTOR_SOAKED, GameConstants::ENVIRO_ISOLATION_WETFACTOR_WET, GameConstants::STATE_BADLY_DAMAGED, GameConstants::STATE_DAMAGED, GameConstants::STATE_DAMP, GameConstants::STATE_DRENCHED, GameConstants::STATE_DRY, GameConstants::STATE_PRISTINE, GameConstants::STATE_RUINED, GameConstants::STATE_SOAKING_WET, GameConstants::STATE_WET, and GameConstants::STATE_WORN.

◆ GetEnergyMetabolicSpeed()

static float GetEnergyMetabolicSpeed ( int movement_speed)
staticprotected

Definition at line 585 of file MiscGameplayFunctions.c.

586 {
587 float speed;
588 switch (movement_speed)
589 {
590 case DayZPlayerConstants.MOVEMENTIDX_WALK:
592 break;
593 case DayZPlayerConstants.MOVEMENTIDX_RUN:
595 break;
596 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
598 break;
599 default:
600 speed = 0;
601 break;
602 }
603
605 return speed;
606 }
static const float METABOLIC_SPEED_ENERGY_JOG
static const float METABOLIC_SPEED_ENERGY_WALK
static const float METABOLIC_SPEED_ENERGY_SPRINT
static const float METABOLIC_SPEED_ENERGY_BASAL
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References PlayerConstants::METABOLIC_SPEED_ENERGY_BASAL, PlayerConstants::METABOLIC_SPEED_ENERGY_JOG, PlayerConstants::METABOLIC_SPEED_ENERGY_SPRINT, and PlayerConstants::METABOLIC_SPEED_ENERGY_WALK.

◆ GetHeadBonePos()

static void GetHeadBonePos ( notnull PlayerBase player,
out vector pos )
staticprotected

Definition at line 557 of file MiscGameplayFunctions.c.

558 {
559 // Get position of head for starting trace pos, otherwise use sane default
560 int headBoneIdx = player.GetBoneIndexByName("Head");
561 if (headBoneIdx == -1)
562 pos = player.GetPosition()[1] + 1.6;
563 else
564 pos = player.GetBonePositionWS(headBoneIdx);
565 }

◆ GetHeadingAngle()

static float GetHeadingAngle ( notnull DayZPlayerImplement player)
staticprotected

Definition at line 577 of file MiscGameplayFunctions.c.

578 {
579 HumanInputController hic = player.GetInputController();
580 float headingAngle = hic.GetHeadingAngle();
581
582 return headingAngle;
583 }

Referenced by GetHeadingVector().

◆ GetHeadingVector()

static vector GetHeadingVector ( notnull PlayerBase player)
staticprotected

Definition at line 567 of file MiscGameplayFunctions.c.

568 {
569 vector dir = vector.Zero;
571 dir[0] = Math.Cos(headingAngle + Math.PI_HALF);
572 dir[2] = Math.Sin(headingAngle + Math.PI_HALF);
573
574 return dir.Normalized();
575 }
static float GetHeadingAngle(notnull DayZPlayerImplement player)
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
static const vector Zero
Definition EnConvert.c:110
static const float PI_HALF
Definition EnMath.c:14

References Math::Cos(), GetHeadingAngle(), vector::Normalized(), Math::PI_HALF, Math::Sin(), and vector::Zero.

◆ GetHealthLevelForAmmo()

static int GetHealthLevelForAmmo ( string class_name,
float health )
staticprotected

Definition at line 508 of file MiscGameplayFunctions.c.

509 {
510 float health_normalized = health / 100;
511 string config_path = CFG_WEAPONSPATH + " " + class_name + " DamageSystem" + " GlobalHealth" + " healthLabels";
513 GetGame().ConfigGetFloatArray(config_path, CachedObjectsArrays.ARRAY_FLOAT);
514 for (int i = 0; i < CachedObjectsArrays.ARRAY_FLOAT.Count(); i++)
515 {
517 return i;
518 }
519 return -1;
520 }
class OptionSelectorMultistate extends OptionSelector class_name
static ref TFloatArray ARRAY_FLOAT
const string CFG_WEAPONSPATH
Definition constants.c:210

References CachedObjectsArrays::ARRAY_FLOAT, CFG_WEAPONSPATH, class_name, and GetGame().

◆ GetItemDisplayName()

static string GetItemDisplayName ( string type)
staticprotected

Definition at line 1518 of file MiscGameplayFunctions.c.

1519 {
1520 return GetGame().ConfigGetTextOut("CfgVehicles " + type + " displayName");
1521 }

References GetGame().

◆ GetMaxValue()

static float GetMaxValue ( array< float > pArray)
staticprotected

Definition at line 1506 of file MiscGameplayFunctions.c.

1507 {
1508 float maxValue = 0.0;
1509 for (int i = 0; i < pArray.Count(); i++)
1510 {
1511 if (maxValue == 0 || pArray.Get(i) > maxValue)
1512 maxValue = pArray.Get(i);
1513 }
1514
1515 return maxValue;
1516 }

◆ GetMinValue()

static float GetMinValue ( array< float > pArray)
staticprotected

Definition at line 1494 of file MiscGameplayFunctions.c.

1495 {
1496 float minValue = 0.0;
1497 for (int i = 0; i < pArray.Count(); i++)
1498 {
1499 if (minValue == 0 || pArray.Get(i) < minValue)
1500 minValue = pArray.Get(i);
1501 }
1502
1503 return minValue;
1504 }

◆ GetProjectedCursorPos3d()

static bool GetProjectedCursorPos3d ( out vector position,
Weapon_Base weapon )
staticprotected

Definition at line 539 of file MiscGameplayFunctions.c.

540 {
541 vector usti_hlavne_position = weapon.GetSelectionPositionMS("usti hlavne");
542 vector konec_hlavne_position = weapon.GetSelectionPositionMS("konec hlavne");
547
551
553 return true;
554 return false;
555 }
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.
const float PROJECTED_CURSOR_DISTANCE
Definition constants.c:591

References PROJECTED_CURSOR_DISTANCE, and DayZPhysics::RaycastRV().

◆ GetSteamPosition()

static vector GetSteamPosition ( EntityAI parent)
staticprotected

Definition at line 855 of file MiscGameplayFunctions.c.

856 {
858 float steam_offset = 0;
859
860 if (parent)
861 {
862 particle_pos = parent.GetPosition();
863
864 if (parent.IsInherited(PortableGasStove))
865 steam_offset = 0.2;
866 else if (parent.IsInherited(FireplaceBase))
867 {
869
870 if (fireplace.IsBaseFireplace())
871 steam_offset = 0.8;
872 else if (fireplace.IsBarrelWithHoles())
873 steam_offset = 1.1;
874 else if (fireplace.IsFireplaceIndoor())
875 steam_offset = 0.45;
876 else if (fireplace.IsIndoorOven())
877 steam_offset = 0.9;
878 }
879 }
880
882
883 return particle_pos;
884 }

◆ GetTypeMaxGlobalHealth()

static float GetTypeMaxGlobalHealth ( string class_name,
string health_type = "Health" )
staticprotected

Definition at line 522 of file MiscGameplayFunctions.c.

523 {
524 float max_health;
525 string cfg_path;
526
527 if (GetGame().ConfigIsExisting(CFG_VEHICLESPATH + " " + class_name))
529 else if (GetGame().ConfigIsExisting(CFG_WEAPONSPATH + " " + class_name))
531 else if (GetGame().ConfigIsExisting(CFG_MAGAZINESPATH + " " + class_name))
533 cfg_path = cfg_path + " " + class_name + " DamageSystem GlobalHealth " + health_type + " hitpoints";
534 max_health = GetGame().ConfigGetFloat(cfg_path);
535
536 return max_health;
537 }
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_MAGAZINESPATH
Definition constants.c:211

References CFG_MAGAZINESPATH, CFG_VEHICLESPATH, CFG_WEAPONSPATH, class_name, and GetGame().

◆ GetWaterMetabolicSpeed()

static float GetWaterMetabolicSpeed ( int movement_speed)
staticprotected

Definition at line 608 of file MiscGameplayFunctions.c.

609 {
610 float speed;
611 switch (movement_speed)
612 {
613 case DayZPlayerConstants.MOVEMENTIDX_WALK:
615 break;
616 case DayZPlayerConstants.MOVEMENTIDX_RUN:
618 break;
619 case DayZPlayerConstants.MOVEMENTIDX_SPRINT:
621 break;
622 default:
623 speed = 0;
624 break;
625 }
626
628 return speed;
629 }
static const float METABOLIC_SPEED_WATER_BASAL
static const float METABOLIC_SPEED_WATER_WALK
static const float METABOLIC_SPEED_WATER_JOG
static const float METABOLIC_SPEED_WATER_SPRINT

References PlayerConstants::METABOLIC_SPEED_WATER_BASAL, PlayerConstants::METABOLIC_SPEED_WATER_JOG, PlayerConstants::METABOLIC_SPEED_WATER_SPRINT, and PlayerConstants::METABOLIC_SPEED_WATER_WALK.

◆ InsertAtPos()

static string InsertAtPos ( string base,
string insert,
int pos )
staticprotected

Insert 'insert' behind index 'pos' of the 'base' string.

Definition at line 248 of file MiscGameplayFunctions.c.

249 {
250 int length_first = pos + 1;
251 int length_base = base.Length();
253 string first = base.Substring(0, length_first);
254 string second = base.Substring(pos + 1, length_second);
255 return first + insert + second;
256 }

Referenced by ValueToBar().

◆ IsComponentInSelection()

static bool IsComponentInSelection ( array< Selection > pSelection,
string pCompName )
staticprotected

Definition at line 1523 of file MiscGameplayFunctions.c.

1524 {
1525 if (pSelection.Count() == 0 || pCompName.Length() == 0)
1526 return false;
1527
1528 for (int i = 0; i < pSelection.Count(); ++i)
1529 {
1530 pCompName.ToLower();
1531 if (pSelection[i] && pSelection[i].GetName() == pCompName)
1532 return true;
1533 }
1534
1535 return false;
1536 }

References GetName().

◆ IsObjectObstructed()

static bool IsObjectObstructed ( Object object,
bool doDistanceCheck = false,
vector distanceCheckPos = "0 0 0",
float maxDist = 0 )
staticprotected

◆ IsObjectObstructedCache()

void IsObjectObstructedCache ( vector rayCastStart,
int totalObjects )
protected

Definition at line 1636 of file MiscGameplayFunctions.c.

1637 {
1640 }
DestroyItemInCorpsesHandsAndCreateNewOnGndLambda RaycastStart
int TotalObjects

References RaycastStart, and TotalObjects.

Referenced by ActionTargets::FilterObstructedObjects(), FilterObstructedObjectsByGrouping(), IsObjectObstructed(), and ActionTargets::IsObstructed().

◆ IsObjectObstructedEx()

static bool IsObjectObstructedEx ( Object object,
IsObjectObstructedCache cache,
bool doDistanceCheck = false,
vector distanceCheckPos = "0 0 0",
float maxDist = 0 )
staticprotected

Definition at line 1230 of file MiscGameplayFunctions.c.

1231 {
1232 if (!object)
1233 return true;
1234
1235 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
1237 return true;
1238
1239 cache.ObjectCenterPos = object.GetCenter();
1240
1241 return IsObjectObstructedFilterEx(object, cache, player);
1242 }
static bool IsObjectObstructedFilterEx(Object object, IsObjectObstructedCache cache, PlayerBase player, int geometryTypeOverride=-1)
groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometr...

References vector::DistanceSq(), g_Game, and IsObjectObstructedFilterEx().

Referenced by FilterObstructedObjectsByGrouping(), and IsObjectObstructed().

◆ IsObjectObstructedFilter()

static bool IsObjectObstructedFilter ( Object object,
IsObjectObstructedCache cache,
PlayerBase player )
staticprotected

Definition at line 1273 of file MiscGameplayFunctions.c.

1274 {
1275 for (int m = 0; m < cache.HitObjects.Count(); m++)
1276 {
1277 Object hit_object = cache.HitObjects.Get(m);
1278
1279 if (hit_object.CanObstruct())
1280 return true;
1281
1282 //4.3. ignore item if items are big and heavy >= OBJECT_OBSTRUCTION_WEIGHT
1283 //EntityAI eai;
1284 //if ( Class.CastTo( eai, hit_object ) )
1285 //{
1286 // if ( eai.GetWeight() >= OBJECT_OBSTRUCTION_WEIGHT )
1287 // {
1288 // if ( eai != filtered_object && eai.GetHierarchyRoot() != filtered_object )
1289 // {
1290 // //Print("!!!!!obstacle vaha: " + hit_object);
1291 // is_obstructed = true;
1292 // }
1293 // }
1294 //}
1295 }
1296
1297 return false;
1298 }

◆ IsObjectObstructedFilterEx()

static bool IsObjectObstructedFilterEx ( Object object,
IsObjectObstructedCache cache,
PlayerBase player,
int geometryTypeOverride = -1 )
staticprotected

groups 'RaycastRVProxy' and 'RaycastRV' approaches into one method, allowes for comprehensive geometry override, if desired

Definition at line 1301 of file MiscGameplayFunctions.c.

1302 {
1303 //first proxy geometries
1304 RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
1305 rayInput.flags = CollisionFlags.ALLOBJECTS;
1306 if (geometryTypeOverride != -1)
1307 rayInput.type = geometryTypeOverride; //default 'ObjIntersectView'
1308 DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
1309 int count;
1310 int i;
1311
1312 if (cache.HitProxyObjects)
1313 {
1314 count = cache.HitProxyObjects.Count();
1315 Object parent;
1316 for (i = 0; i < count; i++)
1317 {
1318 if (cache.HitProxyObjects[i].hierLevel > 0) //parent has to exist, skipping nullcheck
1319 {
1320 parent = cache.HitProxyObjects[i].parent;
1321 if (parent && !parent.IsMan() && parent.CanProxyObstruct())
1322 {
1323 if (parent != object || (parent == object && object.CanProxyObstructSelf()))
1324 return true;
1325 }
1326 }
1327 }
1328 }
1329
1330 //second, regular raycast
1331 int geometry = ObjIntersectFire; //default for the RV raycast
1332 if (geometryTypeOverride != -1)
1334 DayZPhysics.RaycastRV(cache.RaycastStart, cache.ObjectCenterPos, cache.ObjectContactPos, cache.ObjectContactDir, cache.ContactComponent, cache.HitObjects, object, GetGame().GetPlayer(), false, false, geometry, 0.0, CollisionFlags.ALLOBJECTS);
1335 count = cache.HitObjects.Count();
1336 for (i = 0; i < count; i++)
1337 {
1338 if (cache.HitObjects[i].CanObstruct())
1339 return true;
1340 }
1341
1342 return false;
1343 }
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
CollisionFlags
Definition EnDebug.c:141

References GetGame(), GetPlayer(), DayZPhysics::RaycastRV(), and DayZPhysics::RaycastRVProxy().

Referenced by IsObjectObstructedEx().

◆ IsObjectObstructedProxy()

static bool IsObjectObstructedProxy ( Object object,
IsObjectObstructedCache cache,
PlayerBase player )
staticprotected

Definition at line 1244 of file MiscGameplayFunctions.c.

1245 {
1246 if (object.CanProxyObstruct())
1247 {
1248 RaycastRVParams rayInput = new RaycastRVParams(cache.RaycastStart, cache.ObjectCenterPos, player);
1249 DayZPhysics.RaycastRVProxy(rayInput, cache.HitProxyObjects);
1250 if (cache.HitProxyObjects)
1251 {
1252 if (cache.HitProxyObjects.Count() > 0)
1253 {
1254 if (cache.HitProxyObjects[0].hierLevel > 0)
1255 {
1256 // ignores attachments on player
1257 if (!cache.HitProxyObjects[0].parent.IsMan())
1258 {
1259 if (cache.HitProxyObjects[0].parent)
1260 {
1261 EntityAI proxyParent = EntityAI.Cast(cache.HitProxyObjects[0].parent);
1262 if (proxyParent.GetInventory() && proxyParent.GetInventory().GetCargo())
1263 return true;
1264 }
1265 }
1266 }
1267 }
1268 }
1269 }
1270 return false;
1271 }

References DayZPhysics::RaycastRVProxy().

◆ IsPlayerOrientedTowardPos()

static bool IsPlayerOrientedTowardPos ( notnull DayZPlayerImplement player,
vector target_pos,
float cone_angle )
staticprotected

Check if player direction(based on cone of defined angle) is oriented to target position.

dir in cone or in a tip of cone

Definition at line 669 of file MiscGameplayFunctions.c.

670 {
671 if (player)
672 {
673 vector player_dir = player.GetDirection();
674 vector to_target_dir = target_pos - player.GetPosition();
675
676 player_dir[1] = 0;
677 to_target_dir[1] = 0;
678
679 player_dir.Normalize();
680 to_target_dir.Normalize();
681
684
685 int dir = Math.Acos(cos_fi) * Math.RAD2DEG;
686
687 if (cross[1] < 0)
688 dir = -dir;
689
692 return true;
693 }
694
695 return false;
696 }
static const float RAD2DEG
Definition EnMath.c:16

References Math::AbsFloat(), Math::Acos(), vector::Dot(), and Math::RAD2DEG.

◆ IsUnderRoof()

static bool IsUnderRoof ( EntityAI entity,
float height = GameConstants.ROOF_CHECK_RAYCAST_DIST )
staticprotected

Definition at line 821 of file MiscGameplayFunctions.c.

822 {
824 }
static bool IsUnderRoofEx(EntityAI entity, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST, int geometry=ObjIntersectView)

References IsUnderRoofEx().

◆ IsUnderRoofEx()

static bool IsUnderRoofEx ( EntityAI entity,
float height = GameConstants.ROOF_CHECK_RAYCAST_DIST,
int geometry = ObjIntersectView )
staticprotected

Definition at line 826 of file MiscGameplayFunctions.c.

827 {
828 vector from;
829 vector to;
830
832
835
837 //set<Object> hit_object = new set<Object>;
838 bool boo = DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contact_component, /*hit_object*/NULL, NULL, entity, false, false, geometry, 0.25);
839
840 /*if (boo)
841 {
842 Debug.DrawSphere(from , 0.8,Colors.YELLOW, ShapeFlags.ONCE);
843 Debug.DrawSphere(to , 0.8,Colors.RED, ShapeFlags.ONCE);
844 }
845 else
846 {
847 Debug.DrawSphere(from , 0.8,Colors.GREEN, ShapeFlags.ONCE);
848 Debug.DrawSphere(to , 0.8,Colors.RED, ShapeFlags.ONCE);
849 }*/
850
851 return boo;
852 }
static void IsUnderRoofFromToCalculation(EntityAI entity, out vector from, out vector to, float height=GameConstants.ROOF_CHECK_RAYCAST_DIST)

References IsUnderRoofFromToCalculation(), and DayZPhysics::RaycastRV().

Referenced by IsUnderRoof().

◆ IsUnderRoofFromToCalculation()

static void IsUnderRoofFromToCalculation ( EntityAI entity,
out vector from,
out vector to,
float height = GameConstants.ROOF_CHECK_RAYCAST_DIST )
staticprotected

Definition at line 797 of file MiscGameplayFunctions.c.

798 {
799 vector minMax[2];
800 entity.GetCollisionBox(minMax);
801
802 vector size = Vector(0, 0, 0);
803 //size[1] = minMax[1][1] - minMax[0][1];
804 float from_override = entity.HeightStartCheckOverride();
805 if (from_override > 0.0)
806 size[1] = from_override;
807 else
808 size[1] = minMax[1][1] - minMax[0][1];
809
810 from = entity.GetPosition() + size;
811 if (entity.HeightCheckOverride() > 0)
812 to = entity.GetPosition() + Vector(0, entity.HeightCheckOverride(), 0);
813 else
814 {
815 vector ceiling = "0 0 0";
816 ceiling[1] = height;
817 to = from + ceiling; //+size ??? offset to cast same distance
818 }
819 }

References Vector().

Referenced by IsUnderRoofEx().

◆ IsValueInRange()

static bool IsValueInRange ( float value,
float from,
float to )
staticprotected

Definition at line 663 of file MiscGameplayFunctions.c.

664 {
665 return (value >= from) && (value <= to);
666 }

◆ MoveEquipToExistingItemAndDestroyOldRootLambda()

void MoveEquipToExistingItemAndDestroyOldRootLambda ( EntityAI old_item,
string new_item_type,
PlayerBase player,
EntityAI new_item )

Definition at line 158 of file MiscGameplayFunctions.c.

159 {
162 if (new_item_type != string.Empty)
163 Error("MoveEquipAndDestroyRootLambda expects new_item_type to be empty");
164 }
Empty
Definition Hand_States.c:14
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References Empty, Error(), m_NewItem, and m_Player.

Referenced by ActionPlaceFireplaceIntoBarrel::OnExecuteServer().

◆ Normalize()

static float Normalize ( int val,
int maxVal )
staticprotected

Definition at line 1352 of file MiscGameplayFunctions.c.

1353 {
1354 if (maxVal == 0)
1355 {
1356 Debug.LogError("Division by 0 is not allowed");
1357 return 0;
1358 }
1359
1360 return val / maxVal;
1361 }
Definition Debug.c:14
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.
Definition Debug.c:341

References Debug::LogError().

◆ ObtainRestrainItemTargetClassname()

static string ObtainRestrainItemTargetClassname ( notnull EntityAI entity)
staticprotected

Definition at line 631 of file MiscGameplayFunctions.c.

632 {
633 return entity.ConfigGetString("OnRestrainChange");
634 }

◆ OnSuccess()

class TurnItemIntoItemLambdaAnimSysNotifyLambda extends TurnItemIntoItemLambda OnSuccess ( EntityAI new_item)

Definition at line 83 of file MiscGameplayFunctions.c.

96 {
97 super.OnSuccess(new_item);
98 m_Player.SetRestrained(true);
99 }

◆ RemoveAllAttachedChildrenByTypename()

static void RemoveAllAttachedChildrenByTypename ( notnull EntityAI parent,
array< typename > listOfTypenames )
staticprotected

Definition at line 1553 of file MiscGameplayFunctions.c.

1554 {
1555 if (listOfTypenames.Count() > 0)
1556 {
1557 Object child = Object.Cast(parent.GetChildren());
1558 while (child)
1559 {
1561 child = Object.Cast(child.GetSibling());
1562
1563 if (childToRemove.IsAnyInherited(listOfTypenames))
1564 {
1565 vector pos = childToRemove.GetPosition();
1566 parent.RemoveChild(childToRemove, false);
1567
1568 vector m4[4];
1570 m4[3] = pos;
1571 childToRemove.SetTransform(m4);
1572 childToRemove.PlaceOnSurface();
1573 }
1574 }
1575 }
1576 }

References Math3D::MatrixIdentity4().

◆ RemoveNetworkObjectInfo()

void RemoveNetworkObjectInfo ( )
protected

Definition at line 166 of file MiscGameplayFunctions.c.

167 {
168 super.RemoveNetworkObjectInfo();
169 GetGame().RemoteObjectTreeDelete(m_NewItem);
170 }

References GetGame(), and m_NewItem.

◆ RemoveSplint()

static void RemoveSplint ( PlayerBase player)
staticprotected

Definition at line 1385 of file MiscGameplayFunctions.c.

1386 {
1387 EntityAI entity = player.GetInventory().CreateInInventory("Splint");
1388 if (!entity)
1389 entity = player.SpawnEntityOnGroundOnCursorDir("Splint", 0.5);
1390
1393 Class.CastTo(attachment, player.GetItemOnSlot("Splint_Right"));
1394 if (attachment && attachment.GetType() == "Splint_Applied")
1395 {
1396 if (new_item)
1397 {
1398 MiscGameplayFunctions.TransferItemProperties(attachment, new_item);
1399
1400 if (GetGame().IsServer())
1401 {
1402 //Lower health level of splint after use
1403 if (new_item.GetHealthLevel() < 4)
1404 {
1405 int newDmgLevel = new_item.GetHealthLevel() + 1;
1406
1407 float max = new_item.GetMaxHealth("", "");
1408
1409 switch (newDmgLevel)
1410 {
1413 break;
1414
1416 new_item.SetHealth("", "", max * GameConstants.DAMAGE_DAMAGED_VALUE);
1417 break;
1418
1420 new_item.SetHealth("", "", max * GameConstants.DAMAGE_WORN_VALUE);
1421 break;
1422
1424 new_item.SetHealth("", "", max * GameConstants.DAMAGE_RUINED_VALUE);
1425 break;
1426
1427 default:
1428 break;
1429 }
1430 }
1431 }
1432 }
1433
1434 attachment.Delete();
1435 }
1436 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float DAMAGE_BADLY_DAMAGED_VALUE
Definition constants.c:772
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const float DAMAGE_WORN_VALUE
Definition constants.c:770

References Class::CastTo(), GameConstants::DAMAGE_BADLY_DAMAGED_VALUE, GameConstants::DAMAGE_DAMAGED_VALUE, GameConstants::DAMAGE_RUINED_VALUE, GameConstants::DAMAGE_WORN_VALUE, GetGame(), GameConstants::STATE_BADLY_DAMAGED, GameConstants::STATE_DAMAGED, GameConstants::STATE_RUINED, and GameConstants::STATE_WORN.

◆ SanitizeString()

static string SanitizeString ( string input)
staticprotected

Definition at line 699 of file MiscGameplayFunctions.c.

700 {
701 int max_length = 512;
702 string output = input;
703
704 output = output.Substring(0, Math.Clamp(max_length, 0, output.Length()));
705 return output;
706 }
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'.

References Math::Clamp().

◆ SoakItemInsideParentContainingLiquidAboveThreshold()

static void SoakItemInsideParentContainingLiquidAboveThreshold ( notnull ItemBase item,
notnull ItemBase parent,
float liquidQuantityThresholdPercentage = 0.05 )
staticprotected

Definition at line 1588 of file MiscGameplayFunctions.c.

1589 {
1590 if (g_Game.IsServer())
1591 {
1592 if (parent.GetLiquidType() != 0 && parent.GetQuantityNormalized() > liquidQuantityThresholdPercentage)
1593 item.SetWetMax();
1594 }
1595 }

References g_Game.

◆ SplitArrayIntoGroupsByDistance()

static void SplitArrayIntoGroupsByDistance ( array< Object > objects,
array< ref array< Object > > objectGroups,
float squaredDistanceDelta )
staticprotected

Definition at line 1187 of file MiscGameplayFunctions.c.

1188 {
1190 for (int i = 0; i < objects.Count();)
1191 {
1192 Object obj1 = objects[i];
1193 if (obj1)
1194 {
1195 group = new array<Object>;
1196 group.Insert(obj1);
1197 for (int j = objects.Count() - 1; j > i; --j)
1198 {
1199 Object obj2 = objects[j];
1200 if (obj1 && obj2)
1201 {
1202 vector start = obj1.GetWorldPosition();
1203 vector end = obj2.GetWorldPosition();
1204
1207 {
1208 group.Insert(obj2);
1209 objects.Remove(j);
1210 }
1211 }
1212 }
1213 objectGroups.Insert(group);
1214 objects.Remove(i);
1215 continue;
1216 }
1217 ++i;
1218 }
1219 }

References vector::DistanceSq().

Referenced by FilterObstructedObjectsByGrouping().

◆ TeleportCheck()

static void TeleportCheck ( notnull PlayerBase player,
notnull array< ref array< float > > safe_positions )
staticprotected

checks if we should teleport the player to a safe location and if so, performs the teleportation

Definition at line 1439 of file MiscGameplayFunctions.c.

1440 {
1441 if (player.GetSimulationTimeStamp() < 20 && !player.IsPersistentFlag(PersistentFlag.AREA_PRESENCE))
1442 {
1443 //simulation time is bellow a threshold, which means the player has recently connected,
1444 //the player does not have the AREA_PRESENCE flag set, which means they were not inside the area when they disconnected,
1445 //that means they just spawned into a contaminated area, lets move them somewhere safe
1446 vector player_pos = player.GetPosition();
1448
1450 {
1452
1453 player.SetPosition(closest_safe_pos); //...so lets teleport them somewhere safe
1454 //DeveloperTeleport.SetPlayerPosition(player, closest_safe_pos);
1455 GetGame().RPCSingleParam(player, ERPCs.RPC_WARNING_TELEPORT, null, true, player.GetIdentity());
1456 }
1457
1458 player.SetPersistentFlag(PersistentFlag.AREA_PRESENCE, false);
1459 }
1460 }
ERPCs
Definition ERPCs.c:2
PersistentFlag

References GetGame().

◆ ThrowAllItemsInInventory()

static void ThrowAllItemsInInventory ( notnull EntityAI parent,
int flags )
staticprotected

Definition at line 913 of file MiscGameplayFunctions.c.

914 {
915 vector position = parent.GetPosition();
916 vector orientation = parent.GetOrientation();
918 float direction[4];
919
920 vector minmax[2];
921 parent.GetCollisionBox(minmax);
922
925
927 for (int i = 0; i < parent.GetInventory().AttachmentCount(); ++i)
928 {
930 position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
931 position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
932
933 ThrowEntityFromInventory(parent.GetInventory().GetAttachmentFromIndex(i), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
934 }
935
936 for (int j = 0; j < parent.GetInventory().GetCargo().GetItemCount(); ++j)
937 {
939 position[1] + Math.RandomFloat(minmax[0][1], minmax[1][1]),
940 position[2] + Math.RandomFloat(minmax[0][2], minmax[1][2]));
941
942 ThrowEntityFromInventory(parent.GetInventory().GetCargo().GetItem(j), randomPos, direction, -GetVelocity(parent), ThrowEntityFlags.NONE);
943 }
944 }
static void ThrowEntityFromInventory(notnull EntityAI entity, vector position, float direction[4], vector force, int flags)
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 proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.

References GetVelocity(), Math3D::MatrixToQuat(), Math::RandomFloat(), ThrowEntityFromInventory(), Vector(), and Math3D::YawPitchRollMatrix().

◆ ThrowEntityFromInventory()

static void ThrowEntityFromInventory ( notnull EntityAI entity,
vector position,
float direction[4],
vector force,
int flags )
staticprotected

Definition at line 946 of file MiscGameplayFunctions.c.

947 {
949 if (!GetGame().IsMultiplayer())
950 invMode = InventoryMode.LOCAL;
951
953 if (CastTo(entityIB, entity))
954 {
956 dst.SetGroundEx(entity, position, direction);
957
958 if ((flags & ThrowEntityFlags.SPLIT) && entityIB.CanBeSplit())
959 {
960 for (int l = 0; l < entityIB.GetQuantity(); ++l)
961 {
963
964 if (new_item)
965 {
966 MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
967 entityIB.AddQuantity(-1);
968 new_item.SetQuantity(1);
969 new_item.ThrowPhysically(null, force, false);
970 }
971 }
972 }
973 else
974 {
975 float stackable = entityIB.GetTargetQuantityMax();
976 if (!(stackable == 0 || stackable >= entityIB.GetQuantity()))
977 {
978 while (entityIB.GetQuantity() > stackable)
979 {
981 position[1] = position[1] + 0.1;
982 spltDst.SetGroundEx(entity, position, direction);
983
984 ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx(spltDst);
985 splitItem.ThrowPhysically(null, force, false);
986 }
987 }
988
990 entity.GetInventory().GetCurrentInventoryLocation(src);
991
992 entity.GetInventory().TakeToDst(invMode, src, dst);
993 entityIB.ThrowPhysically(null, force, false);
994 }
995 }
996 else
997 {
998 entity.GetInventory().DropEntity(invMode, entity.GetHierarchyRoot(), entity);
1000 }
1001 }
const int ECE_NONE
const int RF_DEFAULT
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)

References dBodyApplyImpulse(), ECE_NONE, GetGame(), GameInventory::LocationCreateEntity(), and RF_DEFAULT.

Referenced by ThrowAllItemsInInventory().

◆ TransferInventory()

static TransferInventoryResult TransferInventory ( EntityAI sourceItem,
EntityAI targetItem,
PlayerBase player )
staticprotected

Definition at line 316 of file MiscGameplayFunctions.c.

317 {
319
321 sourceItem.GetInventory().EnumerateInventory(InventoryTraversalType.LEVELORDER, children);
322 int count = children.Count();
323 for (int i = 0; i < count; i++)
324 {
325 EntityAI child = children.Get(i);
326 if (child)
327 {
329 child.GetInventory().GetCurrentInventoryLocation(child_src);
330
332 child_dst.Copy(child_src);
333 child_dst.SetParent(targetItem);
334
335 bool drop = false;
336
338 {
339 // try to move it to the same exact place in dst
340 targetItem.GetInventory().TakeToDst(InventoryMode.LOCAL, child_src, child_dst);
341 }
342 else
343 {
344 drop = true; // or drop otherwise
345 }
346
347 if (drop)
348 {
349 player.LocalDropEntity(child);
350 GetGame().RemoteObjectTreeCreate(child);
351 result = TransferInventoryResult.DroppedSome;
352 }
353 }
354 }
355 return result;
356 }
TransferInventoryResult
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/....

References GetGame(), and GameInventory::LocationCanAddEntity().

◆ TransferItemProperties()

static void TransferItemProperties ( EntityAI source,
notnull EntityAI target,
bool transfer_agents = true,
bool transfer_variables = true,
bool transfer_health = true,
bool exclude_quantity = false )
staticprotected

will transform item' variables, agents and other local scripted properties as well as any relevant non-scripted properties like health

Definition at line 259 of file MiscGameplayFunctions.c.

260 {
263
264 if (transfer_agents) target_ib.TransferAgents(source.GetAgents());
265
268
269 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
270 {
271 if (transfer_health)
272 target_ib.SetHealth01("", "", source.GetHealth01("", ""));
273 }
274 }

References GetGame().

◆ TransferItemVariables()

static void TransferItemVariables ( ItemBase source,
ItemBase target,
bool exclude_quantity = false )
staticprotected

Definition at line 276 of file MiscGameplayFunctions.c.

277 {
278 target.TransferVariablesFloat(source.GetVariablesFloat());
279 //target.TransferVariablesString( source.GetVariablesString() );
281 target.RemoveItemVariable(VARIABLE_QUANTITY);
282 else if (source.IsMagazine() && target.IsMagazine())
283 {
286
287 target_mag.ServerSetAmmoCount(source_mag.GetAmmoCount());
288 }
289
290 if (source.IsWeapon() && target.IsWeapon())
291 {
294
295 target_wpn.CopyWeaponStateFrom(source_wpn);
296 }
297 else if (source.HasEnergyManager() && target.HasEnergyManager())
298 {
299 ComponentEnergyManager ems = source.GetCompEM();
300 ComponentEnergyManager emt = target.GetCompEM();
301
302 emt.SetEnergy(ems.GetEnergy());
303
304 if (ems.IsSwitchedOn())
305 emt.SwitchOn();
306 }
307 else if (source.CanDecay() && target.CanDecay())
308 {
311
312 target_edb.TransferFoodStage(source_edb);
313 }
314 }
const int VARIABLE_QUANTITY
Definition constants.c:579

References VARIABLE_QUANTITY.

◆ TransformRestrainItem()

static void TransformRestrainItem ( EntityAI current_item,
EntityAI tool,
PlayerBase player_source,
PlayerBase player_target,
bool destroy = false )
staticprotected

Definition at line 636 of file MiscGameplayFunctions.c.

637 {
638 bool type;
639
640 if (tool)
641 {
642 //is unrestrain and not struggle
643 type = tool.ConfigGetBool("RestrainUnlockType");
644 }
645 string new_item_name = current_item.ConfigGetString("OnRestrainChange");
646
647 if (new_item_name != "")
648 {
649 if (player_target)
650 {
651 if (player_target.IsAlive())
653 else
655 }
656 else
658 }
659 else
660 Error("current_item:" + current_item + ", tool:" + tool + ". No value for 'OnRestrainChange' config parameter");
661 }

References Error().

◆ Truncate()

enum ThrowEntityFlags Truncate ( float value,
int decimals = 2 )
protected

truncate float to specified precision

Definition at line 185 of file MiscGameplayFunctions.c.

207 {
208 int multiplier = Math.Pow(10, decimals);
209 return Math.Clamp(Math.Floor(value * multiplier), float.LOWEST, float.MAX) / multiplier;
210 }
static proto float Pow(float v, float power)
Return power of v ^ power.

Referenced by TruncateToS().

◆ TruncateToS()

static string TruncateToS ( float value,
int decimals = 2 )
staticprotected

truncate float to specified precision, output as string

Definition at line 212 of file MiscGameplayFunctions.c.

213 {
214 return Truncate(value, decimals).ToString();
215 }
enum ThrowEntityFlags Truncate(float value, int decimals=2)
truncate float to specified precision

References Truncate().

◆ TruncateVec()

static vector TruncateVec ( vector value,
int decimals = 2 )
staticprotected

truncate float to specified precision

Definition at line 217 of file MiscGameplayFunctions.c.

218 {
219 int multiplier = Math.Pow(10, decimals);
220 float v1 = Math.Clamp(Math.Floor(value[0] * multiplier), float.LOWEST, float.MAX) / multiplier;
221 float v2 = Math.Clamp(Math.Floor(value[1] * multiplier), float.LOWEST, float.MAX) / multiplier;
222 float v3 = Math.Clamp(Math.Floor(value[2] * multiplier), float.LOWEST, float.MAX) / multiplier;
223 return Vector(v1, v2, v3);
224 }

References Math::Clamp(), Math::Floor(), Math::Pow(), and Vector().

◆ TruncateVecToS()

static string TruncateVecToS ( vector value,
int decimals = 2,
string delimiter = " " )
staticprotected

Definition at line 226 of file MiscGameplayFunctions.c.

227 {
228 return MiscGameplayFunctions.TruncateToS(value[0], decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[1], decimals) + delimiter + MiscGameplayFunctions.TruncateToS(value[2], decimals));
229 }

◆ TurnItemInHandsIntoItem()

static void TurnItemInHandsIntoItem ( notnull ItemBase old_item,
string new_item_type,
notnull PlayerBase player )
staticprotected

Definition at line 398 of file MiscGameplayFunctions.c.

399 {
401 }
static void TurnItemInHandsIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)

References TurnItemInHandsIntoItemEx().

◆ TurnItemInHandsIntoItemEx()

static void TurnItemInHandsIntoItemEx ( notnull PlayerBase player,
ReplaceItemWithNewLambdaBase lambda )
staticprotected

Definition at line 403 of file MiscGameplayFunctions.c.

404 {
405 player.ServerReplaceItemInHandsWithNew(lambda);
406 }

Referenced by TurnItemInHandsIntoItem().

◆ TurnItemIntoItem()

static void TurnItemIntoItem ( notnull ItemBase old_item,
string new_item_type,
notnull PlayerBase player )
staticprotected

Definition at line 388 of file MiscGameplayFunctions.c.

389 {
391 }
static void TurnItemIntoItemEx(notnull PlayerBase player, ReplaceItemWithNewLambdaBase lambda)

References TurnItemIntoItemEx().

◆ TurnItemIntoItemEx()

static void TurnItemIntoItemEx ( notnull PlayerBase player,
ReplaceItemWithNewLambdaBase lambda )
staticprotected

Definition at line 393 of file MiscGameplayFunctions.c.

394 {
395 player.ServerReplaceItemWithNew(lambda);
396 }

Referenced by TurnItemIntoItem().

◆ UndoRemoveNetworkObjectInfo()

void UndoRemoveNetworkObjectInfo ( )
protected

Definition at line 171 of file MiscGameplayFunctions.c.

172 {
173 super.UndoRemoveNetworkObjectInfo();
174 GetGame().RemoteObjectTreeCreate(m_NewItem);
175 }

References GetGame(), and m_NewItem.

◆ UnlimitedAmmoDebugCheck()

static void UnlimitedAmmoDebugCheck ( Weapon_Base weapon)
staticprotected

Definition at line 358 of file MiscGameplayFunctions.c.

359 {
360 if (ItemBase.GetDebugActionsMask() & DebugActionType.UNLIMITED_AMMO)
361 {
363 if (GetGame().IsServer())
364 {
365 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
366
367 if (magazine)
368 {
369 if (magazine.GetAmmoCount() <= 5)
370 magazine.ServerSetAmmoMax();
371 }
372 }
373 else
374 {
375 magazine = weapon.GetMagazine(weapon.GetCurrentMuzzle());
376
377 if (magazine)
378 {
379 if (magazine.GetAmmoCount() <= 5)
380 magazine.LocalSetAmmoMax();
381 }
382
383 }
384 }
385 }
DebugActionType

References GetGame().

◆ ValueToBar()

static string ValueToBar ( float value,
string bar = "[----------]",
string mark = "x" )
staticprotected

Produces ACII "progress bar" based on an 0..1 'value' input.

Definition at line 237 of file MiscGameplayFunctions.c.

238 {
239 int length = bar.Length() - 2;
240 float index = Math.Lerp(0, length, value);
242 index = Math.Clamp(index, 0, length);
243
244 return InsertAtPos(bar, mark, index);
245 }
static string InsertAtPos(string base, string insert, int pos)
Insert 'insert' behind index 'pos' of the 'base' string.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Round(float f)
Returns mathematical round of value.

References Math::Clamp(), InsertAtPos(), Math::Lerp(), and Math::Round().

Variable Documentation

◆ ContactComponent

int ContactComponent = -1
protected

Definition at line 1632 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ HitObjects

ref set<Object> HitObjects = new set<Object>
protected

Definition at line 1634 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ HitProxyObjects

ref array<ref RaycastRVResult> HitProxyObjects = new array<ref RaycastRVResult>
protected

Definition at line 1633 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ m_NewItem

◆ m_Player

◆ NONE

@ NONE = 0

Definition at line 207 of file MiscGameplayFunctions.c.

◆ ObjectCenterPos

vector ObjectCenterPos = "0 0 0"
protected

Definition at line 1629 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ ObjectContactDir

vector ObjectContactDir = "0 0 0"
protected

Definition at line 1631 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ ObjectContactPos

vector ObjectContactPos = "0 0 0"
protected

Definition at line 1630 of file MiscGameplayFunctions.c.

Referenced by ClearCache().

◆ RaycastStart

DestroyItemInCorpsesHandsAndCreateNewOnGndLambda RaycastStart = "0 0 0"
protected

Referenced by IsObjectObstructedCache().

◆ SPLIT

SPLIT = 1

Definition at line 208 of file MiscGameplayFunctions.c.

◆ TotalObjects

int TotalObjects = 0
protected

Definition at line 1626 of file MiscGameplayFunctions.c.

Referenced by IsObjectObstructedCache().