Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл DayZPlayerUtils.c

См. исходные тексты.

Структуры данных

class  ComponentCollisionBox
 
class  ComponentCollisionCapsule
 

Перечисления

enum  QueryFlags
 

Функции

enum QueryFlags EnableDebugDraw (bool pEnable)
 enables debug draw in functions
 
static proto native void DrawDebugText (string text, vector pos, float size)
 
static proto native void DrawStartFrame ()
 clear info - new draw starts
 
static proto native void DrawDebugBox (vector pos, float size, int color)
 draws debug box (color=red)
 
static proto native bool DebugOverrideAnimationTranslation (string pAnimName, vector pTranslation)
 overrides total animation translation
 
static proto native bool DebugOverrideAnimationRotation (string pAnimName, vector pRotation)
 overrides total animation rotation
 
static proto native bool DebugOverrideAnimationSpeed (string pAnimName, float pSpeed)
 overrides total animation speed
 
static proto float LinearRangeClamp (float pValueX, float pValueY, float pLimits[])
 
static proto native void PhysicsGetEntitiesInBox (vector min, vector max, notnull out array< EntityAI > entList)
 returns entities overlapping/touching in AABB box -
 
static proto native void SceneGetEntitiesInBox (vector min, vector max, notnull out array< EntityAI > entList, int flags=QueryFlags.DYNAMIC)
 returns entities overlapping/touching in AABB box -
 
static proto native void GetEntitiesInCone (vector pos, vector dir, float angle, float dist, float minHeigh, float maxHeight, out array< Object > entList)
 
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)
 returns fight target
 
static proto native bool PlayerCanChangeStance (DayZPlayer pPlayer, int pTargetStance, bool forceCheck=false)
 
static proto native bool FindMagazinesForAmmo (DayZPlayer player, string ammoTypeName, out array< Magazine > mags)
 
static Magazine SelectStoreCartridge (DayZPlayer player, Weapon_Base weapon, int muzzleIndex, Magazine exclude_mag, float damage, string magTypeName)
 
static bool HandleDropMagazine (DayZPlayer player, Magazine mag)
 
static bool HandleDropCartridge (DayZPlayer player, float damage, string cartTypeName, string magTypeName)
 
static bool HandleStoreCartridge (DayZPlayer player, Weapon_Base weapon, int muzzleIndex, float damage, string cartTypeName, string magTypeName, bool CanDrop=true)
 
static proto native bool InitComponentCollisions (Human player, array< ref ComponentCollisionBox > boxes, array< ref ComponentCollisionCapsule > capsules)
 
static proto native bool IsComponentCollisionInitialized ()
 
static proto native void ClearComponentCollisions ()
 
static proto native vector GetMemoryPointPositionBoneRelative (DayZPlayer pPlayer, int pBoneIndex, int pPointIndex)
 
static void InitPlayerComponentCollisions (Human player)
 
static int ConvertStanceMaskToStanceIdx (int stanceMask)
 
static EWaterLevels CheckWaterLevel (DayZPlayer pPlayer, out vector waterLevel)
 
void DayZPlayerUtils ()
 cannot be instantiated
 
static void InitCachedEntList ()
 

Переменные

 NONE
 
 STATIC
 Static objects are included in the query.
 
 DYNAMIC
 Dynamic objects are included in the query.
 
 ORIGIN_DISTANCE
 Check only distance to object origins, not BB.
 
 ONLY_ROADWAYS
 Only roadways are included in the query.
 
static ref array< Objectm_CachedEntList
 
class ComponentCollisionBox EnableDebugDraw
 

Перечисления

◆ QueryFlags

2{
3 NONE,
5 STATIC,
12}
ONLY_ROADWAYS
Only roadways are included in the query.
Definition DayZPlayerUtils.c:8
ORIGIN_DISTANCE
Check only distance to object origins, not BB.
Definition DayZPlayerUtils.c:6
DYNAMIC
Dynamic objects are included in the query.
Definition DayZPlayerUtils.c:4
NONE
Definition DayZPlayerUtils.c:0
STATIC
Static objects are included in the query.
Definition DayZPlayerUtils.c:2

