-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathUnitType.java
More file actions
1254 lines (1164 loc) · 41.8 KB
/
UnitType.java
File metadata and controls
1254 lines (1164 loc) · 41.8 KB
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
package bwapi;
import java.util.*;
import static bwapi.TechType.*;
/**
* The {@link UnitType} is used to get information about a particular type of unit, such as its cost,
* build time, weapon, hit points, abilities, etc.
*
* @see Unit#getType
*/
public enum UnitType {
Terran_Marine(0),
Terran_Ghost(1),
Terran_Vulture(2),
Terran_Goliath(3),
Terran_Goliath_Turret(4),
Terran_Siege_Tank_Tank_Mode(5),
Terran_Siege_Tank_Tank_Mode_Turret(6),
Terran_SCV(7),
Terran_Wraith(8),
Terran_Science_Vessel(9),
Hero_Gui_Montag(10),
Terran_Dropship(11),
Terran_Battlecruiser(12),
Terran_Vulture_Spider_Mine(13),
Terran_Nuclear_Missile(14),
Terran_Civilian(15),
Hero_Sarah_Kerrigan(16),
Hero_Alan_Schezar(17),
Hero_Alan_Schezar_Turret(18),
Hero_Jim_Raynor_Vulture(19),
Hero_Jim_Raynor_Marine(20),
Hero_Tom_Kazansky(21),
Hero_Magellan(22),
Hero_Edmund_Duke_Tank_Mode(23),
Hero_Edmund_Duke_Tank_Mode_Turret(24),
Hero_Edmund_Duke_Siege_Mode(25),
Hero_Edmund_Duke_Siege_Mode_Turret(26),
Hero_Arcturus_Mengsk(27),
Hero_Hyperion(28),
Hero_Norad_II(29),
Terran_Siege_Tank_Siege_Mode(30),
Terran_Siege_Tank_Siege_Mode_Turret(31),
Terran_Firebat(32),
Spell_Scanner_Sweep(33),
Terran_Medic(34),
Zerg_Larva(35),
Zerg_Egg(36),
Zerg_Zergling(37),
Zerg_Hydralisk(38),
Zerg_Ultralisk(39),
Zerg_Broodling(40),
Zerg_Drone(41),
Zerg_Overlord(42),
Zerg_Mutalisk(43),
Zerg_Guardian(44),
Zerg_Queen(45),
Zerg_Defiler(46),
Zerg_Scourge(47),
Hero_Torrasque(48),
Hero_Matriarch(49),
Zerg_Infested_Terran(50),
Hero_Infested_Kerrigan(51),
Hero_Unclean_One(52),
Hero_Hunter_Killer(53),
Hero_Devouring_One(54),
Hero_Kukulza_Mutalisk(55),
Hero_Kukulza_Guardian(56),
Hero_Yggdrasill(57),
Terran_Valkyrie(58),
Zerg_Cocoon(59),
Protoss_Corsair(60),
Protoss_Dark_Templar(61),
Zerg_Devourer(62),
Protoss_Dark_Archon(63),
Protoss_Probe(64),
Protoss_Zealot(65),
Protoss_Dragoon(66),
Protoss_High_Templar(67),
Protoss_Archon(68),
Protoss_Shuttle(69),
Protoss_Scout(70),
Protoss_Arbiter(71),
Protoss_Carrier(72),
Protoss_Interceptor(73),
Hero_Dark_Templar(74),
Hero_Zeratul(75),
Hero_Tassadar_Zeratul_Archon(76),
Hero_Fenix_Zealot(77),
Hero_Fenix_Dragoon(78),
Hero_Tassadar(79),
Hero_Mojo(80),
Hero_Warbringer(81),
Hero_Gantrithor(82),
Protoss_Reaver(83),
Protoss_Observer(84),
Protoss_Scarab(85),
Hero_Danimoth(86),
Hero_Aldaris(87),
Hero_Artanis(88),
Critter_Rhynadon(89),
Critter_Bengalaas(90),
Special_Cargo_Ship(91),
Special_Mercenary_Gunship(92),
Critter_Scantid(93),
Critter_Kakaru(94),
Critter_Ragnasaur(95),
Critter_Ursadon(96),
Zerg_Lurker_Egg(97),
Hero_Raszagal(98),
Hero_Samir_Duran(99),
Hero_Alexei_Stukov(100),
Special_Map_Revealer(101),
Hero_Gerard_DuGalle(102),
Zerg_Lurker(103),
Hero_Infested_Duran(104),
Spell_Disruption_Web(105),
Terran_Command_Center(106),
Terran_Comsat_Station(107),
Terran_Nuclear_Silo(108),
Terran_Supply_Depot(109),
Terran_Refinery(110),
Terran_Barracks(111),
Terran_Academy(112),
Terran_Factory(113),
Terran_Starport(114),
Terran_Control_Tower(115),
Terran_Science_Facility(116),
Terran_Covert_Ops(117),
Terran_Physics_Lab(118),
Unused_Terran1(119),
Terran_Machine_Shop(120),
Unused_Terran2(121),
Terran_Engineering_Bay(122),
Terran_Armory(123),
Terran_Missile_Turret(124),
Terran_Bunker(125),
Special_Crashed_Norad_II(126),
Special_Ion_Cannon(127),
Powerup_Uraj_Crystal(128),
Powerup_Khalis_Crystal(129),
Zerg_Infested_Command_Center(130),
Zerg_Hatchery(131),
Zerg_Lair(132),
Zerg_Hive(133),
Zerg_Nydus_Canal(134),
Zerg_Hydralisk_Den(135),
Zerg_Defiler_Mound(136),
Zerg_Greater_Spire(137),
Zerg_Queens_Nest(138),
Zerg_Evolution_Chamber(139),
Zerg_Ultralisk_Cavern(140),
Zerg_Spire(141),
Zerg_Spawning_Pool(142),
Zerg_Creep_Colony(143),
Zerg_Spore_Colony(144),
Unused_Zerg1(145),
Zerg_Sunken_Colony(146),
Special_Overmind_With_Shell(147),
Special_Overmind(148),
Zerg_Extractor(149),
Special_Mature_Chrysalis(150),
Special_Cerebrate(151),
Special_Cerebrate_Daggoth(152),
Unused_Zerg2(153),
Protoss_Nexus(154),
Protoss_Robotics_Facility(155),
Protoss_Pylon(156),
Protoss_Assimilator(157),
Unused_Protoss1(158),
Protoss_Observatory(159),
Protoss_Gateway(160),
Unused_Protoss2(161),
Protoss_Photon_Cannon(162),
Protoss_Citadel_of_Adun(163),
Protoss_Cybernetics_Core(164),
Protoss_Templar_Archives(165),
Protoss_Forge(166),
Protoss_Stargate(167),
Special_Stasis_Cell_Prison(168),
Protoss_Fleet_Beacon(169),
Protoss_Arbiter_Tribunal(170),
Protoss_Robotics_Support_Bay(171),
Protoss_Shield_Battery(172),
Special_Khaydarin_Crystal_Form(173),
Special_Protoss_Temple(174),
Special_XelNaga_Temple(175),
Resource_Mineral_Field(176),
Resource_Mineral_Field_Type_2(177),
Resource_Mineral_Field_Type_3(178),
Unused_Cave(179),
Unused_Cave_In(180),
Unused_Cantina(181),
Unused_Mining_Platform(182),
Unused_Independant_Command_Center(183),
Special_Independant_Starport(184),
Unused_Independant_Jump_Gate(185),
Unused_Ruins(186),
Unused_Khaydarin_Crystal_Formation(187),
Resource_Vespene_Geyser(188),
Special_Warp_Gate(189),
Special_Psi_Disrupter(190),
Unused_Zerg_Marker(191),
Unused_Terran_Marker(192),
Unused_Protoss_Marker(193),
Special_Zerg_Beacon(194),
Special_Terran_Beacon(195),
Special_Protoss_Beacon(196),
Special_Zerg_Flag_Beacon(197),
Special_Terran_Flag_Beacon(198),
Special_Protoss_Flag_Beacon(199),
Special_Power_Generator(200),
Special_Overmind_Cocoon(201),
Spell_Dark_Swarm(202),
Special_Floor_Missile_Trap(203),
Special_Floor_Hatch(204),
Special_Upper_Level_Door(205),
Special_Right_Upper_Level_Door(206),
Special_Pit_Door(207),
Special_Right_Pit_Door(208),
Special_Floor_Gun_Trap(209),
Special_Wall_Missile_Trap(210),
Special_Wall_Flame_Trap(211),
Special_Right_Wall_Missile_Trap(212),
Special_Right_Wall_Flame_Trap(213),
Special_Start_Location(214),
Powerup_Flag(215),
Powerup_Young_Chrysalis(216),
Powerup_Psi_Emitter(217),
Powerup_Data_Disk(218),
Powerup_Khaydarin_Crystal(219),
Powerup_Mineral_Cluster_Type_1(220),
Powerup_Mineral_Cluster_Type_2(221),
Powerup_Protoss_Gas_Orb_Type_1(222),
Powerup_Protoss_Gas_Orb_Type_2(223),
Powerup_Zerg_Gas_Sac_Type_1(224),
Powerup_Zerg_Gas_Sac_Type_2(225),
Powerup_Terran_Gas_Tank_Type_1(226),
Powerup_Terran_Gas_Tank_Type_2(227),
None(228),
AllUnits(229),
Men(230),
Buildings(231),
Factories(232),
Unknown(233);
static final UnitType[] idToEnum = new UnitType[233 + 1];
static {
Arrays.stream(UnitType.values()).forEach(v -> idToEnum[v.id] = v);
}
final int id;
UnitType(final int id) {
this.id = id;
}
/**
* Retrieves the maximum unit width from the set of all units. Used
* internally to search through unit positions efficiently.
*
* @return The maximum width of all unit types, in pixels.
*/
public static int maxUnitWidth() {
return Arrays.stream(UnitType.values()).max(Comparator.comparingInt(UnitType::width)).get().width();
}
/**
* Retrieves the maximum unit height from the set of all units. Used
* internally to search through unit positions efficiently.
*
* @return The maximum height of all unit types, in pixels.
*/
public static int maxUnitHeight() {
return Arrays.stream(UnitType.values()).max(Comparator.comparingInt(UnitType::height)).get().height();
}
/**
* Retrieves the {@link Race} that the unit type belongs to.
*
* @return {@link Race} indicating the race that owns this unit type.
* Returns {@link Race#None} indicating that the unit type does not belong to any particular race (a
* critter for example).
*/
public Race getRace() {
return UnitTypeContainer.unitRace[id];
}
/**
* Obtains the source unit type that is used to build or train this unit type, as well as the
* amount of them that are required.
*
* @return std#pair in which the first value is the {@link UnitType} that builds this unit type, and
* the second value is the number of those types that are required (this value is 2 for @Archons, and 1 for all other types).
* Returns pair({@link UnitType#None},0) If this unit type cannot be made by the player.
*/
public Pair<UnitType, Integer> whatBuilds() {
// Retrieve the type
final UnitType type = UnitTypeContainer.whatBuilds[id];
int count = 1;
// Set count to 0 if there is no whatBuilds and 2 if it's an archon
if (type == UnitType.None) {
count = 0;
} else if (this == UnitType.Protoss_Archon || this == UnitType.Protoss_Dark_Archon) {
count = 2;
}
// Return the desired pair
return new Pair<>(type, count);
}
/**
* Retrieves the immediate technology tree requirements to make this unit type.
*
* @return Map containing a UnitType to number mapping of UnitTypes required.
*/
public Map<UnitType, Integer> requiredUnits() {
return UnitTypeContainer.reqUnitsMap.get(id);
}
/**
* Identifies the required {@link TechType} in order to create certain units.
* <p>
* The only unit that requires a technology is the @Lurker, which needs @Lurker_Aspect.
*
* @return {@link TechType} indicating the technology that must be researched in order to create this
* unit type.
* Returns {@link TechType#None} If creating this unit type does not require a technology to be
* researched.
*/
public TechType requiredTech() {
return this == Zerg_Lurker || this == Zerg_Lurker_Egg ? Lurker_Aspect : TechType.None;
}
/**
* Retrieves the cloaking technology associated with certain units.
*
* @return {@link TechType} referring to the cloaking technology that this unit type uses as an
* ability.
* Returns {@link TechType#None} If this unit type does not have an active cloak ability.
*/
public TechType cloakingTech() {
switch (this) {
case Terran_Ghost:
case Hero_Alexei_Stukov:
case Hero_Infested_Duran:
case Hero_Infested_Kerrigan:
case Hero_Sarah_Kerrigan:
case Hero_Samir_Duran:
return Personnel_Cloaking;
case Terran_Wraith:
case Hero_Tom_Kazansky:
return Cloaking_Field;
default:
return TechType.None;
}
}
/**
* Retrieves the set of abilities that this unit can use, provided it is available to you in
* the game.
*
* @return List of TechTypes containing ability information.
*/
public List<TechType> abilities() {
return Collections.unmodifiableList(Arrays.asList(UnitTypeContainer.unitTechs[id]));
}
/**
* Retrieves the set of upgrades that this unit can use to enhance its fighting ability.
*
* @return List of UpgradeTypes containing upgrade types that will impact this unit type.
*/
public List<UpgradeType> upgrades() {
return Collections.unmodifiableList(Arrays.asList(UnitTypeContainer.upgrades[id]));
}
/**
* Retrieves the upgrade type used to increase the armor of this unit type. For each upgrade,
* this unit type gains +1 additional armor.
*
* @return {@link UpgradeType} indicating the upgrade that increases this unit type's armor amount.
*/
public UpgradeType armorUpgrade() {
return UnitTypeContainer.armorUpgrade[id];
}
/**
* Retrieves the default maximum amount of hit points that this unit type can have.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return Integer indicating the maximum amount of hit points for this unit type.
*/
public int maxHitPoints() {
return UnitTypeContainer.defaultMaxHP[id];
}
/**
* Retrieves the default maximum amount of shield points that this unit type can have.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return Integer indicating the maximum amount of shield points for this unit type.
* Returns 0 if this unit type does not have shields.
*/
public int maxShields() {
return UnitTypeContainer.defaultMaxSP[id];
}
/**
* Retrieves the maximum amount of energy this unit type can have by default.
*
* @return Integer indicating the maximum amount of energy for this unit type.
* Retunrs 0 ff this unit does not gain energy for abilities.
*/
public int maxEnergy() {
return isSpellcaster() ? isHero() ? 250 : 200 : 0;
}
/**
* Retrieves the default amount of armor that the unit type starts with, excluding upgrades.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return The amount of armor the unit type has.
*/
public int armor() {
return UnitTypeContainer.defaultArmorAmount[id];
}
/**
* Retrieves the default mineral price of purchasing the unit.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return Mineral cost of the unit.
*/
public int mineralPrice() {
return UnitTypeContainer.defaultOreCost[id];
}
/**
* Retrieves the default vespene gas price of purchasing the unit.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return Vespene gas cost of the unit.
*/
public int gasPrice() {
return UnitTypeContainer.defaultGasCost[id];
}
/**
* Retrieves the default time, in frames, needed to train, morph, or build the unit.
* <p>
* This value may not necessarily match the value seen in the @UMS game type.
*
* @return Number of frames needed in order to build the unit.
* @see Unit#getRemainingBuildTime
*/
public int buildTime() {
return UnitTypeContainer.defaultTimeCost[id];
}
/**
* Retrieves the amount of supply that this unit type will use when created. It will use the
* supply pool that is appropriate for its Race.
* <p>
* In Starcraft programming, the managed supply values are double than what they appear
* in the game. The reason for this is because @Zerglings use 0.5 visible supply.
*
* @return Integer containing the supply required to build this unit.
* @see #supplyProvided
* @see Player#supplyTotal
* @see Player#supplyUsed
*/
public int supplyRequired() {
return UnitTypeContainer.unitSupplyRequired[id];
}
/**
* Retrieves the amount of supply that this unit type produces for its appropriate Race's
* supply pool.
* <p>
* In Starcraft programming, the managed supply values are double than what they appear
* in the game. The reason for this is because @Zerglings use 0.5 visible supply.
*
* @see #supplyRequired
* @see Player#supplyTotal
* @see Player#supplyUsed
*/
public int supplyProvided() {
return UnitTypeContainer.unitSupplyProvided[id];
}
/**
* Retrieves the amount of space required by this unit type to fit inside a @Bunker or @Transport.
*
* @return Amount of space required by this unit type for transport.
* Returns 255 If this unit type can not be transported.
* @see #spaceProvided
*/
public int spaceRequired() {
return UnitTypeContainer.unitSpaceRequired[id];
}
/**
* Retrieves the amount of space provided by this @Bunker or @Transport for unit
* transportation.
*
* @return The number of slots provided by this unit type.
* @see #spaceRequired
*/
public int spaceProvided() {
return UnitTypeContainer.unitSpaceProvided[id];
}
/**
* Retrieves the amount of score points awarded for constructing this unit type. This value is
* used for calculating scores in the post-game score screen.
*
* @return Number of points awarded for constructing this unit type.
* @see #destroyScore
*/
public int buildScore() {
return UnitTypeContainer.unitBuildScore[id];
}
/**
* Retrieves the amount of score points awarded for killing this unit type. This value is
* used for calculating scores in the post-game score screen.
*
* @return Number of points awarded for killing this unit type.
* @see #buildScore
*/
public int destroyScore() {
return UnitTypeContainer.unitDestroyScore[id];
}
/**
* Retrieves the UnitSizeType of this unit, which is used in calculations along with weapon
* damage types to determine the amount of damage that will be dealt to this type.
*
* @return {@link UnitSizeType} indicating the conceptual size of the unit type.
* @see WeaponType#damageType()
*/
public UnitSizeType size() {
return UnitTypeContainer.unitSize[id];
}
/**
* Retrieves the width of this unit type, in tiles. Used for determining the tile size of
* structures.
*
* @return Width of this unit type, in tiles.
*/
public int tileWidth() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.tileWidth];
}
/**
* Retrieves the height of this unit type, in tiles. Used for determining the tile size of
* structures.
*
* @return Height of this unit type, in tiles.
*/
public int tileHeight() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.tileHeight];
}
/**
* Retrieves the tile size of this unit type. Used for determining the tile size of
* structures.
*
* @return {@link TilePosition} containing the width (x) and height (y) of the unit type, in tiles.
*/
public TilePosition tileSize() {
return new TilePosition(tileWidth(), tileHeight());
}
/**
* Retrieves the distance from the center of the unit type to its left edge.
*
* @return Distance to this unit type's left edge from its center, in pixels.
*/
public int dimensionLeft() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.left];
}
/**
* Retrieves the distance from the center of the unit type to its top edge.
*
* @return Distance to this unit type's top edge from its center, in pixels.
*/
public int dimensionUp() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.up];
}
/**
* Retrieves the distance from the center of the unit type to its right edge.
*
* @return Distance to this unit type's right edge from its center, in pixels.
*/
public int dimensionRight() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.right];
}
/**
* Retrieves the distance from the center of the unit type to its bottom edge.
*
* @return Distance to this unit type's bottom edge from its center, in pixels.
*/
public int dimensionDown() {
return UnitTypeContainer.unitDimensions[id][UnitTypeContainer.UnitDimensions.down];
}
/**
* A macro for retrieving the width of the unit type, which is calculated using
* dimensionLeft + dimensionRight + 1.
*
* @return Width of the unit, in pixels.
*/
public int width() {
return dimensionLeft() + 1 + dimensionRight();
}
/**
* A macro for retrieving the height of the unit type, which is calculated using
* dimensionUp + dimensionDown + 1.
*
* @return Height of the unit, in pixels.
*/
public int height() {
return dimensionUp() + 1 + dimensionDown();
}
/**
* Retrieves the range at which this unit type will start targeting enemy units.
*
* @return Distance at which this unit type begins to seek out enemy units, in pixels.
*/
public int seekRange() {
return UnitTypeContainer.seekRangeTiles[id] * 32;
}
/**
* Retrieves the sight range of this unit type.
*
* @return Sight range of this unit type, measured in pixels.
*/
public int sightRange() {
return UnitTypeContainer.sightRangeTiles[id] * 32;
}
/**
* Retrieves this unit type's weapon type used when attacking targets on the ground.
*
* @return {@link WeaponType} used as this unit type's ground weapon.
* @see #maxGroundHits
* @see #airWeapon
*/
public WeaponType groundWeapon() {
return UnitTypeContainer.groundWeapon[id];
}
/**
* Retrieves the maximum number of hits this unit can deal to a ground target using its
* ground weapon. This value is multiplied by the ground weapon's damage to calculate the
* unit type's damage potential.
*
* @return Maximum number of hits given to ground targets.
* @see #groundWeapon
* @see #maxAirHits
*/
public int maxGroundHits() {
return UnitTypeContainer.groundWeaponHits[id];
}
/**
* Retrieves this unit type's weapon type used when attacking targets in the air.
*
* @return WeaponType used as this unit type's air weapon.
* @see #maxAirHits
* @see #groundWeapon
*/
public WeaponType airWeapon() {
return UnitTypeContainer.airWeapon[id];
}
/**
* Retrieves the maximum number of hits this unit can deal to a flying target using its
* air weapon. This value is multiplied by the air weapon's damage to calculate the
* unit type's damage potential.
*
* @return Maximum number of hits given to air targets.
* @see #airWeapon
* @see #maxGroundHits
*/
public int maxAirHits() {
return UnitTypeContainer.airWeaponHits[id];
}
/**
* Retrieves this unit type's top movement speed with no upgrades.
* <p>
* That some units have inconsistent movement and this value is sometimes an
* approximation.
*
* @return The approximate top speed, in pixels per frame, as a double. For liftable @Terran
* structures, this function returns their movement speed while lifted.
*/
public double topSpeed() {
return UnitTypeContainer.unitTopSpeeds[id];
}
/**
* Retrieves the unit's acceleration amount.
*
* @return How fast the unit can accelerate to its top speed.
*/
public int acceleration() {
return UnitTypeContainer.unitAcceleration[id];
}
/**
* Retrieves the unit's halting distance. This determines how fast a unit
* can stop moving.
*
* @return A halting distance value.
*/
public int haltDistance() {
return UnitTypeContainer.unitHaltDistance[id];
}
/**
* Retrieves a unit's turning radius. This determines how fast a unit can
* turn.
*
* @return A turn radius value.
*/
public int turnRadius() {
return UnitTypeContainer.unitTurnRadius[id];
}
/**
* Determines if a unit can train other units. For example,
* UnitType.Terran_Barracks.canProduce() will return true, while
* UnitType.Terran_Marine.canProduce() will return false. This is also true for two
* non-structures: @Carrier (can produce interceptors) and @Reaver (can produce scarabs).
*
* @return true if this unit type can have a production queue, and false otherwise.
*/
public boolean canProduce() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.ProducesUnits) != 0;
}
/**
* Checks if this unit is capable of attacking.
* <p>
* This function returns false for units that can only inflict damage via special
* abilities, such as the @High_Templar.
*
* @return true if this unit type is capable of damaging other units with a standard attack,
* and false otherwise.
*/
public boolean canAttack() {
switch (this) {
case Protoss_Carrier:
case Hero_Gantrithor:
case Protoss_Reaver:
case Hero_Warbringer:
case Terran_Nuclear_Missile:
return true;
case Special_Independant_Starport:
return false;
default:
return airWeapon() != WeaponType.None || groundWeapon() != WeaponType.None;
}
}
/**
* Checks if this unit type is capable of movement.
* <p>
* Buildings will return false, including @Terran liftable buildings which are capable
* of moving when lifted.
*
* @return true if this unit can use a movement command, and false if they cannot move.
*/
public boolean canMove() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.AutoAttackAndMove) != 0;
}
/**
* Checks if this unit type is a flying unit. Flying units ignore ground pathing and
* collisions.
*
* @return true if this unit type is in the air by default, and false otherwise.
*/
public boolean isFlyer() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Flyer) != 0;
}
/**
* Checks if this unit type can regenerate hit points. This generally applies to @Zerg units.
*
* @return true if this unit type regenerates its hit points, and false otherwise.
*/
public boolean regeneratesHP() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.RegeneratesHP) != 0;
}
/**
* Checks if this unit type has the capacity to store energy and use it for special abilities.
*
* @return true if this unit type generates energy, and false if it does not have an energy
* pool.
*/
public boolean isSpellcaster() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Spellcaster) != 0;
}
/**
* Checks if this unit type is permanently cloaked. This means the unit type is always
* cloaked and requires a detector in order to see it.
*
* @return true if this unit type is permanently cloaked, and false otherwise.
*/
public boolean hasPermanentCloak() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.PermanentCloak) != 0;
}
/**
* Checks if this unit type is invincible by default. Invincible units
* cannot take damage.
*
* @return true if this unit type is invincible, and false if it is vulnerable to attacks.
*/
public boolean isInvincible() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Invincible) != 0;
}
/**
* Checks if this unit is an organic unit. The organic property is required for some abilities
* such as @Heal.
*
* @return true if this unit type has the organic property, and false otherwise.
*/
public boolean isOrganic() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.OrganicUnit) != 0;
}
/**
* Checks if this unit is mechanical. The mechanical property is required for some actions
* such as @Repair.
*
* @return true if this unit type has the mechanical property, and false otherwise.
*/
public boolean isMechanical() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Mechanical) != 0;
}
/**
* Checks if this unit is robotic. The robotic property is applied
* to robotic units such as the @Probe which prevents them from taking damage from @Irradiate.
*
* @return true if this unit type has the robotic property, and false otherwise.
*/
public boolean isRobotic() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.RoboticUnit) != 0;
}
/**
* Checks if this unit type is capable of detecting units that are cloaked or burrowed.
*
* @return true if this unit type is a detector by default, false if it does not have this
* property
*/
public boolean isDetector() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Detector) != 0;
}
/**
* Checks if this unit type is capable of storing resources such as @minerals. Resources
* are harvested from resource containers.
*
* @return true if this unit type may contain resources that can be harvested, false
* otherwise.
*/
public boolean isResourceContainer() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.ResourceContainer) != 0;
}
/**
* Checks if this unit type is a resource depot. Resource depots must be placed a certain
* distance from resources. Resource depots are typically the main building for any
* particular race. Workers will return resources to the nearest resource depot.
*
* @return true if the unit type is a resource depot, false if it is not.
*/
public boolean isResourceDepot() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.ResourceDepot) != 0;
}
/**
* Checks if this unit type is a refinery. A refinery is a structure that is placed on top of
* a @geyser . Refinery types are @refinery , @extractor , and @assimilator.
*
* @return true if this unit type is a refinery, and false if it is not.
*/
public boolean isRefinery() {
switch (this) {
case Terran_Refinery:
case Zerg_Extractor:
case Protoss_Assimilator:
return true;
default:
return false;
}
}
/**
* Checks if this unit type is a worker unit. Worker units can harvest resources and build
* structures. Worker unit types include the @SCV , @probe, and @drone.
*
* @return true if this unit type is a worker, and false if it is not.
*/
public boolean isWorker() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Worker) != 0;
}
/**
* Checks if this structure is powered by a psi field. Structures powered
* by psi can only be placed near a @Pylon. If the @Pylon is destroyed, then this unit will
* lose power.
*
* @return true if this unit type can only be placed in a psi field, false otherwise.
*/
public boolean requiresPsi() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.RequiresPsi) != 0;
}
/**
* Checks if this structure must be placed on @Zerg creep.
*
* @return true if this unit type requires creep, false otherwise.
*/
public boolean requiresCreep() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.CreepBuilding) != 0;
}
/**
* Checks if this unit type spawns two units when being hatched from an @Egg.
* This is only applicable to @Zerglings and @Scourges.
*
* @return true if morphing this unit type will spawn two of them, and false if only one
* is spawned.
*/
public boolean isTwoUnitsInOneEgg() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.TwoUnitsIn1Egg) != 0;
}
/**
* Checks if this unit type has the capability to use the @Burrow technology when it
* is researched.
* <p>
* The @Lurker can burrow even without researching the ability.
*
* @return true if this unit can use the @Burrow ability, and false otherwise.
* @see TechType#Burrowing
*/
public boolean isBurrowable() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Burrowable) != 0;
}
/**
* Checks if this unit type has the capability to use a cloaking ability when it
* is researched. This applies only to @Wraiths and @Ghosts, and does not include
* units which are permanently cloaked.
*
* @return true if this unit has a cloaking ability, false otherwise.
* @see #hasPermanentCloak
* @see TechType#Cloaking_Field
* @see TechType#Personnel_Cloaking
*/
public boolean isCloakable() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Cloakable) != 0;
}
/**
* Checks if this unit is a structure. This includes @Mineral_Fields and @Vespene_Geysers.
*
* @return true if this unit is a building, and false otherwise.
*/
public boolean isBuilding() {
return (UnitTypeContainer.unitFlags[id] & UnitTypeContainer.Building) != 0;
}