DayZ 1.24
Loading...
Searching...
No Matches
ActionFishingNew.c File Reference

Go to the source code of this file.

Classes

class  FishingActionData
 
class  ActionFishingNew
 

Functions

override void CreateActionComponent ()
 
override void EndActionComponent ()
 
void HandleFishingResultSuccess ()
 
void HandleFishingResultFailure ()
 
override void OnStateChange (int pOldState, int pCurrentState)
 

Variables

FishingActionData m_ActionDataFishing
 
ref array< stringm_JunkTypes
 

Function Documentation

◆ CreateActionComponent()

override void CreateActionComponent ( )

Definition at line 38 of file ActionFishingNew.c.

39 {
41 m_ActionData.m_ActionComponent = new CAContinuousRepeatFishing(3.0);
42 }
proto native void EnableStateChangeCallback()
enables state change callback OnStateChange

References EnableStateChangeCallback().

◆ EndActionComponent()

override void EndActionComponent ( )

Definition at line 44 of file ActionFishingNew.c.

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 }
FishingActionData m_ActionDataFishing
bool m_Canceled
ref ActionBase m_Action
Definition ActionBase.c:27
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
const int UA_FINISHED
Definition constants.c:436
const int UA_CANCEL
Definition constants.c:437

References ActionData::m_Action, m_ActionDataFishing, m_Canceled, FishingActionData::m_FishingResult, ActionData::m_State, UA_CANCEL, and UA_FINISHED.

◆ HandleFishingResultFailure()

void HandleFishingResultFailure ( )

Definition at line 136 of file ActionFishingNew.c.

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 }
PlayerBase m_Player
Definition ActionBase.c:33
ItemBase m_MainItem
Definition ActionBase.c:28
const float FISHING_HOOK_LOSS
void InitBait(ItemBase item)
const float FISHING_DAMAGE
Definition EnMath.c:7
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

References FishingActionData::FISHING_DAMAGE, FishingActionData::FISHING_HOOK_LOSS, GetGame(), FishingActionData::InitBait(), FishingActionData::IsBaitEmptyHook(), m_ActionDataFishing, FishingActionData::m_Bait, ActionData::m_MainItem, ActionData::m_Player, and Math::RandomFloatInclusive().

Referenced by OnStateChange().

◆ HandleFishingResultSuccess()

void HandleFishingResultSuccess ( )

Definition at line 83 of file ActionFishingNew.c.

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 }
ref array< string > m_JunkTypes
const int ECE_PLACE_ON_SURFACE
eAgents
Definition EAgents.c:3
const float FISHING_GARBAGE_CHANCE
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].

References ECE_PLACE_ON_SURFACE, FishingActionData::FISHING_DAMAGE, FishingActionData::FISHING_GARBAGE_CHANCE, GetGame(), FishingActionData::InitBait(), FishingActionData::IsBaitEmptyHook(), m_ActionDataFishing, FishingActionData::m_Bait, FishingActionData::m_IsSurfaceSea, m_JunkTypes, ActionData::m_MainItem, ActionData::m_Player, Math::RandomFloatInclusive(), Math::RandomInt(), and Math::Round().

Referenced by OnStateChange().

◆ OnStateChange()

override void OnStateChange ( int pOldState,
int pCurrentState )

Definition at line 158 of file ActionFishingNew.c.

159 {
161 {
166 }
167 }
void HandleFishingResultFailure()
void HandleFishingResultSuccess()
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

References HandleFishingResultFailure(), HandleFishingResultSuccess(), m_ActionDataFishing, FishingActionData::m_FishingResult, STATE_LOOP_END, STATE_LOOP_END2, and STATE_NONE.

Variable Documentation

◆ m_ActionDataFishing

◆ m_JunkTypes

ref array<string> m_JunkTypes
Initial value:
= {
"Wellies_Black",
"Wellies_Brown",
"Wellies_Green",
"Wellies_Grey",
"Pot"
}

Definition at line 30 of file ActionFishingNew.c.

30 {
31 "Wellies_Black",
32 "Wellies_Brown",
33 "Wellies_Green",
34 "Wellies_Grey",
35 "Pot"
36 };

Referenced by HandleFishingResultSuccess().