-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreeps.d.ts
2659 lines (2659 loc) · 106 KB
/
screeps.d.ts
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
/**
* This file is Screeps API description file.
* This might need some updates when Screeps publishes new features or changes it's existing API
*/
declare const OK: 0;
declare const ERR_NOT_OWNER: -1;
declare const ERR_NO_PATH: -2;
declare const ERR_NAME_EXISTS: -3;
declare const ERR_BUSY: -4;
declare const ERR_NOT_FOUND: -5;
declare const ERR_NOT_ENOUGH_RESOURCES: -6;
declare const ERR_NOT_ENOUGH_ENERGY: -6;
declare const ERR_INVALID_TARGET: -7;
declare const ERR_FULL: -8;
declare const ERR_NOT_IN_RANGE: -9;
declare const ERR_INVALID_ARGS: -10;
declare const ERR_TIRED: -11;
declare const ERR_NO_BODYPART: -12;
declare const ERR_NOT_ENOUGH_EXTENSIONS: -6;
declare const ERR_RCL_NOT_ENOUGH: -14;
declare const ERR_GCL_NOT_ENOUGH: -15;
declare const FIND_EXIT_TOP: 1;
declare const FIND_EXIT_RIGHT: 3;
declare const FIND_EXIT_BOTTOM: 5;
declare const FIND_EXIT_LEFT: 7;
declare const FIND_EXIT: 10;
declare const FIND_CREEPS: 101;
declare const FIND_MY_CREEPS: 102;
declare const FIND_HOSTILE_CREEPS: 103;
declare const FIND_SOURCES_ACTIVE: 104;
declare const FIND_SOURCES: 105;
declare const FIND_DROPPED_RESOURCES: 106;
declare const FIND_DROPPED_ENERGY: 106;
declare const FIND_STRUCTURES: 107;
declare const FIND_MY_STRUCTURES: 108;
declare const FIND_HOSTILE_STRUCTURES: 109;
declare const FIND_FLAGS: 110;
declare const FIND_CONSTRUCTION_SITES: 111;
declare const FIND_MY_SPAWNS: 112;
declare const FIND_HOSTILE_SPAWNS: 113;
declare const FIND_MY_CONSTRUCTION_SITES: 114;
declare const FIND_HOSTILE_CONSTRUCTION_SITES: 115;
declare const FIND_MINERALS: 116;
declare const FIND_NUKES: 117;
declare const TOP: 1;
declare const TOP_RIGHT: 2;
declare const RIGHT: 3;
declare const BOTTOM_RIGHT: 4;
declare const BOTTOM: 5;
declare const BOTTOM_LEFT: 6;
declare const LEFT: 7;
declare const TOP_LEFT: 8;
declare const COLOR_RED: 1;
declare const COLOR_PURPLE: 2;
declare const COLOR_BLUE: 3;
declare const COLOR_CYAN: 4;
declare const COLOR_GREEN: 5;
declare const COLOR_YELLOW: 6;
declare const COLOR_ORANGE: 7;
declare const COLOR_BROWN: 8;
declare const COLOR_GREY: 9;
declare const COLOR_WHITE: 10;
declare const COLORS_ALL: number[];
declare const CREEP_SPAWN_TIME: 3;
declare const CREEP_LIFE_TIME: 1500;
declare const CREEP_CLAIM_LIFE_TIME: 500;
declare const CREEP_CORPSE_RATE: 0.2;
declare const OBSTACLE_OBJECT_TYPES: string[];
declare const ENERGY_REGEN_TIME: 300;
declare const ENERGY_DECAY: 1000;
declare const REPAIR_COST: 0.01;
declare const RAMPART_DECAY_AMOUNT: 300;
declare const RAMPART_DECAY_TIME: 100;
declare const RAMPART_HITS: 1;
declare const RAMPART_HITS_MAX: {
2: 300000;
3: 1000000;
4: 3000000;
5: 10000000;
6: 30000000;
7: 100000000;
8: 300000000;
};
declare const SPAWN_HITS: 5000;
declare const SPAWN_ENERGY_START: 300;
declare const SPAWN_ENERGY_CAPACITY: 300;
declare const SOURCE_ENERGY_CAPACITY: 3000;
declare const SOURCE_ENERGY_NEUTRAL_CAPACITY: 1500;
declare const SOURCE_ENERGY_KEEPER_CAPACITY: 4000;
declare const WALL_HITS: 1;
declare const WALL_HITS_MAX: 300000000;
declare const EXTENSION_HITS: 1000;
declare const EXTENSION_ENERGY_CAPACITY: {
0: 50;
1: 50;
2: 50;
3: 50;
4: 50;
5: 50;
6: 50;
7: 100;
8: 200;
};
declare const ROAD_HITS: 5000;
declare const ROAD_WEAROUT: 1;
declare const ROAD_DECAY_AMOUNT: 100;
declare const ROAD_DECAY_TIME: 1000;
declare const LINK_HITS: 1000;
declare const LINK_HITS_MAX: 1000;
declare const LINK_CAPACITY: 800;
declare const LINK_COOLDOWN: 1;
declare const LINK_LOSS_RATIO: 0.03;
declare const STORAGE_CAPACITY: 1000000;
declare const STORAGE_HITS: 10000;
declare const BODYPART_COST: {
[part: string]: number;
move: 50;
work: 100;
attack: 80;
carry: 50;
heal: 250;
ranged_attack: 150;
tough: 10;
claim: 600;
};
declare const BODYPARTS_ALL: string[];
declare const CARRY_CAPACITY: 50;
declare const HARVEST_POWER: 2;
declare const HARVEST_MINERAL_POWER: 1;
declare const REPAIR_POWER: 100;
declare const DISMANTLE_POWER: 50;
declare const BUILD_POWER: 5;
declare const ATTACK_POWER: 30;
declare const UPGRADE_CONTROLLER_POWER: 1;
declare const RANGED_ATTACK_POWER: 10;
declare const HEAL_POWER: 12;
declare const RANGED_HEAL_POWER: 4;
declare const DISMANTLE_COST: 0.005;
declare const MOVE: "move";
declare const WORK: "work";
declare const CARRY: "carry";
declare const ATTACK: "attack";
declare const RANGED_ATTACK: "ranged_attack";
declare const TOUGH: "tough";
declare const HEAL: "heal";
declare const CLAIM: "claim";
declare const CONSTRUCTION_COST: {
spawn: 15000;
extension: 3000;
road: 300;
constructedWall: 1;
rampart: 1;
link: 5000;
storage: 30000;
tower: 5000;
observer: 8000;
powerSpawn: 100000;
extractor: 5000;
lab: 50000;
terminal: 100000;
container: 5000;
nuker: 100000;
};
declare const CONSTRUCTION_COST_ROAD_SWAMP_RATIO: 5;
declare const STRUCTURE_EXTENSION: "extension";
declare const STRUCTURE_RAMPART: "rampart";
declare const STRUCTURE_ROAD: "road";
declare const STRUCTURE_SPAWN: "spawn";
declare const STRUCTURE_LINK: "link";
declare const STRUCTURE_WALL: "wall";
declare const STRUCTURE_KEEPER_LAIR: "keeperLair";
declare const STRUCTURE_CONTROLLER: "controller";
declare const STRUCTURE_STORAGE: "storage";
declare const STRUCTURE_TOWER: "tower";
declare const STRUCTURE_OBSERVER: "observer";
declare const STRUCTURE_POWER_BANK: "powerBank";
declare const STRUCTURE_POWER_SPAWN: "powerSpawn";
declare const STRUCTURE_EXTRACTOR: "extractor";
declare const STRUCTURE_LAB: "lab";
declare const STRUCTURE_TERMINAL: "terminal";
declare const STRUCTURE_CONTAINER: "container";
declare const STRUCTURE_NUKER: "nuker";
declare const STRUCTURE_PORTAL: "portal";
declare const RESOURCE_ENERGY: "energy";
declare const RESOURCE_POWER: "power";
declare const RESOURCE_UTRIUM: "U";
declare const RESOURCE_LEMERGIUM: "L";
declare const RESOURCE_KEANIUM: "K";
declare const RESOURCE_GHODIUM: "G";
declare const RESOURCE_ZYNTHIUM: "Z";
declare const RESOURCE_OXYGEN: "O";
declare const RESOURCE_HYDROGEN: "H";
declare const RESOURCE_CATALYST: "X";
declare const RESOURCE_HYDROXIDE: "OH";
declare const RESOURCE_ZYNTHIUM_KEANITE: "ZK";
declare const RESOURCE_UTRIUM_LEMERGITE: "UL";
declare const RESOURCE_UTRIUM_HYDRIDE: "UH";
declare const RESOURCE_UTRIUM_OXIDE: "UO";
declare const RESOURCE_KEANIUM_HYDRIDE: "KH";
declare const RESOURCE_KEANIUM_OXIDE: "KO";
declare const RESOURCE_LEMERGIUM_HYDRIDE: "LH";
declare const RESOURCE_LEMERGIUM_OXIDE: "LO";
declare const RESOURCE_ZYNTHIUM_HYDRIDE: "ZH";
declare const RESOURCE_ZYNTHIUM_OXIDE: "ZO";
declare const RESOURCE_GHODIUM_HYDRIDE: "GH";
declare const RESOURCE_GHODIUM_OXIDE: "GO";
declare const RESOURCE_UTRIUM_ACID: "UH2O";
declare const RESOURCE_UTRIUM_ALKALIDE: "UHO2";
declare const RESOURCE_KEANIUM_ACID: "KH2O";
declare const RESOURCE_KEANIUM_ALKALIDE: "KHO2";
declare const RESOURCE_LEMERGIUM_ACID: "LH2O";
declare const RESOURCE_LEMERGIUM_ALKALIDE: "LHO2";
declare const RESOURCE_ZYNTHIUM_ACID: "ZH2O";
declare const RESOURCE_ZYNTHIUM_ALKALIDE: "ZHO2";
declare const RESOURCE_GHODIUM_ACID: "GH2O";
declare const RESOURCE_GHODIUM_ALKALIDE: "GHO2";
declare const RESOURCE_CATALYZED_UTRIUM_ACID: "XUH2O";
declare const RESOURCE_CATALYZED_UTRIUM_ALKALIDE: "XUHO2";
declare const RESOURCE_CATALYZED_KEANIUM_ACID: "XKH2O";
declare const RESOURCE_CATALYZED_KEANIUM_ALKALIDE: "XKHO2";
declare const RESOURCE_CATALYZED_LEMERGIUM_ACID: "XLH2O";
declare const RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE: "XLHO2";
declare const RESOURCE_CATALYZED_ZYNTHIUM_ACID: "XZH2O";
declare const RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: "ZXHO2";
declare const RESOURCE_CATALYZED_GHODIUM_ACID: "XGH2O";
declare const RESOURCE_CATALYZED_GHODIUM_ALKALIDE: "XGHO2";
declare const RESOURCES_ALL: string[];
declare const SUBSCRIPTION_TOKEN: string;
declare const CONTROLLER_LEVELS: {
[level: number]: number;
};
declare const CONTROLLER_STRUCTURES: {
[structure: string]: {
[level: number]: number;
};
};
declare const CONTROLLER_DOWNGRADE: {
[level: number]: number;
};
declare const CONTROLLER_CLAIM_DOWNGRADE: number;
declare const CONTROLLER_RESERVE: number;
declare const CONTROLLER_RESERVE_MAX: number;
declare const CONTROLLER_MAX_UPGRADE_PER_TICK: number;
declare const CONTROLLER_ATTACK_BLOCKED_UPGRADE: number;
declare const TOWER_HITS: number;
declare const TOWER_CAPACITY: number;
declare const TOWER_ENERGY_COST: number;
declare const TOWER_POWER_ATTACK: number;
declare const TOWER_POWER_HEAL: number;
declare const TOWER_POWER_REPAIR: number;
declare const TOWER_OPTIMAL_RANGE: number;
declare const TOWER_FALLOFF_RANGE: number;
declare const TOWER_FALLOFF: number;
declare const OBSERVER_HITS: number;
declare const OBSERVER_RANGE: number;
declare const POWER_BANK_HITS: number;
declare const POWER_BANK_CAPACITY_MAX: number;
declare const POWER_BANK_CAPACITY_MIN: number;
declare const POWER_BANK_CAPACITY_CRIT: number;
declare const POWER_BANK_DECAY: number;
declare const POWER_BANK_HIT_BACK: number;
declare const POWER_SPAWN_HITS: number;
declare const POWER_SPAWN_ENERGY_CAPACITY: number;
declare const POWER_SPAWN_POWER_CAPACITY: number;
declare const POWER_SPAWN_ENERGY_RATIO: number;
declare const EXTRACTOR_HITS: number;
declare const LAB_HITS: number;
declare const LAB_MINERAL_CAPACITY: number;
declare const LAB_ENERGY_CAPACITY: number;
declare const LAB_BOOST_ENERGY: number;
declare const LAB_BOOST_MINERAL: number;
declare const LAB_COOLDOWN: number;
declare const LAB_REACTION_AMOUNT: number;
declare const GCL_POW: number;
declare const GCL_MULTIPLY: number;
declare const GCL_NOVICE: number;
declare const MODE_SIMULATION: string;
declare const MODE_SURVIVAL: string;
declare const MODE_WORLD: string;
declare const MODE_ARENA: string;
declare const TERRAIN_MASK_WALL: number;
declare const TERRAIN_MASK_SWAMP: number;
declare const TERRAIN_MASK_LAVA: number;
declare const MAX_CONSTRUCTION_SITES: number;
declare const MAX_CREEP_SIZE: number;
declare const MINERAL_REGEN_TIME: number;
declare const MINERAL_MIN_AMOUNT: {
H: number;
O: number;
L: number;
K: number;
Z: number;
U: number;
X: number;
};
declare const MINERAL_RANDOM_FACTOR: number;
declare const MINERAL_DENSITY: {
1: number;
2: number;
3: number;
4: number;
};
declare const MINERAL_DENSITY_PROBABILITY: {
1: number;
2: number;
3: number;
4: number;
};
declare const MINERAL_DENSITY_CHANGE: number;
declare const DENSITY_LOW: number;
declare const DENSITY_MODERATE: number;
declare const DENSITY_HIGH: number;
declare const DENSITY_ULTRA: number;
declare const TERMINAL_CAPACITY: number;
declare const TERMINAL_HITS: number;
declare const TERMINAL_SEND_COST: number;
declare const TERMINAL_MIN_SEND: number;
declare const TERMINAL_COOLDOWN: number;
declare const CONTAINER_HITS: number;
declare const CONTAINER_CAPACITY: number;
declare const CONTAINER_DECAY: number;
declare const CONTAINER_DECAY_TIME: number;
declare const CONTAINER_DECAY_TIME_OWNED: number;
declare const NUKER_HITS: number;
declare const NUKER_COOLDOWN: number;
declare const NUKER_ENERGY_CAPACITY: number;
declare const NUKER_GHODIUM_CAPACITY: number;
declare const NUKE_LAND_TIME: number;
declare const NUKE_RANGE: number;
declare const NUKE_DAMAGE: {
0: number;
1: number;
4: number;
};
declare const REACTIONS: {
[reagent: string]: {
[reagent: string]: string;
};
};
declare const BOOSTS: {
[part: string]: {
[boost: string]: {
[action: string]: number;
};
};
};
declare const LOOK_CREEPS: "creep";
declare const LOOK_ENERGY: "energy";
declare const LOOK_RESOURCES: "resource";
declare const LOOK_SOURCES: "source";
declare const LOOK_MINERALS: "mineral";
declare const LOOK_STRUCTURES: "structure";
declare const LOOK_FLAGS: "flag";
declare const LOOK_CONSTRUCTION_SITES: "constructionSite";
declare const LOOK_NUKES: "nuke";
declare const LOOK_TERRAIN: "terrain";
declare const ORDER_SELL: "sell";
declare const ORDER_BUY: "buy";
/**
* A site of a structure which is currently under construction.
*/
interface ConstructionSite extends RoomObject {
readonly prototype: ConstructionSite;
/**
* A unique object identifier. You can use Game.getObjectById method to retrieve an object instance by its id.
*/
id: string;
/**
* Whether this is your own construction site.
*/
my: boolean;
/**
* An object with the structure’s owner info
*/
owner: Owner;
/**
* The current construction progress.
*/
progress: number;
/**
* The total construction progress needed for the structure to be built.
*/
progressTotal: number;
/**
* One of the following constants: STRUCTURE_EXTENSION, STRUCTURE_RAMPART, STRUCTURE_ROAD, STRUCTURE_SPAWN, STRUCTURE_WALL, STRUCTURE_LINK
*/
structureType: string;
/**
* Remove the construction site.
* @returns Result Code: OK, ERR_NOT_OWNER
*/
remove(): number;
}
interface ConstructionSiteConstructor extends _Constructor<ConstructionSite>, _ConstructorById<ConstructionSite> {
}
declare const ConstructionSite: ConstructionSiteConstructor;
declare var Memory: Memory;
declare var RawMemory: RawMemory;
declare var Game: Game;
declare var PathFinder: PathFinder;
declare function gc(): void;
declare type Controller = StructureController;
declare type Extension = StructureExtension;
declare type KeeperLair = StructureKeeperLair;
declare type Lab = StructureLab;
declare type Link = StructureLink;
declare type Observer = StructureObserver;
declare type PowerBank = StructurePowerBank;
declare type PowerSpawn = StructurePowerSpawn;
declare type Rampart = StructureRampart;
declare type Terminal = StructureTerminal;
declare type Container = StructureContainer;
declare type Tower = StructureTower;
declare type Spawn = StructureSpawn;
declare const Spawn: StructureSpawnConstructor;
interface Storage extends StructureStorage {
}
/**
* Creeps are your units. Creeps can move, harvest energy, construct structures, attack another creeps, and perform other actions. Each creep consists of up to 50 body parts with the following possible types:
*/
interface Creep extends RoomObject {
readonly prototype: Creep;
/**
* An array describing the creep’s body. Each element contains the following properties:
* type: string
* body part constant
* hits: number
* The remaining amount of hit points of this body part.
*/
body: BodyPartDefinition[];
/**
* An object with the creep's cargo contents:
* energy: number
* The current amount of energy the creep is carrying.
*/
carry: StoreDefinition;
/**
* The total amount of resources the creep can carry.
*/
carryCapacity: number;
/**
* The movement fatigue indicator. If it is greater than zero, the creep cannot move.
*/
fatigue: number;
/**
* The current amount of hit points of the creep.
*/
hits: number;
/**
* The maximum amount of hit points of the creep.
*/
hitsMax: number;
/**
* A unique object identifier. You can use Game.getObjectById method to retrieve an object instance by its id.
*/
id: string;
/**
* A shorthand to Memory.creeps[creep.name]. You can use it for quick access the creep’s specific memory data object.
*/
memory: any;
/**
* Whether it is your creep or foe.
*/
my: boolean;
/**
* Creep’s name. You can choose the name while creating a new creep, and it cannot be changed later. This name is a hash key to access the creep via the Game.creeps object.
*/
name: string;
/**
* An object with the creep’s owner info
*/
owner: Owner;
/**
* The link to the Room object. Always defined because creeps give visibility into the room they're in.
*/
room: Room;
/**
* Whether this creep is still being spawned.
*/
spawning: boolean;
/**
* The text message that the creep was saying at the last tick.
*/
saying: string;
/**
* The remaining amount of game ticks after which the creep will die.
*/
ticksToLive: number;
/**
* Attack another creep or structure in a short-ranged attack. Needs the ATTACK body part. If the target is inside a rampart, then the rampart is attacked instead. The target has to be at adjacent square to the creep. If the target is a creep with ATTACK body parts and is not inside a rampart, it will automatically hit back at the attacker.
* @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE, ERR_NO_BODYPART
*/
attack(target: Creep | Structure): number;
/**
* Decreases the controller's downgrade or reservation timer for 1 tick per every 5 CLAIM body parts (so the creep must have at least 5xCLAIM). The controller under attack cannot be upgraded for the next 1,000 ticks. The target has to be at adjacent square to the creep.
* @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE, ERR_NO_BODYPART
*/
attackController(target: Controller): number;
/**
* Build a structure at the target construction site using carried energy. Needs WORK and CARRY body parts. The target has to be within 3 squares range of the creep.
* @param target The target object to be attacked.
* @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_NOT_ENOUGH_RESOURCES, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE, ERR_NO_BODYPART, ERR_RCL_NOT_ENOUGH
*/
build(target: ConstructionSite): number;
/**
* Cancel the order given during the current game tick.
* @param methodName The name of a creep's method to be cancelled.
* @returns Result Code: OK, ERR_NOT_FOUND
*/
cancelOrder(methodName: string): number;
/**
* Requires the CLAIM body part. If applied to a neutral controller, claims it under your control. If applied to a hostile controller, decreases its downgrade or reservation timer depending on the CLAIM body parts count. The target has to be at adjacent square to the creep.
* @param target The target controller object.
* @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_INVALID_TARGET, ERR_FULL, ERR_NOT_IN_RANGE, ERR_NO_BODYPART, ERR_GCL_NOT_ENOUGH
*/
claimController(target: Controller): number;
/**
* Dismantles any (even hostile) structure returning 50% of the energy spent on its repair. Requires the WORK body part. If the creep has an empty CARRY body part, the energy is put into it; otherwise it is dropped on the ground. The target has to be at adjacent square to the creep.
* @param target The target structure.
*/
dismantle(target: Structure): number;
/**
* Drop this resource on the ground.
* @param resourceType One of the RESOURCE_* constants.
* @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used.
*/
drop(resourceType: string, amount?: number): number;
/**
* Add one more available safe mode activation to a room controller. The creep has to be at adjacent square to the target room controller and have 1000 ghodium resource.
* @param target The target room controller.
* @returns Result Code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_NOT_ENOUGH_RESOURCES, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE
*/
generateSafeMode(target: Controller): number;
/**
* Get the quantity of live body parts of the given type. Fully damaged parts do not count.
* @param type A body part type, one of the following body part constants: MOVE, WORK, CARRY, ATTACK, RANGED_ATTACK, HEAL, TOUGH, CLAIM
*/
getActiveBodyparts(type: string): number;
/**
* Harvest energy from the source. Needs the WORK body part. If the creep has an empty CARRY body part, the harvested energy is put into it; otherwise it is dropped on the ground. The target has to be at an adjacent square to the creep.
* @param target The source object to be harvested.
*/
harvest(target: Source | Mineral): number;
/**
* Heal self or another creep. It will restore the target creep’s damaged body parts function and increase the hits counter. Needs the HEAL body part. The target has to be at adjacent square to the creep.
* @param target The target creep object.
*/
heal(target: Creep): number;
/**
* Move the creep one square in the specified direction. Needs the MOVE body part.
* @param direction
*/
move(direction: number): number;
/**
* Move the creep using the specified predefined path. Needs the MOVE body part.
* @param path A path value as returned from Room.findPath or RoomPosition.findPathTo methods. Both array form and serialized string form are accepted.
*/
moveByPath(path: PathStep[] | RoomPosition[] | string): number;
/**
* Find the optimal path to the target within the same room and move to it. A shorthand to consequent calls of pos.findPathTo() and move() methods. If the target is in another room, then the corresponding exit will be used as a target. Needs the MOVE body part.
* @param x X position of the target in the room.
* @param y Y position of the target in the room.
* @param opts An object containing pathfinding options flags (see Room.findPath for more info) or one of the following: reusePath, serializeMemory, noPathFinding
*/
moveTo(x: number, y: number, opts?: MoveToOpts): number;
/**
* Find the optimal path to the target within the same room and move to it. A shorthand to consequent calls of pos.findPathTo() and move() methods. If the target is in another room, then the corresponding exit will be used as a target. Needs the MOVE body part.
* @param target Can be a RoomPosition object or any object containing RoomPosition.
* @param opts An object containing pathfinding options flags (see Room.findPath for more info) or one of the following: reusePath, serializeMemory, noPathFinding
*/
moveTo(target: RoomPosition | {
pos: RoomPosition;
}, opts?: MoveToOpts): number;
/**
* Toggle auto notification when the creep is under attack. The notification will be sent to your account email. Turned on by default.
* @param enabled Whether to enable notification or disable.
*/
notifyWhenAttacked(enabled: boolean): number;
/**
* Pick up an item (a dropped piece of energy). Needs the CARRY body part. The target has to be at adjacent square to the creep or at the same square.
* @param target The target object to be picked up.
*/
pickup(target: Resource): number;
/**
* A ranged attack against another creep or structure. Needs the RANGED_ATTACK body part. If the target is inside a rampart, the rampart is attacked instead. The target has to be within 3 squares range of the creep.
* @param target The target object to be attacked.
*/
rangedAttack(target: Creep | Structure): number;
/**
* Heal another creep at a distance. It will restore the target creep’s damaged body parts function and increase the hits counter. Needs the HEAL body part. The target has to be within 3 squares range of the creep.
* @param target The target creep object.
*/
rangedHeal(target: Creep): number;
/**
* A ranged attack against all hostile creeps or structures within 3 squares range. Needs the RANGED_ATTACK body part. The attack power depends on the range to each target. Friendly units are not affected.
*/
rangedMassAttack(): number;
/**
* Repair a damaged structure using carried energy. Needs the WORK and CARRY body parts. The target has to be within 3 squares range of the creep.
* @param target he target structure to be repaired.
*/
repair(target: Structure): number;
/**
* Temporarily block a neutral controller from claiming by other players. Each tick, this command increases the counter of the period during which the controller is unavailable by 1 tick per each CLAIM body part. The maximum reservation period to maintain is 5,000 ticks. The target has to be at adjacent square to the creep....
* @param target The target controller object to be reserved.
* @return Result code: OK, ERR_NOT_OWNER, ERR_BUSY, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE, ERR_NO_BODYPART
*/
reserveController(target: Controller): number;
/**
* Display a visual speech balloon above the creep with the specified message. The message will disappear after a few seconds. Useful for debugging purposes. Only the creep's owner can see the speech message.
* @param message The message to be displayed. Maximum length is 10 characters.
* @param set to 'true' to allow other players to see this message. Default is 'false'.
*/
say(message: string, toPublic?: boolean): number;
/**
* Sign a controller with a random text visible to all players. This text will appear in the room UI, in the world map, and can be accessed via the API.
* You can sign unowned and hostile controllers. The target has to be at adjacent square to the creep. Pass an empty string to remove the sign.
* @param target The target controller object to be signed.
* @param text The sign text. The maximum text length is 100 characters.
* @returns Result Code: OK, ERR_BUSY, ERR_INVALID_TARGET, ERR_NOT_IN_RANGE
*/
signController(target: Controller, text: string): number;
/**
* Kill the creep immediately.
*/
suicide(): number;
/**
* Transfer resource from the creep to another object. The target has to be at adjacent square to the creep.
* @param target The target object.
* @param resourceType One of the RESOURCE_* constants
* @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used.
*/
transfer(target: Creep | Structure, resourceType: string, amount?: number): number;
/**
* Upgrade your controller to the next level using carried energy. Upgrading controllers raises your Global Control Level in parallel. Needs WORK and CARRY body parts. The target has to be at adjacent square to the creep. A fully upgraded level 8 controller can't be upgraded with the power over 15 energy units per tick regardless of creeps power. The cumulative effect of all the creeps performing upgradeController in the current tick is taken into account.
* @param target The target controller object to be upgraded.
*/
upgradeController(target: Controller): number;
/**
* Withdraw resources from a structure. The target has to be at adjacent square to the creep. Multiple creeps can withdraw from the same structure in the same tick. Your creeps can withdraw resources from hostile structures as well, in case if there is no hostile rampart on top of it.
* @param target The target object.
* @param resourceType The target One of the RESOURCE_* constants..
* @param amount The amount of resources to be transferred. If omitted, all the available amount is used.
*/
withdraw(target: Structure, resourceType: string, amount?: number): number;
}
interface CreepConstructor extends _Constructor<Creep>, _ConstructorById<Creep> {
}
declare const Creep: CreepConstructor;
/**
* A flag. Flags can be used to mark particular spots in a room. Flags are visible to their owners only.
*/
interface Flag extends RoomObject {
readonly prototype: Flag;
/**
* Flag color. One of the following constants: COLOR_WHITE, COLOR_GREY, COLOR_RED, COLOR_PURPLE, COLOR_BLUE, COLOR_CYAN, COLOR_GREEN, COLOR_YELLOW, COLOR_ORANGE, COLOR_BROWN
*/
color: number;
/**
* A shorthand to Memory.flags[flag.name]. You can use it for quick access the flag's specific memory data object.
*/
memory: any;
/**
* Flag’s name. You can choose the name while creating a new flag, and it cannot be changed later. This name is a hash key to access the spawn via the Game.flags object.
*/
name: string;
/**
* Flag secondary color. One of the COLOR_* constants.
*/
secondaryColor: number;
/**
* Remove the flag.
* @returns Result Code: OK
*/
remove(): number;
/**
* Set new color of the flag.
* @param color One of the following constants: COLOR_WHITE, COLOR_GREY, COLOR_RED, COLOR_PURPLE, COLOR_BLUE, COLOR_CYAN, COLOR_GREEN, COLOR_YELLOW, COLOR_ORANGE, COLOR_BROWN
* @parma secondaryColor Secondary color of the flag. One of the COLOR_* constants.
* @returns Result Code: OK, ERR_INVALID_ARGS
*/
setColor(color: number, secondaryColor?: number): number;
/**
* Set new position of the flag.
* @param x The X position in the room.
* @param y The Y position in the room.
* @returns Result Code: OK, ERR_INVALID_TARGET
*/
setPosition(x: number, y: number): number;
/**
* Set new position of the flag.
* @param pos Can be a RoomPosition object or any object containing RoomPosition.
* @returns Result Code: OK, ERR_INVALID_TARGET
*/
setPosition(pos: RoomPosition | {
pos: RoomPosition;
}): number;
}
interface FlagConstructor extends _Constructor<Flag> {
new (name: string, color: number, secondaryColor: number, roomName: string, x: number, y: number): Flag;
(name: string, color: number, secondaryColor: number, roomName: string, x: number, y: number): Flag;
}
declare const Flag: FlagConstructor;
/**
* The main global game object containing all the gameplay information.
*/
interface Game {
/**
* An object containing information about your CPU usage with the following properties:
*/
cpu: CPU;
/**
* A hash containing all your creeps with creep names as hash keys.
*/
creeps: {
[creepName: string]: Creep;
};
/**
* A hash containing all your flags with flag names as hash keys.
*/
flags: {
[flagName: string]: Flag;
};
/**
* Your Global Control Level, an object with the following properties :
*/
gcl: GlobalControlLevel;
/**
* A global object representing world GameMap.
*/
map: GameMap;
/**
* A global object representing the in-game market.
*/
market: Market;
/**
* A hash containing all the rooms available to you with room names as hash keys.
*/
rooms: {
[roomName: string]: Room;
};
/**
* A hash containing all your spawns with spawn names as hash keys.
*/
spawns: {
[spawnName: string]: Spawn;
};
/**
* A hash containing all your structures with structure id as hash keys.
*/
structures: {
[structureId: string]: Structure;
};
/**
* A hash containing all your construction sites with their id as hash keys.
*/
constructionSites: {
[constructionSiteId: string]: ConstructionSite;
};
/**
* System game tick counter. It is automatically incremented on every tick.
*/
time: number;
/**
* Get an object with the specified unique ID. It may be a game object of any type. Only objects from the rooms which are visible to you can be accessed.
* @param id The unique identifier.
* @returns an object instance or null if it cannot be found.
*/
getObjectById<T>(id: string | undefined): T | null;
/**
* Send a custom message at your profile email. This way, you can set up notifications to yourself on any occasion within the game. You can schedule up to 20 notifications during one game tick. Not available in the Simulation Room.
* @param message Custom text which will be sent in the message. Maximum length is 1000 characters.
* @param groupInterval If set to 0 (default), the notification will be scheduled immediately. Otherwise, it will be grouped with other notifications and mailed out later using the specified time in minutes.
*/
notify(message: string, groupInterval?: number): void;
}
interface GlobalControlLevel {
level: number;
progress: number;
progressTotal: number;
}
interface HeapStatistics {
total_heap_size: number;
total_heap_size_executable: number;
total_physical_size: number;
total_available_size: number;
used_heap_size: number;
heap_size_limit: number;
malloced_memory: number;
peak_malloced_memory: number;
does_zap_garbage: 0 | 1;
externally_allocated_size: number;
}
interface CPU {
limit: number;
tickLimit: number;
bucket: number;
/**
* Get amount of CPU time used from the beginning of the current game tick. Always returns 0 in the Simulation mode.
*/
getUsed(): number;
getHeapStatistics(): HeapStatistics;
}
/**
* An array describing the creep’s body. Each element contains the following properties:
*/
interface BodyPartDefinition {
/**
* If the body part is boosted, this property specifies the mineral type which is used for boosting. One of the RESOURCE_* constants.
*/
boost: string;
/**
* One of the body part types constants.
*/
type: string;
/**
* The remaining amount of hit points of this body part.
*/
hits: number;
}
interface Owner {
username: string;
}
interface ReservationDefinition {
username: string;
ticksToEnd: number;
}
interface SignDefinition {
username: string;
text: string;
time: number;
datetime: Date;
}
interface StoreDefinition {
[resource: string]: number | undefined;
energy?: number;
power?: number;
}
interface LookAtResultWithPos {
x: number;
y: number;
type: string;
constructionSite?: ConstructionSite;
creep?: Creep;
terrain?: string;
structure?: Structure;
flag?: Flag;
energy?: Resource;
exit?: any;
source?: Source;
mineral?: Mineral;
resource?: Resource;
}
interface LookAtResult {
type: string;
constructionSite?: ConstructionSite;
creep?: Creep;
energy?: Resource;
exit?: any;
flag?: Flag;
source?: Source;
structure?: Structure;
terrain?: string;
mineral?: Mineral;
resource?: Resource;
}
interface LookAtResultMatrix {
[coord: number]: LookAtResultMatrix | LookAtResult[];
}
interface FindPathOpts {
/**
* Treat squares with creeps as walkable. Can be useful with too many moving creeps around or in some other cases. The default
* value is false.
*/
ignoreCreeps?: boolean;
/**
* Treat squares with destructible structures (constructed walls, ramparts, spawns, extensions) as walkable. Use this flag when
* you need to move through a territory blocked by hostile structures. If a creep with an ATTACK body part steps on such a square,
* it automatically attacks the structure. The default value is false.
*/
ignoreDestructibleStructures?: boolean;
/**
* Ignore road structures. Enabling this option can speed up the search. The default value is false. This is only used when the
* new PathFinder is enabled.
*/
ignoreRoads?: boolean;
/**
* You can use this callback to modify a CostMatrix for any room during the search. The callback accepts two arguments, roomName
* and costMatrix. Use the costMatrix instance to make changes to the positions costs. If you return a new matrix from this callback,
* it will be used instead of the built-in cached one. This option is only used when the new PathFinder is enabled.
*
* @param roomName The name of the room.
* @param costMatrix The current CostMatrix
* @returns The new CostMatrix to use
*/
costCallback?(roomName: string, costMatrix: CostMatrix): boolean | CostMatrix;
/**
* An array of the room's objects or RoomPosition objects which should be treated as walkable tiles during the search. This option
* cannot be used when the new PathFinder is enabled (use costCallback option instead).
*/
ignore?: any[] | RoomPosition[];
/**
* An array of the room's objects or RoomPosition objects which should be treated as obstacles during the search. This option cannot
* be used when the new PathFinder is enabled (use costCallback option instead).
*/
avoid?: any[] | RoomPosition[];
/**
* The maximum limit of possible pathfinding operations. You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU.
* The default value is 2000.
*/
maxOps?: number;
/**
* Weight to apply to the heuristic in the A* formula F = G + weight * H. Use this option only if you understand the underlying
* A* algorithm mechanics! The default value is 1.2.
*/
heuristicWeight?: number;
/**
* If true, the result path will be serialized using Room.serializePath. The default is false.
*/
serialize?: boolean;
/**
* The maximum allowed rooms to search. The default (and maximum) is 16. This is only used when the new PathFinder is enabled.
*/
maxRooms?: number;
/**
* Path to within (range) tiles of target tile. The default is to path to the tile that the target is on (0).
*/
range?: number;
}
interface MoveToOpts extends FindPathOpts {
/**
* This option enables reusing the path found along multiple game ticks. It allows to save CPU time, but can result in a slightly
* slower creep reaction behavior. The path is stored into the creep's memory to the _move property. The reusePath value defines
* the amount of ticks which the path should be reused for. The default value is 5. Increase the amount to save more CPU, decrease
* to make the movement more consistent. Set to 0 if you want to disable path reusing.
*/
reusePath?: number;
/**
* If reusePath is enabled and this option is set to true, the path will be stored in memory in the short serialized form using
* Room.serializePath. The default value is true.
*/
serializeMemory?: boolean;
/**
* If this option is set to true, moveTo method will return ERR_NOT_FOUND if there is no memorized path to reuse. This can
* significantly save CPU time in some cases. The default value is false.
*/
noPathFinding?: boolean;
/**
* Draw a line along the creep’s path using RoomVisual.poly. You can provide either an empty object or custom style parameters.
*/
visualizePathStyle?: PolyStyle;
}
interface PathStep {
x: number;
dx: number;
y: number;
dy: number;
direction: number;
}
/**
* An object with survival game info
*/
interface SurvivalGameInfo {
/**
* Current score.
*/
score: number;
/**
* Time to the next wave of invaders.
*/
timeToWave: number;
/**
* The number of the next wave.
*/
wave: number;
}
interface _Constructor<T> {
readonly prototype: T;
}
interface _ConstructorById<T> extends _Constructor<T> {
new (id: string): T;
(id: string): T;
}
/**
* The options that can be accepted by `findRoute()` and friends.
*/
interface RouteOptions {
routeCallback: {
(roomName: string, fromRoomName: string): any;
};
}
/**
* A global object representing world map. Use it to navigate between rooms. The object is accessible via Game.map property.
*/
interface GameMap {
/**
* List all exits available from the room with the given name.
* @param roomName The room name.
* @returns The exits information or null if the room not found.
*/