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

◆ AdjustBaitItemChance()

float InitCatchMethodMask::AdjustBaitItemChance ( EntityAI item)
protected

Allows for adjustment of all catch probabilities from item qualities (damage, qty...)

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

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