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

◆ UpdateUsedBait()

void InitCatchMethodMask::UpdateUsedBait ( ECatchingBaitCategories type)
protected

if non-empty bait type is used, some 'Bait' attachment is picked as an active bait (currently no direct link between item and sensitivity-weighted target probability)

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

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