DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл CatchingContextBase.c

См. исходные тексты.

Структуры данных

class  BaitData
 

Функции

void CatchingContextBase (Param par)
 
void Init (Param par)
 
void DeserializeData (Param par)
 
void InitBaitCompatibilityMap ()
 
void SetupInitialTypes ()
 
void ParseYieldItemsForCompatibility (array< ECatchingBaitCategories > excludedTypes=null)
 
void SetupProbabilityArray ()
 
YieldsMap GetYieldsMap ()
 
void CreateResultDataStructure ()
 override if using another result
 
void InitCatchMasks ()
 
void InitCatchMethodMask ()
 
void InitCatchEnviroMask ()
 
int GetCatchMethodMask ()
 override using 'ECatchMethodMask'
 
int GetCatchEnviroMask ()
 
bool CheckMaskCompatibility (YieldItemBase yItem)
 
bool CheckBaitCompatibility (YieldItemBase yItem, array< ECatchingBaitCategories > excludedTypes=null)
 
void UpdateCatchingItemData ()
 
void InitCatchingItemData ()
 
void InitItemValues (EntityAI item)
 override to init context-specific values
 
void ClearCatchingItemData ()
 called before actual item data initialization
 
void RecalculateProcessingData ()
 Calculates and sets all data used in ongoing calculations.
 
bool IsValid ()
 Checks if the ScriptCaller is valid.
 
void GenerateResult ()
 
void UpdateBaseProbability (YieldItemBase yItem)
 updates base probability when catching the specific item (some context subclasses only)
 
bool ModifySignalProbability (inout float probability)
 
float GetQualityModifier ()
 
void SetResultChanceOverride (bool ovrd, float val=0.0)
 
void SetResultQualityOverride (bool ovrd, float val=0.0)
 
bool RollCatch ()
 
EntityAI SpawnAndSetupCatch (out int yItemIdx, vector v=vector.Zero)
 

Переменные

class BaitData m_MainItem
 
YieldsMap m_YieldsMapAll
 
bool m_IsValid
 
int m_MethodMask
 
int m_EnviroMask
 
float m_QualityBaseMod
 
float m_QualityDispersionMinMod
 
float m_QualityDispersionMaxMod
 
ref map< int, ref BaitDatam_BaitCompatibilityMap
 
ref array< YieldItemBasem_CompatibleItems
 
ref array< YieldItemBasem_ExcludedItems
 
ref array< intm_ProbabilityArray
 
ref CatchingResultBasic m_Result
 

Функции

◆ CatchingContextBase()

void CatchingContextBase ( Param par)
protected
30 {
31 Init(par);
32 }
override Widget Init()
Definition DayZGame.c:122
Definition EntityAI.c:95

Перекрестные ссылки Init().

◆ CheckBaitCompatibility()

bool CheckBaitCompatibility ( YieldItemBase yItem,
array< ECatchingBaitCategories > excludedTypes = null )
protected
175 {
176 float highestSensitivity = 0.0;
177 float sensitivity = 0.0;
178 int count = m_BaitCompatibilityMap.Count();
180
181 for (int i = 0; i < count; i++)
182 {
184 if (excludedTypes && excludedTypes.Find(baitCategoryType) != -1) //skip ignored bait types in the first run
185 continue;
186
187 sensitivity = yItem.GetBaitTypeSensitivity(baitCategoryType);
188 if (sensitivity < 0)
189 {
190 if (m_ExcludedItems.Find(yItem) != -1)
191 m_ExcludedItems.Insert(yItem);
192 return false;
193 }
194
196 }
197
198 #ifdef DEVELOPER
199 if (IsCLIParam("catchingLogs"))
200 {
201 if (count == 0)
202 Print("dbgTrapz | " + yItem + " compatible due to unspecified bait compatibility!");
203 else if (highestSensitivity > 0.0)
204 Print("dbgTrapz | " + yItem + " compatible with highestSensitivity: " + highestSensitivity);
205 }
206 #endif
207
208 return count == 0 || highestSensitivity > 0.0;
209 }
ref array< YieldItemBase > m_ExcludedItems
Definition CatchingContextBase.c:25
ref map< int, ref BaitData > m_BaitCompatibilityMap
Definition CatchingContextBase.c:23
Definition EnMath.c:7
proto void Print(void var)
Prints content of variable to console/log.
static proto float Max(float x, float y)
Returns bigger of two given values.
proto native bool IsCLIParam(string param)
Returns if command line argument is present.

