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

Go to the source code of this file.

Classes

class  FishingRod_Base_New
 

Functions

void FishingRod_Base ()
 
void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
bool IsFishingActive ()
 
void ActivateFishing ()
 
void DeactivateFishing ()
 
void FishPull ()
 
void Catching ()
 
void Pulling ()
 
void End (int result)
 
void AddPull (float delta)
 
void DisplayState ()
 
override bool CanPutInCargo (EntityAI parent)
 
override void SetActions ()
 
float GetFishingEffectivityBonus ()
 

Variables

FishingRod_Base_New ANIM_PHASE_OPENED = "OpenRod"
 
const string ANIM_PHASE_CLOSED = "CloseRod"
 
const float BREAK_PULL = 36
 
const float TOO_MUCH_PULL = 32
 
const float HIGH_PULL = 22
 
const float LOW_PULL = 18
 
const float TOO_FEW_PULL = 8
 
const float LOOSE_PULL = 0
 
const int LOSS_BREAK = 0
 
const int LOSS_LOOSE = 1
 
const int WIN = 2
 
const int INTERUPTED = 3
 
const float INIT_LINE_STRETCH = 15
 
const float MIN_FISHING_TIME = 100
 
const float MAX_FISHING_TIME = 150
 
const int FISH_PULL_CHANCE = 15
 
const int FISH_AGILITY = 15
 
int m_FishProximity
 
bool m_Fishing
 
ref Timer m_CyclerCatching
 
ref Timer m_Cycler
 
float m_Pull
 
float m_DeltaT
 
bool m_WasPulled
 
bool m_IsFishPulling
 
float m_PullTime
 
float m_FishPull
 
int m_FishingTime
 
PlayerBase m_Player
 
int m_ChanceRange
 

Function Documentation

◆ ActivateFishing()

void ActivateFishing ( )

Definition at line 97 of file FishingRod_Base.c.

98 {
99 m_Fishing = true;
100 //Init();
101 }
bool m_Fishing

References m_Fishing.

◆ AddPull()

void AddPull ( float delta)

Definition at line 258 of file FishingRod_Base.c.

259 {
260 m_DeltaT = delta;
261 m_WasPulled = true;
262 }
bool m_WasPulled
float m_DeltaT

References m_DeltaT, and m_WasPulled.

◆ CanPutInCargo()

override bool CanPutInCargo ( EntityAI parent)

Definition at line 289 of file FishingRod_Base.c.

290 {
291 if (!super.CanPutInCargo(parent)) return false;
292 if (GetAnimationPhase(ANIM_PHASE_CLOSED) > 0.5)
293 return true;
294 return false;
295 }
const string ANIM_PHASE_CLOSED

References ANIM_PHASE_CLOSED.

◆ Catching()

void Catching ( )

Definition at line 134 of file FishingRod_Base.c.

135 {
136 if (m_FishProximity == 0 && m_WasPulled)
137 {
138 m_CyclerCatching.Stop();
139 m_Cycler.Run(0.3, this, "Pulling", NULL, true);
140 }
141 else
142 {
143 if (m_WasPulled)
144 {
145 m_WasPulled = false;
147 }
148 //TIMERDEPRECATED - randomized proximity of fish to
150 string fline = "";
151 for (int i = 0; i < m_FishProximity; i++)
152 fline += " .";
153 m_Player.Message("", "colorStatusChannel");
154 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
155 m_Player.Message("", "colorStatusChannel");
156 m_Player.Message("", "colorStatusChannel");
157 m_Player.Message("", "colorStatusChannel");
158 m_Player.Message("Start pulling when J and <*)))>< meet:", "colorStatusChannel");
159 m_Player.Message("", "colorStatusChannel");
160 m_Player.Message("J" + fline + " <*)))><", "colorImportant");
161 if (m_ChanceRange > 0)
163 }
164 }
ref Timer m_CyclerCatching
PlayerBase m_Player
int m_FishProximity
int m_ChanceRange
ref Timer m_Cycler
Definition EnMath.c:7
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].

References m_ChanceRange, m_Cycler, m_CyclerCatching, m_FishProximity, m_Player, m_WasPulled, and Math::RandomInt().

◆ DeactivateFishing()

void DeactivateFishing ( )

Definition at line 103 of file FishingRod_Base.c.

104 {
106 }
void End()
called on surrender end request end
const int INTERUPTED

References End(), and INTERUPTED.

◆ DisplayState()

