DayZ 1.27
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 (GetGame().ConfigIsExisting(path))
126 {
127 if (GetGame().ConfigIsExisting(path + " resultQuantityBaseMod"))
128 m_QualityBaseMod += GetGame().ConfigGetFloat(path + " resultQuantityBaseMod");
129 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMin"))
130 m_QualityDispersionMinMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMin");
131 if (GetGame().ConfigIsExisting(path + " resultQuantityDispersionMax"))
132 m_QualityDispersionMaxMod += GetGame().ConfigGetFloat(path + " resultQuantityDispersionMax");
133 if (GetGame().ConfigIsExisting(path + " hookLossChanceMod"))
134 m_HookLossChanceMod += GetGame().ConfigGetFloat(path + " hookLossChanceMod");
135 if (GetGame().ConfigIsExisting(path + " baitLossChanceMod"))
136 m_BaitLossChanceMod += GetGame().ConfigGetFloat(path + " baitLossChanceMod");
137
138 if (GetGame().ConfigIsExisting(path + " signalDurationMin"))
139 {
140 if (m_SignalDurationMin == -1)
142 m_SignalDurationMin += GetGame().ConfigGetFloat(path + " signalDurationMin");
143 }
144 if (GetGame().ConfigIsExisting(path + " signalDurationMax"))
145 {
146 if (m_SignalDurationMax == -1)
148 m_SignalDurationMax += GetGame().ConfigGetFloat(path + " signalDurationMax");
149 }
150
151 if (GetGame().ConfigIsExisting(path + " signalCycleTargetAdjustment"))
152 m_SignalCycleTargetAdjustment += GetGame().ConfigGetFloat(path + " signalCycleTargetAdjustment");
153 if (GetGame().ConfigIsExisting(path + " signalCycleTargetEndAdjustment"))
154 m_SignalCycleTargetEndAdjustment += GetGame().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 if (IsCLIParam("fishingLogs"))
190 {
191 Debug.Log("---ModifySignalProbability---","Fishing");
192 Debug.Log("m_SignalCurrent: " + m_SignalCurrent,"Fishing");
193 Debug.Log("easingTime: " + easingTime,"Fishing");
194 Debug.Log("probability: " + probability,"Fishing");
195 }
196 #endif
197
198 return true;
199 }
200
205
206 override bool RollCatch()
207 {
208 bool ret = super.RollCatch();
210 return ret;
211 }
212
213 protected void ResetSignalCounter()
214 {
215 m_SignalCurrent = 0.0;
216 }
217
219 override void GenerateResult()
220 {
221 YieldItemBase yItem;
222 int idx = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,0,m_ProbabilityArray.Count() - 1);
224 m_Result.SetYieldItem(yItem);
225 }
226
228 {
229 if (m_Result)
230 return m_Result.GetYieldItemParticleId();
231
232 return ParticleList.INVALID;
233 }
234
235 override protected void RecalculateProcessingData()
236 {
237 m_Result.UpdateCatchChance(this);
238 }
239
241 {
242 return Math.Clamp(m_HookLossChanceMod,0.001,1);
243 }
244
249
254
256 {
257 float res = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,m_SignalDurationMin,m_SignalDurationMax);
258 #ifdef DEVELOPER
259 if (IsCLIParam("fishingLogs"))
260 {
261 Debug.Log("---RandomizeSignalDuration---","Fishing");
262 Debug.Log("next signal duration: " + res,"Fishing");
263 }
264 #endif
265
266 return res;
267 }
268
270 {
271 float res = m_Player.GetRandomGeneratorSyncManager().GetRandomInRange(RandomGeneratorSyncUsage.RGSAnimalCatching,m_SignalStartTimeMin,m_SignalStartTimeMax);
272 #ifdef DEVELOPER
273 if (IsCLIParam("fishingLogs"))
274 {
275 Debug.Log("---RandomizeSignalStartTime---","Fishing");
276 Debug.Log("next signal start time: " + res,"Fishing");
277 }
278 #endif
279 return res;
280 }
281
282 protected void TryHookLoss()
283 {
284 if (m_Hook && !m_Hook.IsSetForDeletion())
285 {
286 float lossChance = GetHookLossChanceModifierClamped();
287 if (lossChance <= 0)
288 return;
289
290 float roll = m_Player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSAnimalCatching);
291
292 if (lossChance >= 1 || roll < lossChance)
293 {
295 }
296 }
297 }
298
299 protected void RemoveItemSafe(EntityAI item)
300 {
301 if (item && !m_Player.IsQuickFishing())
302 {
303 item.SetPrepareToDelete(); //should probably flag the bait too, but the action terminates anyway
304 item.DeleteSafe();
305 }
306 }
307
308 protected void TryBaitLoss()
309 {
310 if (m_Bait && !m_Bait.IsSetForDeletion())
311 {
312 float lossChance = GetBaitLossChanceModifierClamped();
313 if (lossChance <= 0)
314 return;
315
316 float roll = m_Player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSAnimalCatching);
317
318 if (lossChance >= 1 || roll < lossChance)
319 {
321 }
322 }
323 }
324
325 protected void TryDamageItems()
326 {
327 if (!GetGame().IsMultiplayer() || GetGame().IsDedicatedServer())
328 {
329 if (m_Hook && !m_Hook.IsSetForDeletion())
330 m_Hook.AddHealth("","Health",-UAFishingConstants.DAMAGE_HOOK);
331 }
332 }
333
334 override EntityAI SpawnAndSetupCatch(out int yItemIdx, vector v = vector.Zero)
335 {
336 //hook check on catch
337 if (m_Hook && !m_Hook.IsSetForDeletion())
338 return super.SpawnAndSetupCatch(yItemIdx,v);
339 return null;
340 }
341
342 //events
344 {
345 TryHookLoss();
346 }
347
353
356 {
357 TryHookLoss();
358 TryBaitLoss();
359 }
360
367
369 //Fish pen of deprecated code//
374}
void UpdateCatchingItemData()
Определения CatchingContextBase.c:211
float m_QualityBaseMod
Определения CatchingContextBase.c:20
class BaitData m_MainItem
Определения ActionBase.c:36
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
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
proto native float ConfigGetFloat(string path)
Get float value from config on path.
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.
Определения Debug.c:122
Определения 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
Определения Building.c:6
Определения 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:196
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:110
Определения EnConvert.c:106
proto native CGame GetGame()
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
Определения constants.c:220
proto native bool IsCLIParam(string param)
Returns if command line argument is present.