DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
FishingRod_Base.c
См. документацию.
2{
4 {
5 }
6
7 override void SetActions()
8 {
9 super.SetActions();
10
12 }
13
14 override bool GetActionWidgetOverride(out typename name)
15 {
16 PlayerBase owner;
17 if (Class.CastTo(owner,GetHierarchyRootPlayer()))
18 {
19 ActionFishingNew action;
20 if (Class.CastTo(action,owner.GetActionManager().GetRunningAction()) && owner.GetActionManager().GetActionState() == UA_PROCESSING)
21 {
23 return true;
24 }
25 }
26 return false;
27 }
28
29 override bool IsOpen()
30 {
31 return false;
32 }
33
34 void AnimateFishingRodEx(float phase, bool instant = false)
35 {
36 if (instant)
37 SetAnimationPhaseNow("AnimateRod",phase);
38 else
39 SetAnimationPhase("AnimateRod",phase);
40 }
41
42 override void OnDebugSpawn()
43 {
44 ItemBase hook;
45 for (int i = 0; i < 6; ++i)
46 {
47 if (Class.CastTo(hook,GetGame().CreateObjectEx("Hook", GetPosition(), ECE_PLACE_ON_SURFACE)))
48 hook.GetInventory().CreateAttachment("Worm");
49 }
50
51 if (Class.CastTo(hook,GetInventory().CreateAttachment("Hook")))
52 hook.GetInventory().CreateAttachment("Worm");
53 }
54
56
59 {
60 return 0.0;
61 }
62
64 void AnimateFishingRod(bool state)
65 {
67 }
68}
69
71{
72 const string ANIM_PHASE_OPENED = "OpenRod";
73 const string ANIM_PHASE_CLOSED = "CloseRod";
74
75 const float BREAK_PULL = 36;
76 const float TOO_MUCH_PULL = 32;
77 const float HIGH_PULL = 22;
78 const float LOW_PULL = 18;
79 const float TOO_FEW_PULL = 8;
80 const float LOOSE_PULL = 0;
81 const int LOSS_BREAK = 0;
82 const int LOSS_LOOSE = 1;
83 const int WIN = 2;
84 const int INTERUPTED = 3;
85 const float INIT_LINE_STRETCH = 15;
86 const float MIN_FISHING_TIME = 100;
87 const float MAX_FISHING_TIME = 150;
88 const int FISH_PULL_CHANCE = 15;
89 const int FISH_AGILITY = 15;
90
95 float m_Pull;
96 float m_DeltaT;
104
106 {
107 m_Fishing = false;
108 }
109
110 void Init()
111 {
112 m_Player = PlayerBase.Cast( GetGame().GetPlayer() );
114 m_IsFishPulling = false;
115 //TIMERDEPRECATED - randomized time of fishing
119 //TIMERDEPRECATED
120 if(!m_Cycler)
121 {
122 m_Cycler = new Timer();
123 }
125 {
126 m_CyclerCatching = new Timer();
127 }
128 m_CyclerCatching.Run(4, this, "Catching", NULL,true);
129 m_Player.Message("I have started fishing.", "colorFriendly");
130 }
131
133 {
134 return m_Fishing;
135 }
136
138 {
139 m_Fishing = true;
140 //Init();
141 }
142
144 {
146 }
147
148
149
150 void FishPull()
151 {
152 if ( !m_IsFishPulling )
153 {
154 float rand = Math.RandomInt(1, FISH_PULL_CHANCE);
156 {
157 //TIMERDEPRECATED - randomizing timeframe to pull fish out
158 if ( Math.RandomInt(0, 1) )
159 {
160 m_FishPull = rand;
161 }
162 else
163 {
164 m_FishPull = -rand;
165 }
166 //TIMERDEPRECATED - randomizing timeframe to pull fish out
167 m_PullTime = Math.RandomInt(2, 6);
168 m_IsFishPulling = true;
169 }
170 }
171 else
172 {
173 m_PullTime--;
174 if (m_PullTime == 0)
175 {
176 m_IsFishPulling = false;
177 }
178 }
179 }
180
181 void Catching()
182 {
183 if(m_FishProximity == 0 && m_WasPulled)
184 {
185 m_CyclerCatching.Stop();
186 m_Cycler.Run(0.3, this, "Pulling", NULL,true);
187 }
188 else
189 {
190 if (m_WasPulled)
191 {
192 m_WasPulled = false;
194 }
195 //TIMERDEPRECATED - randomized proximity of fish to
197 string fline = "";
198 for (int i = 0; i < m_FishProximity; i++)
199 {
200 fline += " .";
201 }
202 m_Player.Message("", "colorStatusChannel");
203 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
204 m_Player.Message("", "colorStatusChannel");
205 m_Player.Message("", "colorStatusChannel");
206 m_Player.Message("", "colorStatusChannel");
207 m_Player.Message("Start pulling when J and <*)))>< meet:", "colorStatusChannel");
208 m_Player.Message("", "colorStatusChannel");
209 m_Player.Message("J"+fline+" <*)))><", "colorImportant");
210 if(m_ChanceRange > 0)
211 {
213 }
214 }
215 }
216
217 void Pulling()
218 {
219 float agent_speed_distance = vector.Distance("0 0 0",m_Player.GetModelSpeed());
220 if (m_Player.GetItemInHands() != this || !m_Player.IsInWater() || agent_speed_distance > 1 )
221 {
223 }
224 else
225 {
226 if ( m_FishingTime <= 0)
227 {
228 ItemBase pcatch = ItemBase.Cast( m_Player.GetInventory().CreateInInventory("Carp") );
229 //ItemBase pcatch = ItemBase.Cast( m_Player.CreateInInventory("Carp","cargo_bait") );
230 pcatch.SetQuantity(800,false);
231 End(WIN);
232 }
233 else
234 {
235 FishPull();
236 if ( m_IsFishPulling )
237 {
239 }
240 if (m_WasPulled)
241 {
242 m_Pull += 1;
243 }
244 else
245 {
246 m_Pull -= 1;
247 }
248 m_WasPulled = false;
250 DisplayState();
251 if ( m_Pull <= LOOSE_PULL)
252 {
254 }
255 if ( m_Pull >= BREAK_PULL)
256 {
258 }
259 }
260 }
261 }
262
263 void End( int result )
264 {
265 m_Cycler.Stop();
266 m_CyclerCatching.Stop();
267 m_Fishing = false;
268
269 switch (result)
270 {
271 case LOSS_BREAK:
272 m_Player.Message("", "colorStatusChannel");
273 m_Player.Message("", "colorStatusChannel");
274 m_Player.Message("", "colorStatusChannel");
275 m_Player.Message("The fish had broken the fishing line and swam away.", "colorImportant");
276 m_Player.Message("", "colorStatusChannel");
277 m_Player.Message("", "colorStatusChannel");
278 m_Player.Message("", "colorStatusChannel");
279 m_Player.Message("", "colorStatusChannel");
280 break;
281
282 case LOSS_LOOSE:
283 m_Player.Message("", "colorStatusChannel");
284 m_Player.Message("", "colorStatusChannel");
285 m_Player.Message("", "colorStatusChannel");
286 m_Player.Message("The fish escaped.", "colorImportant");
287 m_Player.Message("", "colorStatusChannel");
288 m_Player.Message("", "colorStatusChannel");
289 m_Player.Message("", "colorStatusChannel");
290 m_Player.Message("", "colorStatusChannel");
291 break;
292
293 case WIN:
294 m_Player.Message("", "colorStatusChannel");
295 m_Player.Message("", "colorStatusChannel");
296 m_Player.Message("", "colorStatusChannel");
297 m_Player.Message("I caught the fish!", "colorFriendly");
298 m_Player.Message("", "colorStatusChannel");
299 m_Player.Message("", "colorStatusChannel");
300 m_Player.Message("", "colorStatusChannel");
301 m_Player.Message("", "colorStatusChannel");
302 break;
303
304 case INTERUPTED:
305 m_Player.Message("", "colorStatusChannel");
306 m_Player.Message("", "colorStatusChannel");
307 m_Player.Message("", "colorStatusChannel");
308 m_Player.Message("Fishing time is over.", "colorFriendly");
309 m_Player.Message("", "colorStatusChannel");
310 m_Player.Message("", "colorStatusChannel");
311 m_Player.Message("", "colorStatusChannel");
312 m_Player.Message("", "colorStatusChannel");
313 break;
314
315 default:
316 Print("Wrong number");
317 break;
318 }
319 }
320
321 void AddPull(float delta)
322 {
323 m_DeltaT = delta;
324 m_WasPulled = true;
325 }
326
328 {
329 string fline = "";
330 for (int i = 0; i < m_Pull; i++)
331 {
332 fline += "-";
333 }
334 m_Player.Message("", "colorStatusChannel");
335 m_Player.Message("HOLD right mouse button to pull the fishing line", "colorAction");
336 m_Player.Message("RELEASE right mouse button to loosen the fishing line", "colorAction");
337 m_Player.Message("", "colorStatusChannel");
338 m_Player.Message("", "colorStatusChannel");
339 m_Player.Message("Fishing line stretch :", "colorStatusChannel");
340 m_Player.Message("", "colorStatusChannel");
341 if (m_Pull >= TOO_MUCH_PULL)
342 {
343 m_Player.Message("<"+fline+">", "colorImportant");
344 }
346 {
347 m_Player.Message("<"+fline+">", "colorAction");
348 }
350 {
351 m_Player.Message("<"+fline+">", "colorFriendly");
352 }
354 {
355 m_Player.Message("<"+fline+">", "colorStatusChannel");
356 }
357 if (m_Pull <= TOO_FEW_PULL)
358 {
359 m_Player.Message("<"+fline+">", "colorImportant");
360 }
361 }
362
363 // Conditions
364 override bool CanPutInCargo( EntityAI parent )
365 {
366 if( !super.CanPutInCargo(parent) ) {return false;}
367 if ( GetAnimationPhase(ANIM_PHASE_CLOSED) > 0.5 )
368 {
369 return true;
370 }
371 return false;
372 }
373
374 override void SetActions()
375 {
376 super.SetActions();
377
378 //AddAction(ActionToggleFishing);
379 //AddAction(ActionFishingNew);
380 }
381
383 {
384 return 0.0;
385 }
386}
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
override Widget Init()
Определения DayZGame.c:127
void Pulling()
Определения FishingRod_Base.c:217
void FishPull()
Определения FishingRod_Base.c:150
const float TOO_FEW_PULL
Определения FishingRod_Base.c:79
const float MIN_FISHING_TIME
Определения FishingRod_Base.c:86
float m_PullTime
Определения FishingRod_Base.c:99
float m_FishPull
Определения FishingRod_Base.c:100
void FishingRod_Base()
Определения FishingRod_Base.c:105
const int INTERUPTED
Определения FishingRod_Base.c:84
const int LOSS_LOOSE
Определения FishingRod_Base.c:82
const float TOO_MUCH_PULL
Определения FishingRod_Base.c:76
const int FISH_AGILITY
Определения FishingRod_Base.c:89
ref Timer m_CyclerCatching
Определения FishingRod_Base.c:93
bool IsFishingActive()
Определения FishingRod_Base.c:132
bool m_Fishing
Определения FishingRod_Base.c:92
const float BREAK_PULL
Определения FishingRod_Base.c:75
bool m_IsFishPulling
Определения FishingRod_Base.c:98
void AddPull(float delta)
Определения FishingRod_Base.c:321
float GetFishingEffectivityBonus()
Определения FishingRod_Base.c:382
float m_Pull
Определения FishingRod_Base.c:95
bool m_WasPulled
Определения FishingRod_Base.c:97
int m_FishingTime
Определения FishingRod_Base.c:101
FishingRod_Base_New ANIM_PHASE_OPENED
void Catching()
Определения FishingRod_Base.c:181
const string ANIM_PHASE_CLOSED
Определения FishingRod_Base.c:73
void ActivateFishing()
Определения FishingRod_Base.c:137
const float LOW_PULL
Определения FishingRod_Base.c:78
const int FISH_PULL_CHANCE
Определения FishingRod_Base.c:88
const float MAX_FISHING_TIME
Определения FishingRod_Base.c:87
void DisplayState()
Определения FishingRod_Base.c:327
float m_DeltaT
Определения FishingRod_Base.c:96
int m_FishProximity
Определения FishingRod_Base.c:91
const float LOOSE_PULL
Определения FishingRod_Base.c:80
int m_ChanceRange
Определения FishingRod_Base.c:103
const float HIGH_PULL
Определения FishingRod_Base.c:77
ref Timer m_Cycler
Определения FishingRod_Base.c:94
void DeactivateFishing()
Определения FishingRod_Base.c:143
const int LOSS_BREAK
Определения FishingRod_Base.c:81
const float INIT_LINE_STRETCH
Определения FishingRod_Base.c:85
const int WIN
Определения FishingRod_Base.c:83
DayZPlayer m_Player
Определения Hand_Events.c:42
PlayerBase GetPlayer()
Определения ModifierBase.c:51
proto static native void End()
Finalizes the testing process.
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
override void OnDebugSpawn()
Определения FishingRod_Base.c:42
void AnimateFishingRod(bool state)
DEPRECATED.
Определения FishingRod_Base.c:64
void FishingRod_Base_New()
Определения FishingRod_Base.c:3
override void SetActions()
Определения FishingRod_Base.c:7
void AnimateFishingRodEx(float phase, bool instant=false)
Определения FishingRod_Base.c:34
float GetFishingEffectivityBonus()
DEPRECATED, used to dictate catch chance.
Определения FishingRod_Base.c:58
override bool IsOpen()
Определения FishingRod_Base.c:29
override bool GetActionWidgetOverride(out typename name)
Определения FishingRod_Base.c:14
override void SetActions()
Определения InventoryItem.c:732
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:269
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
Определения DayZPlayerImplement.c:63
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
const int UA_PROCESSING
Определения constants.c:462