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

◆ ReduceBaitQty()

void InitCatchMethodMask::ReduceBaitQty ( float qtyNorm)
protected

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

479{
484 protected float m_CumulativeTrappingSuccess;
485 protected int m_AttemptsCount;
486 protected ItemBase m_Bait;
487
488 override protected void DeserializeData(Param par)
489 {
491 if (Class.CastTo(p,par))
492 {
493 m_MainItem = p.param1;
494 m_AttemptsCount = p.param2;
495 }
496 }
497
498 override protected void CreateResultDataStructure()
499 {
501
502 super.CreateResultDataStructure();
503 }
504
505 override protected void ClearCatchingItemData()
506 {
507 super.ClearCatchingItemData();
508
510 m_QualityBaseMod = 0.0;
513 }
514
515 override protected void InitItemValues(EntityAI item)
516 {
517 //skip ruined or deleted items entirely
518 if (item.IsRuined() || item.IsSetForDeletion())
519 return;
520
521 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
522 if (GetGame().ConfigIsExisting(path))
523 {
524 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
525 {
530 int count = CachedObjectsArrays.ARRAY_INT.Count();
531 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
532 {
533 int key;
534 float value;
535 for (int i = 0; i < count; i++)
536 {
539 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
540 {
541 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
542 }
543 }
544 }
545 else
546 {
547 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
548 }
549 }
550 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
551 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
552 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
553 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
554 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
555 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
556 }
557 }
558
561 {
562 float ret = 1.0;
563 ItemBase ib;
564 if (Class.CastTo(ib,item))
565 {
566 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
567 }
568
569 return ret;
570 }
571
572 override protected void InitCatchEnviroMask()
573 {
574 vector pos = m_MainItem.GetPosition();
575 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
577 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
579 else
581 }
582
583 override protected void Init(Param par)
584 {
585 super.Init(par);
586
588 }
589
590 override protected void SetupInitialTypes()
591 {
592 #ifdef DEVELOPER
593 if (IsCLIParam("catchingLogs"))
594 {
595 Print("********************"); //just for debug purposes to track the start
596 Print("dbgTrapz | START");
597 Print("********************");
598 }
599 #endif
600
601 super.SetupInitialTypes();
602
603 #ifdef DEVELOPER
604 if (IsCLIParam("catchingLogs"))
605 {
606 Print("***"); //just for debug purposes to track the start
607 }
608 #endif
609 }
610
611 void UpdateDataAndMasks()
612 {
614 InitCatchMethodMask(); //bait check
615 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
618 }
619
621 {
623 return GetCatchEnviroMask();
624 }
625
626 void SetTrapEnviroMask(int value)
627 {
628 m_EnviroMask = value;
629 }
630
632 void UpdateUsedBait(ECatchingBaitCategories type)
633 {
634 m_Bait = null;
635 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
636 {
637 BaitData dta = m_BaitCompatibilityMap.Get(type);
638 if (dta)
639 {
640 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
641 if (potentialBait != m_MainItem)
642 m_Bait = potentialBait;
643 }
644 else
645 ErrorEx("failed to acquire BaitData from type: " + type);
646 }
647
648 #ifdef DEVELOPER
649 if (IsCLIParam("catchingLogs"))
650 {
651 if (m_Bait)
652 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
653 else
654 Print("dbgTrapz | UpdateUsedBait to 'null'!");
655 }
656 #endif
657 }
658
659 override void UpdateBaseProbability(YieldItemBase yItem)
660 {
661 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
662 int usedType = -1;
663 float probability = -1;
664 float highestProbability = 0.0;
665 int count = m_BaitCompatibilityMap.Count();
666 for (int i = 0; i < count; i++)
667 {
668 baitType = m_BaitCompatibilityMap.GetKey(i);
669 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
670 if (probability > highestProbability)
671 {
672 highestProbability = probability;
673 usedType = baitType;
674 }
675 }
676
677 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
678 #ifdef DEVELOPER
679 if (IsCLIParam("catchingLogs"))
680 {
681 //Print("********************");
682 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
683 }
684 #endif
685 UpdateUsedBait(usedType);
686
687 #ifdef DEVELOPER
688 if (IsCLIParam("catchingLogs"))
689 {
690 float dbgProb;
692 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
693 }
694 #endif
695 }
696
697 override bool ModifySignalProbability(inout float probability)
698 {
699 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
700
701 return true;
702 }
703
704 void RemoveBait()
705 {
706 if (m_Bait)
707 m_Bait.DeleteSafe();
708 }
709
710 void ReduceBaitQty(float qtyNorm)
711 {
712 if (m_Bait)
713 {
714 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
715 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
716 else
717 m_Bait.DeleteSafe();
718 }
719 }
720}
721
722class CatchingContextTrapFishSmall : CatchingContextTrapsBase
723{
724 override protected void InitCatchMethodMask()
725 {
726 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
727 }
728}
729
731{
732 override protected void InitCatchMethodMask()
733 {
734 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_LARGE;
735 }
736}
737
738class CatchingContextTrapLandSnare : CatchingContextTrapsBase
739{
740 override protected void InitCatchMethodMask()
741 {
742 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
743 }
744}
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.