void DisplayState ( )

Definition at line 264 of file FishingRod_Base.c.

265 {
266 string fline = "";
267 for (int i = 0; i < m_Pull; i++)
268 fline += "-";
269 m_Player.Message("", "colorStatusChannel");
270 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
271 m_Player.Message("RELEASE right mouse button to loosen the fishing line", "colorAction");
272 m_Player.Message("", "colorStatusChannel");
273 m_Player.Message("", "colorStatusChannel");
274 m_Player.Message("Fishing line stretch :", "colorStatusChannel");
275 m_Player.Message("", "colorStatusChannel");
276 if (m_Pull >= TOO_MUCH_PULL)
277 m_Player.Message("<" + fline + ">", "colorImportant");
279 m_Player.Message("<" + fline + ">", "colorAction");
281 m_Player.Message("<" + fline + ">", "colorFriendly");
283 m_Player.Message("<" + fline + ">", "colorStatusChannel");
284 if (m_Pull <= TOO_FEW_PULL)
285 m_Player.Message("<" + fline + ">", "colorImportant");
286 }
const float TOO_FEW_PULL
const float TOO_MUCH_PULL
float m_Pull
const float LOW_PULL
const float HIGH_PULL

References HIGH_PULL, LOW_PULL, m_Player, m_Pull, TOO_FEW_PULL, and TOO_MUCH_PULL.

Referenced by Pulling().

◆ End()

void End ( int result)

Definition at line 200 of file FishingRod_Base.c.

201 {
202 m_Cycler.Stop();
203 m_CyclerCatching.Stop();
204 m_Fishing = false;
205
206 switch (result)
207 {
208 case LOSS_BREAK:
209 m_Player.Message("", "colorStatusChannel");
210 m_Player.Message("", "colorStatusChannel");
211 m_Player.Message("", "colorStatusChannel");
212 m_Player.Message("The fish had broken the fishing line and swam away.", "colorImportant");
213 m_Player.Message("", "colorStatusChannel");
214 m_Player.Message("", "colorStatusChannel");
215 m_Player.Message("", "colorStatusChannel");
216 m_Player.Message("", "colorStatusChannel");
217 break;
218
219 case LOSS_LOOSE:
220 m_Player.Message("", "colorStatusChannel");
221 m_Player.Message("", "colorStatusChannel");
222 m_Player.Message("", "colorStatusChannel");
223 m_Player.Message("The fish escaped.", "colorImportant");
224 m_Player.Message("", "colorStatusChannel");
225 m_Player.Message("", "colorStatusChannel");
226 m_Player.Message("", "colorStatusChannel");
227 m_Player.Message("", "colorStatusChannel");
228 break;
229
230 case WIN:
231 m_Player.Message("", "colorStatusChannel");
232 m_Player.Message("", "colorStatusChannel");
233 m_Player.Message("", "colorStatusChannel");
234 m_Player.Message("I caught the fish!", "colorFriendly");
235 m_Player.Message("", "colorStatusChannel");
236 m_Player.Message("", "colorStatusChannel");
237 m_Player.Message("", "colorStatusChannel");
238 m_Player.Message("", "colorStatusChannel");
239 break;
240
241 case INTERUPTED:
242 m_Player.Message("", "colorStatusChannel");
243 m_Player.Message("", "colorStatusChannel");
244 m_Player.Message("", "colorStatusChannel");
245 m_Player.Message("Fishing time is over.", "colorFriendly");
246 m_Player.Message("", "colorStatusChannel");
247 m_Player.Message("", "colorStatusChannel");
248 m_Player.Message("", "colorStatusChannel");
249 m_Player.Message("", "colorStatusChannel");
250 break;
251
252 default:
253 Print("Wrong number");
254 break;
255 }
256 }
const int LOSS_LOOSE
const int LOSS_BREAK
const int WIN
proto void Print(void var)
Prints content of variable to console/log.

References INTERUPTED, LOSS_BREAK, LOSS_LOOSE, m_Cycler, m_CyclerCatching, m_Fishing, m_Player, Print(), and WIN.

◆ FishingRod_Base()

void FishingRod_Base ( )

Definition at line 69 of file FishingRod_Base.c.

70 {
71 m_Fishing = false;
72 }

References m_Fishing.

◆ FishPull()

void FishPull ( )

Definition at line 109 of file FishingRod_Base.c.

