-
Notifications
You must be signed in to change notification settings - Fork 1
/
fish_i_main.nss
2158 lines (1805 loc) · 82.2 KB
/
fish_i_main.nss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Filename: fish_i_main.nss
System: SM's Fishing System (include script)
Author: Michael A. Sinclair (Squatting Monk) <[email protected]>
Date Created: Aug. 12, 2015
Summary:
Fishing System include script. This file holds functions and constants commonly
used in the system. This file should not be altered by end users. For
configurable settings and functions, see fish_c_config.
This script is consumed as an include directive by fish_c_config.
Revision Info should only be included for post-release revisions.
-----------------
Revision Date:
Revision Author:
Revision Summary:
*/
// List handling utilities
#include "util_i_lists"
// -----------------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------------
// Blueprints and tags
const string FISH_WP_DATA = "fish_datapoint";
const string FISH_WP_FISHING = "fish_fishingspot";
const string FISH_WP_GENERIC = "nw_waypoint001";
const string FISH_DEFAULT = "nw_it_msmlmisc20";
// Local variables names.
const string FISH_BLACKLIST = "BLACKLIST";
const string FISH_DEBUG = "DEBUG";
const string FISH_DESCRIPTION = "DESCRIPTION";
const string FISH_DISTANCE = "DISTANCE";
const string FISH_ENVIRONMENT = "ENVIRONMENT";
const string FISH_EQUIPMENT = "EQUIPMENT";
const string FISH_FREQUENCY = "FREQUENCY";
const string FISH_MESSAGE = "MSG";
const string FISH_MOD = "MOD";
const string FISH_NAME = "NAME";
const string FISH_RESREF = "RESREF";
const string FISH_STACK = "STACK";
const string FISH_TACKLE = "TACKLE";
const string FISH_TACKLE_ALLOWED = "ALLOWED";
const string FISH_TACKLE_REQUIRED = "REQUIRED";
const string FISH_TACKLE_SLOT = "SLOT";
const string FISH_TAG = "TAG";
const string FISH_WHITELIST = "WHITELIST";
// Fishing events for animation
const int FISH_EVENT_START = 0;
const int FISH_EVENT_NIBBLE = 1;
const int FISH_EVENT_CATCH = 2;
const int FISH_EVENT_NO_CATCH = 3;
const int FISH_EVENT_NO_NIBBLE = 4;
const int FISH_EVENT_USE_TACKLE = 5;
const int FISH_EVENT_BAD_TARGET = 6;
const int FISH_EVENT_NO_SPOT = 7;
const int FISH_EVENT_NO_TACKLE = 8;
struct FishingData
{
// We store all our data on a waypoint accessed through the global variable
// Fish.Data. The waypoint is auto-generated by InitializeFishingSystem().
// We do this to reduce the number of local variables stored on the module,
// which helps reduce access time when dealing with large numbers of
// variables.
object Data;
object PC; // The PC currently fishing
object Spot; // The current fishing spot
string Environment; // The environment the PC is fishing in
object Item; // The PC's current fishing equipment
string Type; // The type of equipment the PC is using
string Tackle; // List of what tackle the equipment is using
string Full; // List of tackle slots with tackle in them
string Empty; // List of tackle slots with no tackle in them
int Debug; // Whether to debug fishing functions
};
// -----------------------------------------------------------------------------
// Global Variables
// -----------------------------------------------------------------------------
// Data structure to hold all variables for this fishing attempt. We instantiate
// it here so it is accessible to all the functions within this script. All data
// is set by fish_t_equipment.nss. The user should use the GetFishing*()
// functions instead of accessing this variable directly.
struct FishingData Fish;
// -----------------------------------------------------------------------------
// Function Prototypes
// -----------------------------------------------------------------------------
// ----- Variable Accessor Functions -------------------------------------------
// ---< GetFishFloat >---
// ---< fish_i_main >---
// Gets a local float of sVarName from sKey. If sKey is blank, will get the
// globally set float. If sKey has not had a float set explicitly by
// SetFishFloat(), this will return any globally set float.
float GetFishFloat(string sVarName, string sKey = "");
// ---< GetFishInt >---
// ---< fish_i_main >---
// Gets a local int of sVarName from sKey. If sKey is blank, will get the
// globally set int. If sKey has not had an int set explicitly by SetFishInt(),
// this will return any globally set int.
int GetFishInt(string sVarName, string sKey = "");
// ---< GetFishString >---
// ---< fish_i_main >---
// Gets a local string of sVarName from sKey. If sKey is blank, will get the
// globally set string. If sKey has not had a string set explicitly by
// SetFishString(), this will return any globally set string.
string GetFishString(string sVarName, string sKey = "");
// ---< SetFishFloat >---
// ---< fish_i_main >---
// Sets a local float of sVarName with fValue on every item in sList. If sList
// is blank, will set the float globally.
void SetFishFloat(string sVarName, float fValue, string sList = "");
// ---< SetFishInt >---
// ---< fish_i_main >---
// Sets a local int of sVarName with nValue on every item in sList. If sList
// is blank, will set the int globally.
void SetFishInt(string sVarName, int nValue, string sList = "");
// ---< SetFishString >---
// ---< fish_i_main >---
// Sets a local string of sVarName with sValue on every item in sList. If sList
// is blank, will set the string globally.
void SetFishString(string sVarName, string sValue, string sList = "");
// ----- Debug Functions -------------------------------------------------------
// ---< SetFishingDebugMode >---
// ---< fish_i_main >---
// Sets debug mode on oTarget to bDebug. If oTarget is invalid, will change
// debug mode for the whole module. If debug mode is on, fishing will generate
// debug messages. This may be useful for tracking down errors in any of the
// config functions.
void SetFishingDebugMode(int bDebug, object oTarget = OBJECT_INVALID);
// ---< GetFishingDebugMode >---
// ---< fish_i_main >---
// Gets whether oTarget has debug mode on. If oTarget is invalid, will return
// debug mode for the whole module. If debug mode is on, fishing will generate
// debug messages. This may be useful for tracking down errors in any of the
// config functions.
int GetFishingDebugMode(object oTarget = OBJECT_INVALID);
// ---< FishingDebug >---
// ---< fish_i_main >---
// If debug mode is on, sends sMessage to the fishing PC and writes the message
// to the log. This is done using the action queue, so the PC will see the
// message at the appropriate time.
void FishingDebug(string sMessage);
// ----- Fishing Equipment and Tackle Functions --------------------------------
// ---< AddFishingTackleSlot >---
// ---< fish_i_main >---
// Defines the tackle slot sSlot as being found on equipment type sEquipment.
// Tackle that fits into sSlot can be used on sEquipment. if bRequired is TRUE,
// sSlot must be filled with matching tackle for the equipment to be used.
//
// This function can be called multiple times for a given equipment type,
// defining a new slot each time. For bulk usage, however, consider using
// AddFishingTackleSlots() instead.
//
// You can create your own types of equipment:
// 1. Give your item a "Cast Spell: OnActivate (Self Only)" item property with
// unlimited uses.
// 2. Set its tag to "fish_t_equipment_*", where * is the type of equipment your
// item is. Alternatively, set the tag to "fish_t_equipment" and use the
// resref as the equipment type. This will be the value you should use to
// refer to your equipment type in this setting and in the config functions.
void AddFishingTackleSlot(string sEquipment, string sSlot, int bRequired = FALSE);
// ---< AddFishingTackleSlots >---
// ---< fish_i_main >---
// Defines the required and optional tackle slots for a list of equipment types.
// Tackle that doesn't match one of these slots can't be used on the equipment.
// Parameters:
// - sEquipmentList: a comma-separated list of equipment types
// - sSlotList: a comma-separated list of tackle slots that the equipment has
// but are not required for the equipment to be used.
// - sRequiredSlotList: a comma-separated list of tackle slots that must be
// filled for the equipment to be successfully used. If a slot is defined both
// here and in sSlotList, this one takes precedence.
//
// You can create your own types of equipment:
// 1. Give your item a "Cast Spell: OnActivate (Self Only)" item property with
// unlimited uses.
// 2. Set its tag to "fish_t_equipment_*", where * is the type of equipment your
// item is. Alternatively, set the tag to "fish_t_equipment" and use the
// resref as the equipment type. This will be the value you should use to
// refer to your equipment type in this setting and in the config functions.
void AddFishingTackleSlots(string sEquipmentList, string sSlotList, string sRequiredSlotList = "");
// ---< GetFishingTackleSlots >---
// ---< fish_i_main >---
// Returns a comma-separated list of the tackle slots enabled for sEquipment. If
// bRequiredOnly is TRUE, will limit the list to required tackle types.
string GetFishingTackleSlots(string sEquipment, int bRequiredOnly = FALSE);
// ---< CanUseFishingTackle >---
// ---< fish_i_main >---
// Returns whether sEquipment has a tackle slot that fits sTackle.
int CanUseFishingTackle(string sEquipment, string sTackle);
// ---< HasFishingTackleSlot >---
// ---< fish_i_main >---
// Returns whether sEquipment uses tackle slot sSlot. If bRequiredOnly is TRUE,
// will return whether the slot is required for use.
int HasFishingTackleSlot(string sEquipment, string sSlot, int bRequiredOnly = FALSE);
// ---< SetIsFishingTackle >---
// ---< fish_i_main >---
// Sets every tackle type in the comma-separated list sTackleList as fitting the
// tackle slot sSlot. If sSlot is blank, will use the tackle name as the slot.
//
// Any equipment that has been defined as tackle cannot be used to fish; it can
// only be applied to fishing equipment items that have a slot for the tackle.
//
// You can create your own types of equipment:
// 1. Give your item a "Cast Spell: OnActivate (Self Only)" item property with
// unlimited uses.
// 2. Set its tag to "fish_t_equipment_*", where * is the type of equipment your
// item is. Alternatively, set the tag to "fish_t_equipment" and use the
// resref as the equipment type. This will be the value you should use to
// refer to your equipment type in this setting and in the config functions.
void SetIsFishingTackle(string sTackleList, string sSlot = "");
// ---< GetFishingTackleSlot >---
// ---< fish_i_main >---
// Returns the slot occupied by sTackle.
string GetFishingTackleSlot(string sTackle);
// ---< IsFishingTackle >---
// ---< fish_i_main >---
// Returns whether sEquipment is a type of fishing tackle.
int GetIsFishingTackle(string sEquipment);
// ---< GetFishingTackle >---
// ---< fish_i_main >---
// Returns a list of the tackle being used in sSlot on oEquipment. If oEquipment
// is invalid, returns the tackle being used on the PC's currently equipped
// fishing equipment. If sSlot is empty, will return a CSV list of all tackle on
// oEquipment.
string GetFishingTackle(string sSlot = "", object oEquipment = OBJECT_INVALID);
// ---< SetFishingDistance >---
// ---< fish_i_main >---
// Gets the maximum distance, in meters, that a PC may be from a waypoint
// fishing spot to fish using sEquipment. If sEquipment is blank, will get a
// default fishing distance.
// Note: the PC will always be able to fish in a trigger fishing spot if he is
// inside of it.
float GetFishingDistance(string sEquipment);
// ---< SetFishingDistance >---
// ---< fish_i_main >---
// Sets the maximum distance, in meters, that a PC may be from a waypoint
// fishing spot to fish using any of the listed equipment.
// Parameters:
// - fMax: If this value is 0.0 or less, the PC will be able to fish in any area
// with a waypoint fishing spot regardless of how far he is from it.
// - sEquipmentList: a comma-separated list of equipment types that have this
// maximum distance. If this value is blank, will set a default fishing
// distance for any equipment type with no explicit setting.
// Note: the PC will always be able to fish in a trigger fishing spot if he is
// inside of it.
void SetFishingDistance(float fMax, string sEquipmentList = "");
// ----- Fish Frequency Functions ----------------------------------------------
// ---< AddFish >---
// ---< fish_i_main >---
// Adds every fish in the CSV list sFishList to the global fish list and sets
// the frequency at which the fish is normally found. The frequency is the
// percentage of time the fish will pass the nibble check and be caught. This
// frequency can be modified by the environment, equipment, or tackle and can be
// modified by the builder using the OnFishNibble() config function.
// Note: a frequency of 0 or lower will guarantee that a fish will not be caught
// unless its probability is raised in some way, and a value of 100 or higher
// will guarantee the fish will be caught unless its probability is decreased in
// some way.
void AddFish(int nFreq, string sFishList);
// ---< GetFish >---
// ---< fish_i_main >---
// Returns the nNth (where 0 is the first) fish that has been defined with
// AddFish(). This can be used in combination with GetFishCount() to loop
// through all defined fish.
string GetFish(int nNth);
// ---< GetFishCount >---
// ---< fish_i_main >---
// Returns the number of fish defined with AddFish(). This can be used in
// combination with GetFish() to loop through all defined fish.
int GetFishCount();
// ---< GetFishFrequency >---
// ---< fish_i_main >---
// Gets the frequency of sFish. This is the percentage of time the fish will
// pass the nibble check and be caught. This frequency can be modified by the
// environment, equipment, or tackle and can be modified by the builder using
// the OnFishNibble() config function.
int GetFishFrequency(string sFish);
// ---< GetFishResRef >---
// ---< fish_i_main >---
// Gets the resref used to create sFish on a successful catch. If the value has
// not been defined for sFish, any globally defined value will be inherited.
string GetFishResRef(string sFish);
// ---< SetFishResRef >---
// ---< fish_i_main >---
// Sets the resref used to create every fish in sFishList on a successful catch.
// If sResRef is blank, any created fish will use the fish's ID as its resref.
// If sFishList is blank, the resref will be defined globally: any fish without
// an explicitly defined resref will use sResRef instead.
void SetFishResRef(string sResRef, string sFishList = "");
// ---< GetFishName >---
// ---< fish_i_main >---
// Gets the name applied to sFish on a successful catch. If the value has not
// been defined for sFish, any globally defined value will be inherited.
string GetFishName(string sFish);
// ---< SetFishName >---
// ---< fish_i_main >---
// Sets the name applied to every fish in sFishList on a successful catch. If
// sName is blank, any created fish will not have its name changed on creation.
// If sFishList is blank, the name will be defined globally: any fish without
// an explicitly defined name will use sName instead.
void SetFishName(string sName, string sFishList = "");
// ---< GetFishTag >---
// ---< fish_i_main >---
// Gets the tag applied to sFish on a successful catch. If the value has not
// been defined for sFish, any globally defined value will be inherited.
string GetFishTag(string sFish);
// ---< SetFishTag >---
// ---< fish_i_main >---
// Sets the tag applied to every fish in sFishList on a successful catch. If
// sTag is blank, any created fish will not have its tag changed on creation.
// If sFishList is blank, the tag will be defined globally: any fish without
// an explicitly defined tag will use sTag instead.
void SetFishTag(string sTag, string sFishList = "");
// ---< GetFishDescription >---
// ---< fish_i_main >---
// Gets the description applied to sFish on a successful catch. If the value has
// not been defined for sFish, any globally defined value will be inherited.
string GetFishDescription(string sFish);
// ---< SetFishName >---
// ---< fish_i_main >---
// Sets the name applied to every fish in sFishList on a successful catch. If
// sName is blank, any created fish will not have its name changed on creation.
// If sFishList is blank, the name will be defined globally: any fish without
// an explicitly defined name will use sName instead.
void SetFishDescription(string sDescription, string sFishList = "");
// ---< GetFishStackSize >---
// ---< fish_i_main >---
// Gets the stack size used to create sFish on a successful catch. If the value
// has not been defined for sFish, any globally defined value will be inherited.
int GetFishStackSize(string sFish);
// ---< SetFishStackSize >---
// ---< fish_i_main >---
// Sets the stack size used to create every fish in sFishList on a successful
// catch. If nStackSize is < 1, any created fish will use a stack size of 1. If
// sFishList is blank, the stack size will be defined globally: any fish without
// an explicitly defined stack size will use nStackSize instead.
void SetFishStackSize(int nStackSize, string sFishList = "");
// ---< SetFishModifier >---
// ---< fish_i_main >---
// Sets the modifier to catch every fish in sFishList when using any item in
// sModifierList. sType is a key to access the correct list of modifiers. The
// SetFish*Modifier() functions are wrappers for this function.
void SetFishModifier(string sType, int nValue, string sModifierList, string sFishList);
// ---< GetFishModifier >---
// ---< fish_i_main >---
// Gets the modifier to catch sFish when using sModifier. sType is a key to
// access the correct list of modifiers. The GetFish*Modifier() functions are
// wrappers for this function.
int GetFishModifier(string sType, string sModifier, string sFish);
// ---< SetFishEnvironmentModifier >---
// ---< fish_i_main >---
// Sets the environment modifier for every fish in sFishList to nValue for every
// environment in sEnvironmentList.
// Parameters:
// - nValue: a modifier to the percentage of the time a fish will be found in
// this environment.
// - sEnvironmentList: a comma-separated list of environments for the fish.
// - sFishList: a comma-separated list of the blueprints used to create the fish
// on a successful catch.
void SetFishEnvironmentModifier(int nValue, string sEnvironmentList, string sFishList);
// ---< GetFishEnvironmentModifier >---
// ---< fish_i_main >---
// Gets the frequency modifier to catch sFish when fishing in sEnvironment.
int GetFishEnvironmentModifier(string sEnvironment, string sFish);
// ---< SetFishEquipmentModifier >---
// ---< fish_i_main >---
// Sets the equipment modifier for every fish in sFishList to nValue for every
// equipment item in sEquipmentList.
// Parameters:
// - nValue: a modifier to the percentage of the time a fish will be caught when
// using this equipment.
// - sEquipmentList: a comma-separated list of equipment for the fish.
// - sFishList: a comma-separated list of the blueprints used to create the fish
// on a successful catch.
void SetFishEquipmentModifier(int nValue, string sEquipmentList, string sFishList);
// ---< GetFishEquipmentModifier >---
// ---< fish_i_main >---
// Gets the frequency modifier that sFish has when fishing with sEquipment.
int GetFishEquipmentModifier(string sEquipment, string sFish);
// ---< SetFishTackleSlotModifier >---
// ---< fish_i_main >---
// Sets a modifier for every fish in sFishList to nValue for every tackle slot
// in sSlotList. If the PC is using tackle that falls into any of these slots,
// the modifier will be applied.
// Parameters:
// - nValue: a modifier to the percentage of the time a fish will be caught when
// using tackle that fits this slot.
// - sSlotList: a comma-separated list of tackle slots.
// - sFishList: a comma-separated list of the blueprints used to create the fish
// on a successful catch.
void SetFishTackleSlotModifier(int nValue, string sSlotList, string sFishList);
// ---< GetFishTackleSlotModifier >---
// ---< fish_i_main >---
// Gets the frequency modifier to catch sFish when fishing with tackle matching
// sSlot.
int GetFishTackleSlotModifier(string sSlot, string sFish);
// ---< SetFishTackleModifier >---
// ---< fish_i_main >---
// Sets the tackle modifier for every fish in sFishList to nValue for every
// tackle item in sTackleList.
// Parameters:
// - nValue: a modifier to the percentage of the time a fish will be caught when
// using this tackle.
// - sTackleList: a comma-separated list of tackle items.
// - sFishList: a comma-separated list of the blueprints used to create the fish
// on a successful catch.
void SetFishTackleModifier(int nValue, string sTackleList, string sFishList);
// ---< GetFishTackleModifier >---
// ---< fish_i_main >---
// Gets the frequency modifier to catch sFish when fishing with sTackle.
int GetFishTackleModifier(string sTackle, string sFish);
// ---< WhitelistFish >---
// ---< fish_i_main >---
// Sets every fish in sFishList as being catchable only when fishing with a
// condition in sWhitelist. sType is a key to access the correct list of
// conditions. The WhitelistFish*() functions are wrappers for this function.
void WhitelistFish(string sType, string sWhitelist, string sFishList);
// ---< WhitelistFishEnvironment >---
// ---< fish_i_main >---
// Sets every fish in sFishList as being catchable only when fishing in an
// environment in sWhitelist. If a fishing spot has multiple environments, only
// one must be present for the fish to be able to be caught.
void WhitelistFishEnvironment(string sWhitelist, string sFishList);
// ---< WhitelistFishEquipment >---
// ---< fish_i_main >---
// Sets every fish in sFishList as being catchable only when fishing with
// equipment in sWhitelist.
void WhitelistFishEquipment(string sWhitelist, string sFishList);
// ---< WhitelistFishTackleSlot >---
// ---< fish_i_main >---
// Sets every fish in sFishList as being catchable only when fishing with tackle
// in all slots found in sWhitelist. The PC will not be penalized for not having
// tackle his equipment does not support; if you wish this to happen, limit the
// equipment the fish can be caught with using WhitelistFishEquipment(). If the
// PC's equipment supports multiple tackle slots found in this list, all of them
// must be filled to catch this fish.
void WhitelistFishTackleSlot(string sWhitelist, string sFishList);
// ---< WhitelistFishTackle >---
// ---< fish_i_main >---
// Sets every fish in sFishList as being catchable only when fishing with tackle
// found in sWhitelist. The PC will not be penalized for not having tackle his
// equipment does not support; if you wish this to happen, limit the equipment
// the fish can be caught with using WhitelistFishEquipment(). Any tackle slot
// which can be filled by a tackle item in this list must be so. If there is no
// tackle in this list that can fill a given slot, the PC may use any tackle in
// that slot to catch the fish.
void WhitelistFishTackle(string sWhitelist, string sFishList);
// ---< BlacklistFish >---
// ---< fish_i_main >---
// Sets every fish in sFishList as not being catchable when fishing with a
// condition in sBlacklist. sType is a key to access the correct list of
// conditions. The BlacklistFish*() functions are wrappers for this function.
void BlacklistFish(string sType, string sBlacklist, string sFishList);
// ---< BlacklistFishEnvironment >---
// ---< fish_i_main >---
// Sets every fish in sFishList as not being catchable only when fishing in an
// environment in sBlacklist. If a fishing spot has multiple environments, only
// one must be present for the fish to not be able to be caught.
void BlacklistFishEnvironment(string sBlacklist, string sFishList);
// ---< BlacklistFishEquipment >---
// ---< fish_i_main >---
// Sets every fish in sFishList as not being catchable when fishing with
// equipment in sBlacklist.
void BlacklistFishEquipment(string sBlacklist, string sFishList);
// ---< BlacklistFishTackleSlot >---
// ---< fish_i_main >---
// Sets every fish in sFishList as not being catchable when fishing with tackle
// in any slot found in sBlacklist. If the PC's equipment supports multiple
// tackle slots found in this list, all of them must be empty to catch this fish.
void BlacklistFishTackleSlot(string sBlacklist, string sFishList);
// ---< BlacklistFishTackle >---
// ---< fish_i_main >---
// Sets every fish in sFishList as not being catchable when fishing with tackle
// found in sBlacklist.
void BlacklistFishTackle(string sBlacklist, string sFishList);
// ---< GetFishWhitelist >---
// ---< fish_i_main >---
// Returns the whitelist for sFish. sType is a key to access the correct list.
string GetFishWhitelist(string sType, string sFish);
// ---< HasFishWhitelist >---
// ---< fish_i_main >---
// Returns whether a whitelist exists for sFish of type sType. sType is a key to
// access the correct list of conditions.
int HasFishWhitelist(string sType, string sFish);
// ---< InFishWhitelist >---
// ---< fish_i_main >---
// Returns whether sFish's whitelist of type sType contains sItem. sType is a
// key to access the correct list of conditions.
int InFishWhitelist(string sType, string sItem, string sFish);
// ---< GetFishBlacklist >---
// ---< fish_i_main >---
// Returns the blacklist for sFish. sType is a key to access the correct list.
string GetFishBlacklist(string sType, string sFish);
// ---< HasFishBlacklist >---
// ---< fish_i_main >---
// Returns whether a blacklist exists for sFish of type sType. sType is a key to
// access the correct list of conditions.
int HasFishBlacklist(string sType, string sFish);
// ---< InFishBlacklist >---
// ---< fish_i_main >---
// Returns whether sFish's blacklist of type sType contains sItem. sType is a
// key to access the correct list of conditions.
int InFishBlacklist(string sType, string sItem, string sFish);
// ----- Fishing Message Functions ---------------------------------------------
// ---< AddFishMessage >---
// ---< fish_i_main >---
// Adds to a list of messages that may be displayed to the player during nEvent.
// Parameters:
// - nEvent: a FISH_EVENT_* constant matching when the message will be sent. You
// can also use your own event numbers, as long as they are > 10.
// - sKeyList: a comma-separated list of keys to identify the proper message to
// send. If sKeyList is blank, the message will be defined globally.
// - sKey: a key to identify the proper message to return.
// - For the START, NO_NIBBLE, and BAD_SPOT events, the key should be an
// equipment type.
// - For the NIBBLE, CATCH, and NO_CATCH events, the key should be an
// equipment type or a fish.
// - The NO_TACKLE, USE_TACKLE, or BAD_TARGET events may be either an
// equipment type or a tackle slot.
// - Other events are up to the builder to implement. Key them as you wish.
// - If blank, will return a globally defined message for this event.
// - Keys will inherit globally defined messages, even if the key has
// explicitly defined messages.
// - sMessage: the message to display to the PC.
// Example usage:
// AddFishMessage(FISH_EVENT_START, "pole", "You cast your line. Now to wait.");
// AddFishMessage(FISH_EVENT_START, "pole", "What a cast!");
// AddFishMessage(FISH_EVENT_START, "spear, net", "You wait, eyes intent on the water.");
// AddFishMessage(FISH_EVENT_CATCH, "", "You caught a fish!");
void AddFishMessage(int nEvent, string sKeyList, string sMessage);
// ---< GetFishMessage >---
// ---< fish_i_main >---
// Returns a random message to be displayed to the player during nEvent. You can
// add messages to display using AddFishMessage().
// Parameters:
// - nEvent: a FISH_EVENT_* constant matching when the message will be sent. You
// can also use your own event numbers, as long as they are > 10.
// - sKey: a key to identify the proper message to return.
// - For the START, NO_NIBBLE, and BAD_SPOT events, the key should be an
// equipment type.
// - For the NIBBLE, CATCH, and NO_CATCH events, the key should be an
// equipment type or a fish.
// - The NO_TACKLE, USE_TACKLE, or BAD_TARGET events may be either an
// equipment type or a tackle slot.
// - Other events are up to the builder to implement. Key them as you wish.
// - If blank, will return a globally defined message for this event.
// - Keys will inherit globally defined messages, even if the key has
// explicitly defined messages.
// Example usage:
// GetFishMessage(FISH_EVENT_START, "pole");
string GetFishMessage(int nEvent, string sKey = "");
// ---< FloatingFishMessage >---
// ---< fish_i_main >---
// Causes a random message to be displayed to the player during nEvent. You can
// add messages to display using AddFishMessage(). If you wish to add the
// message into the action queue so it is displayed at the proper time, use
// ActionFloatingFishMessage() instead.
// Parameters:
// - nEvent: a FISH_EVENT_* constant matching when the message will be sent. You
// can also use your own event numbers, as long as they are > 10.
// - sKey: a key to identify the proper message to return.
// - For the START, NO_NIBBLE, and BAD_SPOT events, the key should be an
// equipment type.
// - For the NIBBLE, CATCH, and NO_CATCH events, the key should be an
// equipment type or a fish.
// - The NO_TACKLE, USE_TACKLE, or BAD_TARGET events may be either an
// equipment type or a tackle slot.
// - Other events are up to the builder to implement. Key them as you wish.
// - If blank, will return a globally defined message for this event.
// - Keys will inherit globally defined messages, even if the key has
// explicitly defined messages.
// Example usage:
// FloatingFishMessage(FISH_EVENT_START, "pole");
void FloatingFishMessage(int nEvent, string sKey = "");
// ----- Public Accessor Functions ---------------------------------------------
// ---< GetFishingSpot >---
// ---< fish_i_main >---
// Returns the fishing spot object where the PC is currently fishing.
object GetFishingSpot();
// ---< GetFishingEnvironment >---
// ---< fish_i_main >---
// Returns the environment of the given fishing spot. If oSpot is invalid,
// returns the environment of the spot the PC is currently fishing in.
string GetFishingEnvironment(object oSpot = OBJECT_INVALID);
// ---< GetFishingEquipment >---
// ---< fish_i_main >---
// Returns the fishing equipment the PC is currently using to fish.
object GetFishingEquipment();
// ---< GetFishingEquipmentType >---
// ---< fish_i_main >---
// Returns the type of the given fishing equipment. If oEquipment is invalid,
// will return the type of equipment the PC is currently using to fish. You can
// create your own types of fishing equipment: simply give your item a "Cast
// Spell: OnActivate (Self Only)" item property with unlimited uses and set its
// tag to "fish_t_equipment_X", where X is the type of equipment your item is.
// That value should then be compared with the return value of this function to
// see whether that type of equipment is being used.
string GetFishingEquipmentType(object oEquipment = OBJECT_INVALID);
// ---< RemoveFishingTackle >---
// ---< fish_i_main >---
// Removes the tackle occupying sSlot from oEquipment, replacing it in the PC's
// inventory if bReplace is TRUE. If oEquipment is invalid, will search the PC's
// currently equipped fishing item.
object RemoveFishingTackle(string sSlot, int bReplace, object oEquipment = OBJECT_INVALID);
// ----- Action Wrappers -------------------------------------------------------
// ---< ActionFloatingTextString >---
// ---< fish_i_main >---
// Inserts FloatingTextStringOnCreature() into OBJECT_SELF's action queue. Will
// not broadcast sMessage to the PC's faction. You can use this to provide
// flavor text to your PCs.
void ActionFloatingTextString(string sMessage);
// ---< ActionFloatingFishMessage >---
// ---< fish_i_main >---
// Inserts FloatingFishMessage() into OBJECT_SELF's action queue. Will not
// broadcast sMessage to the PC's faction. You can use this to provide context-
// specific flavor text to your PCs.
void ActionFloatingFishMessage(int nEvent, string sKey = "");
// ---< ActionRemoveFishingTackle >---
// ---< fish_i_main >---
// Removes sTackle from the PC's fishing equipment, replacing it into the PC's
// inventory if bReplace is TRUE. This is inserted into the action queue so the
// PC can retain his tackle if he aborts the fishing sequence.
void ActionRemoveFishingTackle(string sTackle, int bReplace);
// ---< ActionCreateFish >---
// ---< fish_i_main >---
// Creates sFish on the PC. Plays the FISH_EVENT_CATCH message for sFish. This
// is inserted into the action queue so the PC will not catch the fish if he
// aborts the fishing sequence.
void ActionCreateFish(string sFish);
// ---< ObjectToAction >---
// ---< fish_i_main >---
// Convert oObject into a void. Use this to pass an object-returning function as
// a parameter to an ActionDoCommand() function.
void ObjectToAction(object oObject);
// ----- Config Functions ------------------------------------------------------
// These functions are defined in fish_c_config, but we declare them here so we
// can use them in our internal functions.
// ---< OnFishingSetup >---
// ---< fish_c_config >---
// This is a configurable function you can use to alter the fish, environments,
// and baits used in your module. All of the following code will run the first
// time a fishing pole is used in your module.
void OnFishingSetup();
// ---< OnFishingTackleUsed >---
// ---< fish_c_config >---
// This is a configurable function that runs when the PC uses a fishing tackle
// item and has fishing equipment equipped. Returns whether the tackle should be
// added to the equipped item. Example uses include removing the tackle from the
// player's inventory when used, giving back tackle already applied to the same
// slot, or requiring a hook type of tackle to be applied before allowing a bait
// type of tackle.
//
// You can add tackle to a fish's list using AddFishTackle() in the
// OnFishingSetup() config function below. This function takes a comma-separated
// list of fish and and tackle, making it easy to add many tackle types to many
// fish. The function also allows you to add a modifier to the chances a fish
// will bite when the PC is using that tackle. This allows fish to prefer
// different tackle.
//
// Parameters:
// - oEquipment: the PC's currently equipped fishing equipment
// - oTackle: the tackle item being used
// - sSlot: the slot the tackle is being applied to
// Returns: whether to apply the tackle to the equipment.
int OnFishingTackleUsed(object oEquipment, object oTackle, string sSlot);
// ---< OnFishingStart >---
// ---< fish_c_config >---
// This is a configurable function that runs when the PC uses fishing equipment.
// Returns whether the PC is able to fish. Example uses include setting a max
// distance to the fishing spot based on his equipment, providing flavor text
// about the cast, adding additional restrictions for fishing, or setting a time
// limit between fish bites.
// - OBJECT_SELF: the PC fishing
int OnFishingStart();
// ---< OnFishRequirements >---
// ---< fish_c_config >---
// This is a configurable function that allows you to prevent a fish from
// performing a nibble check. Use this when there are instances that will always
// bar a fish from biting. Example uses include making some fish only active at
// night, during rain, or with certain tackle combinations. For simple
// environment, equipment, or tackle restrictions, consider using the
// WhitelistFish*() and BlacklistFish*() functions in OnFishingSetup() instead.
// - OBJECT_SELF: the PC attempting to catch the fish.
// - sFish: the resref of the fish whose bite we're testing.
// Returns: whether or not the fish may attempt to nibble (TRUE/FALSE).
int OnFishRequirements(string sFish);
// ---< OnFishNibble >---
// ---< fish_c_config >---
// This is a configurable function that allows you to modify the chances a type
// of fish will bite. Example uses include giving fish preferences for different
// types of bait, making fish more or less likely to bite at different times of
// day or month, or keeping a type of fish from biting if it's been "fished out"
// of the spot.
// - OBJECT_SELF: the PC attempting to catch the fish.
// - sFish: the resref of the fish whose chances to bite we're testing.
// Returns: an amount to add to the chance the fish will bite.
int OnFishNibble(string sFish);
// ---< OnFishNibbleFail >---
// ---< fish_c_config >---
// This is a configurable function to handle what happens when the PC fails to
// get a fish to nibble on the line. Example uses include notifying the PC of
// his failure, adding a chance of losing his bait, or having him catch seaweed
// or an old boot instead.
// - OBJECT_SELF: the PC who failed to catch a fish.
// Returns: whether to display the failure animation and message.
int OnFishNibbleFail();
// ---< OnFishNibbleSuccess >---
// ---< fish_c_config >---
// This is a configurable function to handle what happens when a PC gets a fish
// on the line. Returns whether the PC is successful at catching the fish.
// Example uses include giving flavor text about the fish, requiring an ability
// check to catch it, or setting the fishing spot as unavailable for a time.
// - OBJECT_SELF: the PC fishing.
// - sFish: the resref of the fish the PC has on the line.
int OnFishNibbleSuccess(string sFish);
// ---< OnFishCatch >---
// ---< fish_c_config >---
// This is a configurable function to intercept the actual creation of the fish.
// Returns whether the system should create the fish. Example uses include
// removing the PC's bait, copying a fish from a container rather than creating
// one from a blueprint (to save on palette items), increasing a persistently
// stored fishing skill, or even just giving the player some XP.
int OnFishCatch(string sFish);
// ---< PlayFishingAnimation >---
// ---< fish_c_config >---
// This is a configurable function to handle the animations for different stages
// of the fishing. Returns whether or not to play the default animation.
// - nEvent: the fishing event which is currently playing
// - FISH_EVENT_START: plays when fishing begins (after OnFishingStart())
// - FISH_EVENT_NIBBLE: plays when a fish has passed the nibble check
// - FISH_EVENT_CATCH: plays when a PC successfully catches a fish
// - FISH_EVENT_NO_CATCH: plays when a fish nibbled but was not caught
// - FISH_EVENT_NO_NIBBLE: plays when no fish nibbled at all
int PlayFishingAnimation(int nEvent);
// ----- System Functions ------------------------------------------------------
// These functions should only be used by the internal system.
// ---< InitializeFishingSystem >---
// ---< fish_i_main >---
// Runs the config function OnFishingSetup() if it has not been run yet.
// Note: This is an internal function and should not be used by the builder.
void InitializeFishingSystem(object oPC, object oItem);
// ---< HandleFishingTackle >---
// ---< fish_i_main >---
// If the item the PC is currently using is a tackle item, checks to see if the
// item can be used on oTarget (if oTarget is invalid, checks the PC's currently
// equipped item). If so, it applies the tackle. Sends a FISH_EVENT_USE_TACKLE
// or FISH_EVENT_BAD_TARGET message to the PC as appropriate. Returns TRUE if
// the item was tackle.
// Note: This is an internal function and should not be used by the builder.
int HandleFishingTackle(object oTarget);
// ---< VerifyFishingTackle >---
// ---< fish_i_main >---
// Returns whether the PC is using all the required tackle for his equipment. If
// a required slot does not have tackle in it, will send a FISH_EVENT_NO_TACKLE
// message for the equipment type and the tackle slot to the PC.
// Note: This is an internal function and should not be used by the builder.
int VerifyFishingTackle();
// ---< VerifyFishingSpot >---
// ---< fish_i_main >---
// Returns whether the nearest fishing spot is near enough to the PC. Will also
// return TRUE if the PC is inside a fishing spot trigger. The maximum distance
// depends on the value set by SetFishingDistance() (either for the equipment in
// use or globally. If a fishing spot near enough to the PC is not found, will
// send a FISH_EVENT_NO_SPOT message to the PC.
// Note: This is an internal function and should not be used by the builder.
int VerifyFishingSpot();
// ---< ActionFishEvent >---
// ---< fish_i_main >---
// Sends the appropiate message to the PC based on his equipment type, then runs
// the config function PlayFishingAnimation() for the appropriate event.
// Note: This is an internal function and should not be used by the builder.
void ActionFishEvent(int nEvent);
// ---< ActionFish >---
// ---< fish_i_main >---
// Does the actual fishing. This function runs OnActivate when oEquipment is
// used. We place it into a separate function so we can AssignCommand() it to
// the PC and refer to him as OBJECT_SELF.
// Note: This is an internal function and should not be used by the builder.
void ActionFish();
// -----------------------------------------------------------------------------
// Function Implementations
// -----------------------------------------------------------------------------
// ----- Variable Accessor Functions -------------------------------------------
float GetFishFloat(string sVarName, string sKey = "")
{
if (sKey == "" || !GetLocalInt(Fish.Data, "F: " + sKey + sVarName))
return GetLocalFloat(Fish.Data, sVarName);
return GetLocalFloat(Fish.Data, sKey + sVarName);
}
int GetFishInt(string sVarName, string sKey = "")
{
if (sKey == "" || !GetLocalInt(Fish.Data, "I: " + sKey + sVarName))
return GetLocalInt(Fish.Data, sVarName);
return GetLocalInt(Fish.Data, sKey + sVarName);
}
string GetFishString(string sVarName, string sKey = "")
{
if (sKey == "" || !GetLocalInt(Fish.Data, "S: " + sKey + sVarName))
return GetLocalString(Fish.Data, sVarName);
return GetLocalString(Fish.Data, sKey + sVarName);
}
void SetFishFloat(string sVarName, float fValue, string sList = "")
{
string sKey;
int i, nCount = CountList(sList);
for (i = 0; i < nCount; i++)
{
sKey = GetListItem(sList, i);
SetLocalFloat(Fish.Data, sKey + sVarName, fValue);
SetLocalInt(Fish.Data, "F: " + sKey + sVarName, TRUE);
}
// If no key is provided, set the value globally.
if (!nCount)
SetLocalFloat(Fish.Data, sVarName, fValue);
}
void SetFishInt(string sVarName, int nValue, string sList = "")
{
string sKey;
int i, nCount = CountList(sList);
for (i = 0; i < nCount; i++)
{
sKey = GetListItem(sList, i);
SetLocalInt(Fish.Data, sKey + sVarName, nValue);
SetLocalInt(Fish.Data, "I: " + sKey + sVarName, TRUE);
}
// If no key is provided, set the value globally.
if (!nCount)
SetLocalInt(Fish.Data, sVarName, nValue);
}
void SetFishString(string sVarName, string sValue, string sList = "")
{
string sKey;
int i, nCount = CountList(sList);
for (i = 0; i < nCount; i++)
{
sKey = GetListItem(sList, i);
SetLocalString(Fish.Data, sKey + sVarName, sValue);
SetLocalInt(Fish.Data, "S: " + sKey + sVarName, TRUE);
}
// If no key is provided, set the value globally.
if (!nCount)
SetLocalString(Fish.Data, sVarName, sValue);
}
// ----- Debug Functions -------------------------------------------------------
void SetFishingDebugMode(int bDebug, object oTarget = OBJECT_INVALID)
{
if (!GetIsObjectValid(oTarget))
{
if (GetIsObjectValid(Fish.Data))
oTarget = Fish.Data;
else
{
// If Fish.Data is not set, we are being called from outside the
// fishing system. Get the fishing data point. If it doesn't exist,
// then the fishing system has not been set up and this will have no
// effect.
oTarget = GetWaypointByTag(FISH_WP_DATA);
if (!GetIsObjectValid(oTarget))
return;
}
}
SetLocalInt(oTarget, FISH_DEBUG, bDebug);
Fish.Debug = bDebug;
}