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

◆ InitCatchEnviroMask()

void InitCatchMethodMask::InitCatchEnviroMask ( )
protected

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

341{
346 protected float m_CumulativeTrappingSuccess;
347 protected int m_AttemptsCount;
348 protected ItemBase m_Bait;
349
350 override protected void DeserializeData(Param par)
351 {
353 if (Class.CastTo(p,par))
354 {
355 m_MainItem = p.param1;
356 m_AttemptsCount = p.param2;
357 }
358 }
359
360 override protected void CreateResultDataStructure()
361 {
363
364 super.CreateResultDataStructure();
365 }
366
367 override protected void ClearCatchingItemData()
368 {
369 super.ClearCatchingItemData();
370
372 m_QualityBaseMod = 0.0;
375 }
376
377 override protected void InitItemValues(EntityAI item)
378 {
379 //skip ruined or deleted items entirely
380 if (item.IsRuined() || item.IsSetForDeletion())
381 return;
382
383 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
384 if (GetGame().ConfigIsExisting(path))
385 {
386 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
387 {
392 int count = CachedObjectsArrays.ARRAY_INT.Count();
393 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
394 {
395 int key;
396 float value;
397 for (int i = 0; i < count; i++)
398 {
401 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
402 {
403 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
404 }
405 }
406 }
407 else
408 {
409 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
410 }
411 }
412 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
413 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
414 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
415 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
416 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
417 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
418 }
419 }
420
423 {
424 float ret = 1.0;
425 ItemBase ib;
426 if (Class.CastTo(ib,item))
427 {
428 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
429 }
430
431 return ret;
432 }
433
434 override protected void InitCatchEnviroMask()
435 {
436 vector pos = m_MainItem.GetPosition();
437 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
439 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
441 else
443 }
444
445 override protected void Init(Param par)
446 {
447 super.Init(par);
448
450 }
451
452 override protected void SetupInitialTypes()
453 {
454 #ifdef DEVELOPER
455 if (IsCLIParam("catchingLogs"))
456 {
457 Print("********************"); //just for debug purposes to track the start
458 Print("dbgTrapz | START");
459 Print("********************");
460 }
461 #endif
462
463 super.SetupInitialTypes();
464
465 #ifdef DEVELOPER
466 if (IsCLIParam("catchingLogs"))
467 {
468 Print("***"); //just for debug purposes to track the start
469 }
470 #endif
471 }
472
473 void UpdateDataAndMasks()
474 {
476 InitCatchMethodMask(); //bait check
477 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
480 }
481
483 {
485 return GetCatchEnviroMask();
486 }
487
488 void SetTrapEnviroMask(int value)
489 {
490 m_EnviroMask = value;
491 }
492
494 void UpdateUsedBait(ECatchingBaitCategories type)
495 {
496 m_Bait = null;
497 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
498 {
499 BaitData dta = m_BaitCompatibilityMap.Get(type);
500 if (dta)
501 {
502 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
503 if (potentialBait != m_MainItem)
504 m_Bait = potentialBait;
505 }
506 else
507 ErrorEx("failed to acquire BaitData from type: " + type);
508 }
509
510 #ifdef DEVELOPER
511 if (IsCLIParam("catchingLogs"))
512 {
513 if (m_Bait)
514 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
515 else
516 Print("dbgTrapz | UpdateUsedBait to 'null'!");
517 }
518 #endif
519 }
520
521 override void UpdateBaseProbability(YieldItemBase yItem)
522 {
523 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
524 int usedType = -1;
525 float probability = -1;
526 float highestProbability = 0.0;
527 int count = m_BaitCompatibilityMap.Count();
528 for (int i = 0; i < count; i++)
529 {
530 baitType = m_BaitCompatibilityMap.GetKey(i);
531 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
532 if (probability > highestProbability)
533 {
534 highestProbability = probability;
535 usedType = baitType;
536 }
537 }
538
539 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
540 #ifdef DEVELOPER
541 if (IsCLIParam("catchingLogs"))
542 {
543 //Print("********************");
544 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
545 }
546 #endif
547 UpdateUsedBait(usedType);
548
549 #ifdef DEVELOPER
550 if (IsCLIParam("catchingLogs"))
551 {
552 float dbgProb;
554 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
555 }
556 #endif
557 }
558
559 override bool ModifySignalProbability(inout float probability)
560 {
561 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
562
563 return true;
564 }
565
566 void RemoveBait()
567 {
568 if (m_Bait)
569 m_Bait.DeleteSafe();
570 }
571
572 void ReduceBaitQty(float qtyNorm)
573 {
574 if (m_Bait)
575 {
576 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
577 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
578 else
579 m_Bait.DeleteSafe();
580 }
581 }
582}
583
584class CatchingContextTrapFishSmall : CatchingContextTrapsBase
585{
586 override protected void InitCatchMethodMask()
587 {
588 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
589 }
590}
591
593{
594 override protected void InitCatchMethodMask()
595 {
596 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_LARGE;
597 }
598}
599
600class CatchingContextTrapLandSnare : CatchingContextTrapsBase
601{
602 override protected void InitCatchMethodMask()
603 {
604 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
605 }
606}
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.