-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
2156 lines (2131 loc) · 136 KB
/
build.js
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
const fs = require('fs');
function _extend() {
var dst = arguments[0];
var srcs = Array.prototype.slice.call(arguments, 1);
srcs.forEach(function(src) {
for(var i in src) {
dst[i] = src[i];
}
});
return dst;
}
var _docs = {
store: {
store: {
"!doc": "A Store object that contains cargo of this creep.",
"!type": "+Store"
}
}
};
_extend(_docs, {
pathfindingOptions: {
roomCallback: {
"!doc": "Request from the pathfinder to generate a CostMatrix for a certain room. The callback accepts one argument, roomName. This callback will only be called once per room per search. If you are running multiple pathfinding operations in a single room and in a single tick you may consider caching your CostMatrix to speed up your code. Please read the CostMatrix documentation below for more information on CostMatrix. If you return false from the callback the requested room will not be searched, and it won't count against maxRooms",
"!type": "fn(roomName: string) -> +CostMatrix"
},
plainCost: {
"!doc": "Cost for walking on plain positions. The default is 1.",
"!type": "number"
},
swampCost: {
"!doc": "Cost for walking on swamp positions. The default is 5.",
"!type": "number"
},
flee: {
"!doc": "Instead of searching for a path to the goals this will search for a path away from the goals. The cheapest path that is out of range of every goal will be returned. The default is false.",
"!type": "bool"
},
maxOps: {
"!doc": "The maximum allowed pathfinding operations. You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU. The default value is 2000.",
"!type": "number"
},
maxRooms: {
"!doc": "The maximum allowed rooms to search. The default is 16, maximum is 64.",
"!type": "number"
},
maxCost: {
"!doc": "The maximum allowed cost of the path returned. If at any point the pathfinder detects that it is impossible to find a path with a cost less than or equal to maxCost it will immediately halt the search. The default is Infinity.",
"!type": "number"
},
heuristicWeight: {
"!doc": "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.",
"!type": "number"
}
}
});
_extend(_docs, {
roomFindPathOptions: _extend({}, _docs.pathfindingOptions, {
ignoreCreeps: {
"!doc": "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.",
"!type": "boolean"
},
ignoreDestructibleStructures: {
"!doc": "Treat squares with destructible structures (constructed walls, ramparts, spawns, extensions) as walkable. The default value is false.",
"!type": "boolean"
},
ignoreRoads: {
"!doc": "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.",
"!type": "boolean"
},
ignore: {
"!doc": "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).",
"!type": "[+RoomObject]"
},
avoid: {
"!doc": "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).",
"!type": "[+RoomObject]"
},
serialize: {
"!doc": "If true, the result path will be serialized using Room.serializePath. The default is false.",
"!type": "boolean"
},
range: {
"!doc": "Find a path to a position in specified linear range of target. The default is 0.",
"!type": "number"
}
})
});
_extend(_docs, {
moveToOptions: _extend({}, _docs.roomFindPathOptions, {
reusePath: {
"!doc": "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.",
"!type": "boolean"
},
serializeMemory: {
"!doc": "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.",
"!type": "boolean"
},
noPathFinding: {
"!doc": "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.",
"!type": "boolean"
},
visualizePathStyle: {
"!doc": "Draw a line along the creep’s path using RoomVisual.poly. You can provide either an empty object or custom style parameters.",
"!type": "object"
}
})
});
var def_screeps = {
"!name": "screeps",
"!define": {
object: {},
BodyPart: {
type: {
"!doc": "One of the body part types constants",
"!type": "string"
},
hits: {
"!doc": "The remaining amount of hit points of this body part.",
"!type": "number"
},
boost: {
"!doc": "If the body part is boosted, this property specifies the mineral type which is used for boosting. One of the RESOURCE_* constants.",
"!type": "string"
}
},
PathStep: {
x: "number",
y: "number",
dx: "number",
dy: "number",
direction: "number"
},
Path: {
"!type": "[PathStep]"
},
PathfindingResult: {
path: {
"!doc": "An array of RoomPosition objects.",
"!type": "[+RoomPosition]"
},
ops: {
"!doc": "Total number of operations performed before this path was calculated.",
"!type": "number"
},
cost: {
"!doc": "The total cost of the path as derived from plainCost, swampCost and any given CostMatrix instances.",
"!type": "number"
},
incomplete: {
"!doc": "If the pathfinder fails to find a complete path, this will be true. Note that path will still be populated with a partial path which represents the closest path it could find given the search parameters.",
"!type": "boolean"
}
},
PathfindingOptions: _docs.pathfindingOptions,
RoomFindPathOptions: _docs.roomFindPathOptions,
MoveToOptions: _docs.moveToOptions,
FindRouteOptions: {
routeCallback: {
"!doc": "This callback accepts two arguments: function(roomName, fromRoomName). It can be used to calculate the cost of entering that room. You can use this to do things like prioritize your own rooms, or avoid some rooms. You can return a floating point cost or Infinity to block the room.",
"!type": "fn(roomName: string, fromRoomName: string) -> number"
}
},
LookItem: {
type: "string",
creep: "+Creep",
structure: "+Structure",
energy: "+Resource",
resource: "+Resource",
flag: "+Flag",
source: "+Source",
constructionSite: "+ConstructionSite",
terrain: "string"
},
LookArray: {
"!type": "[LookItem]"
},
LookRowArray: {
"!type": "[LookArray]"
},
LookAreaArray: {
"!type": "[LookRowArray]"
},
MapRouteStep: {
exit: "number",
room: "string"
},
CostMatrix: {
"!type": "fn()",
"!doc": "Container for custom navigation cost data. By default PathFinder will only consider terrain data (plain, swamp, wall) — if you need to route around obstacles such as buildings or creeps you must put them into a CostMatrix. Generally you will create your CostMatrix from within roomCallback. If a non-0 value is found in a room's CostMatrix then that value will be used instead of the default terrain cost. You should avoid using large values in your CostMatrix and terrain cost flags. For example, running PathFinder.search with { plainCost: 1, swampCost: 5 } is faster than running it with {plainCost: 2, swampCost: 10 } even though your paths will be the same.",
prototype: {
"set": {
"!doc": "Set the cost of a position in this CostMatrix.",
"!type": "fn(x: number, y: number, cost: number)"
},
"get": {
"!doc": "Get the cost of a position in this CostMatrix.",
"!type": "fn(x: number, y: number)"
},
"clone": {
"!doc": "Copy this CostMatrix into a new CostMatrix with the same data.",
"!type": "fn() -> +CostMatrix"
},
serialize: {
"!doc": "Returns a compact representation of this CostMatrix which can be stored via JSON.stringify",
"!type": "fn() -> [number]"
}
},
deserialize: {
"!doc": "Static method which deserializes a new CostMatrix using the return value of `serialize`.",
"!type": "fn(val: [number]) -> +CostMatrix"
}
},
Transaction: {
transactionId: "string",
time: "number",
sender: {
username: "string"
},
recipient: {
username: "string"
},
resouceType: "string",
amount: "number",
from: "string",
to: "string",
description: "string",
order: {
id: "string",
type: "string",
price: "number"
}
},
MarketOrder: {
id: "string",
created: "number",
type: "string",
resourceType: "string",
roomName: "string",
amount: "number",
remainingAmount: "number",
price: "number",
active: "boolean",
totalAmount: "number"
},
MarketHistoryItem: {
"resourceType": "string",
"date": "string",
"transactions": "number",
"volume": "number",
"avgPrice": "number",
"stddevPrice": "number"
},
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": "number",
"externally_allocated_size": "number"
},
Effect: {
effect: {
"!doc": "Effect ID of the applied effect. Can be either natural effect ID or Power ID.",
"!type": "number"
},
level: {
"!doc": "Power level of the applied effect. Absent if the effect is not a Power effect.",
"!type": "number"
},
ticksRemaining: {
"!doc": "How many ticks will the effect last.",
"!type": "number"
}
},
RoomTerrain: {
"!type": "fn()",
"!doc": "An object which provides fast access to room terrain data. These objects can be constructed for any room in the world even if you have no access to it. Technically every Room.Terrain object is a very lightweight adapter to underlying static terrain buffers with corresponding minimal accessors.",
prototype: {
get: {
"!doc": "Get terrain type at the specified room position by (x,y) coordinates. Unlike the Game.map.getTerrainAt(...) method, this one doesn't perform any string operations and returns integer terrain type values (see below).\n\nArguments:\n* x - X position in the room.\n* y - Y position in the room.\n\nCPU Cost: LOW",
"!type": "fn(x: number, y: number) -> number",
},
getRawBuffer: {
"!doc": "Get copy of underlying static terrain buffer. Current underlying representation is Uint8Array.\n\nArguments:\n* destinationArray (optional) - A typed array view in which terrain will be copied to.\n\nCPU Cost: LOW",
"!type": "fn(destinationArray?: bool) -> +Uint8Array"
},
},
},
StructureSpawnSpawning: {
"!type": "fn()",
"!doc": "Details of the creep being spawned currently that can be addressed by the StructureSpawn.spawning property.",
prototype: {
name: {
"!doc": "The name of a new creep.",
"!type": "string"
},
needTime: {
"!doc": "Time needed in total to complete the spawning.",
"!type": "number"
},
remainingTime: {
"!doc": "Remaining time to go.",
"!type": "number"
},
directions: {
"!doc": "An array with the spawn directions, see StructureSpawn.Spawning.setDirections.",
"!type": "[number]"
},
spawn: {
"!doc": "A link to the spawn.",
"!type": "+StructureSpawn"
},
cancel: {
"!doc": "Cancel spawning immediately. Energy spent on spawning is not returned.",
"!type": "fn() -> number"
},
setDirections: {
"!doc": "Set desired directions where the creep should move when spawned.\n\nArguments:\n* directions - An array with the direction constants as items.\n\nCPU cost: CONST",
"!type": "fn(directions: [number]) -> number"
}
}
},
Power: {
level: {
"!doc": "Current level of the power.",
"!type": "number"
},
cooldown: {
"!doc": "Cooldown ticks remaining, or undefined if the power creep is not spawned in the world.",
"!type": "number"
}
},
RoomStatus: {
status: {
"!doc": "One of the following string values:\n* normal – the room has no restrictions\n* closed – the room is not available\n* novice – the room is part of a novice area\n* respawn – the room is part of a respawn area",
"!type": "string"
},
timestamp: {
"!doc": "Status expiration time in milliseconds since UNIX epoch time. This property is null if the status is permanent.",
"!type": "number"
},
},
LineStyle: {
width: {
"!doc": "Line width, default is 0.1.",
"!type": "number"
},
color: {
"!doc": "Line color in any web format, default is #ffffff (white).",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
MapLineStyle: {
width: {
"!doc": "Line width, default is 0.5.",
"!type": "number"
},
color: {
"!doc": "Line color in any web format, default is #ffffff (white).",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
CircleStyle: {
radius: {
"!doc": "Circle radius, default is 0.15.",
"!type": "number"
},
fill: {
"!doc": "Fill color in any web format, default is #ffffff (white).",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
stroke: {
"!doc": "Stroke color in any web format, default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.1.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
MapCircleStyle: {
radius: {
"!doc": "Circle radius, default is 10.",
"!type": "number"
},
fill: {
"!doc": "Fill color in the following format: #ffffff (hex triplet). Default is #ffffff.",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
stroke: {
"!doc": "Stroke color in the following format: #ffffff (hex triplet). Default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.5.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
PolyStyle: {
fill: {
"!doc": "Fill color in any web format, default is #ffffff (white).",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
stroke: {
"!doc": "Stroke color in any web format, default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.1.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
MapRectStyle: {
fill: {
"!doc": "Fill color in the following format: #ffffff (hex triplet). Default is #ffffff.",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
stroke: {
"!doc": "Stroke color in the following format: #ffffff (hex triplet). Default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.5.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
MapPolyStyle: {
fill: {
"!doc": "Fill color in the following format: #ffffff (hex triplet). Default is #ffffff.",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
},
stroke: {
"!doc": "Stroke color in the following format: #ffffff (hex triplet). Default is #ffffff.",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.5.",
"!type": "number"
},
lineStyle: {
"!doc": "Either undefined (solid line), dashed, or dotted. Default is undefined.",
"!type": "string"
}
},
TextStyle: {
color: {
"!doc": "Font color in any web format, default is #ffffff (white).",
"!type": "string"
},
font: {
"!doc": "Either a number or a string in one of the following forms:\n" +
"0.7 - relative size in game coordinates\n" +
"20px - absolute size in pixels\n" +
"0.7 serif\n" +
"bold italic 1.5 Times New Roman"
},
stroke: {
"!doc": "Stroke color in any web format, default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.1.",
"!type": "number"
},
backgroundColor: {
"!doc": "Background color in any web format, default is undefined (no background). When background is enabled, text vertical align is set to middle (default is baseline).",
"!type": "string"
},
backgroundPadding: {
"!doc": "Background rectangle padding, default is 0.3.",
"!type": "number"
},
align: {
"!doc": "Text align, either center, left, or right. Default is center.",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 1.0.",
"!type": "number"
}
},
MapTextStyle: {
color: {
"!doc": "Font color in the following format: #ffffff (hex triplet). Default is #ffffff.",
"!type": "string"
},
fontFamily: {
"!doc": "The font family, default is sans-serif",
"!type": "string"
},
fontSize: {
"!doc": "The font size in game coordinates, default is 10",
"!type": "number"
},
fontStyle: {
"!doc": "The font style ('normal', 'italic' or 'oblique')",
"!type": "string"
},
fontVariant: {
"!doc": "The font variant ('normal' or 'small-caps')",
"!type": "string"
},
stroke: {
"!doc": "Stroke color in the following format: #ffffff (hex triplet). Default is undefined (no stroke).",
"!type": "string"
},
strokeWidth: {
"!doc": "Stroke line width, default is 0.15.",
"!type": "number"
},
backgroundColor: {
"!doc": "Background color in the following format: #ffffff (hex triplet). Default is undefined (no background). When background is enabled, text vertical align is set to middle (default is baseline).",
"!type": "string"
},
backgroundPadding: {
"!doc": "Background rectangle padding, default is 2.",
"!type": "number"
},
align: {
"!doc": "Text align, either center, left, or right. Default is center.",
"!type": "string"
},
opacity: {
"!doc": "Opacity value, default is 0.5.",
"!type": "number"
}
}
},
RoomObject: {
"!type": "fn()",
"!doc": "Any object with a position in a room. Almost all game objects prototypes are derived from RoomObject.",
prototype: {
pos: {
"!doc": "An object representing the position of this object in a room.",
"!type": "+RoomPosition"
},
room: {
"!doc": "The link to the Room object of this object. May be undefined in case if an object is a flag and is placed in a room that is not visible to you.",
"!type": "+Room"
},
effects: {
"!doc": "Applied effects, an array of objects.",
"!type": "[Effect]"
}
}
},
Store: {
"!type": "fn()",
"!doc": "An object that can contain resources in its cargo.",
prototype: {
getCapacity: {
"!doc": "Returns capacity of this store for the specified resource, or total capacity if resource is undefined.\n\nReturns capacity number, or null in case of a not valid resource for this store type.\n\nArguments:\n* resource (optional) - The type of the resource.",
"!type": "fn(resource?: string) -> number"
},
getFreeCapacity: {
"!doc": "A shorthand for getCapacity(resource) - getUsedCapacity(resource).\n\nArguments:\n* resource (optional) - The type of the resource.",
"!type": "fn(resource?: string) -> number"
},
getUsedCapacity: {
"!doc": "Returns the capacity used by the specified resource, or total used capacity for general purpose stores if resource is undefined.\n\nReturns used capacity number, or null in case of a not valid resource for this store type.\n\nArguments:\n* resource (optional) - The type of the resource.",
"!type": "fn(resource?: string) -> number"
}
}
}
};
_extend(def_screeps, {
Structure: {
"!type": "fn()",
"!doc": "Creeps are your units. Creeps can move, harvest energy, construct structures, attack another creeps, and perform other actions.",
prototype: _extend({}, def_screeps.RoomObject.prototype, {
id: {
"!type": "string",
"!doc": "A unique object identificator. You can use `Game.getObjectById` method to retrieve an object instance by its `id`.",
},
hits: {
"!doc": "The current amount of hit points of the structure.",
"!type": "number"
},
hitsMax: {
"!doc": "The total amount of hit points of the structure.",
"!type": "number"
},
structureType: {
"!doc": "One of the STRUCTURE_* constants.",
"!type": "string"
},
destroy: {
"!doc": "Destroy this structure immediately. You are not allowed to destroy a structure when there are hostile creeps in the room.\n\nCPU cost: CONST",
"!type": "fn() -> number"
},
notifyWhenAttacked: {
"!doc": "Toggle auto notification when the structure is under attack. The notification will be sent to your account email. Turned on by default.\n\nArguments:\n* enabled - Whether to enable notification or disable.\n\nCPU cost: CONST",
"!type": "fn(enabled: bool) -> number"
},
isActive: {
"!doc": "Check whether this structure can be used. If the room controller level is not enough, then this method will return false, and the structure will be highlighted with red in the game.\n\nCPU cost: LOW",
"!type": "fn() -> bool"
},
})
},
});
_extend(def_screeps, {
OwnedStructure: {
"!type": "fn()",
"!doc": "The base prototype for a structure that has an owner. Such structures can be found using FIND_MY_STRUCTURES and FIND_HOSTILE_STRUCTURES constants.",
prototype: _extend({}, def_screeps.Structure.prototype, {
my: {
"!type": "bool",
"!doc": "Whether it is your own structure."
},
owner: {
"!": "An object with the owner info",
username: {
"!doc": "The name of the owner user.",
"!type": "string"
}
},
})
},
});
_extend(def_screeps, {
ConstructionSite: {
"!type": "fn()",
"!doc": "A site of a structure which is currently under construction. A construction site can be created using the 'Construct' button at the left of the game field or the Room.createConstructionSite() method. Construction sites are visible to their owners only.\n\nTo build a structure on the construction site, give a worker creep some amount of energy and perform Creep.build() action.",
prototype: _extend({}, def_screeps.RoomObject.prototype, {
id: {
"!type": "string",
"!doc": "A unique object identificator. You can use `Game.getObjectById` method to retrieve an object instance by its `id`.",
},
my: {
"!type": "bool",
"!doc": "Whether it is your own construction site."
},
owner: {
"!doc": "An object with the owner info",
username: {
"!doc": "The name of the owner user.",
"!type": "string"
}
},
progress: {
"!doc": "The current construction progress.",
"!type": "number"
},
progressTotal: {
"!doc": "The total construction progress needed for the structure to be built.",
"!type": "number"
},
structureType: {
"!doc": "One of the STRUCTURE_* constants.",
"!type": "string"
},
remove: {
"!doc": "Remove the construction site.\n\nCPU cost: CONST",
"!type": "fn() -> number"
}
})
},
Creep: {
"!type": "fn()",
"!doc": "Creeps are your units. Creeps can move, harvest energy, construct structures, attack another creeps, and perform other actions.",
prototype: _extend({}, _docs.store, def_screeps.RoomObject.prototype, {
body: {
"!doc": "An array describing the creep’s body.",
"!type": "[BodyPart]",
"!url": "http://docs.screeps.com/api/#Creep.body"
},
fatigue: {
"!type": "number",
"!doc": "The movement fatigue indicator. If it is greater than zero, the creep cannot move.",
},
hits: {
"!type": "number",
"!doc": "The current amount of hit points of the creep.",
},
hitsMax: {
"!type": "number",
"!doc": "The maximum amount of hit points of the creep.",
},
id: {
"!type": "string",
"!doc": "A unique object identificator. You can use `Game.getObjectById` method to retrieve an object instance by its `id`.",
},
memory: {
"!doc": "A shorthand to `Memory.creeps[creep.name]`. You can use it for quick access the creep’s specific memory data object.",
},
my: {
"!type": "bool",
"!doc": "Whether it is your creep or foe."
},
name: {
"!doc": "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.",
"!type": "string"
},
owner: {
"!doc": "An object with the owner info",
username: {
"!doc": "The name of the owner user.",
"!type": "string"
}
},
spawning: {
"!doc": "Whether this creep is still being spawned.",
"!type": "bool"
},
ticksToLive: {
"!doc": "The remaining amount of game ticks after which the creep will die.",
"!type": "number"
},
attack: {
"!type": "fn(target: object) -> number",
"!doc": "Attack another creep or structure in a short-ranged attack. Requires 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.\n\nArguments:\n* target - The target object to be attacked.\n\nCPU cost: CONST"
},
build: {
"!doc": "Build a structure at the target construction site using carried energy. Requires WORK and CARRY body parts. The target has to be within 3 squares range of the creep.\n\nArguments:\n* target - The target construction site to be built.\n\nCPU cost:CONST",
"!type": "fn(target: +ConstructionSite) -> number"
},
cancelOrder: {
"!doc": "Cancel the order given during the current game tick.\n\nArguments:\n* methodName - The name of a creep's method to be cancelled.\n\nCPU cost:NONE",
"!type": "fn(methodName: string) -> number"
},
claimController: {
"!doc": "Claims a neutral controller under your control. Requires the CLAIM body part. \n\nArguments:\n* target - The target controller object.\n\nCPU cost: CONST",
"!type": "fn(target: +Structure) -> number"
},
attackController: {
"!doc": "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.\n\nArguments:\n* target - The target controller object.\n\nCPU cost: CONST",
"!type": "fn(target: +Structure) -> number"
},
getActiveBodyparts: {
"!doc": "Get the quantity of live body parts of the given type. Fully damaged parts do not count.\n\nArguments:\n* type - A body part type, one of the body part constants.\n\nCPU cost: NONE",
"!type": "fn(type: string) -> number"
},
harvest: {
"!doc": "Harvest energy from the source. Requires 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. You cannot harvest a source if the room controller is owned or reserved by another player.\n\nArguments:\n* target - The source object to be harvested.\n\nCPU cost: CONST",
"!type": "fn(target: +Source) -> number"
},
heal: {
"!doc": "Heal self or another creep. It will restore the target creep’s damaged body parts function and increase the hits counter. Requires the HEAL body part. The target has to be at adjacent square to the creep.\n\nArguments:\n* target - The target creep object.\n\nCPU cost: CONST",
"!type": "fn(target: +Creep) -> number"
},
move: {
"!doc": "Move the creep one square in the specified direction. Requires the MOVE body part.\n\nArguments:\n* direction - One of the direction constants.\n\nCPU cost: CONST",
"!type": "fn(direction: number) -> number"
},
moveByPath: {
"!doc": "Move the creep using the specified predefined path. Requires the MOVE body part.\n\nArguments:\n* path - A path value as returned from `Room.findPath`, `RoomPosition.findPathTo`, or `PathFinder.search` methods. Both array form and serialized string form are accepted.\n\nCPU cost: CONST",
"!type": "fn(path: Path) -> number"
},
moveTo: {
"!doc": "Syntax:\nmoveTo(x, y, [opts])\nmoveTo(target, [opts])\n\nFind 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. Requires the MOVE body part.\n\nArguments:\n* x - X position of the target in the same room.\n* y - Y position of the target in the same room.\n* target - Can be a RoomPosition object or any object containing RoomPosition. The position doesn't have to be in the same room.\n* opts (optional) - An object containing pathfinding options flags (see Room.findPath for more info) or one of the following:\n - reusePath - 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.\n - serializeMemory - 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.\n - noPathFinding - 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.\n - visualizePathStyle - draw a line along the creep’s path using RoomVisual.poly. You can provide either an empty object or custom style parameters.\n\nCPU cost: HIGH",
"!type": "fn(arg1: ?, arg2?: ?, arg3?: ?) -> number"
},
notifyWhenAttacked: {
"!doc": "Toggle auto notification when the creep is under attack. The notification will be sent to your account email. Turned on by default.\n\nArguments:\n* enabled - Whether to enable notification or disable.\n\nCPU cost: CONST",
"!type": "fn(enabled: bool) -> number"
},
pickup: {
"!doc": "Pick up an item (a dropped piece of energy). Requires the CARRY body part. The target has to be at adjacent square to the creep or at the same square.\n\nArguments:\n* target - The target object to be picked up.\n\nCPU cost: CONST",
"!type": "fn(target: +Resource) -> number"
},
rangedAttack: {
"!doc": "A ranged attack against another creep or structure. Requires 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.\n\nArguments:\n* target - The target object to be attacked.\n\nCPU cost: CONST",
"!type": "fn(target: object) -> number"
},
rangedHeal: {
"!doc": "Heal another creep at a distance. It will restore the target creep’s damaged body parts function and increase the hits counter. Requires the HEAL body part. The target has to be within 3 squares range of the creep.\n\nArguments:\n* target - The target creep object.\n\nCPU cost: CONST",
"!type": "fn(target: +Creep) -> number"
},
rangedMassAttack: {
"!doc": "A ranged attack against all hostile creeps or structures within 3 squares range. Requires the RANGED_ATTACK body part. The attack power depends on the range to each target. Friendly units are not affected.\n\nCPU cost: CONST",
"!type": "fn() -> number"
},
repair: {
"!doc": "Repair a damaged structure using carried energy. Requires the WORK and CARRY body parts. The target has to be within 3 squares range of the creep.\n\nArguments:\n* target - The target structure to be repaired.\n\nCPU cost: CONST",
"!type": "fn(target: object) -> number"
},
reserveController: {
"!doc": "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.\n\nArguments:\n* target - The target controller object to be reserved.\n\nCPU cost: CONST",
"!type": "fn(target: +StructureController) -> number"
},
signController: {
"!doc": "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.\n\nArguments:\n* target - The target controller object to be signed.\n* text - The sign text. The maximum text length is 100 characters.\n\nCPU cost: CONST",
"!type": "fn(target: +StructureController, target: string) -> number"
},
say: {
"!doc": "Display a visual speech balloon above the creep with the specified message. The message will be available for one tick. You can read the last message using the `saying` property.\n\nArguments:\n* message - The message to be displayed. Maximum length is 10 characters.\n* public (optional) - Set to true to allow other players to see this message. Default is false.\n\nCPU cost: NONE",
"!type": "fn(message: string, public?: boolean) -> number"
},
saying: {
"!doc": "The text message that the creep was saying at the last tick.",
"!type": "string"
},
suicide: {
"!doc": "Kill the creep immediately.\n\nCPU cost: CONST",
"!type": "fn() -> number"
},
upgradeController: {
"!doc": "Upgrade your controller to the next level using carried energy. Upgrading controllers raises your Global Control Level in parallel. Requires WORK and CARRY body parts. The target has to be within 3 squares range of 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. This limit can be increased by using ghodium mineral boost.\n\nArguments:\n* target - The target controller object to be upgraded.\n\nCPU cost: CONST",
"!type": "fn(target: +Structure) -> number"
},
drop: {
"!doc": "Drop resource on the ground.\n\nArguments:\n* resourceType - One of the RESOURCE_* constants.\n* amount - The amount of resource units to be dropped.\n\nCPU cost: CONST",
"!type": "fn(resourceType: string, amount?: number) -> number"
},
transfer: {
"!doc": "Transfer resource from the creep to another creep, storage, or power spawn. The target has to be at adjacent square to the creep.\n\nArguments:\n* target - The target object.\n* resourceType - One of the RESOURCE_* constants.\n* amount (optional) - The amount of resources to be transferred. If omitted, all the available carried amount is used.\n\nCPU cost: CONST",
"!type": "fn(target: object, resourceType: string, amount?: number) -> number"
},
dismantle: {
"!type": "fn(target: +Structure) -> number",
"!doc": "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.\n\nArguments:\n* target - The target structure.\n\nCPU cost: CONST"
},
withdraw: {
"!doc": "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.\n\nArguments:\n* target - The target object.\n* resourceType - One of the RESOURCE_* constants.\n* amount (optional) - The amount of resources to be transferred. If omitted, all the available amount is used.\n\nCPU cost: CONST",
"!type": "fn(target: +Structure, resourceType: string, amount?: number) -> number"
},
generateSafeMode: {
"!doc": "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.\n\nArguments:\n* target - The target room controller.\n\nCPU cost: CONST",
"!type": "fn(target: +StructureController) -> number"
}
})
},
PowerCreep: {
"!type": "fn()",
"!doc": "Power Creeps are immortal \"heroes\" that are tied to your account and can be respawned in any PowerSpawn after death.",
prototype: _extend({}, _docs.store, def_screeps.RoomObject.prototype, {
cancelOrder: {
"!doc": "Cancel the order given during the current game tick.\n\nArguments:\n* methodName - The name of a power creep's method to be cancelled.\n\nCPU cost:NONE",
"!type": "fn(methodName: string) -> number"
},
className: {
"!type": "string",
"!doc": "The power creep's class, one of the POWER_CLASS constants."
},
delete: {
"!doc": "Delete the power creep permanently from your account. It should NOT be spawned in the world. The creep is not deleted immediately, but a 24-hours delete timer is started instead (see deleteTime). You can cancel deletion by calling delete(true).",
"!type": "fn(cancel?: boolean) -> number"
},
deleteTime: {
"!type": "number",
"!doc": "A timestamp when this creep is marked to be permanently deleted from the account, or undefined otherwise.",
},
drop: {
"!doc": "Drop resource on the ground.\n\nArguments:\n* resourceType - One of the RESOURCE_* constants.\n* amount - The amount of resource units to be dropped.\n\nCPU cost: CONST",
"!type": "fn(resourceType: string, amount?: number) -> number"
},
enableRoom: {
"!doc": "Enable powers usage in this room.\n\nArguments:\n* controller - The room controller.\n\nCPU cost: CONST",
"!type": "fn(controller: +StructureController) -> number"
},
hits: {
"!type": "number",
"!doc": "The current amount of hit points of the power creep.",
},
hitsMax: {
"!type": "number",
"!doc": "The maximum amount of hit points of the power creep.",
},
id: {
"!type": "string",
"!doc": "A unique object identificator. You can use `Game.getObjectById` method to retrieve an object instance by its `id`.",
},
level: {
"!type": "number",
"!doc": "The power creep's level.",
},
memory: {
"!doc": "A shorthand to `Memory.powerCreeps[creep.name]`. You can use it for quick access the power creep’s specific memory data object.",
},
move: {
"!doc": "Move the power creep one square in the specified direction.\n\nArguments:\n* direction - One of the direction constants.\n\nCPU cost: CONST",
"!type": "fn(direction: number) -> number"
},
moveByPath: {
"!doc": "Move the power creep using the specified predefined path.\n\nArguments:\n* path - A path value as returned from `Room.findPath`, `RoomPosition.findPathTo`, or `PathFinder.search` methods. Both array form and serialized string form are accepted.\n\nCPU cost: CONST",
"!type": "fn(path: Path) -> number"
},
moveTo: {
"!doc": "Syntax:\nmoveTo(x, y, [opts])\nmoveTo(target, [opts])\n\nFind the optimal path to the target within the same room and move to it.\n\nArguments:\n* x - X position of the target in the same room.\n* y - Y position of the target in the same room.\n* target - Can be a RoomPosition object or any object containing RoomPosition. The position doesn't have to be in the same room.\n* opts (optional) - An object containing pathfinding options flags (see Room.findPath for more info) or one of the following:\n - reusePath - 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.\n - serializeMemory - 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.\n - noPathFinding - 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.\n - visualizePathStyle - draw a line along the creep’s path using RoomVisual.poly. You can provide either an empty object or custom style parameters.\n\nCPU cost: HIGH",
"!type": "fn(arg1: ?, arg2?: ?, arg3?: ?) -> number"
},
my: {
"!type": "bool",
"!doc": "Whether it is your power creep or foe."
},
name: {
"!doc": "Power creep's name. You can choose the name while creating a new power creep, and it cannot be changed later. This name is a hash key to access the creep via the `Game.powerCreeps` object.",
"!type": "string"
},
notifyWhenAttacked: {
"!doc": "Toggle auto notification when the power creep is under attack. The notification will be sent to your account email. Turned on by default.\n\nArguments:\n* enabled - Whether to enable notification or disable.\n\nCPU cost: CONST",
"!type": "fn(enabled: bool) -> number"
},
owner: {
"!doc": "An object with the owner info",
username: {
"!doc": "The name of the owner user.",
"!type": "string"
}
},
pickup: {
"!doc": "Pick up an item (a dropped piece of energy). The target has to be at adjacent square to the creep or at the same square.\n\nArguments:\n* target - The target object to be picked up.\n\nCPU cost: CONST",
"!type": "fn(target: +Resource) -> number"
},
rename: {
"!doc": "Rename the power creep. It must not be spawned in the world.\n\nArguments:\n* name - The new name of the power creep.\n\nCPU cost: NONE",
"!type": "fn(name: string) -> number"
},
renew: {
"!doc": "Instantly restore time to live to the maximum using a Power Spawn or a Power Bank nearby.\n\nArguments:\n* target - The target structure\n\nCPU cost: CONST",
"!type": "fn(target: object) -> number"
},
powers: {
"!doc": "Available powers, an object with power ID as a key",
"!type": "[+Power]"
},
say: {
"!doc": "Display a visual speech balloon above the power creep with the specified message. The message will be available for one tick. You can read the last message using the `saying` property.\n\nArguments:\n* message - The message to be displayed. Maximum length is 10 characters.\n* public (optional) - Set to true to allow other players to see this message. Default is false.\n\nCPU cost: NONE",
"!type": "fn(message: string, public?: boolean) -> number"
},
saying: {
"!doc": "The text message that the power creep was saying at the last tick.",
"!type": "string"
},
shard: {
"!doc": "The name of the shard where the power creep is spawned, or undefined.",
"!type": "string"
},
spawn: {
"!doc": "Spawn this power creep in the specified Power Spawn.\n\nArguments:\n* powerSpawn - Your Power Spawn structure.\n\nCPU cost: CONST",
"!type": "fn(powerSpawn: +StructurePowerSpawn) -> number"
},
spawnCooldownTime: {