-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.ai
3325 lines (2883 loc) · 123 KB
/
common.ai
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
//==================================================================================================
// $Id: common.ai,v 1.68 2003/05/12 02:34:18 bfitch Exp $
//==================================================================================================
native DebugS takes string str returns nothing
native DebugFI takes string str, integer val returns nothing
native DebugUnitID takes string str, integer val returns nothing
native DisplayText takes integer p, string str returns nothing
native DisplayTextI takes integer p, string str, integer val returns nothing
native DisplayTextII takes integer p, string str, integer v1, integer v2 returns nothing
native DisplayTextIII takes integer p, string str, integer v1, integer v2, integer v3 returns nothing
native DoAiScriptDebug takes nothing returns boolean
native GetAiPlayer takes nothing returns integer
native GetHeroId takes nothing returns integer
native GetHeroLevelAI takes nothing returns integer
native GetUnitCount takes integer unitid returns integer
native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
native GetUnitCountDone takes integer unitid returns integer
native GetTownUnitCount takes integer id, integer tn, boolean dn returns integer
native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
native GetUnitBuildTime takes integer unitid returns integer
native GetMinesOwned takes nothing returns integer
native GetGoldOwned takes nothing returns integer
native TownWithMine takes nothing returns integer
native TownHasMine takes integer townid returns boolean
native TownHasHall takes integer townid returns boolean
native GetUpgradeLevel takes integer id returns integer
native GetUpgradeGoldCost takes integer id returns integer
native GetUpgradeWoodCost takes integer id returns integer
native GetNextExpansion takes nothing returns integer
native GetMegaTarget takes nothing returns unit
native GetBuilding takes player p returns unit
native GetEnemyPower takes nothing returns integer
native SetAllianceTarget takes unit id returns nothing
native GetAllianceTarget takes nothing returns unit
native SetProduce takes integer qty, integer id, integer town returns boolean
native Unsummon takes unit unitid returns nothing
native SetExpansion takes unit peon, integer id returns boolean
native SetUpgrade takes integer id returns boolean
native SetHeroLevels takes code func returns nothing
native SetNewHeroes takes boolean state returns nothing
native PurchaseZeppelin takes nothing returns nothing
native MergeUnits takes integer qty, integer a, integer b, integer make returns boolean
native ConvertUnits takes integer qty, integer id returns boolean
native SetCampaignAI takes nothing returns nothing
native SetMeleeAI takes nothing returns nothing
native SetTargetHeroes takes boolean state returns nothing
native SetPeonsRepair takes boolean state returns nothing
native SetRandomPaths takes boolean state returns nothing
native SetDefendPlayer takes boolean state returns nothing
native SetHeroesFlee takes boolean state returns nothing
native SetHeroesBuyItems takes boolean state returns nothing
native SetWatchMegaTargets takes boolean state returns nothing
native SetIgnoreInjured takes boolean state returns nothing
native SetHeroesTakeItems takes boolean state returns nothing
native SetUnitsFlee takes boolean state returns nothing
native SetGroupsFlee takes boolean state returns nothing
native SetSlowChopping takes boolean state returns nothing
native SetCaptainChanges takes boolean allow returns nothing
native SetSmartArtillery takes boolean state returns nothing
native SetReplacementCount takes integer qty returns nothing
native GroupTimedLife takes boolean allow returns nothing
native RemoveInjuries takes nothing returns nothing
native RemoveSiege takes nothing returns nothing
native InitAssault takes nothing returns nothing
native AddAssault takes integer qty, integer id returns boolean
native AddDefenders takes integer qty, integer id returns boolean
native GetCreepCamp takes integer min, integer max, boolean flyers_ok returns unit
native StartGetEnemyBase takes nothing returns nothing
native WaitGetEnemyBase takes nothing returns boolean
native GetEnemyBase takes nothing returns unit
native GetExpansionFoe takes nothing returns unit
native GetEnemyExpansion takes nothing returns unit
native GetExpansionX takes nothing returns integer
native GetExpansionY takes nothing returns integer
native SetStagePoint takes real x, real y returns nothing
native AttackMoveKill takes unit target returns nothing
native AttackMoveXY takes integer x, integer y returns nothing
native LoadZepWave takes integer x, integer y returns nothing
native SuicidePlayer takes player id, boolean check_full returns boolean
native SuicidePlayerUnits takes player id, boolean check_full returns boolean
native CaptainInCombat takes boolean attack_captain returns boolean
native IsTowered takes unit target returns boolean
native ClearHarvestAI takes nothing returns nothing
native HarvestGold takes integer town, integer peons returns nothing
native HarvestWood takes integer town, integer peons returns nothing
native GetExpansionPeon takes nothing returns unit
native StopGathering takes nothing returns nothing
native AddGuardPost takes integer id, real x, real y returns nothing
native FillGuardPosts takes nothing returns nothing
native ReturnGuardPosts takes nothing returns nothing
native CreateCaptains takes nothing returns nothing
native SetCaptainHome takes integer which, real x, real y returns nothing
native ResetCaptainLocs takes nothing returns nothing
native ShiftTownSpot takes real x, real y returns nothing
native TeleportCaptain takes real x, real y returns nothing
native ClearCaptainTargets takes nothing returns nothing
native CaptainAttack takes real x, real y returns nothing
native CaptainVsUnits takes player id returns nothing
native CaptainVsPlayer takes player id returns nothing
native CaptainGoHome takes nothing returns nothing
native CaptainIsHome takes nothing returns boolean
native CaptainIsFull takes nothing returns boolean
native CaptainIsEmpty takes nothing returns boolean
native CaptainGroupSize takes nothing returns integer
native CaptainReadiness takes nothing returns integer
native CaptainRetreating takes nothing returns boolean
native CaptainReadinessHP takes nothing returns integer
native CaptainReadinessMa takes nothing returns integer
native CaptainAtGoal takes nothing returns boolean
native CreepsOnMap takes nothing returns boolean
native SuicideUnit takes integer count, integer unitid returns nothing
native SuicideUnitEx takes integer ct, integer uid, integer pid returns nothing
native StartThread takes code func returns nothing
native Sleep takes real seconds returns nothing
native UnitAlive takes unit id returns boolean
native UnitInvis takes unit id returns boolean
native IgnoredUnits takes integer unitid returns integer
native TownThreatened takes nothing returns boolean
native DisablePathing takes nothing returns nothing
native SetAmphibious takes nothing returns nothing
native CommandsWaiting takes nothing returns integer
native GetLastCommand takes nothing returns integer
native GetLastData takes nothing returns integer
native PopLastCommand takes nothing returns nothing
native MeleeDifficulty takes nothing returns integer
//============================================================================
// Globals for all AI scripts
//============================================================================
globals
// the constants are defined in common.j of WoW Reforged
//--------------------------------------------------------------------
player ai_player
integer sleep_seconds
integer total_gold = 0
integer total_wood = 0
integer gold_buffer = 0 // usually for potion money
integer difficulty = NORMAL
integer exp_seen = 0
integer racial_farm = 'hhou'
integer hero_id = 'Hamg'
integer hero_id2 = 'Hmkg'
integer hero_id3 = 'Hpal'
integer array skill
integer array skills1
integer array skills2
integer array skills3
integer max_hero_level = 0
integer array harass_qty
integer array harass_max
integer array harass_units
integer harass_length = 0
integer array defense_qty
integer array defense_units
integer defense_length = 0
integer array build_qty
integer array build_type
integer array build_item
integer array build_town
integer build_length = 0
integer campaign_gold_peons = 5
integer campaign_wood_peons = 3
integer campaign_basics_speed = 5
integer min_creeps = -1
integer max_creeps = -1
boolean harvest_town1 = true
boolean harvest_town2 = true
boolean harvest_town3 = true
boolean do_campaign_farms = true
boolean two_heroes = false
boolean allow_air_creeps = false
boolean take_exp = false
boolean allow_signal_abort = false
boolean ready_for_zeppelin = true
boolean get_zeppelin = false
boolean build_campaign_attackers = true
boolean do_debug_cheats = false
boolean array trace_on
boolean zep_next_wave = false
boolean form_group_timeouts = true
// WoW Reforged
// data
integer array heroTypes
integer heroTypesCounter = 0
integer array mountTypes
integer mountTypesCounter = 0
integer array housingTypes
integer housingTypesCounter = 0
// AI command options
boolean attackEnemyPlayers = true
boolean buildShips = false
integer shipyards = 0
integer ships_simple = 0
integer ships_strong = 0
boolean disabled = false
integer expansions = 0
boolean attackTargetLocation = false
integer attackTargetLocationX = 0
integer attackTargetLocationY = 0
integer zeppelins = 3
integer shredders = 3
endglobals
//============================================================================
// https://www.hiveworkshop.com/threads/i2s-without-natives-for-use-in-ai-scripts.348472/
function I2C2 takes integer i returns string
if i == 0 then
return "0"
elseif i == 1 then
return "1"
elseif i == 2 then
return "2"
elseif i == 3 then
return "3"
elseif i == 4 then
return "4"
elseif i == 5 then
return "5"
elseif i == 6 then
return "6"
elseif i == 7 then
return "7"
elseif i == 8 then
return "8"
elseif i == 9 then
return "9"
endif
return ""
endfunction
function I2S2 takes integer i returns string
local integer j = i
local string s = ""
local integer k = 0
local boolean is_negative = false
local integer MAX_DIGITS = 20
if i < 0 then
set is_negative = true
set j = -j
endif
loop
set s = I2C2(j - (j / 10) * 10) + s
set j = j / 10
set k = k + 1
exitwhen j == 0 or k >= MAX_DIGITS
endloop
if is_negative then
set s = "-" + s
endif
return s
endfunction
//============================================================================
// recipient: changes the type of chat channel prefix shown. It has no effect on the message's visibility.
// 0: "All" chat prefix
// 1: "Allies"
// 2: "Observers"
// 3+: "Private"
function NotifySpecificPlayer takes integer playerIndex, string message returns nothing
call BlzDisplayChatMessage(Player(GetAiPlayer()), 3 + playerIndex, message)
endfunction
function NotifyOtherPlayers takes string message returns nothing
call BlzDisplayChatMessage(Player(GetAiPlayer()), 0, message)
endfunction
//============================================================================
function PlayerEx takes integer slot returns player
return Player(slot-1)
endfunction
//============================================================================
function Trace takes string message returns nothing
local integer i = 0
loop
exitwhen (i == GetBJMaxPlayers())
if trace_on[i] then
call DisplayText(i, message)
call NotifySpecificPlayer(i, message)
endif
set i = i + 1
endloop
endfunction
//============================================================================
function TraceI takes string message, integer val returns nothing
local integer i = 0
loop
exitwhen (i == GetBJMaxPlayers())
if trace_on[i] then
call DisplayTextI(i, message, val)
call NotifySpecificPlayer(i, message + " v1=" + I2S2(val))
endif
set i = i + 1
endloop
endfunction
//============================================================================
function TraceII takes string message, integer v1, integer v2 returns nothing
local integer i = 0
loop
exitwhen (i == GetBJMaxPlayers())
if trace_on[i] then
call DisplayTextII(i,message,v1,v2)
call NotifySpecificPlayer(i, message + " v1=" + I2S2(v1) + ", v2=" + I2S2(v2))
endif
set i = i + 1
endloop
endfunction
//============================================================================
function TraceIII takes string message, integer v1, integer v2, integer v3 returns nothing
local integer i = 0
loop
exitwhen (i == GetBJMaxPlayers())
if trace_on[i] then
call DisplayTextIII(i,message,v1,v2,v3)
call NotifySpecificPlayer(i, message + " v1=" + I2S2(v1) + " v2=" + I2S2(v2) + " v3=" + I2S2(v3))
endif
set i = i + 1
endloop
endfunction
//============================================================================
function InitAI takes nothing returns nothing
local integer i = 0
loop
exitwhen (i == GetBJMaxPlayers())
set trace_on[i] = false
set i = i + 1
endloop
set ai_player = Player(GetAiPlayer())
set sleep_seconds = 0
call StopGathering()
endfunction
//============================================================================
function StandardAI takes code heroes, code peons, code attacks returns nothing
local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE)
call InitAI()
call SetMeleeAI()
call SetDefendPlayer(true)
call SetGroupsFlee(not isNewbie)
call SetHeroesBuyItems(not isNewbie)
call SetHeroesFlee(true)
call SetHeroesTakeItems(true)
call SetIgnoreInjured(true)
call SetPeonsRepair(true)
call SetSmartArtillery(not isNewbie)
call SetTargetHeroes(not isNewbie)
call SetUnitsFlee(not isNewbie)
call SetWatchMegaTargets(true)
call CreateCaptains()
call SetHeroLevels(heroes)
call Sleep(0.1)
call StartThread(peons)
call StartThread(attacks)
endfunction
//============================================================================
// Utility Functions
//============================================================================
function Min takes integer A, integer B returns integer
if A < B then
return A
else
return B
endif
endfunction
function Max takes integer A, integer B returns integer
if A > B then
return A
else
return B
endif
endfunction
function SetZepNextWave takes nothing returns nothing
set zep_next_wave = true
endfunction
function SuicideSleep takes integer seconds returns nothing
set sleep_seconds = sleep_seconds - seconds
loop
exitwhen seconds <= 0
exitwhen allow_signal_abort and CommandsWaiting() != 0
if seconds >= 5 then
call Sleep(5)
set seconds = seconds - 5
else
call Sleep(seconds)
set seconds = 0
endif
endloop
endfunction
//============================================================================
function WaitForSignal takes nothing returns integer
local integer cmd
local boolean display = false //xxx
loop
exitwhen CommandsWaiting() != 0
//xxx
call Trace("waiting for a signal to begin AI script...\n")
set display = true
call Sleep(2)
exitwhen CommandsWaiting() != 0
call Sleep(2)
exitwhen CommandsWaiting() != 0
call Sleep(2)
exitwhen CommandsWaiting() != 0
call Sleep(2)
exitwhen CommandsWaiting() != 0
call Sleep(2)
//xxx
endloop
//xxx
if display then
call Trace("signal received, beginning AI script\n")
endif
//xxx
set cmd = GetLastCommand()
call PopLastCommand()
return cmd
endfunction
//============================================================================
function SetWoodPeons takes integer count returns nothing
set campaign_wood_peons = count
endfunction
//============================================================================
function SetGoldPeons takes integer count returns nothing
set campaign_gold_peons = count
endfunction
//============================================================================
function SetHarvestLumber takes boolean harvest returns nothing
if harvest then
set campaign_wood_peons = 3
else
set campaign_wood_peons = 0
endif
endfunction
//============================================================================
function SetFormGroupTimeouts takes boolean state returns nothing
set form_group_timeouts = state
endfunction
//============================================================================
function DoCampaignFarms takes boolean state returns nothing
set do_campaign_farms = state
endfunction
//============================================================================
function GetMinorCreep takes nothing returns unit
return GetCreepCamp(0,9,false)
endfunction
//============================================================================
function GetMajorCreep takes nothing returns unit
return GetCreepCamp(10,100,allow_air_creeps)
endfunction
//============================================================================
function GetGold takes nothing returns integer
return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_GOLD)
endfunction
//============================================================================
function GetWood takes nothing returns integer
return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_LUMBER)
endfunction
//============================================================================
function InitBuildArray takes nothing returns nothing
set build_length = 0
endfunction
//============================================================================
function InitAssaultGroup takes nothing returns nothing
set harass_length = 0
endfunction
//============================================================================
function InitDefenseGroup takes nothing returns nothing
set defense_length = 0
endfunction
//============================================================================
function InitMeleeGroup takes nothing returns nothing
call InitAssaultGroup()
call RemoveInjuries()
call RemoveSiege()
endfunction
//============================================================================
function PrepFullSuicide takes nothing returns nothing
call InitAssaultGroup()
call InitDefenseGroup()
set campaign_gold_peons = 0
set campaign_wood_peons = 0
endfunction
//============================================================================
function SetReplacements takes integer easy, integer med, integer hard returns nothing
if difficulty == EASY then
call SetReplacementCount(easy)
elseif difficulty == NORMAL then
call SetReplacementCount(med)
else
call SetReplacementCount(hard)
endif
endfunction
//============================================================================
function StartTownBuilder takes code func returns nothing
call StartThread(func)
endfunction
//============================================================================
function SetBuildAll takes integer t, integer qty, integer unitid, integer town returns nothing
if qty > 0 then
set build_qty[build_length] = qty
set build_type[build_length] = t
set build_item[build_length] = unitid
set build_town[build_length] = town
set build_length = build_length + 1
endif
endfunction
//============================================================================
function SetBuildUnit takes integer qty, integer unitid returns nothing
call SetBuildAll(BUILD_UNIT,qty,unitid,-1)
endfunction
//============================================================================
function SetBuildNext takes integer qty, integer unitid returns nothing
local integer has = GetUnitCount(unitid)
if has >= qty then
return
endif
call SetBuildAll(BUILD_UNIT,GetUnitCountDone(unitid)+1,unitid,-1)
endfunction
//============================================================================
function SetBuildUnitEx takes integer easy, integer med, integer hard, integer unitid returns nothing
if difficulty == EASY then
call SetBuildAll(BUILD_UNIT,easy,unitid,-1)
elseif difficulty == NORMAL then
call SetBuildAll(BUILD_UNIT,med,unitid,-1)
else
call SetBuildAll(BUILD_UNIT,hard,unitid,-1)
endif
endfunction
//============================================================================
function SecondaryTown takes integer town, integer qty, integer unitid returns nothing
call SetBuildAll(BUILD_UNIT,qty,unitid,town)
endfunction
//============================================================================
function SecTown takes integer town, integer qty, integer unitid returns nothing
call SetBuildAll(BUILD_UNIT,qty,unitid,town)
endfunction
//============================================================================
function SetBuildUpgr takes integer qty, integer unitid returns nothing
if MeleeDifficulty() != MELEE_NEWBIE or qty == 1 then
call SetBuildAll(BUILD_UPGRADE,qty,unitid,-1)
endif
endfunction
//============================================================================
function SetBuildUpgrEx takes integer easy, integer med, integer hard, integer unitid returns nothing
if difficulty == EASY then
call SetBuildAll(BUILD_UPGRADE,easy,unitid,-1)
elseif difficulty == NORMAL then
call SetBuildAll(BUILD_UPGRADE,med,unitid,-1)
else
call SetBuildAll(BUILD_UPGRADE,hard,unitid,-1)
endif
endfunction
//============================================================================
function SetBuildExpa takes integer qty, integer unitid returns nothing
call SetBuildAll(BUILD_EXPAND,qty,unitid,-1)
endfunction
//============================================================================
function StartUpgrade takes integer level, integer upgid returns boolean
local integer gold_cost
local integer wood_cost
if GetUpgradeLevel(upgid) >= level then
return true
endif
set gold_cost = GetUpgradeGoldCost(upgid)
if total_gold < gold_cost then
return false
endif
set wood_cost = GetUpgradeWoodCost(upgid)
if total_wood < wood_cost then
return false
endif
return SetUpgrade(upgid)
endfunction
//============================================================================
function BuildFactory takes integer unitid returns nothing
if GetGold() > 1000 and GetWood() > 500 then
call SetBuildUnit( 2, unitid )
else
call SetBuildUnit( 1, unitid )
endif
endfunction
//============================================================================
function HallsCompleted takes integer unitid returns boolean
return GetUnitCount(unitid) == GetUnitCountDone(unitid)
endfunction
//============================================================================
function GuardSecondary takes integer townid, integer qty, integer unitid returns nothing
if TownHasHall(townid) and TownHasMine(townid) then
call SecondaryTown( townid, qty, unitid )
endif
endfunction
//============================================================================
function GetUnitCountEx takes integer unitid, boolean only_done, integer townid returns integer
if townid == -1 then
if only_done then
return GetUnitCountDone(unitid)
else
return GetUnitCount(unitid)
endif
else
return GetTownUnitCount(unitid,townid,only_done)
endif
endfunction
//============================================================================
function TownCountEx takes integer unitid, boolean only_done, integer townid returns integer
local integer have_qty = GetUnitCountEx(unitid,only_done,townid)
if unitid == TOWN_HALL then
set have_qty = have_qty + GetUnitCountEx(KEEP,false,townid) + GetUnitCountEx(CASTLE,false,townid)
elseif unitid == KEEP then
set have_qty = have_qty + GetUnitCountEx(CASTLE,false,townid)
elseif unitid == WATCH_TOWER then
set have_qty = have_qty + GetUnitCountEx(GUARD_TOWER,false,townid) + GetUnitCountEx(CANNON_TOWER,false,townid) + GetUnitCountEx(ARCANE_TOWER,false,townid)
elseif unitid == PEASANT then
set have_qty = have_qty + GetUnitCountEx(MILITIA,false,townid)
elseif unitid == TANK then
set have_qty = have_qty + GetUnitCountEx(ROCKET_TANK,false,townid)
elseif unitid == GREAT_HALL then
set have_qty = have_qty + GetUnitCountEx(STRONGHOLD,false,townid) + GetUnitCountEx(FORTRESS,false,townid)
elseif unitid == STRONGHOLD then
set have_qty = have_qty + GetUnitCountEx(FORTRESS,false,townid)
elseif unitid == HEAD_HUNTER then
set have_qty = have_qty + GetUnitCountEx(BERSERKER,false,townid)
elseif unitid == SPIRIT_WALKER then
set have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER_M,false,townid)
elseif unitid == SPIRIT_WALKER_M then
set have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER,only_done,townid)
elseif unitid == NECROPOLIS_1 then
set have_qty = have_qty + GetUnitCountEx(NECROPOLIS_2,false,townid) + GetUnitCountEx(NECROPOLIS_3,false,townid)
elseif unitid == NECROPOLIS_2 then
set have_qty = have_qty + GetUnitCountEx(NECROPOLIS_3,false,townid)
elseif unitid == ZIGGURAT_1 then
set have_qty = have_qty + GetUnitCountEx(ZIGGURAT_2,false,townid) + GetUnitCountEx(ZIGGURAT_FROST,false,townid)
elseif unitid == GARGOYLE then
set have_qty = have_qty + GetUnitCountEx(GARGOYLE_MORPH,false,townid)
elseif unitid == TREE_LIFE then
set have_qty = have_qty + GetUnitCountEx(TREE_AGES,false,townid) + GetUnitCountEx(TREE_ETERNITY,false,townid)
elseif unitid == TREE_AGES then
set have_qty = have_qty + GetUnitCountEx(TREE_ETERNITY,false,townid)
elseif unitid == DRUID_TALON then
set have_qty = have_qty + GetUnitCountEx(DRUID_TALON_M,false,townid)
elseif unitid == DRUID_TALON_M then
set have_qty = have_qty + GetUnitCountEx(DRUID_TALON,only_done,townid)
elseif unitid == DRUID_CLAW then
set have_qty = have_qty + GetUnitCountEx(DRUID_CLAW_M,false,townid)
elseif unitid == DRUID_CLAW_M then
set have_qty = have_qty + GetUnitCountEx(DRUID_CLAW,only_done,townid)
elseif unitid == ILLIDAN then
set have_qty = have_qty + GetUnitCountEx(ILLIDAN_DEMON,false,townid)
// World of Warcraft Reforged
elseif unitid == WATER_TOWER then
set have_qty = have_qty + GetUnitCountEx(ADVANCED_WATER_TOWER,false,townid)
elseif unitid == HIDEOUT then
set have_qty = have_qty + GetUnitCountEx(FORTIFIED_HIDEOUT,false,townid) + GetUnitCountEx(GUARDIANS_CITADEL,false,townid)
elseif unitid == FORTIFIED_HIDEOUT then
set have_qty = have_qty + GetUnitCountEx(GUARDIANS_CITADEL,false,townid)
elseif unitid == FREELANCER_TOWER then
set have_qty = have_qty + GetUnitCountEx(FREELANCER_ADVANCED_TOWER,false,townid)
elseif unitid == OLD_HORDE_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_TIER_2,false,townid) + GetUnitCountEx(OLD_HORDE_TIER_3,false,townid)
elseif unitid == OLD_HORDE_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_TIER_3,false,townid)
elseif unitid == OLD_HORDE_WATCH_TOWER then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_GUARD_TOWER,false,townid) + GetUnitCountEx(OLD_HORDE_CANNON_TOWER,false,townid)
elseif unitid == OLD_HORDE_WORKER_BASE then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_WORKER_NORMAL,false,townid) + GetUnitCountEx(OLD_HORDE_WORKER_ADVANCED,false,townid)
elseif unitid == OLD_HORDE_TROLL_AXETHROWER then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_TROLL_BERSERKER,false,townid)
elseif unitid == OLD_HORDE_OGRE then
set have_qty = have_qty + GetUnitCountEx(OLD_HORDE_OGRE_MAGE,false,townid)
elseif unitid == ALLIANCE_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_TIER_2,false,townid) + GetUnitCountEx(ALLIANCE_TIER_3,false,townid)
elseif unitid == ALLIANCE_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_TIER_3,false,townid)
elseif unitid == ALLIANCE_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_GUARD_TOWER,false,townid) + GetUnitCountEx(ALLIANCE_CANNON_TOWER,false,townid)
elseif unitid == ALLIANCE_WORKER_BASE then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_WORKER_NORMAL,false,townid) + GetUnitCountEx(ALLIANCE_WORKER_ADVANCED,false,townid)
elseif unitid == ALLIANCE_ELVEN_ARCHER then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_ELVEN_RANGER,false,townid)
elseif unitid == ALLIANCE_KNIGHT then
set have_qty = have_qty + GetUnitCountEx(ALLIANCE_PALADIN,false,townid)
elseif unitid == BLOOD_ELF_TOWN_HALL then
set have_qty = have_qty + GetUnitCountEx(BLOOD_ELF_KEEP,false,townid) + GetUnitCountEx(BLOOD_ELF_CASTLE,false,townid)
elseif unitid == BLOOD_ELF_KEEP then
set have_qty = have_qty + GetUnitCountEx(BLOOD_ELF_CASTLE,false,townid)
elseif unitid == BLOOD_ELF_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(BLOOD_ELF_GUARD_TOWER,false,townid) + GetUnitCountEx(BLOOD_ELF_ARCANE_TOWER,false,townid)
elseif unitid == NAGA_TEMPLE_1 then
set have_qty = have_qty + GetUnitCountEx(NAGA_TEMPLE,false,townid) + GetUnitCountEx(NAGA_TEMPLE_3,false,townid)
elseif unitid == NAGA_TEMPLE then
set have_qty = have_qty + GetUnitCountEx(NAGA_TEMPLE_3,false,townid)
elseif unitid == NAGA_SNAP_DRAGON then
set have_qty = have_qty + GetUnitCountEx(NAGA_SNAP_DRAGON_SUBMERGED,false,townid)
elseif unitid == NAGA_MYRMIDON then
set have_qty = have_qty + GetUnitCountEx(NAGA_MYRMIDON_SUBMERGED,false,townid)
elseif unitid == NAGA_ROYAL then
set have_qty = have_qty + GetUnitCountEx(NAGA_ROYAL_SUBMERGED,false,townid)
elseif unitid == DEMON_GATE_1 then
set have_qty = have_qty + GetUnitCountEx(DEMON_GATE_2,false,townid) + GetUnitCountEx(DEMON_GATE_3,false,townid)
elseif unitid == DEMON_GATE_2 then
set have_qty = have_qty + GetUnitCountEx(DEMON_GATE_3,false,townid)
elseif unitid == DEMON_FORTIFIED_INFERNAL_MACHINE then
set have_qty = have_qty + GetUnitCountEx(DEMON_FORTIFIED_INFERNAL_JUGGERNAUT,false,townid)
elseif unitid == GOBLIN_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_TIER_2,false,townid) + GetUnitCountEx(GOBLIN_TIER_3,false,townid)
elseif unitid == GOBLIN_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_TIER_3,false,townid)
elseif unitid == GOBLIN_TOWER then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_TURRET,false,townid) + GetUnitCountEx(GOBLIN_ROCKET_TOWER_1,false,townid) + GetUnitCountEx(GOBLIN_ROCKET_TOWER_2,false,townid) + GetUnitCountEx(GOBLIN_ROCKET_TOWER_3,false,townid)
elseif unitid == GOBLIN_ROCKET_TOWER_1 then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_ROCKET_TOWER_2,false,townid) + GetUnitCountEx(GOBLIN_ROCKET_TOWER_3,false,townid)
elseif unitid == GOBLIN_ROCKET_TOWER_2 then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_ROCKET_TOWER_3,false,townid)
elseif unitid == GOBLIN_FLAMETHROWER then
set have_qty = have_qty + GetUnitCountEx(GOBLIN_MOBILE_TURRET,false,townid)
elseif unitid == DWARF_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(DWARF_TIER_2,false,townid) + GetUnitCountEx(DWARF_TIER_3,false,townid)
elseif unitid == DWARF_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(DWARF_TIER_3,false,townid)
elseif unitid == HIGH_ELF_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(HIGH_ELF_TIER_2,false,townid) + GetUnitCountEx(HIGH_ELF_TIER_3,false,townid)
elseif unitid == HIGH_ELF_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(HIGH_ELF_TIER_3,false,townid)
elseif unitid == HIGH_ELF_OUTPOST then
set have_qty = have_qty + GetUnitCountEx(HIGH_ELF_GUARD_TOWER,false,townid)
elseif unitid == GNOME_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(GNOME_TIER_2,false,townid) + GetUnitCountEx(GNOME_TIER_3,false,townid)
elseif unitid == GNOME_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(GNOME_TIER_3,false,townid)
elseif unitid == DALARAN_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(DALARAN_TIER_2,false,townid) + GetUnitCountEx(DALARAN_TIER_3,false,townid)
elseif unitid == DALARAN_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(DALARAN_TIER_3,false,townid)
elseif unitid == DALARAN_GUARD_TOWER_1 then
set have_qty = have_qty + GetUnitCountEx(DALARAN_GUARD_TOWER_2,false,townid)
elseif unitid == KULTIRAS_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(KULTIRAS_TIER_2,false,townid) + GetUnitCountEx(KULTIRAS_TIER_3,false,townid)
elseif unitid == KULTIRAS_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(KULTIRAS_TIER_3,false,townid)
elseif unitid == KULTIRAS_WATCH_TOWER then
set have_qty = have_qty + GetUnitCountEx(KULTIRAS_GUARD_TOWER,false,townid) + GetUnitCountEx(KULTIRAS_CANNON_TOWER,false,townid) + GetUnitCountEx(KULTIRAS_ARCANE_TOWER,false,townid)
elseif unitid == LORDAERON_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(LORDAERON_TIER_2,false,townid) + GetUnitCountEx(LORDAERON_TIER_3,false,townid)
elseif unitid == LORDAERON_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(LORDAERON_TIER_3,false,townid)
elseif unitid == LORDAERON_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(LORDAERON_GUARD_TOWER,false,townid) + GetUnitCountEx(LORDAERON_CANNON_TOWER,false,townid) + GetUnitCountEx(LORDAERON_ARCANE_TOWER,false,townid)
elseif unitid == STORMWIND_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(STORMWIND_TIER_2,false,townid) + GetUnitCountEx(STORMWIND_TIER_3,false,townid)
elseif unitid == STORMWIND_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(STORMWIND_TIER_3,false,townid)
elseif unitid == STORMWIND_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(STORMWIND_GUARD_TOWER,false,townid) + GetUnitCountEx(STORMWIND_CANNON_TOWER,false,townid) + GetUnitCountEx(STORMWIND_ARCANE_TOWER,false,townid)
elseif unitid == STORMWIND_KNIGHT then
set have_qty = have_qty + GetUnitCountEx(STORMWIND_KNIGHT_UNMOUNTED,false,townid)
elseif unitid == PANDAREN_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(PANDAREN_TIER_2,false,townid) + GetUnitCountEx(PANDAREN_TIER_3,false,townid)
elseif unitid == PANDAREN_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(PANDAREN_TIER_3,false,townid)
elseif unitid == PANDAREN_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(PANDAREN_MAGIC_TOWER,false,townid) + GetUnitCountEx(PANDAREN_CANNON_TOWER,false,townid) + GetUnitCountEx(PANDAREN_GUARD_TOWER,false,townid)
elseif unitid == TROLL_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(TROLL_TIER_2,false,townid) + GetUnitCountEx(TROLL_TIER_3,false,townid)
elseif unitid == TROLL_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(TROLL_TIER_3,false,townid)
elseif unitid == TAUREN_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(TAUREN_TIER_2,false,townid) + GetUnitCountEx(TAUREN_TIER_3,false,townid)
elseif unitid == TAUREN_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(TAUREN_TIER_3,false,townid)
elseif unitid == WORGEN_TOWN_HALL then
set have_qty = have_qty + GetUnitCountEx(WORGEN_KEEP,false,townid) + GetUnitCountEx(WORGEN_CASTLE,false,townid)
elseif unitid == WORGEN_KEEP then
set have_qty = have_qty + GetUnitCountEx(WORGEN_CASTLE,false,townid)
elseif unitid == WORGEN_SCOUT_TOWER then
set have_qty = have_qty + GetUnitCountEx(WORGEN_GUARD_TOWER,false,townid) + GetUnitCountEx(WORGEN_CANNON_TOWER,false,townid) + GetUnitCountEx(WORGEN_ARCANE_TOWER,false,townid)
elseif unitid == VRYKUL_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(VRYKUL_TIER_2,false,townid) + GetUnitCountEx(VRYKUL_TIER_3,false,townid)
elseif unitid == VRYKUL_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(VRYKUL_TIER_3,false,townid)
elseif unitid == TUSKARR_FROZEN_HALL then
set have_qty = have_qty + GetUnitCountEx(TUSKARR_FROZEN_STRONGHOLD,false,townid) + GetUnitCountEx(TUSKARR_FROZEN_FORTRESS,false,townid)
elseif unitid == TUSKARR_FROZEN_STRONGHOLD then
set have_qty = have_qty + GetUnitCountEx(TUSKARR_FROZEN_FORTRESS,false,townid)
elseif unitid == TUSKARR_BLOCK_OF_ICE then
set have_qty = have_qty + GetUnitCountEx(TUSKARR_ICE_WALL,false,townid) + GetUnitCountEx(TUSKARR_SPIDER_SHRINE,false,townid) + GetUnitCountEx(TUSKARR_FROST_SNOWMAN,false,townid)
elseif unitid == NERUBIAN_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_TIER_2,false,townid) + GetUnitCountEx(NERUBIAN_TIER_3,false,townid) + GetUnitCountEx(NERUBIAN_TIER_1_BURROWED,false,townid) + GetUnitCountEx(NERUBIAN_TIER_2_BURROWED,false,townid) + GetUnitCountEx(NERUBIAN_TIER_3_BURROWED,false,townid)
elseif unitid == NERUBIAN_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_TIER_3,false,townid) + GetUnitCountEx(NERUBIAN_TIER_2_BURROWED,false,townid) + GetUnitCountEx(NERUBIAN_TIER_3_BURROWED,false,townid)
elseif unitid == NERUBIAN_ALTAR then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_ALTAR_BURROWED,false,townid)
elseif unitid == NERUBIAN_ANCIENT_SHRINE then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_ANCIENT_SHRINE_BURROWED,false,townid)
elseif unitid == NERUBIAN_HATCHERY then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_HATCHERY_BURROWED,false,townid)
elseif unitid == NERUBIAN_TOWER then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_TOWER_BURROWED,false,townid)
elseif unitid == NERUBIAN_ZIGGURAT then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_ZIGGURAT_BURROWED,false,townid)
elseif unitid == NERUBIAN_NEST then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_NEST_BURROWED,false,townid)
elseif unitid == NERUBIAN_SPAWNING_GROUND then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_SPAWNING_GROUND_BURROWED,false,townid)
elseif unitid == NERUBIAN_SPAWNING_PIT then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_SPAWNING_PIT_BURROWED,false,townid)
elseif unitid == NERUBIAN_VAULT_OF_RELICS then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_VAULT_OF_RELICS_BURROWED,false,townid)
elseif unitid == NERUBIAN_HOUSING then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_HOUSING_BURROWED,false,townid)
elseif unitid == CRYPT_LORD then
set have_qty = have_qty + GetUnitCountEx(CRYPT_LORD_BURROWED,false,townid)
elseif unitid == NERUBIAN_QUEEN_HERO then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_QUEEN_HERO_BURROWED,false,townid)
elseif unitid == ANUBARAK_HERO then
set have_qty = have_qty + GetUnitCountEx(ANUBARAK_HERO_BURROWED,false,townid)
elseif unitid == NERUBIAN_WORKER then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_WORKER_BURROWED,false,townid)
elseif unitid == NERUBIAN_CRYPT_FIEND then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_CRYPT_FIEND_BURROWED,false,townid)
elseif unitid == NERUBIAN_SEER then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_SEER_BURROWED,false,townid)
elseif unitid == NERUBIAN_SPEAR_THROWER then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_SPEAR_THROWER_BURROWED,false,townid)
elseif unitid == NERUBIAN_SPIDER_LORD then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_SPIDER_LORD_BURROWED,false,townid)
elseif unitid == NERUBIAN_WARRIOR then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_WARRIOR_BURROWED,false,townid)
elseif unitid == NERUBIAN_WEBSPINNER then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_WEBSPINNER_BURROWED,false,townid)
elseif unitid == NERUBIAN_CRYPT_DRONE then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_CRYPT_DRONE_COCOON,false,townid)
elseif unitid == NERUBIAN_QUEEN then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_QUEEN_BURROWED,false,townid)
elseif unitid == MURLOC_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(MURLOC_TIER_2,false,townid) + GetUnitCountEx(MURLOC_TIER_3,false,townid)
elseif unitid == MURLOC_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(NERUBIAN_TIER_3,false,townid)
elseif unitid == OGRE_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(OGRE_TIER_2,false,townid) + GetUnitCountEx(OGRE_TIER_3,false,townid)
elseif unitid == OGRE_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(OGRE_TIER_3,false,townid)
elseif unitid == OGRE_BOULDER_TOWER then
set have_qty = have_qty + GetUnitCountEx(OGRE_ADVANCED_BOULDER_TOWER,false,townid)
elseif unitid == EREDAR_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(EREDAR_TIER_2,false,townid) + GetUnitCountEx(EREDAR_TIER_3,false,townid)
elseif unitid == EREDAR_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(EREDAR_TIER_3,false,townid)
elseif unitid == FEL_ORC_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(FEL_ORC_TIER_2,false,townid) + GetUnitCountEx(FEL_ORC_TIER_3,false,townid)
elseif unitid == FEL_ORC_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(FEL_ORC_TIER_3,false,townid)
elseif unitid == FACELESS_ONE_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(FACELESS_ONE_TIER_2,false,townid) + GetUnitCountEx(FACELESS_ONE_TIER_3,false,townid)
elseif unitid == FACELESS_ONE_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(FACELESS_ONE_TIER_3,false,townid)
elseif unitid == SATYR_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(SATYR_TIER_2,false,townid) + GetUnitCountEx(SATYR_TIER_3,false,townid)
elseif unitid == SATYR_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(SATYR_TIER_3,false,townid)
elseif unitid == CENTAUR_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(CENTAUR_TIER_2,false,townid) + GetUnitCountEx(CENTAUR_TIER_3,false,townid)
elseif unitid == CENTAUR_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(CENTAUR_TIER_3,false,townid)
elseif unitid == GNOLL_TIER_1 then
set have_qty = have_qty + GetUnitCountEx(GNOLL_TIER_2,false,townid) + GetUnitCountEx(GNOLL_TIER_3,false,townid)
elseif unitid == GNOLL_TIER_2 then
set have_qty = have_qty + GetUnitCountEx(GNOLL_TIER_3,false,townid)