DayZ 1.24
Loading...
Searching...
No Matches
ActionFishingNew.c
Go to the documentation of this file.
2{
3 const float FISHING_SUCCESS = 0.2;
4 const float FISHING_BAIT_LOSS = 0.02;
5 const float FISHING_HOOK_LOSS = 0.015;
6 const float FISHING_DAMAGE = 1.5;
7 const float FISHING_GARBAGE_CHANCE = 0.2;
8
14
16 {
17 m_Bait = item;
18 m_IsBaitAnEmptyHook = !m_Bait.ConfigIsExisting("hookType");
19 }
20
22 {
24 }
25}
26
28{
31 "Wellies_Black",
32 "Wellies_Brown",
33 "Wellies_Green",
34 "Wellies_Grey",
35 "Pot"
36 };
37
38 override void CreateActionComponent()
39 {
41 m_ActionData.m_ActionComponent = new CAContinuousRepeatFishing(3.0);
42 }
43
44 override void EndActionComponent()
45 {
46 m_ActionDataFishing = FishingActionData.Cast(m_ActionData);
47
49 {
50 super.EndActionComponent();
51 return;
52 }
53
55 {
57 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
59 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
60 }
62 {
64 if (action.HasAlternativeInterrupt())
65 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
66 else
67 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
68
69 m_Canceled = true;
70 return;
71 }
72 else
73 {
75 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
77 SetCommand(DayZPlayerConstants.CMD_ACTIONINT_FINISH);
78 }
79
81 }
82
84 {
85 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
86 {
88
90 m_ActionDataFishing.InitBait(ItemBase.Cast(m_ActionDataFishing.m_MainItem.FindAttachmentBySlotName("Hook")));
91
93 {
96 }
97 else
99
100 float rnd = Math.RandomFloatInclusive(0.0, 1.0);
102 {
104 fish = ItemBase.Cast(GetGame().CreateObjectEx("Mackerel", m_ActionDataFishing.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
105 else
106 fish = ItemBase.Cast(GetGame().CreateObjectEx("Carp", m_ActionDataFishing.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
107 }
108 else
109 {
111 {
112 string junkType = m_JunkTypes.Get(Math.RandomInt(0, m_JunkTypes.Count()));
113 fish = ItemBase.Cast(GetGame().CreateObjectEx(junkType, m_ActionDataFishing.m_Player.GetPosition(), ECE_PLACE_ON_SURFACE));
114 fish.SetHealth("", "Health", fish.GetMaxHealth("", "Health") * 0.1);
115 }
116 }
117
118 if (fish)
119 {
120 //Print("---Caught something: " + fish + "---");
121 fish.SetWet(0.3);
122 if (fish.HasQuantity())
123 {
124 float coef = Math.RandomFloatInclusive(0.5, 1.0);
125 float item_quantity = fish.GetQuantityMax() * coef;
127 fish.SetQuantity(item_quantity);
128 fish.InsertAgent(eAgents.CHOLERA);
129 }
130 }
131
133 }
134 }
135
137 {
138 if (!GetGame().IsMultiplayer() || GetGame().IsServer())
139 {
141 m_ActionDataFishing.InitBait(ItemBase.Cast(m_ActionDataFishing.m_MainItem.FindAttachmentBySlotName("Hook")));
142
143 if (Math.RandomFloatInclusive(0.0, 1.0) > m_ActionDataFishing.FISHING_HOOK_LOSS) //loss of worm only
144 {
146 {
149 }
150 }
151 else //loss of the entire hook
153
155 }
156 }
157
168};
169
171{
172 private const string ALLOWED_WATER_SURFACES = string.Format("%1|%2", UAWaterType.SEA, UAWaterType.FRESH);
173
175 {
178 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FISHING;
179 m_FullBody = true;
180 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
181 m_Text = "#start_fishing";
182 }
183
189
190 override bool HasTarget()
191 {
192 return true;
193 }
194
196 {
197 return true;
198 }
199
200 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
201 {
204
205 if (rod)
206 bait = ItemBase.Cast(rod.FindAttachmentBySlotName("Hook"));
207
208 if (bait && !bait.IsRuined())
209 return true;
210
211 return false;
212 }
213
219
221 {
222 if (super.SetupAction(player, target, item, action_data, extra_data))
223 {
224 vector cursorPosition = action_data.m_Target.GetCursorHitPos();
226 cursorPosition = player.GetPosition();
227
228 if (GetGame().SurfaceIsSea(cursorPosition[0], cursorPosition[2]))
230
232 if (rod)
233 {
234 FishingActionData.Cast(action_data).m_RodQualityModifier = rod.GetFishingEffectivityBonus();
235 FishingActionData.Cast(action_data).InitBait(ItemBase.Cast(action_data.m_MainItem.FindAttachmentBySlotName("Hook")));
236 }
237 return true;
238 }
239 return false;
240 }
241
243 {
244 action_data.m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
246 }
247
249 {
250 action_data.m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_ACTION);
252 }
253
255 {
257 rod.AnimateFishingRod(true);
258 }
260 {
262 rod.AnimateFishingRod(true);
263 }
264
266 {
268 rod.AnimateFishingRod(false);
269 }
271 {
273 rod.AnimateFishingRod(false);
274 }
275
277 {
278 super.WriteToContext(ctx, action_data);
279
280 if (HasTarget())
281 ctx.Write(action_data.m_Target.GetCursorHitPos());
282 }
283
285 {
286 super.ReadFromContext(ctx, action_recive_data);
287
288 if (HasTarget())
289 {
291 if (!ctx.Read(cursor_position))
292 return false;
293
294 action_recive_data.m_Target.SetCursorHitPos(cursor_position);
295 }
296 return true;
297 }
298
300 {
301 if (action_data.m_Player.IsQuickFishing())
302 return 1;
303
305 float rnd = fad.m_Player.GetRandomGeneratorSyncManager().GetRandom01(RandomGeneratorSyncUsage.RGSGeneric);
306 float daytimeModifier = 1;
307 float hookModifier = 1;
308 float chance;
309
310 daytimeModifier = GetGame().GetDayTime();
311 if ((daytimeModifier > 18 && daytimeModifier < 22) || (daytimeModifier > 5 && daytimeModifier < 9))
312 daytimeModifier = 1;
313 else
314 daytimeModifier = 0.5;
315
316 //fishing with an empty hook
317 if (fad.IsBaitEmptyHook())
318 hookModifier = 0.05;
319
320 chance = 1 - (((fad.FISHING_SUCCESS * daytimeModifier) + fad.m_RodQualityModifier)) * hookModifier;
321
322 if (rnd > chance)
323 return 1;
324 else if (rnd < fad.FISHING_BAIT_LOSS && !fad.IsBaitEmptyHook()) // restricts the loss of an empty hook (low chance is enough)
325 return 0;
326
327 return -1;
328 }
329}
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
ActionEmptyMagazine CreateActionComponent
void HandleFishingResultFailure()
void HandleFishingResultSuccess()
ref array< string > m_JunkTypes
FishingActionData m_ActionDataFishing
override void EndActionComponent()
const int ECE_PLACE_ON_SURFACE
eAgents
Definition EAgents.c:3
bool m_Canceled
PlayerBase m_Player
Definition ActionBase.c:33
ItemBase m_MainItem
Definition ActionBase.c:28
ref ActionBase m_Action
Definition ActionBase.c:27
int EvaluateFishingResult(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override void CreateConditionComponents()
override void OnStartClient(ActionData action_data)
const string ALLOWED_WATER_SURFACES
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override void OnStartServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool HasTarget()
override void OnEndClient(ActionData action_data)
override bool HasAlternativeInterrupt()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=null)
override void OnFinishProgressClient(ActionData action_data)
override void OnEndServer(ActionData action_data)
override ActionData CreateActionData()
override void OnFinishProgressServer(ActionData action_data)
const float FISHING_BAIT_LOSS
const float FISHING_GARBAGE_CHANCE
const float FISHING_HOOK_LOSS
void InitBait(ItemBase item)
const float FISHING_DAMAGE
const float FISHING_SUCCESS
Definition EnMath.c:7
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float BASEBUILDING
const float PRECISE_MEDIUM
const string FRESH
fake
const string SEA
static const vector Zero
Definition EnConvert.c:110
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static float RandomFloatInclusive(float min, float max)
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
static proto float Round(float f)
Returns mathematical round of value.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
const int UA_FINISHED
Definition constants.c:436
const int UA_CANCEL
Definition constants.c:437
static const int STATE_NONE
undef state - not running anymore
Definition human.c:348
static const int STATE_LOOP_END2
Definition human.c:354
static const int STATE_LOOP_END
Definition human.c:353
void OnStateChange(int pOldState, int pCurrentState)
called when enabled by EnableStateChangeCallback and state changes, call GetState() to get actual sta...
Definition human.c:407
proto native void EnableStateChangeCallback()
enables state change callback OnStateChange