DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CatchingContextFishingRodAction.c
См. документацию.
2{
4 //chances + modifiers
5 protected float m_BaitLossChanceMod;
6 protected float m_HookLossChanceMod;
7 //times
8 protected float m_SignalDurationMin; //seconds
9 protected float m_SignalDurationMax; //seconds
10 protected float m_SignalStartTimeMin; //seconds
11 protected float m_SignalStartTimeMax; //seconds
12 //signal targets
13 protected float m_SignalCycleTarget;
14 protected float m_SignalCycleEndTarget;
17 //signal targets - constant
20 //misc
21 protected int m_SignalCurrent;
22
23 //important items
24 protected EntityAI m_Hook;
25 protected EntityAI m_Bait;
26 protected EntityAI m_Rod;
27
28 override protected void Init(Param par)
29 {
30 super.Init(par);
31
32 m_Rod = m_MainItem; //only stable one, rest initialized on 'InitItemValues' periodically
33 m_Player = PlayerBase.Cast(m_MainItem.GetHierarchyRootPlayer());
34 }
35
40
48
49 override protected void CreateResultDataStructure()
50 {
52
53 super.CreateResultDataStructure();
54 }
55
75
76 override void InitCatchingItemData()
77 {
78 super.InitCatchingItemData();
79
80 //sanitize fishing values
81 if (m_SignalDurationMin == -1) //if not set by any item
83 else
85
86 if (m_SignalDurationMax == -1) //if not set by any item
88 else
90
91 if (m_SignalStartTimeMin == -1) //if not set by any item (else already clamped)
93
94 if (m_SignalStartTimeMax == -1) //if not set by any item (else already clamped)
96
99
100 #ifdef DEVELOPER
101 if (IsCLIParam("fishingLogs"))
102 {
103 Debug.Log("---InitCatchingItemData---","Fishing");
104 Debug.Log("m_SignalCycleTarget (adjusted): " + m_SignalCycleTarget,"Fishing");
105 Debug.Log("m_SignalCycleTargetAdjustment: " + m_SignalCycleTargetAdjustment,"Fishing");
106 Debug.Log("m_SignalTargetProbability: " + m_SignalTargetProbability,"Fishing");
107 Debug.Log("m_SignalCycleEndTarget (adjusted): " + m_SignalCycleEndTarget,"Fishing");
108 Debug.Log("m_SignalCycleTargetEndAdjustment: " + m_SignalCycleTargetEndAdjustment,"Fishing");
109 Debug.Log("m_SignalTargetEndProbability: " + m_SignalTargetEndProbability,"Fishing");
110 Debug.Log("m_SignalDurationMin: " + m_SignalDurationMin,"Fishing");
111 Debug.Log("m_SignalDurationMax: " + m_SignalDurationMax,"Fishing");
112 Debug.Log("m_SignalStartTimeMin: " + m_SignalStartTimeMin,"Fishing");
113 Debug.Log("m_SignalStartTimeMax: " + m_SignalStartTimeMax,"Fishing");
114 }
115 #endif
116 }
117
118 override protected void InitItemValues(EntityAI item)
119 {
120 //skip ruined or deleted items entirely
121 if (item.IsRuined() || item.IsSetForDeletion())
122 return;
123
124 string path = "" + CFG_VEHICLESPATH + " " + item.GetType() + " Fishing";
125 if (g_Game.ConfigIsExisting(path))
126 {
127 if (g_Game.ConfigIsExisting(path + " resultQuantityBaseMod"))
128 m_QualityBaseMod += g_Game.ConfigGetFloat(path + " resultQuantityBaseMod");
129 if (g_Game.ConfigIsExisting(path + " resultQuantityDispersionMin"))
130 m_QualityDispersionMinMod += g_Game.ConfigGetFloat(path + " resultQuantityDispersionMin");
131 if (g_Game.ConfigIsExisting(path + " resultQuantityDispersionMax"))
132 m_QualityDispersionMaxMod += g_Game.ConfigGetFloat(path + " resultQuantityDispersionMax");
133 if (g_Game.ConfigIsExisting(path + " hookLossChanceMod"))
134 m_HookLossChanceMod += g_Game.ConfigGetFloat(path + " hookLossChanceMod");
135 if (g_Game.ConfigIsExisting(path + " baitLossChanceMod"))
136 m_BaitLossChanceMod += g_Game.ConfigGetFloat(path + " baitLossChanceMod");
137
138 if (g_Game.ConfigIsExisting(path + " signalDurationMin"))
139 {
140 if (m_SignalDurationMin == -1)
142 m_SignalDurationMin += g_Game.ConfigGetFloat(path + " signalDurationMin");
143 }
144 if (g_Game.ConfigIsExisting(path + " signalDurationMax"))
145 {
146 if (m_SignalDurationMax == -1)
148 m_SignalDurationMax += g_Game.ConfigGetFloat(path + " signalDurationMax");
149 }
150
151 if (g_Game.ConfigIsExisting(path + " signalCycleTargetAdjustment"))
152 m_SignalCycleTargetAdjustment += g_Game.ConfigGetFloat(path + " signalCycleTargetAdjustment");
153 if (g_Game.ConfigIsExisting(path + " signalCycleTargetEndAdjustment"))
154 m_SignalCycleTargetEndAdjustment += g_Game.ConfigGetFloat(path + " signalCycleTargetEndAdjustment");
155
156 int slotID;
157 string slotName;
158 if (item.GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName))
159 {
160 switch (slotName)
161 {
162 case "Bait":
163 m_Bait = item;
164 break;
165
166 case "Hook":
167 m_Hook = item;
168 break;
169 }
170 }
171 }
172 }
173
174 override bool ModifySignalProbability(inout float probability)
175 {
176 float easingTime;
178 {
180 probability = Easing.EaseInExpo(easingTime) * m_SignalTargetProbability * GetChanceCoef();
181 }
182 else
183 {
186 }
187
188 #ifdef DEVELOPER
189 // Needs to be revisited, won't work when the autotests run inside of workbench
190 if (IsCLIParam("autotest"))
191 probability = UAFishingConstants.DEBUG_FISHING_CHANCE_PROBABILITY;
192
193 if (IsCLIParam("fishingLogs"))
194 {
195 Debug.Log("---ModifySignalProbability---","Fishing");
196 Debug.Log("m_SignalCurrent: " + m_SignalCurrent,"Fishing");
197 Debug.Log("easingTime: " + easingTime,"Fishing");
198 Debug.Log("probability: " + probability,"Fishing");
199 }
200 #endif
201
202 return true;
203 }
204
209
210 override bool RollCatch()
211 {
212 bool ret = super.RollCatch();
214 return ret;
215 }
216
217 protected void ResetSignalCounter()
218 {
219 m_SignalCurrent = 0.0;
220 }
221
223 override void GenerateResult()
224 {
225 YieldItemBase yItem;
226 int idx = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,0,m_ProbabilityArray.Count() - 1);
228 m_Result.SetYieldItem(yItem);
229 }
230
232 {
233 if (m_Result)
234 return m_Result.GetYieldItemParticleId();
235
236 return ParticleList.INVALID;
237 }
238
239 override protected void RecalculateProcessingData()
240 {
241 m_Result.UpdateCatchChance(this);
242 }
243
245 {
246 return Math.Clamp(m_HookLossChanceMod,0.001,1);
247 }
248
253
258
260 {
261 float res = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,m_SignalDurationMin,m_SignalDurationMax);
262 #ifdef DEVELOPER
263 if (IsCLIParam("fishingLogs"))
264 {
265 Debug.Log("---RandomizeSignalDuration---","Fishing");
266 Debug.Log("next signal duration: " + res,"Fishing");
267 }
268 #endif
269
270 return res;
271 }
272
274 {
275 float res = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,m_SignalStartTimeMin,m_SignalStartTimeMax);
276 #ifdef DEVELOPER
277 if (IsCLIParam("fishingLogs"))
278 {
279 Debug.Log("---RandomizeSignalStartTime---","Fishing");
280 Debug.Log("next signal start time: " + res,"Fishing");
281 }
282 #endif
283 return res;
284 }
285
286 protected void TryHookLoss()
287 {
288 if (m_Hook && !m_Hook.IsSetForDeletion())
289 {
290 float lossChance = GetHookLossChanceModifierClamped();
291 if (lossChance <= 0)
292 return;
293
294 float roll = m_Player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSAnimalCatching);
295
296 if (lossChance >= 1 || roll < lossChance)
297 {
299 }
300 }
301 }
302
303 protected void RemoveItemSafe(EntityAI item)
304 {
305 if (item && !m_Player.IsQuickFishing())
306 {
307 item.SetPrepareToDelete(); //should probably flag the bait too, but the action terminates anyway
308 item.DeleteSafe();
309 }
310 }
311
312 protected void TryBaitLoss()
313 {
314 if (m_Bait && !m_Bait.IsSetForDeletion())
315 {
316 float lossChance = GetBaitLossChanceModifierClamped();
317 if (lossChance <= 0)
318 return;
319
320 float roll = m_Player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSAnimalCatching);
321
322 if (lossChance >= 1 || roll < lossChance)
323 {
325 }
326 }
327 }
328
329 protected void TryDamageItems()
330 {
331 if (!g_Game.IsMultiplayer() || g_Game.IsDedicatedServer())
332 {
333 if (m_Hook && !m_Hook.IsSetForDeletion())
334 m_Hook.AddHealth("","Health",-UAFishingConstants.DAMAGE_HOOK);
335 }
336 }
337
338 override EntityAI SpawnAndSetupCatch(out int yItemIdx, vector v = vector.Zero)
339 {
340 //hook check on catch
341 if (m_Hook && !m_Hook.IsSetForDeletion())
342 return super.SpawnAndSetupCatch(yItemIdx,v);
343 return null;
344 }
345
346 //events
348 {
349 TryHookLoss();
350 }
351
357
360 {
361 TryHookLoss();
362 TryBaitLoss();
363 }
364
371
373 //Fish pen of deprecated code//
378}
void UpdateCatchingItemData()
Определения CatchingContextBase.c:211
float m_QualityBaseMod
Определения CatchingContextBase.c:20
class BaitData m_MainItem
Определения ActionBase.c:42
ref CatchingResultBasic m_Result
Определения CatchingContextBase.c:27
int m_MethodMask
Определения CatchingContextBase.c:18
float m_QualityDispersionMinMod
Определения CatchingContextBase.c:21
ref array< int > m_ProbabilityArray
Определения CatchingContextBase.c:26
float m_QualityDispersionMaxMod
Определения CatchingContextBase.c:22
YieldsMap m_YieldsMapAll
Определения CatchingContextBase.c:16
int m_EnviroMask
Определения CatchingContextBase.c:19
PlayerSpawnPreset slotName
DayZGame g_Game
Определения DayZGame.c:3942
const int MAX
Определения EnConvert.c:27
string path
Определения OptionSelectorMultistate.c:142
RandomGeneratorSyncUsage
Определения RandomGeneratorSyncManager.c:2
static const int MASK_ENVIRO_POND
Определения CatchingConstants.c:11
static const int MASK_METHOD_ROD
Определения CatchingConstants.c:19
const float POISSON_CYCLE_MEAN_DEFAULT
Определения CatchingConstants.c:25
static const int MASK_ENVIRO_SEA
Определения CatchingConstants.c:12
float GetCurrentCycleTime(CatchingContextFishingRodAction ctx)
Определения CarchingResultFishingAction.c:14
override bool ModifySignalProbability(inout float probability)
void InitItemValues(EntityAI item)
float GetSignalPoissonMean()
Deprecated, left here due to inheritance change.
void RemoveItemSafe(EntityAI item)
void ClearCatchingItemData()
only clear stuff you need to update
void OnSignalMiss()
release without signal
int GetSignalMax()
Deprecated, left here due to inheritance change.
override EntityAI SpawnAndSetupCatch(out int yItemIdx, vector v=vector.Zero)
override void GenerateResult()
done locally on both sides, needs a synced random
Super root of all classes in Enforce script.
Определения EnScript.c:11
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения 3_Game/DayZ/tools/Debug.c:182
Определения 3_Game/DayZ/tools/Debug.c:2
static float EaseInExpo(float t)
Определения Easing.c:103
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Определения Easing.c:3
Определения EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
static const int INVALID
Определения ParticleList.c:20
Определения ParticleList.c:12
Определения PlayerBaseClient.c:2
const float DAMAGE_HOOK
modifies chance for every signal roll
Определения ActionConstants.c:198
const float SIGNAL_START_TIME_MAX_BASE
Определения ActionConstants.c:186
const float SIGNAL_START_TIME_MIN_BASE
Определения ActionConstants.c:185
const float SIGNAL_DURATION_MIN_BASE
Определения ActionConstants.c:183
const float SIGNAL_DURATION_MAX_BASE
Определения ActionConstants.c:184
const float SIGNAL_MEAN_CHANCE_DEFAULT
re-purposed as soft cycle target
Определения ActionConstants.c:191
const float SIGNAL_CYCLE_MEAN_DEFAULT
Определения ActionConstants.c:190
const float SIGNAL_CYCLE_HARD_TARGET_DEFAULT
chance at MEAN
Определения ActionConstants.c:192
const float SIGNAL_HARD_TARGET_CHANCE_DEFAULT
hard cycle target
Определения ActionConstants.c:193
const float SIGNAL_FISHING_CHANCE_COEF
chance at HARD_TARGET (we probably want close to 100% here, randomness being random....
Определения ActionConstants.c:194
static const vector Zero
Определения EnConvert.c:123
Определения EnConvert.c:119
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 InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static proto float Ceil(float f)
Returns ceil of value.
const string CFG_VEHICLESPATH
Определения 3_Game/DayZ/constants.c:220
proto native bool IsCLIParam(string param)
Returns if command line argument is present.