Перекрестные ссылки IsCLIParam(), m_BaitCompatibilityMap, m_ExcludedItems, Math::Max() и Print().

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

◆ CheckMaskCompatibility()

bool CheckMaskCompatibility ( YieldItemBase yItem)
protected
170 {
171 return (yItem.GetMethodMask() & GetCatchMethodMask()) && (yItem.GetEnviroMask() & GetCatchEnviroMask());
172 }
int GetCatchEnviroMask()
Definition CatchingContextBase.c:164
int GetCatchMethodMask()
override using 'ECatchMethodMask'
Definition CatchingContextBase.c:159

Перекрестные ссылки GetCatchEnviroMask() и GetCatchMethodMask().

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

◆ ClearCatchingItemData()

void ClearCatchingItemData ( )
protected

called before actual item data initialization

242 {
243 m_QualityBaseMod = 0.0;
246 }
float m_QualityBaseMod
Definition CatchingContextBase.c:20
float m_QualityDispersionMinMod
Definition CatchingContextBase.c:21
float m_QualityDispersionMaxMod
Definition CatchingContextBase.c:22

Перекрестные ссылки m_QualityBaseMod, m_QualityDispersionMaxMod и m_QualityDispersionMinMod.

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

◆ CreateResultDataStructure()

void CreateResultDataStructure ( )
protected

override if using another result

132 {
133 //m_Result = new CatchingResultSomethingSomethingCustom(someItem);
134
135 if (!m_Result)
136 {
137 ErrorEx("Failed to create 'm_Result' structure for item: " + m_MainItem,ErrorExSeverity.INFO);
138 m_IsValid = false;
139 }
140 }
class BaitData m_MainItem
Definition ActionBase.c:36
ref CatchingResultBasic m_Result
Definition CatchingContextBase.c:27
bool m_IsValid
Definition CatchingContextBase.c:17
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx

Перекрестные ссылки ErrorEx, m_IsValid, m_MainItem и m_Result.

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

◆ DeserializeData()