110 {
111 if (!m_IsFishPulling)
112 {
115 {
116 //TIMERDEPRECATED - randomizing timeframe to pull fish out
117 if (Math.RandomInt(0, 1))
119 else
120 m_FishPull = -rand;
121 //TIMERDEPRECATED - randomizing timeframe to pull fish out
122 m_PullTime = Math.RandomInt(2, 6);
123 m_IsFishPulling = true;
124 }
125 }
126 else
127 {
128 m_PullTime--;
129 if (m_PullTime == 0)
130 m_IsFishPulling = false;
131 }
132 }
float m_PullTime
float m_FishPull
bool m_IsFishPulling
const int FISH_PULL_CHANCE

References FISH_PULL_CHANCE, m_FishPull, m_IsFishPulling, m_PullTime, Math::RandomInt(), and TOO_FEW_PULL.

Referenced by Pulling().

◆ GetFishingEffectivityBonus()

float GetFishingEffectivityBonus ( )

Definition at line 306 of file FishingRod_Base.c.

307 {
308 return 0.0;
309 }

◆ Init()

void Init ( )

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

pre-init arrays

Definition at line 74 of file FishingRod_Base.c.

75 {
78 m_IsFishPulling = false;
79 //TIMERDEPRECATED - randomized time of fishing
83 //TIMERDEPRECATED
84 if (!m_Cycler)
85 m_Cycler = new Timer();
87 m_CyclerCatching = new Timer();
88 m_CyclerCatching.Run(4, this, "Catching", NULL, true);
89 m_Player.Message("I have started fishing.", "colorFriendly");
90 }
const float MIN_FISHING_TIME
const int FISH_AGILITY
int m_FishingTime
const float MAX_FISHING_TIME
const float INIT_LINE_STRETCH
PlayerBase GetPlayer()
proto native CGame GetGame()

References FISH_AGILITY, GetGame(), GetPlayer(), INIT_LINE_STRETCH, m_ChanceRange, m_Cycler, m_CyclerCatching, m_FishingTime, m_FishProximity, m_IsFishPulling, m_Player, m_Pull, MAX_FISHING_TIME, MIN_FISHING_TIME, and Math::RandomInt().

◆ IsFishingActive()

bool IsFishingActive ( )

Definition at line 92 of file FishingRod_Base.c.

93 {
94 return m_Fishing;
95 }

References m_Fishing.

◆ Pulling()

void Pulling ( )

Definition at line 166 of file FishingRod_Base.c.

167 {
168 float agent_speed_distance = vector.Distance("0 0 0", m_Player.GetModelSpeed());
169 if (m_Player.GetItemInHands() != this || !m_Player.IsInWater() || agent_speed_distance > 1)
171 else
172 {
173 if (m_FishingTime <= 0)
174 {
175 ItemBase pcatch = ItemBase.Cast(m_Player.GetInventory().CreateInInventory("Carp"));
176 //ItemBase pcatch = ItemBase.Cast( m_Player.CreateInInventory("Carp","cargo_bait") );
177 pcatch.SetQuantity(800, false);
178 End(WIN);
179 }
180 else
181 {
182 FishPull();
183 if (m_IsFishPulling)
185 if (m_WasPulled)
186 m_Pull += 1;
187 else
188 m_Pull -= 1;
189 m_WasPulled = false;
191 DisplayState();
192 if (m_Pull <= LOOSE_PULL)
194 if (m_Pull >= BREAK_PULL)
196 }
197 }
198 }
void FishPull()
const float BREAK_PULL
void DisplayState()
const float LOOSE_PULL
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.

References BREAK_PULL, DisplayState(), vector::Distance(), End(), FishPull(), INTERUPTED, LOOSE_PULL, LOSS_BREAK, LOSS_LOOSE, m_FishingTime, m_FishPull, m_IsFishPulling, m_Player, m_Pull, m_WasPulled, and WIN.

◆ SetActions()

override void SetActions ( )

Definition at line 297 of file FishingRod_Base.c.

298 {
299 super.SetActions();
300
301 //AddAction(ActionToggleFishing);
302 //AddAction(ActionFishing);
303 //AddAction(ActionFishingNew);
304 }

Variable Documentation

◆ ANIM_PHASE_CLOSED

const string ANIM_PHASE_CLOSED = "CloseRod"

Definition at line 37 of file FishingRod_Base.c.

Referenced by CanPutInCargo().

◆ ANIM_PHASE_OPENED

FishingRod_Base_New ANIM_PHASE_OPENED = "OpenRod"