Функции

◆ CheckWaterLevel()

static EWaterLevels CheckWaterLevel ( DayZPlayer pPlayer,
out vector waterLevel )
static

if total water depth >= 1.5m && character is 1.5m in water

426 {
427 SHumanCommandSwimSettings swimData = pPlayer.GetDayZPlayerType().CommandSwimSettingsW();
428 vector pp = pPlayer.GetPosition();
429 waterLevel = HumanCommandSwim.WaterLevelCheck(pPlayer, pp);
430
431 if (waterLevel[1] < swimData.m_fToCrouchLevel)
432 {
433 return EWaterLevels.LEVEL_LOW;
434 }
435 else if (waterLevel[1] >= swimData.m_fToCrouchLevel && waterLevel[1] < swimData.m_fToErectLevel)
436 {
437 return EWaterLevels.LEVEL_CROUCH;
438 }
439 else// if (waterLevel[1] >= swimData.m_fToErectLevel)
440 {
442 if (waterLevel[0] >= swimData.m_fWaterLevelIn && waterLevel[1] >= swimData.m_fWaterLevelIn)
443 {
444 return EWaterLevels.LEVEL_SWIM_START;
445 }
446 else
447 {
448 return EWaterLevels.LEVEL_ERECT;
449 }
450 }
451 }
EWaterLevels
Definition EWaterLevels.c:2
Definition EntityAI.c:95
Definition humansettings.c:46
Definition EnConvert.c:106
class HumanCommandLadder HumanCommandSwim()
Definition human.c:673

Перекрестные ссылки HumanCommandSwim().

◆ ClearComponentCollisions()

ClearComponentCollisions ( )
static

◆ ConvertStanceMaskToStanceIdx()

static int ConvertStanceMaskToStanceIdx ( int stanceMask)
static
400 {
401 switch (stanceMask)
402 {
403 case stanceMask & DayZPlayerConstants.STANCEMASK_PRONE:
404 return DayZPlayerConstants.STANCEIDX_PRONE;
405
406 case stanceMask & DayZPlayerConstants.STANCEMASK_CROUCH:
407 return DayZPlayerConstants.STANCEIDX_CROUCH;
408
409 case stanceMask & DayZPlayerConstants.STANCEMASK_ERECT:
410 return DayZPlayerConstants.STANCEIDX_ERECT;
411
412 case stanceMask & DayZPlayerConstants.STANCEMASK_RAISEDPRONE:
413 return DayZPlayerConstants.STANCEIDX_RAISEDPRONE;
414
415 case stanceMask & DayZPlayerConstants.STANCEMASK_RAISEDCROUCH:
416 return DayZPlayerConstants.STANCEIDX_RAISEDCROUCH;
417
418 case stanceMask & DayZPlayerConstants.STANCEMASK_RAISEDERECT:
419 return DayZPlayerConstants.STANCEIDX_RAISEDERECT;
420 }
421
422 return -1;
423 }
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602

◆ DayZPlayerUtils()

◆ DebugOverrideAnimationRotation()

static proto native bool DebugOverrideAnimationRotation ( string pAnimName,
vector pRotation )
static

overrides total animation rotation

◆ DebugOverrideAnimationSpeed()

static proto native bool DebugOverrideAnimationSpeed ( string pAnimName,
float pSpeed )
static

overrides total animation speed

◆ DebugOverrideAnimationTranslation()

static proto native bool DebugOverrideAnimationTranslation ( string pAnimName,
vector pTranslation )
static

overrides total animation translation

◆ DrawDebugBox()

static proto native void DrawDebugBox ( vector pos,
float size,
int color )
static

draws debug box (color=red)

◆ DrawDebugText()

static proto native void DrawDebugText ( string text,
vector pos,
float size )
static

◆ DrawStartFrame()

static proto native void DrawStartFrame ( )
static

clear info - new draw starts

◆ EnableDebugDraw()

enum QueryFlags EnableDebugDraw ( bool pEnable)