void DeserializeData ( Param par)
protected
256 {
258 }
259}
260
262{
263 override protected void InitCatchMethodMask()
264 {
void InitCatchMethodMask()
Definition CatchingContextBase.c:148
int m_MethodMask
Definition CatchingContextBase.c:18
Definition CatchingConstants.c:2
static const int MASK_METHOD_FISHTRAP_LARGE
Definition CatchingConstants.c:20
Definition CatchingContextTraps.c:2

Перекрестные ссылки m_MethodMask и AnimalCatchingConstants::MASK_METHOD_FISHTRAP_LARGE.

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

◆ GenerateResult()

void GenerateResult ( )
protected
258 {
260 if (m_IsValid)
261 {
262 Class.CastTo(yItem,m_YieldsMapAll.Get(m_ProbabilityArray.GetRandomElement()));
263 m_Result.SetYieldItem(yItem);
265 }
266 }
ref array< int > m_ProbabilityArray
Definition CatchingContextBase.c:26
YieldsMap m_YieldsMapAll
Definition CatchingContextBase.c:16
void UpdateBaseProbability(YieldItemBase yItem)
updates base probability when catching the specific item (some context subclasses only)
Definition CatchingContextTraps.c:427
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition CatchYieldItemBase.c:2
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo(), m_IsValid, m_ProbabilityArray, m_Result, m_YieldsMapAll и UpdateBaseProbability().

Используется в CatchingContextTrapsBase::Init().

◆ GetCatchEnviroMask()

int GetCatchEnviroMask ( )
protected
165 {
166 return m_EnviroMask;
167 }
int m_EnviroMask
Definition CatchingContextBase.c:19

Перекрестные ссылки m_EnviroMask.

Используется в CheckMaskCompatibility() и CatchingContextTrapsBase::UpdateTrapEnviroMask().

◆ GetCatchMethodMask()

int GetCatchMethodMask ( )
protected

override using 'ECatchMethodMask'

160 {
161 return m_MethodMask;
162 }

Перекрестные ссылки m_MethodMask.

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

◆ GetQualityModifier()

float GetQualityModifier ( )
protected
277 {
279 return ret;
280 }
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106

Перекрестные ссылки m_QualityBaseMod, m_QualityDispersionMaxMod, m_QualityDispersionMinMod и Math::RandomFloatInclusive().

◆ GetYieldsMap()

YieldsMap GetYieldsMap ( )
protected
126 {
127 return m_YieldsMapAll;
128 }

Перекрестные ссылки m_YieldsMapAll.

◆ Init()

void Init ( Param par)
protected
35 {
36 m_IsValid = true;
37 m_YieldsMapAll = GetGame().GetMission().GetWorldData().GetCatchYieldBank().GetYieldsMap();
44 }
void SetupInitialTypes()
Definition CatchingContextBase.c:56
void DeserializeData(Param par)
Definition CatchingContextTraps.c:256
void CreateResultDataStructure()
override if using another result
Definition CatchingContextBase.c:131
void InitCatchingItemData()
Definition CatchingContextBase.c:217
void InitCatchMasks()
Definition CatchingContextBase.c:142
void SetupProbabilityArray()
Definition CatchingContextBase.c:97
proto native CGame GetGame()

Перекрестные ссылки CreateResultDataStructure(), DeserializeData(), GetGame(), InitCatchingItemData(), InitCatchMasks(), m_IsValid, m_YieldsMapAll, SetupInitialTypes() и SetupProbabilityArray().

◆ InitBaitCompatibilityMap()

void InitBaitCompatibilityMap ( )
protected

Перекрестные ссылки m_BaitCompatibilityMap.

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

◆ InitCatchEnviroMask()

void InitCatchEnviroMask ( )
protected
154 {
155 m_EnviroMask = 0;
156 }

Перекрестные ссылки m_EnviroMask.

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

◆ InitCatchingItemData()

void InitCatchingItemData ( )
protected
218 {
219 if (!m_MainItem)
220 {
221 ErrorEx("No item defined for 'InitCatchingItemData'. Skipping.");
222 m_IsValid = false;
223 return;
224 }
225
228
229 //bruteforce, but should be done sparingly enough..
231 m_MainItem.GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,children);
232 foreach (EntityAI child: children)
233 {
235 }
236 }
void InitBaitCompatibilityMap()
Definition CatchingContextBase.c:48
void ClearCatchingItemData()
called before actual item data initialization
Definition CatchingContextBase.c:241
void InitItemValues(EntityAI item)
override to init context-specific values
Definition CatchingContextTraps.c:283
Definition Building.c:6
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6

Перекрестные ссылки ClearCatchingItemData(), ErrorEx, InitBaitCompatibilityMap(), InitItemValues(), m_IsValid и m_MainItem.

Используется в Init(), UpdateCatchingItemData() и CatchingContextTrapsBase::UpdateDataAndMasks().

◆ InitCatchMasks()

void InitCatchMasks ( )
protected
143 {
146 }
void InitCatchEnviroMask()
Definition CatchingContextBase.c:153

Перекрестные ссылки InitCatchEnviroMask() и InitCatchMethodMask().

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

◆ InitCatchMethodMask()

void InitCatchMethodMask ( )
protected
149 {
150 m_MethodMask = 0;
151 }

Перекрестные ссылки m_MethodMask.

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

◆ InitItemValues()

void InitItemValues ( EntityAI item)
protected

override to init context-specific values

283 : CatchingContextBase
284{
288
289 protected float m_CumulativeTrappingSuccess;
290 protected int m_AttemptsCount;
291 protected ItemBase m_Bait;
292
293 override protected void DeserializeData(Param par)
294 {
296 if (Class.CastTo(p,par))
297 {
298 m_MainItem = p.param1;
299 m_AttemptsCount = p.param2;
300 }
301 }
302
303 override protected void CreateResultDataStructure()
304 {
306
307 super.CreateResultDataStructure();
308 }
309
310 override protected void ClearCatchingItemData()
311 {
312 super.ClearCatchingItemData();
313
315 m_QualityBaseMod = 0.0;
318 }
319
320 override protected void InitItemValues(EntityAI item)
321 {
322 //skip ruined or deleted items entirely
323 if (item.IsRuined() || item.IsSetForDeletion())
324 return;
325
326 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
327 if (GetGame().ConfigIsExisting(path))
328 {
329 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
330 {
333 GetGame().ConfigGetIntArray(path + " baitTypes",CachedObjectsArrays.ARRAY_INT);
334 GetGame().ConfigGetFloatArray(path + " baitTypeChances",CachedObjectsArrays.ARRAY_FLOAT);
335 int count = CachedObjectsArrays.ARRAY_INT.Count();
337 {
338 int key;
339 float value;
340 for (int i = 0; i < count; i++)
341 {
344 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
345 {
347 }
348 }
349 }
350 else
351 {
352 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
353 }
354 }
355 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
356 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
357 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
358 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
359 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
360 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
361 }
362 }
363
366 {
367 float ret = 1.0;
368 ItemBase ib;
369 if (Class.CastTo(ib,item))
370 {
371 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
372 }
373
374 return ret;
375 }
376
377 override protected void InitCatchEnviroMask()
378 {
379 vector pos = m_MainItem.GetPosition();
380 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
382 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
384 else
386 }
387
388 override protected void Init(Param par)
389 {
390 super.Init(par);
391
393 }
394
395 override protected void SetupInitialTypes()
396 {
397 #ifdef DEVELOPER
398 if (IsCLIParam("catchingLogs"))
399 {
400 Print("********************"); //just for debug purposes to track the start
401 Print("dbgTrapz | START");
402 Print("********************");
403 }
404 #endif
405
406 super.SetupInitialTypes();
407
408 #ifdef DEVELOPER
409 if (IsCLIParam("catchingLogs"))
410 {
411 Print("***"); //just for debug purposes to track the start
412 }
413 #endif
414 }
415
416 void UpdateDataAndMasks()
417 {
419 InitCatchMethodMask(); //bait check
420 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
423 }
424
426 {
428 return GetCatchEnviroMask();
429 }
430
431 void SetTrapEnviroMask(int value)
432 {
434 }
435
438 {
439 m_Bait = null;
440 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
441 {
443 if (dta)
444 {
445 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
448 }
449 else
450 ErrorEx("failed to acquire BaitData from type: " + type);
451 }
452
453 #ifdef DEVELOPER
454 if (IsCLIParam("catchingLogs"))
455 {
456 if (m_Bait)
457 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
458 else
459 Print("dbgTrapz | UpdateUsedBait to 'null'!");
460 }
461 #endif
462 }
463
465 {
466 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
467 int usedType = -1;
468 float probability = -1;
469 float highestProbability = 0.0;
470 int count = m_BaitCompatibilityMap.Count();
471 for (int i = 0; i < count; i++)
472 {
474 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
476 {
479 }
480 }
481
483 #ifdef DEVELOPER
484 if (IsCLIParam("catchingLogs"))
485 {
486 //Print("********************");
487 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
488 }
489 #endif
491
492 #ifdef DEVELOPER
493 if (IsCLIParam("catchingLogs"))
494 {
495 float dbgProb;
497 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
498 }
499 #endif
500 }
501
502 override bool ModifySignalProbability(inout float probability)
503 {
505
506 return true;
507 }
508
509 void RemoveBait()
510 {
511 if (m_Bait)
512 m_Bait.DeleteSafe();
513 }
514
515 void ReduceBaitQty(float qtyNorm)
516 {
517 if (m_Bait)
518 {
519 if (m_Bait.HasQuantity() && !m_Bait.CanBeSplit())
520 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
521 else
522 m_Bait.DeleteSafe();
523 }
524 }
525}
526
528{
529 override protected void InitCatchMethodMask()
530 {
532 }
533}
534
536{
537 override protected void InitCatchMethodMask()
538 {
540 }
541}
542
544{
545 override protected void InitCatchMethodMask()
546 {
548 }
549}
void GenerateResult()
Definition CatchingContextBase.c:257
void SetupInitialTypes()
Definition CatchingContextTraps.c:358
void ClearCatchingItemData()
Definition CatchingContextTraps.c:273
ItemBase m_Bait
Definition CatchingContextTraps.c:254
void DeserializeData(Param par)
Definition CatchingContextTraps.c:256
override bool ModifySignalProbability(inout float probability)
Definition CatchingContextTraps.c:465
int UpdateTrapEnviroMask()
Definition CatchingContextTraps.c:388
CatchingContextTrapsBase CatchingContextBase InitCatchMethodMask()
Definition CatchingContextTraps.c:247
void UpdateUsedBait(ECatchingBaitCategories type)
if non-empty bait type is used, some 'Bait' attachment is picked as an active bait (currently no dire...
Definition CatchingContextTraps.c:400
void InitItemValues(EntityAI item)
override to init context-specific values
Definition CatchingContextTraps.c:283
float m_CumulativeTrappingSuccess
after N attempts, the chance to catch should be this. Only highest one applies. @NOTE: Take care,...
Definition CatchingContextTraps.c:252
void UpdateDataAndMasks()
Definition CatchingContextTraps.c:379
void ReduceBaitQty(float qtyNorm)
Definition CatchingContextTraps.c:478
void CreateResultDataStructure()
Definition CatchingContextTraps.c:266
override void UpdateBaseProbability(YieldItemBase yItem)
updates base probability when catching the specific item (some context subclasses only)
Definition CatchingContextTraps.c:427
int m_AttemptsCount
Definition CatchingContextTraps.c:253
void InitCatchEnviroMask()
Definition CatchingContextTraps.c:340
float AdjustBaitItemChance(EntityAI item)
Allows for adjustment of all catch probabilities from item qualities (damage, qty....
Definition CatchingContextTraps.c:328
void RemoveBait()
Definition CatchingContextTraps.c:472
void SetTrapEnviroMask(int value)
Definition CatchingContextTraps.c:394
string path
Definition OptionSelectorMultistate.c:142
static const int MASK_ENVIRO_LAND_ALL
Definition CatchingConstants.c:16
static const int MASK_METHOD_LANDTRAP_SNARE
Definition CatchingConstants.c:22
static const int MASK_ENVIRO_SEA
Definition CatchingConstants.c:12
static const int MASK_ENVIRO_POND
Definition CatchingConstants.c:11
static const int MASK_METHOD_FISHTRAP_SMALL
Definition CatchingConstants.c:21
Definition CatchingContextBase.c:2
Definition UtilityClasses.c:41
static ref TIntArray ARRAY_INT
Definition UtilityClasses.c:51
static ref TFloatArray ARRAY_FLOAT
Definition UtilityClasses.c:50
Definition CatchingContextTraps.c:254
void InitCatchMethodMask()
Definition CatchingContextTraps.c:255
Definition CarchingResultTrapBase.c:2
Definition InventoryItem.c:731
override bool CanBeSplit()
Definition Rag.c:34
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Definition EnConvert.c:106
static proto float Pow(float v, float power)
Return power of v ^ power.
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'.
const string CFG_VEHICLESPATH
Definition constants.c:217

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

◆ IsValid()

bool IsValid ( )
protected

Checks if the ScriptCaller is valid.

252 {
253 return m_IsValid;
254 }

Перекрестные ссылки m_IsValid.

◆ ModifySignalProbability()

bool ModifySignalProbability ( inout float probability)
protected
272 {
273 return false;
274 }

◆ ParseYieldItemsForCompatibility()

void ParseYieldItemsForCompatibility ( array< ECatchingBaitCategories > excludedTypes = null)
protected
81 {
83 int count = m_YieldsMapAll.Count();
84 for (int i = 0; i < count; i++)
85 {
86 yItem = m_YieldsMapAll.GetElement(i);
87 if (m_ExcludedItems.Find(yItem) != -1) //skip already excluded yitems
88 continue;
89
91 {
93 }
94 }
95 }
ref array< YieldItemBase > m_CompatibleItems
Definition CatchingContextBase.c:24
bool CheckBaitCompatibility(YieldItemBase yItem, array< ECatchingBaitCategories > excludedTypes=null)
Definition CatchingContextBase.c:174
bool CheckMaskCompatibility(YieldItemBase yItem)
Definition CatchingContextBase.c:169

Перекрестные ссылки CheckBaitCompatibility(), CheckMaskCompatibility(), m_CompatibleItems, m_ExcludedItems и m_YieldsMapAll.

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

◆ RecalculateProcessingData()

void RecalculateProcessingData ( )
protected

Calculates and sets all data used in ongoing calculations.

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

◆ RollCatch()

bool RollCatch ( )
protected
294 {
295 m_Result.UpdateCatchChance(this);
296 return m_Result.RollChance();
297 }

Перекрестные ссылки m_Result.

◆ SetResultChanceOverride()

void SetResultChanceOverride ( bool ovrd,
float val = 0.0 )
protected
283 {
284 m_Result.SetCatchChanceOverride(ovrd,val);
285 }

Перекрестные ссылки m_Result.

◆ SetResultQualityOverride()

void SetResultQualityOverride ( bool ovrd,
float val = 0.0 )
protected
288 {
289 m_Result.SetQualityOverride(ovrd,val);
290 }

Перекрестные ссылки m_Result.

◆ SetupInitialTypes()

void SetupInitialTypes ( )
protected
57 {
60 else
61 m_CompatibleItems.Clear();
62
63 if (!m_ExcludedItems)
65 else
66 m_ExcludedItems.Clear();
67
68
70 if (m_CompatibleItems.Count() == 0)
72
73 if (m_CompatibleItems.Count() == 0)
74 {
75 ErrorEx("Empty m_CompatibleItems for item: " + m_MainItem,ErrorExSeverity.INFO);
76 m_IsValid = false;
77 }
78 }
void ParseYieldItemsForCompatibility(array< ECatchingBaitCategories > excludedTypes=null)
Definition CatchingContextBase.c:80

Перекрестные ссылки ErrorEx, m_CompatibleItems, m_ExcludedItems, m_IsValid, m_MainItem и ParseYieldItemsForCompatibility().

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

◆ SetupProbabilityArray()

void SetupProbabilityArray ( )
protected
98 {
101 m_ProbabilityArray.Clear();
102
103 int count = m_CompatibleItems.Count();
105
106 for (int i = 0; i < count; i++)
107 {
109 string type = yItem.GetType();
110 int weight = yItem.GetYieldWeight(this);
111
112 for (int j = 0; j < weight; j++)
113 {
114 m_ProbabilityArray.Insert(type.Hash());
115 }
116 }
117
118 if (m_ProbabilityArray.Count() == 0)
119 {
120 ErrorEx("Empty m_ProbabilityArray for item: " + m_MainItem,ErrorExSeverity.INFO);
121 m_IsValid = false;
122 }
123 }
proto native int Hash()
Returns hash of string.

Перекрестные ссылки ErrorEx, string::Hash(), m_CompatibleItems, m_IsValid, m_MainItem и m_ProbabilityArray.

Используется в Init() и CatchingContextTrapsBase::UpdateDataAndMasks().

◆ SpawnAndSetupCatch()

EntityAI SpawnAndSetupCatch ( out int yItemIdx,
vector v = vector.Zero )
protected
301 {
302 if (!m_IsValid)
303 {
304 ErrorEx("Could not spawn catch for item: " + m_MainItem,ErrorExSeverity.INFO);
305 return null;
306 }
307 m_Result.UpdateCatchQuality(this);
308
309 return m_Result.SpawnAndSetup(yItemIdx,v);
310 }

Перекрестные ссылки ErrorEx, m_IsValid, m_MainItem и m_Result.

◆ UpdateBaseProbability()

void UpdateBaseProbability ( YieldItemBase yItem)
protected

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

427 : CatchingContextBase
428{
432
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 {
477 GetGame().ConfigGetIntArray(path + " baitTypes",CachedObjectsArrays.ARRAY_INT);
478 GetGame().ConfigGetFloatArray(path + " baitTypeChances",CachedObjectsArrays.ARRAY_FLOAT);
479 int count = CachedObjectsArrays.ARRAY_INT.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 {
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 {
578 }
579
582 {
583 m_Bait = null;
584 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
585 {
587 if (dta)
588 {
589 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
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
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 {
618 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
620 {
623 }
624 }
625
627 #ifdef DEVELOPER
628 if (IsCLIParam("catchingLogs"))
629 {
630 //Print("********************");
631 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
632 }
633 #endif
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 {
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.CanBeSplit())
664 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
665 else
666 m_Bait.DeleteSafe();
667 }
668 }
669}
670
672{
673 override protected void InitCatchMethodMask()
674 {
676 }
677}
678
680{
681 override protected void InitCatchMethodMask()
682 {
684 }
685}
686
688{
689 override protected void InitCatchMethodMask()
690 {
692 }
693}

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

◆ UpdateCatchingItemData()

void UpdateCatchingItemData ( )
protected
212 {
215 }
void RecalculateProcessingData()
Calculates and sets all data used in ongoing calculations.

Перекрестные ссылки InitCatchingItemData() и RecalculateProcessingData().

Используется в CatchingContextFishingRodAction::OnAfterSpawnSignalHit(), CatchingContextFishingRodAction::OnSignalMiss() и CatchingContextFishingRodAction::OnSignalPass().

Переменные

◆ m_BaitCompatibilityMap

◆ m_CompatibleItems

ref array<YieldItemBase> m_CompatibleItems
protected

◆ m_EnviroMask

◆ m_ExcludedItems

ref array<YieldItemBase> m_ExcludedItems
protected

◆ m_IsValid

◆ m_MainItem

◆ m_MethodMask

◆ m_ProbabilityArray

ref array<int> m_ProbabilityArray
protected

◆ m_QualityBaseMod

◆ m_QualityDispersionMaxMod

◆ m_QualityDispersionMinMod

◆ m_Result

◆ m_YieldsMapAll