DayZ 1.24
Loading...
Searching...
No Matches
FishingRod_Base.c
Go to the documentation of this file.
2{
4 {
5 }
6
7 override void SetActions()
8 {
9 super.SetActions();
10
12 }
13
15 {
16 return 0.0;
17 }
18
19 override bool IsOpen()
20 {
21 return false;
22 }
23
25
26 override void OnDebugSpawn()
27 {
28 GetInventory().CreateAttachment("Bait");
29 for (int i = 0; i < 6; ++i)
30 GetGame().CreateObjectEx("Bait", GetPosition(), ECE_PLACE_ON_SURFACE);
31 }
32}
33
35{
36 const string ANIM_PHASE_OPENED = "OpenRod";
37 const string ANIM_PHASE_CLOSED = "CloseRod";
38
39 const float BREAK_PULL = 36;
40 const float TOO_MUCH_PULL = 32;
41 const float HIGH_PULL = 22;
42 const float LOW_PULL = 18;
43 const float TOO_FEW_PULL = 8;
44 const float LOOSE_PULL = 0;
45 const int LOSS_BREAK = 0;
46 const int LOSS_LOOSE = 1;
47 const int WIN = 2;
48 const int INTERUPTED = 3;
49 const float INIT_LINE_STRETCH = 15;
50 const float MIN_FISHING_TIME = 100;
51 const float MAX_FISHING_TIME = 150;
52 const int FISH_PULL_CHANCE = 15;
53 const int FISH_AGILITY = 15;
54
59 float m_Pull;
60 float m_DeltaT;
68
70 {
71 m_Fishing = false;
72 }
73
74 void Init()
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 }
91
93 {
94 return m_Fishing;
95 }
96
98 {
99 m_Fishing = true;
100 //Init();
101 }
102
104 {
106 }
107
108
109 void FishPull()
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 }
133
134 void Catching()
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 }
165
166 void Pulling()
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 }
199
200 void End(int result)
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 }
257
258 void AddPull(float delta)
259 {
260 m_DeltaT = delta;
261 m_WasPulled = true;
262 }
263
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 }
287
288 // Conditions
289 override bool CanPutInCargo(EntityAI parent)
290 {
291 if (!super.CanPutInCargo(parent)) return false;
292 if (GetAnimationPhase(ANIM_PHASE_CLOSED) > 0.5)
293 return true;
294 return false;
295 }
296
297 override void SetActions()
298 {
299 super.SetActions();
300
301 //AddAction(ActionToggleFishing);
302 //AddAction(ActionFishing);
303 //AddAction(ActionFishingNew);
304 }
305
307 {
308 return 0.0;
309 }
310}
void AddAction(typename actionName)
const int ECE_PLACE_ON_SURFACE
override Widget Init()
Definition DayZGame.c:120
void End()
called on surrender end request end
void Pulling()
void FishPull()
const float TOO_FEW_PULL
const float MIN_FISHING_TIME
float m_PullTime
float m_FishPull
void FishingRod_Base()
const int INTERUPTED
const int LOSS_LOOSE
const float TOO_MUCH_PULL
const int FISH_AGILITY
ref Timer m_CyclerCatching
bool IsFishingActive()
bool m_Fishing
const float BREAK_PULL
bool m_IsFishPulling
void AddPull(float delta)
float GetFishingEffectivityBonus()
float m_Pull
bool m_WasPulled
int m_FishingTime
FishingRod_Base_New ANIM_PHASE_OPENED
void Catching()
const string ANIM_PHASE_CLOSED
void ActivateFishing()
const float LOW_PULL
const int FISH_PULL_CHANCE
const float MAX_FISHING_TIME
void DisplayState()
float m_DeltaT
int m_FishProximity
const float LOOSE_PULL
int m_ChanceRange
const float HIGH_PULL
ref Timer m_Cycler
void DeactivateFishing()
const int LOSS_BREAK
const float INIT_LINE_STRETCH
const int WIN
DayZPlayer m_Player
Definition Hand_Events.c:42
PlayerBase GetPlayer()
class JsonUndergroundAreaTriggerData GetPosition
override void OnDebugSpawn()
void AnimateFishingRod(bool state)
override void SetActions()
float GetFishingEffectivityBonus()
override bool IsOpen()
override void SetActions()
override bool CanPutInCargo(EntityAI parent)
Definition GardenBase.c:278
Definition EnMath.c:7
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].