DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CatchingContextTraps.c
См. документацию.
2{
8 protected int m_AttemptsCount;
9 protected ItemBase m_Bait;
10
11 override protected void DeserializeData(Param par)
12 {
14 if (Class.CastTo(p,par))
15 {
16 m_MainItem = p.param1;
17 m_AttemptsCount = p.param2;
18 }
19 }
20
21 override protected void CreateResultDataStructure()
22 {
24
25 super.CreateResultDataStructure();
26 }
27
28 override protected void ClearCatchingItemData()
29 {
30 super.ClearCatchingItemData();
31
33 m_QualityBaseMod = 0.0;
36 }
37
38 override protected void InitItemValues(EntityAI item)
39 {
40 //skip ruined or deleted items entirely
41 if (item.IsRuined() || item.IsSetForDeletion())
42 return;
43
44 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Trapping";
45 if (GetGame().ConfigIsExisting(path))
46 {
47 if (GetGame().ConfigIsExisting(path + " baitTypes") && GetGame().ConfigIsExisting(path + " baitTypeChances"))
48 {
53 int count = CachedObjectsArrays.ARRAY_INT.Count();
54 if (count == CachedObjectsArrays.ARRAY_FLOAT.Count())
55 {
56 int key;
57 float value;
58 for (int i = 0; i < count; i++)
59 {
62 if (!m_BaitCompatibilityMap.Contains(key) || (m_BaitCompatibilityMap.Get(key).m_BaseProbability < value))
63 {
64 m_BaitCompatibilityMap.Set(key,new BaitData(value,item));
65 }
66 }
67 }
68 else
69 {
70 ErrorEx("'baitTypes' and 'baitTypeChances' arrray counts of " + item.GetType() + " do not match!",ErrorExSeverity.INFO);
71 }
72 }
73 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
74 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
75 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
76 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
77 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
78 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
79 }
80 }
81
84 {
85 float ret = 1.0;
86 ItemBase ib;
87 if (Class.CastTo(ib,item))
88 {
89 //ret *= ib.GetBaitEffectivity(); //disconnected for the Time Being
90 }
91
92 return ret;
93 }
94
95 override protected void InitCatchEnviroMask()
96 {
97 vector pos = m_MainItem.GetPosition();
98 if (GetGame().SurfaceIsSea(pos[0], pos[2]))
100 else if (GetGame().SurfaceIsPond( pos[0], pos[2]))
102 else
104 }
105
106 override protected void Init(Param par)
107 {
108 super.Init(par);
109
111 }
112
113 override protected void SetupInitialTypes()
114 {
115 #ifdef DEVELOPER
116 if (IsCLIParam("catchingLogs"))
117 {
118 Print("********************"); //just for debug purposes to track the start
119 Print("dbgTrapz | START");
120 Print("********************");
121 }
122 #endif
123
124 super.SetupInitialTypes();
125
126 #ifdef DEVELOPER
127 if (IsCLIParam("catchingLogs"))
128 {
129 Print("***"); //just for debug purposes to track the start
130 }
131 #endif
132 }
133
135 {
137 InitCatchMethodMask(); //bait check
138 //InitCatchEnviroMask(); //skipping, raycasts are unreliable outside network bubbles
141 }
142
144 {
146 return GetCatchEnviroMask();
147 }
148
149 void SetTrapEnviroMask(int value)
150 {
151 m_EnviroMask = value;
152 }
153
155 void UpdateUsedBait(ECatchingBaitCategories type)
156 {
157 m_Bait = null;
158 if (type != ECatchingBaitCategories.BAIT_TYPE_EMPTY)
159 {
160 BaitData dta = m_BaitCompatibilityMap.Get(type);
161 if (dta)
162 {
163 ItemBase potentialBait = ItemBase.Cast(dta.m_Owner);
164 if (potentialBait != m_MainItem)
165 m_Bait = potentialBait;
166 }
167 else
168 ErrorEx("failed to acquire BaitData from type: " + type);
169 }
170
171 #ifdef DEVELOPER
172 if (IsCLIParam("catchingLogs"))
173 {
174 if (m_Bait)
175 Print("dbgTrapz | UpdateUsedBait to: " + m_Bait + " | with base bait probability used: " + m_BaitCompatibilityMap.Get(type).m_BaseProbability);
176 else
177 Print("dbgTrapz | UpdateUsedBait to 'null'!");
178 }
179 #endif
180 }
181
183 {
184 int baitType = ECatchingBaitCategories.BAIT_TYPE_EMPTY;
185 int usedType = -1;
186 float probability = -1;
187 float highestProbability = 0.0;
188 int count = m_BaitCompatibilityMap.Count();
189 for (int i = 0; i < count; i++)
190 {
191 baitType = m_BaitCompatibilityMap.GetKey(i);
192 probability = m_BaitCompatibilityMap.Get(baitType).m_BaseProbability * yItem.GetBaitTypeSensitivity(baitType);
193 if (probability > highestProbability)
194 {
195 highestProbability = probability;
196 usedType = baitType;
197 }
198 }
199
200 m_CumulativeTrappingSuccess = Math.Clamp(highestProbability,0,1);
201 #ifdef DEVELOPER
202 if (IsCLIParam("catchingLogs"))
203 {
204 //Print("********************");
205 Print("dbgTrapz | using bait type: " + baitType + " to catch: " + yItem);
206 }
207 #endif
208 UpdateUsedBait(usedType);
209
210 #ifdef DEVELOPER
211 if (IsCLIParam("catchingLogs"))
212 {
213 float dbgProb;
215 Print("dbgTrapz | starting catching of " + yItem + " | at probability: " + dbgProb + " | with target success: " + m_CumulativeTrappingSuccess);
216 }
217 #endif
218 }
219
220 override bool ModifySignalProbability(inout float probability)
221 {
222 probability = 1 - Math.Pow((1 - m_CumulativeTrappingSuccess),(1/m_AttemptsCount));
223
224 return true;
225 }
226
228 {
229 if (m_Bait)
230 m_Bait.DeleteSafe();
231 }
232
233 void ReduceBaitQty(float qtyNorm)
234 {
235 if (m_Bait)
236 {
237 if (m_Bait.HasQuantity() && !m_Bait.IsSplitable())
238 m_Bait.SetQuantityNormalized((m_Bait.GetQuantityNormalized() - qtyNorm));
239 else
240 m_Bait.DeleteSafe();
241 }
242 }
243}
244
245class CatchingContextTrapFishSmall : CatchingContextTrapsBase
246{
247 override protected void InitCatchMethodMask()
248 {
249 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_FISHTRAP_SMALL;
250 }
251}
255 override protected void InitCatchMethodMask()
258 }
259}
260
261class CatchingContextTrapLandSnare : CatchingContextTrapsBase
262{
263 override protected void InitCatchMethodMask()
264 {
265 m_MethodMask = AnimalCatchingConstants.MASK_METHOD_LANDTRAP_SNARE;
267}
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
CatchingContextTrapsBase CatchingContextBase InitCatchMethodMask()
Определения CatchingContextTraps.c:247
string path
Определения OptionSelectorMultistate.c:142
static const int MASK_ENVIRO_POND
Определения CatchingConstants.c:11
static const int MASK_METHOD_FISHTRAP_LARGE
Определения CatchingConstants.c:20
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
float AdjustBaitItemChance(EntityAI item)
Allows for adjustment of all catch probabilities from item qualities (damage, qty....
Определения CatchingContextTraps.c:83
void Init(Param par)
Определения CatchingContextTraps.c:106
void InitCatchEnviroMask()
Определения CatchingContextTraps.c:95
void DeserializeData(Param par)
Определения CatchingContextTraps.c:11
void ClearCatchingItemData()
Определения CatchingContextTraps.c:28
void ReduceBaitQty(float qtyNorm)
Определения CatchingContextTraps.c:233
float m_CumulativeTrappingSuccess
after N attempts, the chance to catch should be this. Only highest one applies. @NOTE: Take care,...
Определения CatchingContextTraps.c:7
void InitItemValues(EntityAI item)
Определения CatchingContextTraps.c:38
override void UpdateBaseProbability(YieldItemBase yItem)
Определения CatchingContextTraps.c:182
int UpdateTrapEnviroMask()
Определения CatchingContextTraps.c:143
void UpdateDataAndMasks()
Определения CatchingContextTraps.c:134
override bool ModifySignalProbability(inout float probability)
Определения CatchingContextTraps.c:220
void CreateResultDataStructure()
Определения CatchingContextTraps.c:21
void SetupInitialTypes()
Определения CatchingContextTraps.c:113
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:155
void SetTrapEnviroMask(int value)
Определения CatchingContextTraps.c:149
ItemBase m_Bait
Определения CatchingContextTraps.c:9
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.