DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ClearCatchingItemData()

void InitCatchMethodMask::ClearCatchingItemData ( )
protected

См. определение в файле CatchingContextTraps.c строка 273

274{
279 protected float m_CumulativeTrappingSuccess;
280 protected int m_AttemptsCount;
281 protected ItemBase m_Bait;
282
283 override protected void DeserializeData(Param par)
284 {
286 if (Class.CastTo(p,par))
287 {
288 m_MainItem = p.param1;
289 m_AttemptsCount = p.param2;
290 }
291 }
292
293 override protected void CreateResultDataStructure()
294 {
296
297 super.CreateResultDataStructure();
298 }
299
300 override protected void ClearCatchingItemData()
301 {
302 super.ClearCatchingItemData();
303
305 m_QualityBaseMod = 0.0;
308 }
309
310 override protected void InitItemValues(EntityAI item)
311 {
312 //skip ruined or deleted items entirely
313 if (item.IsRuined() || item.IsSetForDeletion())
314 return;
315
316 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
317 if (GetGame().ConfigIsExisting(path))
318 {
319 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
320 {
325 int count = CachedObjectsArrays.ARRAY_INT.Count();
326 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
327 {
328 int key;
329 float value;
330 for (int i = 0; i < count; i++)
331 {
334 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
335 {
336 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
337 }
338 }
339 }
340 else
341 {
342 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
343 }
344 }
345 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
346 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
347 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
348 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
349 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
350 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
351 }
352 }
353
356 {
357 float ret = 1.0;
358 ItemBase ib;
359 if (Class.CastTo(ib,item))
360 {
361 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
362 }
363
364 return ret;
365 }
366
367 override protected void InitCatchEnviroMask()
368 {
369 vector pos = m_MainItem.GetPosition();
370 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
372 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
374 else
376 }
377
378 override protected void Init(Param par)
379 {
380 super.Init(par);
381
383 }
384
385 override protected void SetupInitialTypes()
386 {
387 #ifdef DEVELOPER
388 if (IsCLIParam("catchingLogs"))
389 {
390 Print("********************"); //just for debug purposes to track the start
391 Print("dbgTrapz | START");
392 Print("********************");
393 }
394 #endif
395
396 super.SetupInitialTypes();
397
398 #ifdef DEVELOPER
399 if (IsCLIParam("catchingLogs"))
400 {
401 Print("***"); //just for debug purposes to track the start
402 }
403 #endif
404 }
405
406 void UpdateDataAndMasks()
407 {
409 InitCatchMethodMask(); //bait check
410 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
413 }
414
416 {
418 return GetCatchEnviroMask();
419 }
420
421 void SetTrapEnviroMask(int value)
422 {
423 m_EnviroMask = value;
424 }
425
427 void UpdateUsedBait(ECatchingBaitCategories type)
428 {
429 m_Bait = null;
430 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
431 {
432 BaitData dta = m_BaitCompatibilityMap.Get(type);
433 if (dta)
434 {
435 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
436 if (potentialBait != m_MainItem)
437 m_Bait = potentialBait;
438 }
439 else
440 ErrorEx("failed to acquire BaitData from type: " + type);
441 }
442
443 #ifdef DEVELOPER
444 if (IsCLIParam("catchingLogs"))
445 {
446 if (m_Bait)
447 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
448 else
449 Print("dbgTrapz | UpdateUsedBait to 'null'!");
450 }
451 #endif
452 }
453
454 override void UpdateBaseProbability(YieldItemBase yItem)
455 {
456 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
457 int usedType = -1;
458 float probability = -1;
459 float highestProbability = 0.0;
460 int count = m_BaitCompatibilityMap.Count();
461 for (int i = 0; i < count; i++)
462 {
463 baitType = m_BaitCompatibilityMap.GetKey(i);
464 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
465 if (probability > highestProbability)
466 {
467 highestProbability = probability;
468 usedType = baitType;
469 }
470 }
471
472 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
473 #ifdef DEVELOPER
474 if (IsCLIParam("catchingLogs"))
475 {
476 //Print("********************");
477 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
478 }
479 #endif
480 UpdateUsedBait(usedType);
481
482 #ifdef DEVELOPER
483 if (IsCLIParam("catchingLogs"))
484 {
485 float dbgProb;
487 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
488 }
489 #endif
490 }
491
492 override bool ModifySignalProbability(inout float probability)
493 {
494 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
495
496 return true;
497 }
498
499 void RemoveBait()
500 {
501 if (m_Bait)
502 m_Bait.DeleteSafe();
503 }
504
505 void ReduceBaitQty(float qtyNorm)
506 {
507 if (m_Bait)
508 {
509 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
510 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
511 else
512 m_Bait.DeleteSafe();
513 }
514 }
515}
516
517class CatchingContextTrapFishSmall : CatchingContextTrapsBase
518{
519 override protected void InitCatchMethodMask()
520 {
521 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
522 }
523}
524
526{
527 override protected void InitCatchMethodMask()
528 {
529 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_LARGE;
530 }
531}
532
533class CatchingContextTrapLandSnare : CatchingContextTrapsBase
534{
535 override protected void InitCatchMethodMask()
536 {
537 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
538 }
539}
ItemBase m_Bait
Определения ActionFishingNew.c:57
int GetCatchEnviroMask()
Определения CatchingContextBase.c:164
float m_QualityBaseMod
Определения CatchingContextBase.c:20
ref map< int, ref BaitData > m_BaitCompatibilityMap
Определения CatchingContextBase.c:23
class BaitData m_MainItem
Определения ActionBase.c:36
ref CatchingResultBasic m_Result
Определения CatchingContextBase.c:27
void GenerateResult()
Определения CatchingContextBase.c:257
int m_MethodMask
Определения CatchingContextBase.c:18
float m_QualityDispersionMinMod
Определения CatchingContextBase.c:21
void InitCatchingItemData()
Определения CatchingContextBase.c:217
void CatchingContextBase(Param par)
Определения CatchingContextBase.c:29
float m_QualityDispersionMaxMod
Определения CatchingContextBase.c:22
int m_EnviroMask
Определения CatchingContextBase.c:19
void SetupProbabilityArray()
Определения CatchingContextBase.c:97
void SetupInitialTypes()
Определения CatchingContextTraps.c:358
void InitItemValues(EntityAI item)
override to init context-specific values
Определения CatchingContextTraps.c:283
void RemoveBait()
Определения CatchingContextTraps.c:472
float AdjustBaitItemChance(EntityAI item)
Allows for adjustment of all catch probabilities from item qualities (damage, qty....
Определения CatchingContextTraps.c:328
void SetTrapEnviroMask(int value)
Определения CatchingContextTraps.c:394
CatchingContextTrapsBase CatchingContextBase InitCatchMethodMask()
Определения CatchingContextTraps.c:247
int UpdateTrapEnviroMask()
Определения CatchingContextTraps.c:388
void UpdateDataAndMasks()
Определения CatchingContextTraps.c:379
void UpdateUsedBait(ECatchingBaitCategories type)
if non-empty bait type is used, some 'Bait' attachment is picked as an active bait (currently no dire...
Определения CatchingContextTraps.c:400
void ClearCatchingItemData()
Определения CatchingContextTraps.c:273
void InitCatchEnviroMask()
Определения CatchingContextTraps.c:340
void CreateResultDataStructure()
Определения CatchingContextTraps.c:266
void DeserializeData(Param par)
Определения CatchingContextTraps.c:256
override bool ModifySignalProbability(inout float probability)
Определения CatchingContextTraps.c:465
void ReduceBaitQty(float qtyNorm)
Определения CatchingContextTraps.c:478
int m_AttemptsCount
Определения CatchingContextTraps.c:253
float m_CumulativeTrappingSuccess
after N attempts, the chance to catch should be this. Only highest one applies. @NOTE: Take care,...
Определения CatchingContextTraps.c:252
override void UpdateBaseProbability(YieldItemBase yItem)
updates base probability when catching the specific item (some context subclasses only)
Определения CatchingContextTraps.c:427
override Widget Init()
Определения DayZGame.c:127
string path
Определения OptionSelectorMultistate.c:142
static const int MASK_ENVIRO_POND
Определения CatchingConstants.c:11
static const int MASK_ENVIRO_LAND_ALL
Определения CatchingConstants.c:16
static const int MASK_ENVIRO_SEA
Определения CatchingConstants.c:12
EntityAI m_Owner
Определения CatchingContextBase.c:4
Определения CatchingContextBase.c:2
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native void ConfigGetIntArray(string path, out TIntArray values)
Get array of integers from config on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
static ref TIntArray ARRAY_INT
Определения UtilityClasses.c:51
static ref TFloatArray ARRAY_FLOAT
Определения UtilityClasses.c:50
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения PPEConstants.c:68
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
float GetBaitTypeSensitivity(ECatchingBaitCategories type)
Определения CatchYieldItemBase.c:53
Определения EnConvert.c:106
proto native CGame GetGame()
ErrorExSeverity
Определения EnDebug.c:62
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float Pow(float v, float power)
Return power of v ^ power.
const string CFG_VEHICLESPATH
Определения constants.c:220
proto native bool IsCLIParam(string param)
Returns if command line argument is present.