enables debug draw in functions

◆ FindMagazinesForAmmo()

static proto native bool FindMagazinesForAmmo ( DayZPlayer player,
string ammoTypeName,
out array< Magazine > mags )
static

◆ GetEntitiesInCone()

static proto native void GetEntitiesInCone ( vector pos,
vector dir,
float angle,
float dist,
float minHeigh,
float maxHeight,
out array< Object > entList )
static

Используется в GetMeleeTarget().

◆ GetMeleeTarget()

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

returns fight target

95 {
96 // Print("In: GetFightTarget");
98
100
101 Object ret = NULL;
102 Object obj = NULL;
103
104 float retVal = dist * 2; // max value
105 float tgAngle = Math.Tan(Math.DEG2RAD * angle);
106
107 // DrawStartFrame();
108
109 foreach(auto ent: m_CachedEntList)
110 {
111 if (ent == pToIgnore)
112 {
113 continue;
114 }
115
116 Class.CastTo(obj, ent);
117 if(obj)
118 {
119 // check for targetable objects
120 if( !obj.IsAnyInherited(targetableObjects) )
121 { continue; }
122
123 if( !obj.IsAlive() )
124 { continue; }
125 }
126
127 vector entpos = ent.GetPosition();
128
129 vector diff = entpos - pos;
130 float cDistSq = diff.LengthSq();
131 if (cDistSq > dist*dist) // out of distance
132 {
133 //Print("out of distance");
134 continue;
135 }
136
137 float frontDist = diff[0]*dir[0] + diff[2]*dir[2];
138 if (frontDist < 0.1) // behind the pos/dist half plane or further than dist
139 {
140 //Print("behind the pos/dist half plane or further than dist");
141 continue;
142 }
143
144 vector project = pos + dir * frontDist;
145 vector posdiff = Vector(project[0] - entpos[0], 0, project[2] - entpos[2]);
146 float sideDist = posdiff.LengthSq();
147
148 if (sideDist > tgAngle) // out of cone
149 {
150 //Print("out of cone");
151 continue;
152 }
153
154 float sum = frontDist + sideDist;
155 if (sum < retVal)
156 {
157 ret = ent;
158 retVal = sum;
159 }
160 else
161 {
162 //Print("sum !< retVal");
163 }
164
165 // string txt = project.ToString() + ": " + sum.ToString();
166 // DrawDebugBox(project,0.01,0xffff0000);
167 // DrawDebugBox(entpos,0.01,0xffff0000);
168 // DrawDebugText(txt, project, 1.0);
169 allTargets.Insert(ent);
170 }
171
172 return ret;
173 }
static ref array< Object > m_CachedEntList
Definition DayZPlayerUtils.c:457
static proto native void GetEntitiesInCone(vector pos, vector dir, float angle, float dist, float minHeigh, float maxHeight, out array< Object > entList)
static void InitCachedEntList()
Definition DayZPlayerUtils.c:464
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Definition ObjectTyped.c:2
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Tan(float angle)
Returns tangent of angle in radians.
static const float DEG2RAD
Definition EnMath.c:17

Перекрестные ссылки Class::CastTo(), Math::DEG2RAD, GetEntitiesInCone(), InitCachedEntList(), m_CachedEntList, Math::Tan() и Vector().

◆ GetMemoryPointPositionBoneRelative()

static proto native vector GetMemoryPointPositionBoneRelative ( DayZPlayer pPlayer,
int pBoneIndex,
int pPointIndex )
static

◆ HandleDropCartridge()

static bool HandleDropCartridge ( DayZPlayer player,
float damage,
string cartTypeName,
string magTypeName )
static
276 {
277 vector pos = player.GetPosition();
278 EntityAI entityGround = player.SpawnEntityOnGroundPos(magTypeName, pos);
279 if (entityGround && entityGround.IsInherited(Magazine))
280 {
283 {
284 magazineGround.ServerSetAmmoCount(0);
285 magazineGround.SetHealth("", "", (1 - damage) * magazineGround.GetMaxHealth());
286 if (magazineGround.ServerStoreCartridge(damage, cartTypeName))
287 return true;
288 }
289 }
290
291 return false;
292 }
Definition Building.c:6

