forked from jzy-chitong56/AMAI-CN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlizzard.eai
2397 lines (2194 loc) · 83.6 KB
/
Blizzard.eai
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
#INCLUDE <$VER$\tmp\Blizzard1.j>
//-----------------------------------------------------------------------
// Commander globals
//-----------------------------------------------------------------------
// default values
string language = "Chinese" // Possible values: "" (dialog), "English", "Deutsch", "Swedish", "French", "Spanish", "Romanian", "Russian", "Portuguese", "Norwegian", "Chinese"
string game_mode = "" // Possible values: "" (dialog), "commander", "no_human", "ai_only", "shared"
string backlanguage = "Chinese"
integer array command_number
integer array command_par1
integer array command_par2
integer array command_par3
string array command_key1
string array command_key2
string array command_key3
string array command_text1
string array command_text2
string array command_text3
string array command_text4
string array command_dlg1
integer array command_hotkey1
string array command_dlg2
integer array command_hotkey2
string array command_dlg3
integer array command_hotkey3
string array command_msg
integer command_length = 0
string array parsed_command
string command_prefix = "-cmd"
string array switch_state
string switch_on = " |cff00ff00[on]|r"
string switch_off = " |cffff0000[off]|r"
#INCLUDETABLE <Commands.txt> #EFR #COND "%12" eq "arr_on" or "%12" eq "arr_off"
string array current_%4_switch
#ENDINCLUDE
button array cdlg_button
integer array cdlg_number
dialog array cdlg_dialog
integer cdlg_length = 0
dialog number_dialog = null
dialog last_number_dialog = null
dialog player_dialog = null
dialog last_player_dialog = null
dialog start_dialog = null
dialog root_dialog = null
dialog clanguage_dialog = null
dialog tribute_type_dlg = null
integer array current_command
integer array current_player_par
integer array current_number_par
player array commanded_player
#INCLUDETABLE <$VER$\Races.txt>
string array %1_StrategyName
integer %1_strategyNum = 0
#ENDINCLUDE
button strategyBtn = null
boolean strategyDialog = false
string array tribute_type
button tribute_g = null
button tribute_l = null
button tribute_give_g = null
button tribute_give_l = null
dialog tribute_dlg = null
button array tribute_dlg_button
integer tribute_dlg_length = 0
button array sdbn_button
integer array sdbn_number
integer sdbn_length = 0
integer sdbn_paged_length = 0
button array pcbn_button
integer array pcbn_number
integer pcbn_length = 0
integer pcbn_paged_length = 0
button array ndbn_button
button next_button = null
button previous_button = null
button all_button = null
button clanguage_button = null
integer ndbn_length = 0
integer ndbn_paged_length = 0
dialog array dlg_dialog
string array dlg_string
integer dlg_length = 0
trigger ZoomSetx = null
trigger AdjustZoomUp = null
trigger AdjustZoomDown = null
boolean array ZoomKey
real array current_zoom
dialog game_start_dialog = null
trigger game_start_trigger = null
button commander_mode = null
button no_human_mode = null
button shared_mode = null
button ai_only_mode = null
dialog language_dialog = null
trigger language_trigger = null
#INCLUDETABLE <Languages.txt> #EFR
button %1_button = null
#ENDINCLUDE
#DEFINE GLOBAL
#INCLUDESCRIPT <Blizzard_UIFrame.eai>
#UNDEF GLOBAL
trigger W3CDeny = CreateTrigger()
trigger W3CDenyControl = CreateTrigger()
boolean W3CWorkerCount = true
unit array W3CMines
group array W3CWorkerMine
texttag array W3CWorkTextTag
integer array W3CWorkers
integer W3CMind_Length = 0
integer KK_TP_num = 0
effect array KK_TPEffect
trigger KK_TP = null
timer array KK_TPTimer
string chat_no_ally = ""
string you_no_gold = ""
string i_no_gold = ""
string tribute_of_gold = ""
string gold_received_thanks = ""
string you_no_lumber = ""
string i_no_lumber = ""
string tribute_of_lumber = ""
string lumber_received_thanks = ""
string you_mistyped_tribute = ""
string specified_player_not_valid = ""
string command_not_valid = ""
string all_not_allowed = ""
string player_id_mistyped = ""
string color_word_mistyped = ""
string not_specified_computer = ""
string dlgbutton_next_page = ""
string dlgbutton_previous_page = ""
string dlghdr_choose_ally = ""
string dlghdr_choose_number = ""
string dlghdr_choose_player = ""
string dlghdr_game_type = ""
string dlghdr_root = ""
string dlghdr_tribute_type = ""
string dlghdr_tribute_amount = ""
string dlgbutton_cancel = ""
string dlgbutton_all = ""
string dlgbutton_gold = ""
string dlgbutton_lumber = ""
string dlgbutton_give_gold = "Give Gold"
string dlgbutton_give_lumber = "Give Lumber"
string dlgbutton_tribute = ""
string dlgbutton_commander = ""
string dlgbutton_commander_language = ""
string dlgbutton_player_ally = ""
string dlgbutton_no_human = ""
string dlgbutton_shared = ""
string dlgbutton_ai_only = ""
boolean debugging = false
string dglchoose_language = "Choose Language"
leaderboard color_board = null
//gamecache translation = InitGameCache("Commander.w3v")
hashtable translation = InitHashtable()
timer last_timer = null
trigger last_player_trigger = null
triggeraction last_player_trigger_action = null
trigger last_number_trigger = null
triggeraction last_number_trigger_action = null
trigger last_dialog_trigger = null
triggeraction last_dialog_trigger_action = null
trigger last_main_trigger = null
trigger array dlg_trigger
trigger array last_tribute_trigger
#DEFINE GLOBAL
#INCLUDESCRIPT <custom_common.eai>
#UNDEF GLOBAL
#INCLUDE <$VER$\tmp\Blizzard2.j>
#INCLUDESCRIPT <custom_common.eai>
#INCLUDE <$VER$\tmp\Blizzard3Gen.j>
#INCLUDE <$VER$\tmp\Blizzard4.j>
function DestroyLastTrigger takes trigger t, triggeraction ta returns nothing
if (ta != null and t != null) then
call TriggerRemoveAction(t, ta)
endif
if (t != null) then
call TriggerClearActions(t)
call DestroyTrigger(t)
endif
endfunction
//***************************************************************************
//*
//* Commander
//*
//***************************************************************************
//===========================================================================
// The Parser (Takes a String, Seperates words, puts in string array)
//===========================================================================
function Parser takes string ChatMsg returns nothing
//Required Variables
local integer Last = 0
local integer A = 1
local integer I = 0
local integer Length = StringLength(ChatMsg)
//Pulls Words and places them each in their own Variable
loop
if (SubStringBJ(ChatMsg,A,A) == " ") then
set parsed_command[I] = StringCase(SubStringBJ(ChatMsg, (Last + 1), (A - 1)), true)
set Last = A
set I = I + 1
elseif (SubStringBJ(ChatMsg,A,A) == ":") then
if (SubStringBJ(ChatMsg,A+1,A+1) == " ") then
set A = A + 1 // space after the : so include in separator
endif
set parsed_command[I] = StringCase(SubStringBJ(ChatMsg, (Last + 1), (A - 1)), true)
set Last = A
set I = I + 1
elseif (A == Length) then
set parsed_command[I] = StringCase(SubStringBJ(ChatMsg, (Last + 1), A), true)
set I = I + 1
endif
set A = A + 1
exitwhen(A>Length)
endloop
loop
exitwhen I > 6
set parsed_command[I] = ""
set I = I + 1
endloop
endfunction
//===========================================================================
// ColorPlayer (Converts from text version of a color to a playercolor)
//===========================================================================
function ColorPlayer takes string CompC returns playercolor
//Finds player color of the text color
if (CompC == "Red") then
return PLAYER_COLOR_RED
elseif (CompC == "Blue") then
return PLAYER_COLOR_BLUE
elseif (CompC == "Cyan") then
return PLAYER_COLOR_CYAN
elseif (CompC == "Purple") then
return PLAYER_COLOR_PURPLE
elseif (CompC == "Yellow") then
return PLAYER_COLOR_YELLOW
elseif (CompC == "Orange") then
return PLAYER_COLOR_ORANGE
elseif (CompC == "Green") then
return PLAYER_COLOR_GREEN
elseif (CompC == "Pink") then
return PLAYER_COLOR_PINK
elseif (CompC == "Light Gray") then
return PLAYER_COLOR_LIGHT_GRAY
elseif (CompC == "Light Blue") then
return PLAYER_COLOR_LIGHT_BLUE
elseif (CompC == "Aqua") then
return PLAYER_COLOR_AQUA
elseif (CompC == "Brown") then
return PLAYER_COLOR_BROWN
elseif (CompC == "MAROON") then
return PLAYER_COLOR_MAROON
elseif (CompC == "Navy") then
return PLAYER_COLOR_NAVY
elseif (CompC == "Turquoise") then
return PLAYER_COLOR_TURQUOISE
elseif (CompC == "Violet") then
return PLAYER_COLOR_VIOLET
elseif (CompC == "Wheat") then
return PLAYER_COLOR_WHEAT
elseif (CompC == "Peach") then
return PLAYER_COLOR_PEACH
elseif (CompC == "Mint") then
return PLAYER_COLOR_MINT
elseif (CompC == "Lavender") then
return PLAYER_COLOR_LAVENDER
elseif (CompC == "Coal") then
return PLAYER_COLOR_COAL
elseif (CompC == "Snow") then
return PLAYER_COLOR_SNOW
elseif (CompC == "Emerald") then
return PLAYER_COLOR_EMERALD
elseif (CompC == "Peanut") then
return PLAYER_COLOR_PEANUT
else
return null
endif
endfunction
#INCLUDE <playercolors.j>
function c2s takes player p returns string
return cs2s(GetPlayerName(p), GetPlayerColor(p)) + ": "
endfunction
function DisplayToTP takes string msg returns nothing
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 5, msg )
endfunction
function TraceToTP takes string msg returns nothing
if debugging then
call DisplayToTP(msg)
endif
endfunction
function DisplayToPlayer takes player p, string msg returns nothing
call DisplayTimedTextToPlayer(p, 0, 0, 5, msg )
endfunction
function DisplayToAll takes string msg returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 7, msg )
endfunction
function TraceToAll takes string msg returns nothing
if debugging then
call DisplayToAll(msg)
endif
endfunction
function DisplayFromPlayer takes player p, string msg returns nothing
call DisplayToTP(c2s(p) + msg)
endfunction
function DisplayFromToPlayer takes player sp, player rp, string msg returns nothing
call DisplayToPlayer(rp, c2s(sp) + msg)
endfunction
function DisplayFromDlg takes string msg returns nothing
if msg == "" or commanded_player[GetPlayerId(GetTriggerPlayer())] == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
return
endif
if GetTriggerPlayer() != null then
if commanded_player[GetPlayerId(GetTriggerPlayer())] != null then
call DisplayFromToPlayer(commanded_player[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer(), msg)
else
call DisplayToPlayer(commanded_player[GetPlayerId(GetTriggerPlayer())], msg)
endif
else
call DisplayToAll(msg)
endif
endfunction
//===========================================================================
// Sync integer
//===========================================================================
function SyncInteger takes player sync_p, integer unsynced returns integer
local integer array source_int // the bits of the unsynced integer are stored in there
local integer array target_int // the bits of the synced integer are stored in there
local unit array sel_unit // the units used for the selection
local integer i = 1
local integer j = 0
local integer sum = unsynced
local group old_selection = null
local unit u = null
local integer bits_per_selection = 8 // that many bits are sent per selection
local integer selection_num = 2 // that many times a selection is done
local integer bits_number = selection_num * bits_per_selection // number of bits of integer used
local timer t = null
local location l = null
// call DisplayToPlayer(sync_p, I2S(sum))
if bj_isSinglePlayer then
return unsynced
endif
set old_selection = CreateGroup()
set t = CreateTimer()
// separate integer in bits
if sum < 0 then
set source_int[0] = 1
set sum = -sum
else
set source_int[0] = 0
endif
loop
exitwhen i >= bits_number
set source_int[i] = ModuloInteger(sum, 2)
set sum = sum / 2
set i = i + 1
endloop
// create units to select
set i = 0
set l = GetPlayerStartLocationLoc(sync_p)
loop
exitwhen i >= bits_per_selection
set sel_unit[i] = CreateUnitAtLoc( sync_p, 'nshf', l, bj_UNIT_FACING )
set i = i + 1
endloop
call RemoveLocation(l)
set l = null
// save old selection
call SyncSelections()
call GroupEnumUnitsSelected(old_selection, sync_p, null)
// send the bits by selection
set i = 0
loop
exitwhen i >= selection_num
// write information
if GetLocalPlayer() == sync_p then
set j = 0
call ClearSelection()
loop
exitwhen j >= bits_per_selection
if source_int[i*bits_per_selection + j] == 0 then
call SelectUnit(sel_unit[j], false)
else
call SelectUnit(sel_unit[j], true)
endif
set j = j + 1
endloop
endif
// read information
call TimerStart(t, 1, false, null) // prevent wait bug
loop
exitwhen TimerGetRemaining(t) <= 0
call TriggerSleepAction(0.5)
endloop
call DestroyTimer(t)
set t = null
call SyncSelections()
set j = 0
loop
exitwhen j >= bits_per_selection
if IsUnitSelected(sel_unit[j], sync_p) then
set target_int[i*bits_per_selection + j] = 1
else
set target_int[i*bits_per_selection + j] = 0
endif
set j = j + 1
endloop
set i = i + 1
endloop
// restore selection
if GetLocalPlayer() == sync_p then
call ClearSelection()
loop
set u = FirstOfGroup(old_selection)
exitwhen u == null
call SelectUnit(u, true)
call GroupRemoveUnit(old_selection, u)
endloop
endif
call SyncSelections()
// remove units to select
set i = 0
loop
exitwhen i >= bits_per_selection
call RemoveUnit(sel_unit[i])
set sel_unit[i] = null
set i = i + 1
endloop
// rebuild integer
set i = bits_number - 1
set sum = 0
loop
exitwhen i < 1
set sum = 2 * sum + target_int[i]
set i = i - 1
endloop
if target_int[0] != 0 then
set sum = -sum
endif
call DestroyGroup(old_selection)
set old_selection = null
set u = null
// call DisplayToPlayer(sync_p, I2S(sum))
return sum
endfunction
//===========================================================================
// Convert2Player (Converts either text color or id to player)
//===========================================================================
function Convert2Player takes string Comp, boolean all_allowed returns player
//Required Variables
local integer j = 0
local playercolor CColor = ColorPlayer(Comp) //Gets the player color
local player theplayer = null
if Comp == "All" then
if all_allowed then
set theplayer = Player(PLAYER_NEUTRAL_AGGRESSIVE)
else
call DisplayToTP(all_not_allowed)
endif
elseif (CColor == null) then
//Makes Sure color was typed Correctly
//Makes sure number is 0 or bigger and 23 or smaller
if (S2I(Comp) >= 0) and (S2I(Comp) < GetBJMaxPlayers()) then
set theplayer = Player(S2I(Comp))
else
call DisplayToTP(player_id_mistyped)
endif
else
//Compares the color until we get a match then stores that player
loop
exitwhen((CColor == GetPlayerColor(Player(j))) or (j > GetBJMaxPlayers()))
set j = j + 1
if (j > GetBJMaxPlayers()) then
call DisplayToTP(color_word_mistyped)
endif
endloop
if j <= GetBJMaxPlayers() then
set theplayer = Player(j)
endif
endif
set CColor = null
//Returns player
return theplayer
endfunction
//===========================================================================
// Colorboard Function (Displays all the Colors on screen)
//===========================================================================
//Required by GetPlayersMatching to select a players playing
function GetPlayersMatchingCode takes nothing returns boolean
return ( GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING )
endfunction
//Required by ForForce to add a player name for each player
function ForForceCode takes nothing returns nothing
call LeaderboardAddItemBJ(GetEnumPlayer(), color_board, GetPlayerName(GetEnumPlayer()), 0 )
call LeaderboardSetPlayerItemLabelBJ(GetEnumPlayer(), color_board, ColorText(GetEnumPlayer()))
call LeaderboardSetPlayerItemValueBJ(GetEnumPlayer(), color_board, GetPlayerId(GetEnumPlayer()))
endfunction
//The Main function for Showing the Colorboard
function CreateBoard takes nothing returns nothing
//Required Variables
local integer j = 0
//Creates Colorboard
set color_board =CreateLeaderboardBJ( GetPlayersAll(), "Colorboard" ) //Creates board
//Adds all player to Colorboard
call ForForce( GetPlayersMatching(Condition(function GetPlayersMatchingCode)), function ForForceCode )
//Displays the Colorboard
call LeaderboardDisplay(color_board, false)
endfunction
function ShowBoard takes nothing returns nothing
call LeaderboardDisplay(color_board, not IsLeaderboardDisplayed(color_board))
endfunction
//===========================================================================
// W3C Worker count
//===========================================================================
function updateMineText takes integer i returns nothing
if W3CWorkTextTag[i] != null then
call SetTextTagTextBJ(W3CWorkTextTag[i], I2S(W3CWorkers[i]) + "/5", 13)
call SetTextTagPos(W3CWorkTextTag[i], GetUnitX(W3CMines[i]) - 30, GetUnitY(W3CMines[i]) - 140, 0)
if W3CWorkers[i] == 5 then
call SetTextTagColorBJ(W3CWorkTextTag[i], 0, 100, 0, 100)
elseif W3CWorkers[i] > 5 then
call SetTextTagColorBJ(W3CWorkTextTag[i], 100, 0, 0, 100)
else
call SetTextTagColorBJ(W3CWorkTextTag[i], 100, 100, 30, 100)
endif
call SetTextTagVisibility(W3CWorkTextTag[i], W3CWorkerCount and W3CWorkers[i] > 0 and (IsPlayerObserver(GetLocalPlayer()) or not IsPlayerEnemy(GetTriggerPlayer(), GetLocalPlayer())))
endif
endfunction
function addMineExist takes unit u returns integer
set W3CWorkerMine[W3CMind_Length] = CreateGroup()
set W3CMines[W3CMind_Length] = u
set W3CWorkers[W3CMind_Length] = 0
set W3CWorkTextTag[W3CMind_Length] = CreateTextTag()
set W3CMind_Length = W3CMind_Length + 1
return W3CMind_Length - 1
endfunction
function isMineExist takes unit u returns integer
local integer i = 0
loop
exitwhen i >= W3CMind_Length
if u == W3CMines[i] then
return i
endif
set i = i + 1
endloop
return -1
endfunction
function removeWorkerFromMine takes unit u returns nothing
local integer i = 0
loop
exitwhen i >= W3CMind_Length
if W3CWorkerMine[i] != null and IsUnitInGroup(u, W3CWorkerMine[i]) then
call GroupRemoveUnit(W3CWorkerMine[i], u)
set W3CWorkers[i] = W3CWorkers[i] - 1
call updateMineText(i)
endif
set i = i + 1
endloop
endfunction
function unitIsWorker takes unit u, integer i returns boolean
return not IsUnitHidden(u) and (IsUnitType(u, UNIT_TYPE_PEON) or i == 'ngir' or i == 'hpea' or i == 'opeo' or i == 'ewsp' or i == 'uaco' or i == 'ncpn' or i == 'ndrl')
endfunction
function targetIsGold takes integer i returns boolean
return i == 'ngol' or i == 'ugol' or i == 'egol'
endfunction
function W3CWorker_lossOfMine takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i = 0
if targetIsGold(GetUnitTypeId(u)) then
set i = isMineExist(u)
if i >= 0 then
call DestroyGroup(W3CWorkerMine[i])
call DestroyTextTag(W3CWorkTextTag[i])
loop
exitwhen i >= W3CMind_Length
set W3CWorkers[i] = W3CWorkers[i + 1]
set W3CMines[i] = W3CMines[i + 1]
set W3CWorkerMine[i] = W3CWorkerMine[i + 1]
set W3CWorkTextTag[i] = W3CWorkTextTag[i + 1]
set i = i + 1
endloop
set W3CMind_Length = W3CMind_Length - 1
set W3CWorkers[W3CMind_Length] = 0
set W3CMines[W3CMind_Length] = null
set W3CWorkerMine[W3CMind_Length] = null
set W3CWorkTextTag[W3CMind_Length] = null
endif
endif
set u = null
endfunction
function W3CWorker_lossOfUnit takes nothing returns nothing
local unit u = GetTriggerUnit()
if unitIsWorker(u, GetUnitTypeId(u)) then
call removeWorkerFromMine(u)
endif
set u = null
endfunction
function unitOrderedToGather takes integer orderId, integer id, unit u returns boolean
local integer target = id
if u != null then
set target = GetUnitTypeId(u)
endif
return ((orderId >= 851970 or orderId <= 852018) and target != 0) or (orderId == 851971 and targetIsGold(id))
endfunction
function W3CWorker_Order takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer orderId = GetIssuedOrderId()
if unitIsWorker(u, GetUnitTypeId(u)) and orderId != 852017 and not unitOrderedToGather(orderId, GetUnitTypeId(GetOrderTargetUnit()), null) then
call removeWorkerFromMine(u)
endif
set u = null
endfunction
function unitCanGatherAppropriateGoldMine takes integer mineid, integer id returns boolean
return (id == 'uaco' and mineid == 'ugol') or (id == 'ewsp' and mineid == 'egol') or (id != 'uaco' and id != 'ewsp' and mineid == 'ngol')
endfunction
function unitCanGatherTarget takes unit u, unit mine returns boolean
local integer id = GetUnitTypeId(u)
local integer mineid = GetUnitTypeId(mine)
return unitIsWorker(u, id) and targetIsGold(mineid) and unitCanGatherAppropriateGoldMine(mineid, id)
endfunction
function W3CWorker_TargetOrderTrigger takes nothing returns nothing
local unit mine = GetOrderTargetUnit()
local unit u = GetTriggerUnit()
local integer i = 0
if unitIsWorker(u, GetUnitTypeId(u)) then
if mine != null and unitCanGatherTarget(u, mine) and unitOrderedToGather(GetIssuedOrderId(), GetUnitTypeId(mine), mine) then
call removeWorkerFromMine(u)
set i = isMineExist(mine)
if i < 0 then
set i = addMineExist(mine)
endif
call GroupAddUnit(W3CWorkerMine[i], u)
set W3CWorkers[i] = W3CWorkers[i] + 1
call updateMineText(i)
elseif GetIssuedOrderId() != 852017 then
call removeWorkerFromMine(u)
endif
endif
set mine = null
set u = null
endfunction
function W3CWorker_chat takes nothing returns nothing
local integer i = 0
local player p = GetTriggerPlayer()
if p != null then // Making sure local player use
if W3CWorkerCount == true then
set W3CWorkerCount = false
call DisplayTextToPlayer(p, 0, 0, "Worker count |cfffd0000[off]|r")
else
set W3CWorkerCount = true
call DisplayTextToPlayer(p, 0, 0, "Worker count |cff00ff00[on]|r")
endif
loop
exitwhen i >= W3CMind_Length
if W3CWorkTextTag[i] != null then
call SetTextTagVisibility(W3CWorkTextTag[i], W3CWorkerCount and W3CWorkers[i] > 0 and (IsPlayerObserver(GetLocalPlayer()) or not IsPlayerEnemy(p, GetLocalPlayer())))
endif
set i = i + 1
endloop
set p = null
endif
endfunction
function InitW3CWorkerCount takes nothing returns nothing
local integer i = 0
local player p = null
local trigger workerCountTrigger = CreateTrigger()
local trigger issuedTargetOrderTrigger = CreateTrigger()
local trigger issuedOrder = CreateTrigger()
local trigger issuedPointOrder = CreateTrigger()
local trigger lossOfUnitTrigger = CreateTrigger()
local trigger lossOfMineTrigger = CreateTrigger()
loop
exitwhen i >= GetBJMaxPlayers()
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and not IsPlayerObserver(p) and GetPlayerController(p) == MAP_CONTROL_USER then
call TriggerRegisterPlayerChatEvent(workerCountTrigger, p, "-workercount", true)
call TriggerRegisterPlayerUnitEventSimple(issuedTargetOrderTrigger, p, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterPlayerUnitEventSimple(issuedOrder, p, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerRegisterPlayerUnitEventSimple(issuedOrder, p, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
call TriggerRegisterPlayerUnitEventSimple(issuedPointOrder, p, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterPlayerUnitEventSimple(lossOfUnitTrigger, p, EVENT_PLAYER_UNIT_DEATH)
call TriggerRegisterPlayerUnitEventSimple(lossOfUnitTrigger, p, EVENT_PLAYER_UNIT_CHANGE_OWNER)
endif
set i = i + 1
endloop
call TriggerRegisterPlayerUnitEventSimple(lossOfMineTrigger, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_DEATH)
call TriggerAddAction(issuedTargetOrderTrigger, function W3CWorker_TargetOrderTrigger)
call TriggerAddAction(issuedOrder, function W3CWorker_Order)
call TriggerAddAction(issuedPointOrder, function W3CWorker_Order)
call TriggerAddAction(lossOfUnitTrigger, function W3CWorker_lossOfUnit)
call TriggerAddAction(workerCountTrigger, function W3CWorker_chat)
call TriggerAddAction(lossOfMineTrigger, function W3CWorker_lossOfMine)
set p = null
endfunction
//===========================================================================
// W3C UNIT DENY TIP
//===========================================================================
function W3CDenyTip takes nothing returns nothing
local unit u1 = GetDyingUnit()
local unit u2 = GetKillingUnit()
local player p1 = GetOwningPlayer(u1)
local player p2 = GetOwningPlayer(u2)
local real x = GetUnitX(u1)
local real y = GetUnitY(u1)
local texttag t = null
local string s = cs2s("!",GetPlayerColor(p2))
if (not (IsUnitType(u1,UNIT_TYPE_STRUCTURE) and GetUnitTypeId(u2) == 'uaco')) and GetUnitTypeId(u2) != 'otot' and GetUnitTypeId(u2) != 'usap' and not IsUnitHidden(u1) then
if (IsPlayerAlly(p1,p2) or p1 == Player(PLAYER_NEUTRAL_AGGRESSIVE) or p2 == Player(PLAYER_NEUTRAL_AGGRESSIVE)) and p1 != Player(PLAYER_NEUTRAL_PASSIVE) then
if p2 == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
set s = "|cff323232!|r"
elseif IsUnitType(u2,UNIT_TYPE_STRUCTURE) then
set s = s + "|cff323232!|r"
endif
set t = CreateTextTagUnitBJ(s, u1, -80, 13, 100, 100, 100, 0)
call SetTextTagVisibility(t, (IsVisibleToPlayer(x,y,GetLocalPlayer()) and not IsFoggedToPlayer(x,y,GetLocalPlayer()) and not IsMaskedToPlayer(x,y,GetLocalPlayer())) or IsPlayerObserver(GetLocalPlayer()))
call SetTextTagPermanentBJ(t, false)
call SetTextTagVelocityBJ(t, 20, 90)
call SetTextTagLifespanBJ(t, 2)
call SetTextTagFadepointBJ(t, 1.5)
set t = null
endif
endif
set s = null
set u1 = null
set u2 = null
set p1 = null
set p2 = null
endfunction
function SetW3CDenyTip takes nothing returns nothing
if IsTriggerEnabled(W3CDeny) then
call DisableTrigger(W3CDeny)
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "DenyTip |cfffd0000[off]|r")
else
call EnableTrigger(W3CDeny)
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "DenyTip |cff00ff00[on]|r")
endif
endfunction
function W3CDenyTipControl takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= GetBJMaxPlayers()
if GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER then
call TriggerRegisterPlayerChatEvent(W3CDenyControl, Player(i), "-deny", false)
endif
set i = i + 1
endloop
call TriggerAddAction(W3CDenyControl, function SetW3CDenyTip )
call TriggerRegisterAnyUnitEventBJ(W3CDeny, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction(W3CDeny, function W3CDenyTip )
endfunction
//===========================================================================
// KK_Teleportation_Point_Tip
//===========================================================================
function DestroyTPEffect takes nothing returns nothing
local integer i = 1
call DestroyEffect(KK_TPEffect[1])
call DestroyTimer(KK_TPTimer[1])
set KK_TPEffect[1] = null
set KK_TPTimer[1] = null
loop
exitwhen i >= KK_TP_num
set KK_TPEffect[i] = KK_TPEffect[i + 1]
set KK_TPTimer[i] = KK_TPTimer[i + 1]
set i = i + 1
endloop
if KK_TP_num > 0 then
set KK_TP_num = KK_TP_num - 1
endif
endfunction
function TPEffect takes nothing returns nothing
local unit u = null
local group g = CreateGroup()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local integer i = GetSpellAbilityId()
local player p1 = GetOwningPlayer(GetTriggerUnit())
local player p2 = null
if p1 != null and (i == 'AItp' or i == 'AHmt') then
call GroupEnumUnitsInRange(g, x, y, 850, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
exitwhen (IsUnitType(u, UNIT_TYPE_TOWNHALL) or i == 'AHmt') and IsUnitAlly(u, p1) and GetUnitState(u, UNIT_STATE_LIFE) > 0 and not IsUnitHidden(u)
call GroupRemoveUnit(g, u)
endloop
if u != null then
set i = 0
loop
exitwhen i >= GetBJMaxPlayers()
set p2 = Player(i)
if GetPlayerSlotState(p2) == PLAYER_SLOT_STATE_PLAYING and (IsPlayerObserver(p2) or (GetPlayerController(p2) == MAP_CONTROL_USER) and IsPlayerAlly(p1, p2)) then
set KK_TP_num = KK_TP_num + 1
set KK_TPEffect[KK_TP_num] = AddSpecialEffect("Doodads\\Cityscape\\Props\\MagicRunes\\MagicRunes0.mdl", x, y)
set KK_TPTimer[KK_TP_num] = CreateTimer()
call TimerStart(KK_TPTimer[KK_TP_num], 3, false, function DestroyTPEffect)
endif
set i = i + 1
endloop
set p2 = null
endif
endif
call DestroyGroup(g)
set g = null
set p1 = null
endfunction
function InitTP takes nothing returns nothing
if KK_TP == null then
set KK_TP = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(KK_TP, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddAction(KK_TP, function TPEffect)
endif
endfunction
//===========================================================================
// Zoom
//===========================================================================
function ZoomSet takes nothing returns nothing
local real Zoom = 0
local integer i = GetPlayerId(GetTriggerPlayer())
if SubStringBJ(GetEventPlayerChatString(), 6, 6) != "k" then
if SubStringBJ(GetEventPlayerChatString(), 6, 6) != " " then
set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 6, 10))
else
set Zoom = S2R(SubStringBJ(GetEventPlayerChatString(), 7, 11))
endif
if Zoom < 1650 then
call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, 1650, 0 )
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "zoom min: |cff00ff001650|r" )
elseif Zoom > 3000 then
call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, 3000, 0 )
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "zoom max: |cff00ff003000|r" )
else
call SetCameraFieldForPlayer( GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, Zoom, 0 )
endif
// Fix desync, variables must be same across players
if Zoom < 1650 then
set current_zoom[i] = 1650
elseif Zoom > 3000 then
set current_zoom[i] = 3000
else
set current_zoom[i] = Zoom
endif
elseif legacyCamera then
if ZoomKey[i] == true then
set ZoomKey[i] = false
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "Zoom Hot Key: |cfffd0000[off]|r" )
else
set ZoomKey[i] = true
call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 7, "Zoom Hot Key: |cff00ff00[on]|r" )
endif
endif
endfunction
function ZoomDown takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
if ZoomKey[i] and current_zoom[i] > 1650 then
if GetTriggerPlayer() == GetLocalPlayer() then
call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom[i] - 50 ), 0 )
set current_zoom[i] = current_zoom[i] - 50
endif
endif
endfunction
function ZoomUp takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
if ZoomKey[i] and current_zoom[i] < 3000 then
if GetTriggerPlayer() == GetLocalPlayer() then
call SetCameraFieldForPlayer(GetTriggerPlayer(), CAMERA_FIELD_TARGET_DISTANCE, ( current_zoom[i] + 50 ), 0 )
set current_zoom[i] = current_zoom[i] + 50
endif
endif
endfunction
function InitZoom takes nothing returns nothing
local integer i = 0
set ZoomSetx = CreateTrigger()
set AdjustZoomUp = CreateTrigger()
set AdjustZoomDown = CreateTrigger()
call TriggerAddAction(ZoomSetx, function ZoomSet)
call TriggerAddAction(AdjustZoomUp , function ZoomUp)
call TriggerAddAction(AdjustZoomDown , function ZoomDown)
loop
exitwhen i >= GetBJMaxPlayers()
if GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER then
call DisplayTimedTextToPlayer(Player(i),0,0,7,"Set Zoom type: |c00d5f038-zoom1850|r")
call TriggerRegisterPlayerChatEvent( ZoomSetx, Player(i), "-zoom", false )
if legacyCamera then // Only required for legacy versions as no camera support built into the game
call TriggerRegisterPlayerKeyEventBJ( AdjustZoomUp, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
call TriggerRegisterPlayerKeyEventBJ( AdjustZoomDown, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
set current_zoom[i] = 1650 // Default expected in legacy systems
set ZoomKey[i] = true
call DisplayTimedTextToPlayer(Player(i),0,0,7,"Enable/Disable Zoom Hot Keys: |c00d5f038-zoomkey|r")
if IsPlayerObserver(Player(i)) then
call SetCameraFieldForPlayer(Player(i), CAMERA_FIELD_TARGET_DISTANCE, 1950, 0)
set current_zoom[i] = 1950
endif
endif
endif
set i = i + 1
endloop
endfunction
#INCLUDESCRIPT <Blizzard_UIFrame.eai>
//===========================================================================
// Help Function (Displays help on screen)