◆ BREAK_PULL

const float BREAK_PULL = 36

Definition at line 39 of file FishingRod_Base.c.

Referenced by Pulling().

◆ FISH_AGILITY

const int FISH_AGILITY = 15

Definition at line 53 of file FishingRod_Base.c.

Referenced by Init().

◆ FISH_PULL_CHANCE

const int FISH_PULL_CHANCE = 15

Definition at line 52 of file FishingRod_Base.c.

Referenced by FishPull().

◆ HIGH_PULL

const float HIGH_PULL = 22

Definition at line 41 of file FishingRod_Base.c.

Referenced by DisplayState().

◆ INIT_LINE_STRETCH

const float INIT_LINE_STRETCH = 15

Definition at line 49 of file FishingRod_Base.c.

Referenced by Init().

◆ INTERUPTED

const int INTERUPTED = 3

Definition at line 48 of file FishingRod_Base.c.

Referenced by DeactivateFishing(), End(), and Pulling().

◆ LOOSE_PULL

const float LOOSE_PULL = 0

Definition at line 44 of file FishingRod_Base.c.

Referenced by Pulling().

◆ LOSS_BREAK

const int LOSS_BREAK = 0

Definition at line 45 of file FishingRod_Base.c.

Referenced by End(), and Pulling().

◆ LOSS_LOOSE

const int LOSS_LOOSE = 1

Definition at line 46 of file FishingRod_Base.c.

Referenced by End(), and Pulling().

◆ LOW_PULL

const float LOW_PULL = 18

Definition at line 42 of file FishingRod_Base.c.

Referenced by DisplayState().

◆ m_ChanceRange

int m_ChanceRange

Definition at line 67 of file FishingRod_Base.c.

Referenced by Catching(), and Init().

◆ m_Cycler

ref Timer m_Cycler

Definition at line 58 of file FishingRod_Base.c.

Referenced by Catching(), End(), and Init().

◆ m_CyclerCatching

ref Timer m_CyclerCatching

Definition at line 57 of file FishingRod_Base.c.

Referenced by Catching(), End(), and Init().

◆ m_DeltaT

float m_DeltaT

Definition at line 60 of file FishingRod_Base.c.

Referenced by AddPull().

◆ m_Fishing

bool m_Fishing

Definition at line 56 of file FishingRod_Base.c.

Referenced by ActivateFishing(), End(), FishingRod_Base(), and IsFishingActive().

◆ m_FishingTime

int m_FishingTime

Definition at line 65 of file FishingRod_Base.c.

Referenced by Init(), and Pulling().

◆ m_FishProximity

int m_FishProximity

Definition at line 55 of file FishingRod_Base.c.

Referenced by Catching(), and Init().

◆ m_FishPull

float m_FishPull

Definition at line 64 of file FishingRod_Base.c.

Referenced by FishPull(), and Pulling().

◆ m_IsFishPulling

bool m_IsFishPulling

Definition at line 62 of file FishingRod_Base.c.

Referenced by FishPull(), Init(), and Pulling().

◆ m_Player

PlayerBase m_Player

Definition at line 66 of file FishingRod_Base.c.

◆ m_Pull

float m_Pull

Definition at line 59 of file FishingRod_Base.c.

Referenced by DisplayState(), Init(), and Pulling().

◆ m_PullTime

float m_PullTime

Definition at line 63 of file FishingRod_Base.c.

Referenced by FishPull().

◆ m_WasPulled

bool m_WasPulled

Definition at line 61 of file FishingRod_Base.c.

Referenced by AddPull(), Catching(), and Pulling().

◆ MAX_FISHING_TIME

const float MAX_FISHING_TIME = 150

Definition at line 51 of file FishingRod_Base.c.

Referenced by Init().

◆ MIN_FISHING_TIME

const float MIN_FISHING_TIME = 100

Definition at line 50 of file FishingRod_Base.c.

Referenced by Init().

◆ TOO_FEW_PULL

const float TOO_FEW_PULL = 8

Definition at line 43 of file FishingRod_Base.c.

Referenced by DisplayState(), and FishPull().

◆ TOO_MUCH_PULL

const float TOO_MUCH_PULL = 32

Definition at line 40 of file FishingRod_Base.c.

Referenced by DisplayState().

◆ WIN

const int WIN = 2

Definition at line 47 of file FishingRod_Base.c.

Referenced by End(), and Pulling().