Перекрестные ссылки Class::CastTo().

Используется в HandleStoreCartridge().

◆ HandleDropMagazine()

static bool HandleDropMagazine ( DayZPlayer player,
Magazine mag )
static

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

255 {
256 vector m4[4];
258
262 il_mag_next.SetGround(mag, m4);
264 if (mag.GetInventory().GetCurrentInventoryLocation(il_mag_curr))
265 {
267 }
268 else
269 {
270 Error("DayZPlayerUtils::HandleDropMagazine - cannot get current inv location of mag=" + mag);
271 return false;
272 }
273 }
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...
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
InventoryLocation.
Definition InventoryLocation.c:28
Definition EnMath3D.c:28
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Definition EnMath3D.c:256

Перекрестные ссылки Error(), GameInventory::LocationSyncMoveEntity(), Math3D::MatrixIdentity4() и GameInventory::PrepareDropEntityPos().

◆ HandleStoreCartridge()

static bool HandleStoreCartridge ( DayZPlayer player,
Weapon_Base weapon,
int muzzleIndex,
float damage,
string cartTypeName,
string magTypeName,
bool CanDrop = true )
static

find suitable heap / mag

create a new one in inventory

drop on ground

295 {
296 if (damage < 1.0)
297 {
300 if (DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, magazines))
301 {
302 int healthLevel = -1;
303 float testHeatlh = 1 - damage;
304 foreach (Magazine magazine : magazines)
305 {
306 if (healthLevel == -1)
307 {
308 if (magazine.CanAddCartridges(1))
309 {
310 int numberOfHealthLevels = magazine.GetNumberOfHealthLevels();
311 for (int i = 1; i < numberOfHealthLevels; i++)
312 {
313 if (magazine.GetHealthLevelValue(i) < testHeatlh)
314 {
315 healthLevel = i - 1;
316 break;
317 }
318 }
319 }
320 }
321
322 if (magazine.GetHealthLevel() == healthLevel)
323 {
324 if (magazine.ServerStoreCartridge(damage, cartTypeName))
325 return true;
326 }
327 }
328 }
329
332 if (player.GetInventory().FindFirstFreeLocationForNewEntity(magTypeName, FindInventoryLocationType.ANY, inventoryLocation))
333 {
335 if (entityInventory && entityInventory.IsInherited(Magazine))
336 {
339 {
340 magazineInventory.ServerSetAmmoCount(0);
341 magazineInventory.SetHealth("", "", (1 - damage) * magazineInventory.GetMaxHealth());
342 if (magazineInventory.ServerStoreCartridge(damage, cartTypeName))
343 return true;
344 }
345 }
346 }
347
349 if (CanDrop)
351 }
352
353 return false;
354 }
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Definition CentralEconomy.c:36
const int RF_DEFAULT
Definition CentralEconomy.c:65
void DayZPlayerUtils()
cannot be instantiated
Definition DayZPlayerUtils.c:461
static bool HandleDropCartridge(DayZPlayer player, float damage, string cartTypeName, string magTypeName)
Definition DayZPlayerUtils.c:275
FindInventoryLocationType
flags for searching locations in inventory
Definition InventoryLocation.c:16

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

◆ InitCachedEntList()

static void InitCachedEntList ( )
staticprivate
465 {
466 if (m_CachedEntList == NULL)
467 {
469 }
470
471 m_CachedEntList.Clear();
472 }

Перекрестные ссылки m_CachedEntList.

Используется в GetMeleeTarget().

◆ InitComponentCollisions()

static proto native bool InitComponentCollisions ( Human player,
array< ref ComponentCollisionBox > boxes,
array< ref ComponentCollisionCapsule > capsules )
static

◆ InitPlayerComponentCollisions()

