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

◆ UpdateDataAndMasks()

void InitCatchMethodMask::UpdateDataAndMasks ( )
protected

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

380{
385 protected float m_CumulativeTrappingSuccess;
386 protected int m_AttemptsCount;
387 protected ItemBase m_Bait;
388
389 override protected void DeserializeData(Param par)
390 {
392 if (Class.CastTo(p,par))
393 {
394 m_MainItem = p.param1;
395 m_AttemptsCount = p.param2;
396 }
397 }
398
399 override protected void CreateResultDataStructure()
400 {
402
403 super.CreateResultDataStructure();
404 }
405
406 override protected void ClearCatchingItemData()
407 {
408 super.ClearCatchingItemData();
409
411 m_QualityBaseMod = 0.0;
414 }
415
416 override protected void InitItemValues(EntityAI item)
417 {
418 //skip ruined or deleted items entirely
419 if (item.IsRuined() || item.IsSetForDeletion())
420 return;
421
422 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
423 if (GetGame().ConfigIsExisting(path))
424 {
425 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
426 {
431 int count = CachedObjectsArrays.ARRAY_INT.Count();
432 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
433 {
434 int key;
435 float value;
436 for (int i = 0; i < count; i++)
437 {
440 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
441 {
442 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
443 }
444 }
445 }
446 else
447 {
448 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
449 }
450 }
451 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
452 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
453 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
454 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
455 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
456 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
457 }
458 }
459
462 {
463 float ret = 1.0;
464 ItemBase ib;
465 if (Class.CastTo(ib,item))
466 {
467 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
468 }
469
470 return ret;
471 }
472
473 override protected void InitCatchEnviroMask()
474 {
475 vector pos = m_MainItem.GetPosition();
476 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
478 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
480 else
482 }
483
484 override protected void Init(Param par)
485 {
486 super.Init(par);
487
489 }
490
491 override protected void SetupInitialTypes()
492 {
493 #ifdef DEVELOPER
494 if (IsCLIParam("catchingLogs"))
495 {
496 Print("********************"); //just for debug purposes to track the start
497 Print("dbgTrapz | START");
498 Print("********************");
499 }
500 #endif
501
502 super.SetupInitialTypes();
503
504 #ifdef DEVELOPER
505 if (IsCLIParam("catchingLogs"))
506 {
507 Print("***"); //just for debug purposes to track the start
508 }
509 #endif
510 }
511
512 void UpdateDataAndMasks()
513 {
515 InitCatchMethodMask(); //bait check
516 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
519 }
520
522 {
524 return GetCatchEnviroMask();
525 }
526
527 void SetTrapEnviroMask(int value)
528 {
529 m_EnviroMask = value;
530 }
531
533 void UpdateUsedBait(ECatchingBaitCategories type)
534 {
535 m_Bait = null;
536 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
537 {
538 BaitData dta = m_BaitCompatibilityMap.Get(type);
539 if (dta)
540 {
541 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
542 if (potentialBait != m_MainItem)
543 m_Bait = potentialBait;
544 }
545 else
546 ErrorEx("failed to acquire BaitData from type: " + type);
547 }
548
549 #ifdef DEVELOPER
550 if (IsCLIParam("catchingLogs"))
551 {
552 if (m_Bait)
553 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
554 else
555 Print("dbgTrapz | UpdateUsedBait to 'null'!");
556 }
557 #endif
558 }
559
560 override void UpdateBaseProbability(YieldItemBase yItem)
561 {
562 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
563 int usedType = -1;
564 float probability = -1;
565 float highestProbability = 0.0;
566 int count = m_BaitCompatibilityMap.Count();
567 for (int i = 0; i < count; i++)
568 {
569 baitType = m_BaitCompatibilityMap.GetKey(i);
570 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
571 if (probability > highestProbability)
572 {
573 highestProbability = probability;
574 usedType = baitType;
575 }
576 }
577
578 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
579 #ifdef DEVELOPER
580 if (IsCLIParam("catchingLogs"))
581 {
582 //Print("********************");
583 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
584 }
585 #endif
586 UpdateUsedBait(usedType);
587
588 #ifdef DEVELOPER
589 if (IsCLIParam("catchingLogs"))
590 {
591 float dbgProb;
593 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
594 }
595 #endif
596 }
597
598 override bool ModifySignalProbability(inout float probability)
599 {
600 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
601
602 return true;
603 }
604
605 void RemoveBait()
606 {
607 if (m_Bait)
608 m_Bait.DeleteSafe();
609 }
610
611 void ReduceBaitQty(float qtyNorm)
612 {
613 if (m_Bait)
614 {
615 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
616 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
617 else
618 m_Bait.DeleteSafe();
619 }
620 }
621}
622
623class CatchingContextTrapFishSmall : CatchingContextTrapsBase
624{
625 override protected void InitCatchMethodMask()
626 {
627 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
628 }
629}
630
632{
633 override protected void InitCatchMethodMask()
634 {
635 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_LARGE;
636 }
637}
638
639class CatchingContextTrapLandSnare : CatchingContextTrapsBase
640{
641 override protected void InitCatchMethodMask()
642 {
643 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
644 }
645}
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.