DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CatchingContextBase.c
См. документацию.
2{
5
6 void BaitData(float value, EntityAI owner)
7 {
8 m_BaseProbability = value;
9 m_Owner = owner;
10 }
11}
12
14{
15 protected EntityAI m_MainItem;
17 protected bool m_IsValid;
18 protected int m_MethodMask;
19 protected int m_EnviroMask;
20 protected float m_QualityBaseMod; //base quality
21 protected float m_QualityDispersionMinMod; //extra added quality, min
22 protected float m_QualityDispersionMaxMod; //extra added quality, max
24 protected ref array<YieldItemBase> m_CompatibleItems; //list of all useful yields (initial evaluation based on masks)
26 protected ref array<int> m_ProbabilityArray; //actual probability list
28
30 {
31 Init(par);
32 }
33
45
46 protected void DeserializeData(Param par);
47
55
56 protected void SetupInitialTypes()
57 {
60 else
61 m_CompatibleItems.Clear();
62
63 if (!m_ExcludedItems)
65 else
66 m_ExcludedItems.Clear();
67
68
69 ParseYieldItemsForCompatibility({ECatchingBaitCategories.BAIT_TYPE_EMPTY});
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 }
79
81 {
82 YieldItemBase yItem;
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
90 if (CheckMaskCompatibility(yItem) && CheckBaitCompatibility(yItem,excludedTypes))
91 {
92 m_CompatibleItems.Insert(yItem);
93 }
94 }
95 }
96
97 protected void SetupProbabilityArray()
98 {
101 m_ProbabilityArray.Clear();
102
103 int count = m_CompatibleItems.Count();
104 YieldItemBase yItem;
105
106 for (int i = 0; i < count; i++)
107 {
108 yItem = m_CompatibleItems[i];
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 }
124
126 {
127 return m_YieldsMapAll;
128 }
129
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 }
141
142 protected void InitCatchMasks()
143 {
146 }
147
148 protected void InitCatchMethodMask()
149 {
150 m_MethodMask = 0;
151 }
152
153 protected void InitCatchEnviroMask()
154 {
155 m_EnviroMask = 0;
156 }
157
159 protected int GetCatchMethodMask()
160 {
161 return m_MethodMask;
162 }
163
164 protected int GetCatchEnviroMask()
165 {
166 return m_EnviroMask;
167 }
168
170 {
171 return (yItem.GetMethodMask() & GetCatchMethodMask()) && (yItem.GetEnviroMask() & GetCatchEnviroMask());
172 }
173
174 protected bool CheckBaitCompatibility(YieldItemBase yItem, array<ECatchingBaitCategories> excludedTypes = null)
175 {
176 float highestSensitivity = 0.0;
177 float sensitivity = 0.0;
178 int count = m_BaitCompatibilityMap.Count();
179 ECatchingBaitCategories baitCategoryType;
180
181 for (int i = 0; i < count; i++)
182 {
183 baitCategoryType = m_BaitCompatibilityMap.GetKey(i);
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
195 highestSensitivity = Math.Max(highestSensitivity,sensitivity);
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 }
210
216
217 protected void InitCatchingItemData()
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..
230 array<EntityAI> children = new array<EntityAI>();
231 m_MainItem.GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,children);
232 foreach (EntityAI child: children)
233 {
234 InitItemValues(child);
235 }
236 }
237
239 protected void InitItemValues(EntityAI item);
241 protected void ClearCatchingItemData()
242 {
243 m_QualityBaseMod = 0.0;
246 }
247
250
251 bool IsValid()
252 {
253 return m_IsValid;
254 }
255
256 //result-related methods
258 {
259 YieldItemBase yItem;
260 if (m_IsValid)
261 {
262 Class.CastTo(yItem,m_YieldsMapAll.Get(m_ProbabilityArray.GetRandomElement()));
263 m_Result.SetYieldItem(yItem);
265 }
266 }
267
269 void UpdateBaseProbability(YieldItemBase yItem);
270
271 bool ModifySignalProbability(inout float probability)
272 {
273 return false;
274 }
275
277 {
279 return ret;
280 }
281
282 void SetResultChanceOverride(bool ovrd, float val = 0.0)
283 {
284 m_Result.SetCatchChanceOverride(ovrd,val);
285 }
286
287 void SetResultQualityOverride(bool ovrd, float val = 0.0)
288 {
289 m_Result.SetQualityOverride(ovrd,val);
290 }
291
292 //done independently to help guide fishing action flow
294 {
295 m_Result.UpdateCatchChance(this);
296 return m_Result.RollChance();
297 }
298
299 //done independently to help guide fishing action flow
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 }
311};
proto bool IsValid()
Checks if the ScriptCaller is valid.
Определения CfgPlayerSpawnDataJson.c:134
class LogManager EntityAI
map< int, ref YieldItemBase > YieldsMap
Определения CatchYieldBank.c:1
void SetupInitialTypes()
Определения CatchingContextBase.c:56
void InitBaitCompatibilityMap()
Определения CatchingContextBase.c:48
void ClearCatchingItemData()
called before actual item data initialization
Определения CatchingContextBase.c:241
ref array< YieldItemBase > m_ExcludedItems
Определения CatchingContextBase.c:25
bool RollCatch()
Определения CatchingContextBase.c:293
void UpdateCatchingItemData()
Определения CatchingContextBase.c:211
int GetCatchEnviroMask()
Определения CatchingContextBase.c:164
void ParseYieldItemsForCompatibility(array< ECatchingBaitCategories > excludedTypes=null)
Определения CatchingContextBase.c:80
float m_QualityBaseMod
Определения CatchingContextBase.c:20
void InitCatchMethodMask()
Определения CatchingContextBase.c:148
void DeserializeData(Param par)
Определения CatchingContextTraps.c:256
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
void InitItemValues(EntityAI item)
override to init context-specific values
Определения CatchingContextTraps.c:283
int GetCatchMethodMask()
override using 'ECatchMethodMask'
Определения CatchingContextBase.c:159
bool ModifySignalProbability(inout float probability)
Определения CatchingContextBase.c:271
int m_MethodMask
Определения CatchingContextBase.c:18
void SetResultQualityOverride(bool ovrd, float val=0.0)
Определения CatchingContextBase.c:287
float m_QualityDispersionMinMod
Определения CatchingContextBase.c:21
ref array< YieldItemBase > m_CompatibleItems
Определения CatchingContextBase.c:24
ref array< int > m_ProbabilityArray
Определения CatchingContextBase.c:26
void CreateResultDataStructure()
override if using another result
Определения CatchingContextBase.c:131
void InitCatchingItemData()
Определения CatchingContextBase.c:217
EntityAI SpawnAndSetupCatch(out int yItemIdx, vector v=vector.Zero)
Определения CatchingContextBase.c:300
void CatchingContextBase(Param par)
Определения CatchingContextBase.c:29
float m_QualityDispersionMaxMod
Определения CatchingContextBase.c:22
YieldsMap m_YieldsMapAll
Определения CatchingContextBase.c:16
void SetResultChanceOverride(bool ovrd, float val=0.0)
Определения CatchingContextBase.c:282
void InitCatchMasks()
Определения CatchingContextBase.c:142
float GetQualityModifier()
Определения CatchingContextBase.c:276
void InitCatchEnviroMask()
Определения CatchingContextBase.c:153
bool m_IsValid
Определения CatchingContextBase.c:17
bool CheckBaitCompatibility(YieldItemBase yItem, array< ECatchingBaitCategories > excludedTypes=null)
Определения CatchingContextBase.c:174
int m_EnviroMask
Определения CatchingContextBase.c:19
bool CheckMaskCompatibility(YieldItemBase yItem)
Определения CatchingContextBase.c:169
void RecalculateProcessingData()
Calculates and sets all data used in ongoing calculations.
void UpdateBaseProbability(YieldItemBase yItem)
updates base probability when catching the specific item (some context subclasses only)
Определения CatchingContextTraps.c:427
YieldsMap GetYieldsMap()
Определения CatchingContextBase.c:125
void SetupProbabilityArray()
Определения CatchingContextBase.c:97
map
Определения ControlsXboxNew.c:4
override Widget Init()
Определения DayZGame.c:127
float m_BaseProbability
Определения CatchingContextBase.c:3
EntityAI m_Owner
Определения CatchingContextBase.c:4
void BaitData(float value, EntityAI owner)
Определения CatchingContextBase.c:6
proto native Mission GetMission()
YieldsMap GetYieldsMap()
Определения CatchYieldBank.c:19
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
Определения EnMath.c:7
WorldData GetWorldData()
Определения gameplay.c:743
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
CatchYieldBank GetCatchYieldBank()
Определения WorldData.c:387
int GetYieldWeight(CatchingContextBase ctx)
Определения CatchYieldItemBase.c:38
int GetMethodMask()
Определения CatchYieldItemBase.c:48
int GetEnviroMask()
Определения CatchYieldItemBase.c:43
float GetBaitTypeSensitivity(ECatchingBaitCategories type)
Определения CatchYieldItemBase.c:53
string GetType()
Определения CatchYieldItemBase.c:20
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static const vector Zero
Определения EnConvert.c:110
Определения EnConvert.c:106
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
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 Max(float x, float y)
Returns bigger of two given values.
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:106
proto native int Hash()
Returns hash of string.
proto native bool IsCLIParam(string param)
Returns if command line argument is present.