static void InitPlayerComponentCollisions ( Human player)
static
377 {
379 Error("DayZPlayerUtils.InitComponentCollisions: already initialized!");
380
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"));
384
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"));
395
396 DayZPlayerUtils.InitComponentCollisions(player, b, c);
397 }
static proto native bool IsComponentCollisionInitialized()
Definition DayZPlayerUtils.c:476
Definition DayZPlayerUtils.c:492

Перекрестные ссылки DayZPlayerUtils(), Error() и IsComponentCollisionInitialized().

◆ IsComponentCollisionInitialized()

IsComponentCollisionInitialized ( )
static
Возвращает
true if already initialized

Используется в InitPlayerComponentCollisions().

◆ LinearRangeClamp()

static proto float LinearRangeClamp ( float pValueX,
float pValueY,
float pLimits[] )
static

pLimits in form Xvalue, Ymin, Ymax, Xvalue1, Ymin1, Ymax1, .... sample 0, 0, 5, 1, 2, 3, 2, 0, 1 for X <= 0 it clamps Y to Rangle (0,5)
for X == 0.5 it clamps Y to Rangle (1,4)
for X == 1 it clamps Y to Rangle (2,3)
for X == 1.5 it clamps Y to Rangle (1,2)
for X >= 2 it clamps Y to Rangle (0,1)

◆ PhysicsGetEntitiesInBox()

static proto native void PhysicsGetEntitiesInBox ( vector min,
vector max,
notnull out array< EntityAI > entList )
static

returns entities overlapping/touching in AABB box -

◆ PlayerCanChangeStance()

static proto native bool PlayerCanChangeStance ( DayZPlayer pPlayer,
int pTargetStance,
bool forceCheck = false )
static

◆ SceneGetEntitiesInBox()

static proto native void SceneGetEntitiesInBox ( vector min,
vector max,
notnull out array< EntityAI > entList,
int flags = QueryFlags.DYNAMIC )
static

returns entities overlapping/touching in AABB box -

◆ SelectStoreCartridge()

static Magazine SelectStoreCartridge ( DayZPlayer player,
Weapon_Base weapon,
int muzzleIndex,
Magazine exclude_mag,
float damage,
string magTypeName )
static
204 {
205 if (damage < 1.0)
206 {
207 // find suitable heap / mag (but not the excluded one)
209 if (DayZPlayerUtils.FindMagazinesForAmmo(player, magTypeName, mags))
210 {
211 int sz = mags.Count();
212 for (int i = 0; i < sz; ++i)
213 {
214 Magazine mag_i = mags.Get(i);
215 if (mag_i != exclude_mag && mag_i.CanAddCartridges(1))
216 {
217 return mag_i;
218 }
219 }
220 }
221
222 // create a new one in inventory
224 if (player.GetInventory().FindFirstFreeLocationForNewEntity(magTypeName, FindInventoryLocationType.ANY, inv_loc))
225 {
227 if (eai_inv && eai_inv.IsInherited(Magazine))
228 {
231 {
232 mag_inv.ServerSetAmmoCount(0);
233 return mag_inv;
234 }
235 }
236 }
237 }
238
239 vector pos = player.GetPosition();
240 EntityAI eai_gnd = player.SpawnEntityOnGroundPos(magTypeName, pos);
241 if (eai_gnd && eai_gnd.IsInherited(Magazine))
242 {
245 {
246 mag_gnd.ServerSetAmmoCount(0);
247 return mag_gnd;
248 }
249 }
250
251 return NULL;
252 }

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

Переменные

◆ DYNAMIC

@ DYNAMIC

Dynamic objects are included in the query.

◆ EnableDebugDraw

class ComponentCollisionBox EnableDebugDraw
private

◆ m_CachedEntList

ref array<Object> m_CachedEntList
staticprivate

Используется в GetMeleeTarget() и InitCachedEntList().

◆ NONE

@ NONE

◆ ONLY_ROADWAYS

ONLY_ROADWAYS

Only roadways are included in the query.

◆ ORIGIN_DISTANCE

ORIGIN_DISTANCE

Check only distance to object origins, not BB.

◆ STATIC

@ STATIC

Static objects are included in the query.