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

◆ UpdateBaseProbability()

void UpdateBaseProbability ( YieldItemBase yItem)
protected

updates base probability when catching the specific item (some context subclasses only)

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

428{
433 protected float m_CumulativeTrappingSuccess;
434 protected int m_AttemptsCount;
435 protected ItemBase m_Bait;
436
437 override protected void DeserializeData(Param par)
438 {
440 if (Class.CastTo(p,par))
441 {
442 m_MainItem = p.param1;
443 m_AttemptsCount = p.param2;
444 }
445 }
446
447 override protected void CreateResultDataStructure()
448 {
450
451 super.CreateResultDataStructure();
452 }
453
454 override protected void ClearCatchingItemData()
455 {
456 super.ClearCatchingItemData();
457
459 m_QualityBaseMod = 0.0;
462 }
463
464 override protected void InitItemValues(EntityAI item)
465 {
466 //skip ruined or deleted items entirely
467 if (item.IsRuined() || item.IsSetForDeletion())
468 return;
469
470 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
471 if (GetGame().ConfigIsExisting(path))
472 {
473 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
474 {
479 int count = CachedObjectsArrays.ARRAY_INT.Count();
480 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
481 {
482 int key;
483 float value;
484 for (int i = 0; i < count; i++)
485 {
488 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
489 {
490 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
491 }
492 }
493 }
494 else
495 {
496 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
497 }
498 }
499 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
500 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
501 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
502 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
503 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
504 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
505 }
506 }
507
510 {
511 float ret = 1.0;
512 ItemBase ib;
513 if (Class.CastTo(ib,item))
514 {
515 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
516 }
517
518 return ret;
519 }
520
521 override protected void InitCatchEnviroMask()
522 {
523 vector pos = m_MainItem.GetPosition();
524 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
526 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
528 else
530 }
531
532 override protected void Init(Param par)
533 {
534 super.Init(par);
535
537 }
538
539 override protected void SetupInitialTypes()
540 {
541 #ifdef DEVELOPER
542 if (IsCLIParam("catchingLogs"))
543 {
544 Print("********************"); //just for debug purposes to track the start
545 Print("dbgTrapz | START");
546 Print("********************");
547 }
548 #endif
549
550 super.SetupInitialTypes();
551
552 #ifdef DEVELOPER
553 if (IsCLIParam("catchingLogs"))
554 {
555 Print("***"); //just for debug purposes to track the start
556 }
557 #endif
558 }
559
560 void UpdateDataAndMasks()
561 {
563 InitCatchMethodMask(); //bait check
564 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
567 }
568
570 {
572 return GetCatchEnviroMask();
573 }
574
575 void SetTrapEnviroMask(int value)
576 {
577 m_EnviroMask = value;
578 }
579
581 void UpdateUsedBait(ECatchingBaitCategories type)
582 {
583 m_Bait = null;
584 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
585 {
586 BaitData dta = m_BaitCompatibilityMap.Get(type);
587 if (dta)
588 {
589 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
590 if (potentialBait != m_MainItem)
591 m_Bait = potentialBait;
592 }
593 else
594 ErrorEx("failed to acquire BaitData from type: " + type);
595 }
596
597 #ifdef DEVELOPER
598 if (IsCLIParam("catchingLogs"))
599 {
600 if (m_Bait)
601 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
602 else
603 Print("dbgTrapz | UpdateUsedBait to 'null'!");
604 }
605 #endif
606 }
607
608 override void UpdateBaseProbability(YieldItemBase yItem)
609 {
610 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
611 int usedType = -1;
612 float probability = -1;
613 float highestProbability = 0.0;
614 int count = m_BaitCompatibilityMap.Count();
615 for (int i = 0; i < count; i++)
616 {
617 baitType = m_BaitCompatibilityMap.GetKey(i);
618 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
619 if (probability > highestProbability)
620 {
621 highestProbability = probability;
622 usedType = baitType;
623 }
624 }
625
626 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
627 #ifdef DEVELOPER
628 if (IsCLIParam("catchingLogs"))
629 {
630 //Print("********************");
631 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
632 }
633 #endif
634 UpdateUsedBait(usedType);
635
636 #ifdef DEVELOPER
637 if (IsCLIParam("catchingLogs"))
638 {
639 float dbgProb;
641 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
642 }
643 #endif
644 }
645
646 override bool ModifySignalProbability(inout float probability)
647 {
648 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
649
650 return true;
651 }
652
653 void RemoveBait()
654 {
655 if (m_Bait)
656 m_Bait.DeleteSafe();
657 }
658
659 void ReduceBaitQty(float qtyNorm)
660 {
661 if (m_Bait)
662 {
663 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
664 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
665 else
666 m_Bait.DeleteSafe();
667 }
668 }
669}
670
671class CatchingContextTrapFishSmall : CatchingContextTrapsBase
672{
673 override protected void InitCatchMethodMask()
674 {
675 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
676 }
677}
678
680{
681 override protected void InitCatchMethodMask()
682 {
683 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_LARGE;
684 }
685}
686
687class CatchingContextTrapLandSnare : CatchingContextTrapsBase
688{
689 override protected void InitCatchMethodMask()
690 {
691 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
692 }
693}
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.

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