23 static proto native
void EnableDebugDraw(
bool pEnable);
24 static proto native
void DrawDebugText(
string text, vector pos,
float size);
27 static proto native
void DrawStartFrame();
29 static proto native
void DrawDebugBox(vector pos,
float size,
int color);
36 static proto native
bool DebugOverrideAnimationTranslation(
string pAnimName, vector pTranslation);
39 static proto native
bool DebugOverrideAnimationRotation(
string pAnimName, vector pRotation);
42 static proto native
bool DebugOverrideAnimationSpeed(
string pAnimName,
float pSpeed);
57 static proto
float LinearRangeClamp(
float pValueX,
float pValueY,
float pLimits[]);
66 static proto native
void PhysicsGetEntitiesInBox(vector min, vector max, notnull out array<EntityAI> entList);
75 static proto native
void SceneGetEntitiesInBox(vector min, vector max, notnull out array<EntityAI> entList,
int flags =
QueryFlags.DYNAMIC);
89 static proto native
void GetEntitiesInCone(vector pos, vector dir,
float angle,
float dist,
float minHeigh,
float maxHeight, out array<Object> entList);
94 static Object GetMeleeTarget(vector pos, vector dir,
float angle,
float dist,
float minHeight,
float maxHeight,
EntityAI pToIgnore, array<typename> targetableObjects, out array<Object> allTargets = NULL)
99 GetEntitiesInCone(pos, dir, angle, dist, minHeight, maxHeight, m_CachedEntList);
104 float retVal = dist * 2;
105 float tgAngle = Math.Tan(Math.DEG2RAD * angle);
109 foreach(
auto ent: m_CachedEntList)
111 if (ent == pToIgnore)
116 Class.CastTo(obj, ent);
120 if( !obj.IsAnyInherited(targetableObjects) )
127 vector entpos = ent.GetPosition();
129 vector diff = entpos - pos;
130 float cDistSq = diff.LengthSq();
131 if (cDistSq > dist*dist)
137 float frontDist = diff[0]*dir[0] + diff[2]*dir[2];
144 vector project = pos + dir * frontDist;
145 vector posdiff =
Vector(project[0] - entpos[0], 0, project[2] - entpos[2]);
146 float sideDist = posdiff.LengthSq();
148 if (sideDist > tgAngle)
154 float sum = frontDist + sideDist;
169 allTargets.Insert(ent);
175 static proto native
bool PlayerCanChangeStance(DayZPlayer pPlayer,
int pTargetStance,
bool forceCheck =
false);
186 static proto native
bool FindMagazinesForAmmo(DayZPlayer player,
string ammoTypeName, out array<Magazine> mags);
203 static Magazine SelectStoreCartridge(DayZPlayer player, Weapon_Base weapon,
int muzzleIndex, Magazine exclude_mag,
float damage,
string magTypeName)
208 ref array<Magazine> mags =
new array<Magazine>;
209 if (DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, mags))
211 int sz = mags.Count();
212 for (
int i = 0; i < sz; ++i)
214 Magazine mag_i = mags.Get(i);
215 if (mag_i != exclude_mag && mag_i.CanAddCartridges(1))
223 InventoryLocation inv_loc =
new InventoryLocation;
227 if (eai_inv && eai_inv.IsInherited(Magazine))
230 if (Class.CastTo(mag_inv, eai_inv))
232 mag_inv.ServerSetAmmoCount(0);
239 vector pos = player.GetPosition();
240 EntityAI eai_gnd = player.SpawnEntityOnGroundPos(magTypeName, pos);
241 if (eai_gnd && eai_gnd.IsInherited(Magazine))
244 if (Class.CastTo(mag_gnd, eai_gnd))
246 mag_gnd.ServerSetAmmoCount(0);
254 static bool HandleDropMagazine(DayZPlayer player, Magazine mag)
257 Math3D.MatrixIdentity4(m4);
260 GameInventory.PrepareDropEntityPos(player, mag, m4,
false, -1);
261 InventoryLocation il_mag_next =
new InventoryLocation;
262 il_mag_next.SetGround(mag, m4);
263 InventoryLocation il_mag_curr =
new InventoryLocation;
264 if (mag.GetInventory().GetCurrentInventoryLocation(il_mag_curr))
266 return GameInventory.LocationSyncMoveEntity(il_mag_curr, il_mag_next);
270 Error(
"DayZPlayerUtils::HandleDropMagazine - cannot get current inv location of mag=" + mag);
275 static bool HandleDropCartridge(DayZPlayer player,
float damage,
string cartTypeName,
string magTypeName)
277 vector pos = player.GetPosition();
278 EntityAI entityGround = player.SpawnEntityOnGroundPos(magTypeName, pos);
279 if (entityGround && entityGround.IsInherited(Magazine))
281 Magazine magazineGround;
282 if (Class.CastTo(magazineGround, entityGround))
284 magazineGround.ServerSetAmmoCount(0);
285 magazineGround.SetHealth(
"",
"", (1 - damage) * magazineGround.GetMaxHealth());
286 if (magazineGround.ServerStoreCartridge(damage, cartTypeName))
294 static bool HandleStoreCartridge(DayZPlayer player, Weapon_Base weapon,
int muzzleIndex,
float damage,
string cartTypeName,
string magTypeName,
bool CanDrop =
true)
299 array<Magazine> magazines =
new array<Magazine>();
300 if (DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, magazines))
302 int healthLevel = -1;
303 float testHeatlh = 1 - damage;
304 foreach (Magazine magazine : magazines)
306 if (healthLevel == -1)
308 if (magazine.CanAddCartridges(1))
310 int numberOfHealthLevels = magazine.GetNumberOfHealthLevels();
311 for (
int i = 1; i < numberOfHealthLevels; i++)
313 if (magazine.GetHealthLevelValue(i) < testHeatlh)
322 if (magazine.GetHealthLevel() == healthLevel)
324 if (magazine.ServerStoreCartridge(damage, cartTypeName))
331 InventoryLocation inventoryLocation =
new InventoryLocation();
332 if (player.GetInventory().FindFirstFreeLocationForNewEntity(magTypeName,
FindInventoryLocationType.ANY, inventoryLocation))
335 if (entityInventory && entityInventory.IsInherited(Magazine))
337 Magazine magazineInventory;
338 if (Class.CastTo(magazineInventory, entityInventory))
340 magazineInventory.ServerSetAmmoCount(0);
341 magazineInventory.SetHealth(
"",
"", (1 - damage) * magazineInventory.GetMaxHealth());
342 if (magazineInventory.ServerStoreCartridge(damage, cartTypeName))
350 return HandleDropCartridge(player, damage, cartTypeName, magTypeName);
363 static proto native
bool InitComponentCollisions(Human player, array<ref ComponentCollisionBox> boxes, array<ref ComponentCollisionCapsule> capsules);
368 static proto native
bool IsComponentCollisionInitialized();
372 static proto native
void ClearComponentCollisions();
374 static proto native vector GetMemoryPointPositionBoneRelative(DayZPlayer pPlayer,
int pBoneIndex,
int pPointIndex);
376 static void InitPlayerComponentCollisions(Human player)
378 if (IsComponentCollisionInitialized())
379 Error(
"DayZPlayerUtils.InitComponentCollisions: already initialized!");
381 array<ref ComponentCollisionBox> b =
new array<ref ComponentCollisionBox>;
382 b.Insert(
new ComponentCollisionBox(0.40, 0.31, 0.31,
"Pelvis",
"Spine2"));
383 b.Insert(
new ComponentCollisionBox(0.40, 0.31, 0.31,
"Spine3",
"Neck"));
385 array<ref ComponentCollisionCapsule> c =
new array<ref ComponentCollisionCapsule>;
386 c.Insert(
new ComponentCollisionCapsule(0.11,
"Neck1",
"Head"));
387 c.Insert(
new ComponentCollisionCapsule(0.09,
"LeftArm",
"LeftArmRoll"));
388 c.Insert(
new ComponentCollisionCapsule(0.08,
"LeftForeArm",
"LeftHand"));
389 c.Insert(
new ComponentCollisionCapsule(0.09,
"RightArm",
"RightArmRoll"));
390 c.Insert(
new ComponentCollisionCapsule(0.08,
"RightForeArm",
"RightHand"));
391 c.Insert(
new ComponentCollisionCapsule(0.11,
"LeftUpLeg",
"LeftUpLegRoll"));
392 c.Insert(
new ComponentCollisionCapsule(0.10,
"LeftLeg",
"LeftFoot"));
393 c.Insert(
new ComponentCollisionCapsule(0.11,
"RightUpLeg",
"RightUpLegRoll"));
394 c.Insert(
new ComponentCollisionCapsule(0.10,
"RightLeg",
"RightFoot"));
396 DayZPlayerUtils.InitComponentCollisions(player, b, c);
399 static int ConvertStanceMaskToStanceIdx(
int stanceMask)
425 static EWaterLevels CheckWaterLevel(DayZPlayer pPlayer, out vector waterLevel)
427 SHumanCommandSwimSettings swimData = pPlayer.GetDayZPlayerType().CommandSwimSettingsW();
428 vector pp = pPlayer.PhysicsGetPositionWS();
429 waterLevel = HumanCommandSwim.WaterLevelCheck(pPlayer, pp);
431 if (waterLevel[1] < swimData.m_fToCrouchLevel)
435 else if (waterLevel[1] >= swimData.m_fToCrouchLevel && waterLevel[1] < swimData.m_fToErectLevel)
441 float waterLevelToSwim = swimData.m_fWaterLevelIn;
442 if (PlayerBase.Cast(pPlayer).IsClimbingLadder())
443 waterLevelToSwim += 0.2;
446 if (waterLevel[0] >= swimData.m_fWaterLevelIn && waterLevel[1] >= waterLevelToSwim)
461 private static ref array<Object> m_CachedEntList;
465 private void DayZPlayerUtils() {};
468 private static void InitCachedEntList()
470 if (m_CachedEntList == NULL)
472 m_CachedEntList =
new array<Object>;
475 m_CachedEntList.Clear();
479class ComponentCollisionBox
485 void ComponentCollisionBox(
float x,
float y,
float z,
string b0,
string b1)
495class ComponentCollisionCapsule
501 void ComponentCollisionCapsule(
float r,
string b0,
string b1)
const int ECE_IN_INVENTORY
DayZPlayerConstants
defined in C++
ONLY_ROADWAYS
Only roadways are included in the query.
ORIGIN_DISTANCE
Check only distance to object origins, not BB.
void Error(string err)
Messagebox with error message.
@ STATIC
Static objects are included in the query.
@ DYNAMIC
Dynamic objects are included in the query.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
@ NONE
body is not in simulation, nor in collision world
FindInventoryLocationType
flags for searching locations in inventory
MeleeTargetData GetMeleeTarget(MeleeTargetSettings settings, out array< Object > allTargets=null)