Repository: screepers/typed-screeps Branch: master Commit: 77ad7692efe5 Files: 57 Total size: 575.6 KB Directory structure: gitextract_o_a42e6b/ ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug-report.md │ │ └── definition-changes.md │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows/ │ └── CI.yml ├── .gitignore ├── .husky/ │ └── pre-commit ├── .npmignore ├── .prettierrc ├── .vscode/ │ ├── extensions.json │ └── settings.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build/ │ └── concat.js ├── dist/ │ ├── .eslintrc.json │ ├── .npmignore │ ├── index.d.ts │ ├── package.json │ ├── screeps-tests.ts │ └── tsconfig.json ├── eslint.config.mjs ├── eslint.config.test.mjs ├── package.json ├── src/ │ ├── constants.ts │ ├── construction-site.ts │ ├── creep.ts │ ├── deposit.ts │ ├── flag.ts │ ├── game.ts │ ├── helpers.ts │ ├── inter-shard-memory.ts │ ├── literals.ts │ ├── map.ts │ ├── market.ts │ ├── memory.ts │ ├── mineral.ts │ ├── nuke.ts │ ├── path-finder.ts │ ├── power-creep.ts │ ├── raw-memory.ts │ ├── resource.ts │ ├── room-object.ts │ ├── room-position.ts │ ├── room-terrain.ts │ ├── room-visual.ts │ ├── room.ts │ ├── ruin.ts │ ├── source.ts │ ├── spawn.ts │ ├── store.ts │ ├── structure.ts │ └── tombstone.ts └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # editorconfig.org root = true [*] indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package*.json,*.md}] indent_style = space indent_size = 2 ================================================ FILE: .gitattributes ================================================ # Set end-of-line to LF * text eol=lf ================================================ FILE: .github/ISSUE_TEMPLATE/bug-report.md ================================================ --- name: "Bug Report 🐛" about: For reporting bugs/problems with the definition. labels: "bug" --- ### Expected Behavior {Please write here} ### Actual Behavior {Please write here} ### Sample code (if available) ```ts // Please include your code within this block. ``` ### Your Environment - Node.js version: {Please write here} - TypeScript version: {Please write here} - {`typed-screeps` or `@types/screeps` delete as appropriate} version: {Please write here} ================================================ FILE: .github/ISSUE_TEMPLATE/definition-changes.md ================================================ --- name: "Declaration Changes 👨‍💻" about: For changes/additions to the declaration files. labels: "enhancement" --- ### Brief Description {Please write here} ### Reference to Screeps Changelog (if available) {Please write here} ### Sample code (if available) ```ts // Please include your code within this block. ``` ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ### Brief Description {Please write here} ### Checklists - [ ] Test passed - [ ] Coding style (indentation, etc) - [ ] Edits have been made to `src/` files not `index.d.ts` - [ ] Run `npm run compile` to update `index.d.ts` ================================================ FILE: .github/workflows/CI.yml ================================================ name: CI on: pull_request: push: branches: ["master"] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v3 - name: Install pnpm uses: pnpm/action-setup@v4 with: version: 8 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: "pnpm" - name: Install dependencies run: pnpm i - name: Lint run: pnpm lint ================================================ FILE: .gitignore ================================================ .idea node_modules npm-debug.log *.*~ .DS_Store test/typed-screeps-tests.js dist/screeps.ts dist/screeps.js dist/screeps-tests.js .vscode/tasks.json ================================================ FILE: .husky/pre-commit ================================================ #!/bin/sh . "$(dirname "$0")/_/husky.sh" npx --no-install lint-staged npm run pre-commit ================================================ FILE: .npmignore ================================================ node_modules/ *.d.ts *.log *.tgz .editorconfig .gitattributes tsconfig.json eslint.config.* src/ dist/screeps.ts !dist/screeps.d.ts ================================================ FILE: .prettierrc ================================================ { "semi": true, "tabWidth": 4, "printWidth": 140, "useTabs": false, "trailingComma": "all", "overrides": [ { "files": "package*.json", "options": { "tabWidth": 2, "trailingComma": "none" } }, { "files": "*.md", "options": { "tabWidth": 2 } } ] } ================================================ FILE: .vscode/extensions.json ================================================ { "recommendations": [ "EditorConfig.EditorConfig", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint" ] } ================================================ FILE: .vscode/settings.json ================================================ { "editor.insertSpaces": true, "editor.tabSize": 4, "editor.rulers": [140], "files.encoding": "utf8", "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, "search.exclude": { "dist/**": true, "node_modules/**": true, "typings/**": true } } ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [v3.4.0] - 2026-04-25 ### Added - Add type inference for params in filter callbacks ([#221](https://github.com/screepers/typed-screeps/pull/221)) - Add missing `MARKET_FEE` constant ([#213](https://github.com/screepers/typed-screeps/pull/213)) - Add `CommodityTypes` type and `CommidityEntry` interface ([#212](https://github.com/screepers/typed-screeps/pull/212)) - Add RoomTerrain.getRawBuffer() ([#247](https://github.com/screepers/typed-screeps/pull/247)) - Feat: Setting the Order type to ORDER_BUY | ORDER_SELL instead of string ([#255](https://github.com/screepers/typed-screeps/pull/255)) - Add restricted shard support by @tiennou in ([#290](https://github.com/screepers/typed-screeps/pull/290)) ### Updated - Update `PathFinder.CostMatrix` to be `CostMatrixConstructor` to separate static methods from `CostMatrix`. ([#214](https://github.com/screepers/typed-screeps/pull/214)) - Update `LOOK_STRUCTURES` return type to `AnyStructure` ([#217](https://github.com/screepers/typed-screeps/pull/217)) - Update `Game.structures` type to `OwnedStructure` ([#211](https://github.com/screepers/typed-screeps/pull/211)) - Refactor: Decoupling `FilterOption` and `FindConstant` and improve `FilterOption` ([#238](https://github.com/screepers/typed-screeps/pull/238)) - Fix: Mark `Spawning.directions` as optional ([#244](https://github.com/screepers/typed-screeps/pull/244)) - Fix: Unlimited stores have no notion of free capacity ([#208](https://github.com/screepers/typed-screeps/pull/208)) - Fix: `Room.getEventLog()` may return string ([#245](https://github.com/screepers/typed-screeps/pull/245)) - FIx: Mark `RoomObject.effects` as optional - Fix: Update invader core-related constants to their actual values ([#249](https://github.com/screepers/typed-screeps/pull/249)) - Game.map.describeExits returns null for non-existent rooms ([#250](https://github.com/screepers/typed-screeps/pull/250)) - Fix: lookForAtArea matrix result type. ([#253](https://github.com/screepers/typed-screeps/pull/253)) - Update Game.market.deal documentation ([#256](https://github.com/screepers/typed-screeps/pull/256)) - Fix a transferEnergy type error where it suggested a creep. ([#258](https://github.com/screepers/typed-screeps/pull/258)) - Improve docs on Game.map.findRoute by @tiennou in ([#262](https://github.com/screepers/typed-screeps/pull/262)) - Cleanup unused code by @tiennou in ([#264](https://github.com/screepers/typed-screeps/pull/264)) - Type Mineral.density by @tiennou in ([#268](https://github.com/screepers/typed-screeps/pull/268)) - Document createOrder's parameter properly by @tiennou in ([#269](https://github.com/screepers/typed-screeps/pull/269)) - Improve documentation for methods and their return types by @tiennou in ([#270](https://github.com/screepers/typed-screeps/pull/270)) - Update the Game.market.calcTransactionCost formula by @tiennou in ([#277](https://github.com/screepers/typed-screeps/pull/277)) - Fix EVENT_BUILD data by @rmuchan in ([#279](https://github.com/screepers/typed-screeps/pull/279)) - Default heuristicWeight is 1.2, not 1 by @tiennou in ([#278](https://github.com/screepers/typed-screeps/pull/278)) ### Removed - None ## 3.3.2 to 3.3.8 These versions were pushed by DefinitelyTyped maintainers, has no effect on type definitions - MarkoSulamagi resigns from DT side maintainers ## [3.3.1] - 2023-02-16 ### Updated - Update `ConcreteStructure` syntax to use map instead of conditional chain ([#209](https://github.com/screepers/typed-screeps/pull/209)) ### Fixed - Fix: brings removed `Game.getObjectById(id: string)` back to avoid breaking changes. ([#226](https://github.com/screepers/typed-screeps/pull/226)) ## [3.3.0] - 2022-04-18 ### Updated - Updates `ticksToRegeneration` to be optional in `Minerals` ([#204](https://github.com/screepers/typed-screeps/pull/204)) - Updates `level` to be optional in `StructureFactory` ([#205](https://github.com/screepers/typed-screeps/pull/205)) - Updates `Id` type to only be used on types with an `id` property ([#207](https://github.com/screepers/typed-screeps/pull/207)) ### Removed - Removes deprecated `Game.getObjectById(id: string)` function. Use version with `Id` typed ids. ([#207](https://github.com/screepers/typed-screeps/pull/207)) ## [3.2.4] - 2021-08-21 ### Added - Add `Game.GetObjectById` support for union of Id's ([#201](https://github.com/screepers/typed-screeps/pull/201)) - Add support for type predicates in `room.find` and similar functions ([#199](https://github.com/screepers/typed-screeps/pull/199)) - Add explicit `| undefined` to undefined types that may exist with an undefined value. ### Fixed - Fix typo in docstring in `Flag` interface ([#198](https://github.com/screepers/typed-screeps/pull/198)) - Fix function documentation. 10k per pixel ([#200](https://github.com/screepers/typed-screeps/pull/200)) ## 3.2.3 This version was pushed by DefinitelyTyped maintainers, not present in this repository. ## [3.2.2] - 2021-03-14 ### Added - Added `StructureInvaderCore.Spawning` ([d798c56](https://github.com/screepers/typed-screeps/commit/d798c56f2724c21910b5b66e06a9b129e98020a7)) ### Updated - Updated `PIXEL_CPU_COST` constant to 10000 ([d798c56](https://github.com/screepers/typed-screeps/commit/d798c56f2724c21910b5b66e06a9b129e98020a7)) - MarketResourceConstant as argument for Game.market.getHistory ([#184](https://github.com/screepers/typed-screeps/pull/184)) - Updated `Deposit.depositType` documentation ([#189](https://github.com/screepers/typed-screeps/pull/189)) - Updated `Creep.build` documentation ([#186](https://github.com/screepers/typed-screeps/pull/186)) - Adds `import` and `export` to `RoomVisual` and `MapVisual` ([#181](https://github.com/screepers/typed-screeps/pull/181)) ## [3.2.1] - 2020-09-24 ### Added - Adds `import` and `export` to `RoomVisual` and `MapVisual` ([#181](https://github.com/screepers/typed-screeps/pull/181)) - Add `InterShardResourceConstant`, fix resources missing from `MarketResourceConstant` ([#182](https://github.com/screepers/typed-screeps/pull/182)) ### Fixed - Adds `RESOURCE_ENERGY` to `COMMODITIES` record. ([#178](https://github.com/screepers/typed-screeps/pull/178)) - Fixes signature of `RoomPosition.findClosestByPath()` ([#179](https://github.com/screepers/typed-screeps/pull/179)) ## [3.2.0] - 2020-09-06 ### Added - Add new `MapVisual` type for new map visual feature ([#177](https://github.com/screepers/typed-screeps/pull/177)) ### Fixed - Fix decumentation for `PWR_OPERATE_FACTORY` duration ([#174](https://github.com/screepers/typed-screeps/pull/174)) ## [3.1.3] - 2020-06-22 ### Added - Add constants `CPU_UNLOCK`, `PIXEL`, `ACCESS_KEY` ([#172](https://github.com/screepers/typed-screeps/pull/172)) - Add `Game.cpu.generatePixel()` ([#172](https://github.com/screepers/typed-screeps/pull/172)) - Add `Game.cpu.unlock()`, `Game.cpu.unlocked`, and `Game.cpu.unlockedTime` ([#172](https://github.com/screepers/typed-screeps/pull/172)) ### Fixed - Fixed `tower.attack()` to allow targeting Structures ([#170](https://github.com/screepers/typed-screeps/pull/170)) ## [3.1.2] - 2020-05-12 ### Added - Add `level?: number` to `COMMODITIES` record ([522a9ca](https://github.com/screepers/typed-screeps/commit/522a9ca1780ae2d6eade0311983c2e4933eeee68)) - Add `RESOURCE_ENERGY` to commodities components ([a3a59c9](https://github.com/screepers/typed-screeps/commit/a3a59c96ea3988d3362969ff9b7372624aa0a8f2)) ### Fixed - Fix `FindOpts.costCallback` type to `void | CostMatrix` ([32f051c](https://github.com/screepers/typed-screeps/commit/32f051c70b1572a507f5b483ea829a07bba344a5)) - Fix `StructureController.my` to be `boolean` ([062e4a4](https://github.com/screepers/typed-screeps/commit/062e4a4b8b8496979e073eb577fa6d023bba473d)) ### Changed - Slight change to `store` signatures to allow better type inference in certain editors ([#166](https://github.com/screepers/typed-screeps/pull/166)) ## [3.1.1] - 2020-04-23 ### Fixed - Added type `Ruin` to `PowerCreep.withdraw` parameter `target` ## [3.1.0] - 2020-04-01 - Fixed `StructureSpawn.renewCreep()` documentation ([#158](https://github.com/screepers/typed-screeps/pull/158)) - Added missing `PWR_OPERATE_FACTORY` constant ([#161](https://github.com/screepers/typed-screeps/pull/161)) - Changed `BodyPartConstant` to allow inferred Boost type from part type ([#162](https://github.com/screepers/typed-screeps/pull/162)) - Added `ConcreteStructure` type - Change `owner` to allow undefined on `StructureController` ([#164](https://github.com/screepers/typed-screeps/pull/164)) - Various updates from 2020-03-24 game update ([#163](https://github.com/screepers/typed-screeps/pull/163)) - Added `Game.map.getRoomStauts(roomName)` - Added `RoomStatus` type, a discriminated union on `status` of `RoomStatusTemporary` and `RoomStatusPermanent`. - Added `StructureLab.reverseReaction(lab1,lab2)` - Changed `room.name` to be readonly - Changed typing of `StoreBase.getFreeCapacity()` to return `null` for invalid resources types on limited stores. - Changed documentation of `store` functions - Deprecated `Game.map.isRoomAvailable()`, see `Game.map.getRoomStatus()` ## [3.0.1] - 2019-11-27 - Fix POSSIBLE_RESSOURCES typo in store definition ([#151](https://github.com/screepers/typed-screeps/pull/151)) - Remove unecessary tslint:disable rules in OpaqueTag definition ([#151](https://github.com/screepers/typed-screeps/pull/151)) ## [3.0.0] - 2019-11-23 ### Added - Add missing halt command to CPU ([#141](https://github.com/screepers/typed-screeps/pull/141)) - Add market price history and other updates ([#138](https://github.com/screepers/typed-screeps/pull/138)) - Add support for 'Natural Effects' on RoomObjects ([#135](https://github.com/screepers/typed-screeps/pull/135)) - Add support for Factories, Ruins, Deposits, and Strongholds ([#132](https://github.com/screepers/typed-screeps/pull/132)) ### Changed - Retype constants with same named types ([#143](https://github.com/screepers/typed-screeps/pull/143)), ([#147](https://github.com/screepers/typed-screeps/pull/147)) - Update StoreDefinition ([#130](https://github.com/screepers/typed-screeps/pull/130)) - Explicitly type game object Ids ([#139](https://github.com/screepers/typed-screeps/pull/139)) ### Fixed - Updated dependencies ([#133](https://github.com/screepers/typed-screeps/pull/133)), ([#134](https://github.com/screepers/typed-screeps/pull/134)) ### Deprecated - Deprecated use of string typed ids to get game objects ([#144](https://github.com/screepers/typed-screeps/pull/144)) - Deprecated `creep.carry` ([#130](https://github.com/screepers/typed-screeps/pull/130)) ### Removed - Remove deprecated FIND_DROPPED_ENERGY constant ([#129](https://github.com/screepers/typed-screeps/pull/129)) ## [2.5.4] - 2019-05-12 ### Added - Add support for `PowerCreep`, `InterShardMemory` and an `AnyCreep` union ([#117](https://github.com/screepers/typed-screeps/pull/118)) ## [2.5.3] - 2018-12-27 ### Fixed - Add missing properties to FindPathOpts (#106) ### Changed - Change `EventType` to an interface with a type argument (#110) ## [2.5.2] - 2018-11-09 ### Added - Implements `Room.Terrain` and `room.getTerrain()` ([#103](https://github.com/screepers/typed-screeps/pull/103)) ## [2.5.1] - 2018-10-11 ### Fixed - Fix definition of `RawMemory.segments`. ([#91](https://github.com/screepers/typed-screeps/pull/91)) - Fixed incorrect definition of `getEventLog()`. ([#101](https://github.com/screepers/typed-screeps/pull/101)) ## [2.5.0] - 2018-10-04 ### Added - Added `getRoomTerrain` ([#98](https://github.com/screepers/typed-screeps/pull/98)) - Added WIP types for `room.eventLog` ([#88](https://github.com/screepers/typed-screeps/pull/88)) - Added missing safemode/downgrade constants ([#96](https://github.com/screepers/typed-screeps/pull/96)) ### Changed - `filterOptions` Revamp ([#87](https://github.com/screepers/typed-screeps/pull/87)) ## [2.4.1] - 2018-08-24 ### Added - Added `INVADERS_ENERGY_GOAL` ([#83](https://github.com/screepers/typed-screeps/pull/83)) ### Changed - Update CREEP_CLAIM_LIFE_TIME to match with Screeps 2018-03-05 update ([#84](https://github.com/screepers/typed-screeps/pull/84)) ## [2.4.0] - 2018-06-24 ### Added - Add inter-shard portals ([#74](https://github.com/screepers/typed-screeps/pull/74)) ### Changed - The findClosestBy\* functions potentially return null ([#69](https://github.com/screepers/typed-screeps/pull/69)) ### Fixed - Various improvements by @pmoehl (thank you!) - Fix type of StructureLab.mineralType ([#73](https://github.com/screepers/typed-screeps/pull/73)) - Fix result type of Room.lookAtArea ([#75](https://github.com/screepers/typed-screeps/pull/75)) - Add subscription token as market resource types ([#76](https://github.com/screepers/typed-screeps/pull/76)) - Spawn options +directions ([#77](https://github.com/screepers/typed-screeps/pull/77)) - Add createConstructionSite name parameter ([#78](https://github.com/screepers/typed-screeps/pull/78)) - Updated Tombstone docs ([#79](https://github.com/screepers/typed-screeps/pull/79)) - Improve exit typings ([#80](https://github.com/screepers/typed-screeps/pull/80)) - Fixed missing Constructor extends declarations ([#71](https://github.com/screepers/typed-screeps/pull/71)) - Fixed createFlag method return type to include string ([#72](https://github.com/screepers/typed-screeps/pull/72)) - claimController() uses GCL, not RCL ([#81](https://github.com/screepers/typed-screeps/pull/81)) ## [2.3.0] - 2018-04-16 ### Added - `TERMINAL_COOLDOWN` constant ([#64](https://github.com/screepers/typed-screeps/pull/64)) - Better tombstone support ([#60](https://github.com/screepers/typed-screeps/pull/60)) ### Fixed - Declare `Game` with `var` instead of `let` ([#62](https://github.com/screepers/typed-screeps/pull/62)) - `ERR_NOT_ENOUGH_RESOURCES` missing in return codes for creep build action ([#66](https://github.com/screepers/typed-screeps/pull/66)) ## [2.2.2] - 2018-03-17 ### Added - Added IVM typings ([#55](https://github.com/screepers/typed-screeps/pull/55)) - Added Tombstone typings ([#48](https://github.com/screepers/typed-screeps/pull/48)) ### Fixed - Fixed some DefinitelyTyped linting errors ([#54](https://github.com/screepers/typed-screeps/pull/54)) ## [2.2.1] - 2018-03-09 ### Added - Added `StructureSpawn.Spawning` ([#52](https://github.com/screepers/typed-screeps/pull/52)) ### Changed - Changed `StructureLab.mineralType` from `MineralConstant` to `_ResourceConstantSansEnergy | undefined`. ([#49](https://github.com/screepers/typed-screeps/pull/49)) ### Fixed - `RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE` has a typo ([#51](https://github.com/screepers/typed-screeps/pull/51)) ## [2.2.0] - 2018-01-26 ### Added - Added missing constants: `EXTRACTOR_COOLDOWN`, `SYSTEM_USERNAME` ([#34](https://github.com/screepers/typed-screeps/pull/34)) - Added missing `ScreepsReturnCode` definition: `ERR_NAME_EXISTS` ([#44](https://github.com/screepers/typed-screeps/pull/44)) ### Removed - Remove `FIND_DROPPED_ENERGY` ([#39](https://github.com/screepers/typed-screeps/pull/39) [#40](https://github.com/screepers/typed-screeps/pull/40)) ### Fixed - `Creep.attackController()` returns `ERR_TIRED` if the controller has upgrade blocked ([#32](https://github.com/screepers/typed-screeps/pull/32)) - `PowerBank`s are considered to be owned structures (and are owned by "Power Bank") ([#33](https://github.com/screepers/typed-screeps/pull/33)) - Allow `creep.ticksToLive` to be undefined ([#36](https://github.com/screepers/typed-screeps/pull/36)) - Fixes for `PathFinder.search`, `LookAtTypes` ([#41](https://github.com/screepers/typed-screeps/pull/41), [#47](https://github.com/screepers/typed-screeps/pull/47)) ## [2.1.0] - 2017-12-22 ### Changed - Restuctured project for DefinitelyTyped publishing ([#24](https://github.com/screepers/typed-screeps/pull/24)) ### Fixed - Allow `Game` interface to be extended ([#29](https://github.com/screepers/typed-screeps/pull/29)) - Allow controller sign + reservation to be undefined ([#28](https://github.com/screepers/typed-screeps/pull/28)) ## [2.0.1] - 2017-12-13 ### Fixed - Reduce package size when installing via npm ([#25](https://github.com/screepers/typed-screeps/pull/25)) ## [2.0.0] - 2017-12-05 ### Added - Added contributing guidelines and Issue/PR templates ([#18](https://github.com/screepers/typed-screeps/pull/18)) - Added CI tests (thanks, [@Arcath](https://github.com/Arcath)!) - [Constants] Added `BuildableStructureConstant`, which is a subset of `StructureConstant` ([#17](https://github.com/screepers/typed-screeps/pull/17)) ### Changed - Improved build tooling around compiling scripts and running tests. - [Room][roomposition] Improved generic-based overloads for `.find*()`, `lookAt()`, and `lookForAt()` functions ([#14](https://github.com/screepers/typed-screeps/pull/14), [#19](https://github.com/screepers/typed-screeps/pull/19)) - [Constants] `OBSTACLE_OBJECT_TYPES` are now strictly defined ([#17](https://github.com/screepers/typed-screeps/pull/17)) ### Fixed - [RawMemory] On `setActiveForeignSegment`, id should be optional. ([commit](https://github.com/screepers/typed-screeps/pull/16/commits/9aa7e3efe457f5500cd0eb6a76804bff657db1db)) ## [1.0.4] - 2017-11-09 ### Added - Added `Game.resources` - Added `Game.map.getWorldSize()` - Added `RawMemory.interShardSegment` ### Deprecated - Deprecated `spawn.canCreateCreep(body, [name])` - Deprecated `spawn.createCreep(body, [name], [memory])` - Deprecated `spawn.transferEnergy(target, [amount])` - Deprecated `PathFinder.use(isEnabled)` ## [1.0.3] - 2017-11-05 ### Fixed - Emergency patch to fix mismatched `STRUCTURE_WALL` constant. ## [1.0.2] - 2017-11-05 ### Added - Added `Game.cpu.setShardLimits(limits)` ### Fixed - [Constants] `STRUCTURE_WALL` should be `'constructedWall'`, not `'wall'` ## [1.0.1] - 2017-11-05 ### Changed - Added forgotten documentation material from v1.0.0 ## 1.0.0 - 2017-11-05 ### Added - Initial public `npm` release. [unreleased]: https://github.com/screepers/typed-screeps/compare/v3.3.1...HEAD [3.3.1]: https://github.com/screepers/typed-screeps/compare/v3.3.0...v3.3.1 [3.3.0]: https://github.com/screepers/typed-screeps/compare/v3.2.4...v3.3.0 [3.2.4]: https://github.com/screepers/typed-screeps/compare/v3.2.2...v3.2.4 [3.2.2]: https://github.com/screepers/typed-screeps/compare/v3.2.1...v3.2.2 [3.2.1]: https://github.com/screepers/typed-screeps/compare/v3.2.0...v3.2.1 [3.2.0]: https://github.com/screepers/typed-screeps/compare/v3.1.3...v3.2.0 [3.1.3]: https://github.com/screepers/typed-screeps/compare/v3.1.2...v3.1.3 [3.1.2]: https://github.com/screepers/typed-screeps/compare/v3.1.1...v3.1.2 [3.1.1]: https://github.com/screepers/typed-screeps/compare/v3.1.0...v3.1.1 [3.1.0]: https://github.com/screepers/typed-screeps/compare/v3.0.1...v3.1.0 [3.0.1]: https://github.com/screepers/typed-screeps/compare/v3.0.0...v3.0.1 [3.0.0]: https://github.com/screepers/typed-screeps/compare/v2.5.4...v3.0.0 [2.5.4]: https://github.com/screepers/typed-screeps/compare/v2.5.3...v2.5.4 [2.5.3]: https://github.com/screepers/typed-screeps/compare/v2.5.2...v2.5.3 [2.5.2]: https://github.com/screepers/typed-screeps/compare/v2.5.1...v2.5.2 [2.5.1]: https://github.com/screepers/typed-screeps/compare/v2.5.0...v2.5.1 [2.5.0]: https://github.com/screepers/typed-screeps/compare/v2.4.1...v2.5.0 [2.4.1]: https://github.com/screepers/typed-screeps/compare/v2.4.0...v2.4.1 [2.4.0]: https://github.com/screepers/typed-screeps/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/screepers/typed-screeps/compare/v2.2.2...v2.3.0 [2.2.2]: https://github.com/screepers/typed-screeps/compare/v2.2.1...v2.2.2 [2.2.1]: https://github.com/screepers/typed-screeps/compare/v2.2.0...v2.2.1 [2.2.0]: https://github.com/screepers/typed-screeps/compare/v2.1.0...v2.2.0 [2.1.0]: https://github.com/screepers/typed-screeps/compare/v2.0.1...v2.1.0 [2.0.1]: https://github.com/screepers/typed-screeps/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/screepers/typed-screeps/compare/v1.0.4...v2.0.0 [1.0.4]: https://github.com/screepers/typed-screeps/compare/v1.0.3...v1.0.4 [1.0.3]: https://github.com/screepers/typed-screeps/compare/v1.0.2...v1.0.3 [1.0.2]: https://github.com/screepers/typed-screeps/compare/v1.0.1...v1.0.2 [1.0.1]: https://github.com/screepers/typed-screeps/compare/v1.0.0...v1.0.1 ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at `resir014+screepers@gmail.com`. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org ================================================ FILE: CONTRIBUTING.md ================================================ # Thank you for contributing to `typed-screeps`! This document contains guides on getting started with developing `typed-screeps`, as well as the guidelines for contributing to this repository. This library will stay up to date only with the help of you! If active players don't update it, it'll get lost. ## The Five Golden Rules The simple steps of contributing to any GitHub project are as follows: 1. [Fork the repository](https://github.com/screepers/typed-screeps/fork) 2. Create your feature branch: `git checkout -b my-new-feature` 3. Commit your changes: `git commit -am 'Add some feature'` 4. Push to the branch: `git push -u origin my-new-feature` 5. Create a [Pull Request](https://github.com/screepers/typed-screeps/pulls)! To keep your fork of in sync with this repository, [follow this guide](https://help.github.com/articles/syncing-a-fork/). ## Getting Started To get started, just clone this repository, and install the required dependencies. ```bash npm install ``` The code lives in the `src/` directory. Feel free to make your changes, and when you're done, run the following command to compile them: ```bash npm run compile ``` ## Running Tests To test your changes, run the following command. ```bash npm test ``` This command will compile your most recent changes, and then run linting checks. It will also test compiling against the `test/typed-screeps-tests.ts` file. The tests pass if all code is lint-checked and the tests file compiles without any errors. The `test/typed-screeps-tests.ts` file also works as a sandbox for your additions. If you open this file and see no red squiggly lines, then you're good! ## Committing This codebase uses [husky](https://github.com/typicode/husky) to auto-compile changes on commit. When you commit the changes, husky will first automatically run `npm run compile` and compile your changes. ## Filing Issues We've created [a handy template](ISSUE_TEMPLATE.md) for you to submit any issues with. Please use it! It will assist us in triaging your issues. ## Submitting a Pull Request We accept almost all pull requests, provided your code passes all of the tests, and your pull request description follows the [template](PULL_REQUEST_TEMPLATE.md) we've set up for you. When adding new features, don't forget to add tests for them at the `dist/screeps-tests.ts` file. Likewise, don't forget to edit the [readme](README.md) if you are introducing any major changes or updates. When making changes that are potentially breaking, careful discussion must be done with the community at large. Generally we do this either on the [#typescript](https://screeps.slack.com/messages/typescript/) channel on the Screeps Slack, or on the corresponding pull request discussion thread. ## Update checklist If you are just submitting a PR, this isn't needed, but for new maintainers, when preparing a new version or updates: 1. Update the changelog with links to each relevant PR 2. Update the contributors list. 3. Update version numbers if required 4. (If releasing) Package a release / Update the relevant draft release 5. Close / Update relevant issues 6. (If publishing) Submit a PR to Definitely-Typed ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2016-2017 typed-screeps contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # typed-screeps > Strong TypeScript declarations for the game Screeps: World. [![Github action](https://github.com/screepers/typed-screeps/actions/workflows/CI.yml/badge.svg)](https://github.com/screepers/typed-screeps/actions/workflows/CI.yml) [![npm](https://img.shields.io/npm/v/@types/screeps)](https://www.npmjs.com/package/@types/screeps) ## Installation The type definitions are published on [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped). To install them, run the following. ```bash # npm npm install @types/screeps # yarn yarn add @types/screeps # pnpm pnpm add @types/screeps ``` ## Differences from **[Screeps-Typescript-Declarations](https://github.com/screepers/Screeps-Typescript-Declarations)** This repo has more activity and is considerably more up-to-date. ### Breaking Changes: - `Memory` is typed by default. The added typings are: - `CreepMemory` - `FlagMemory` - `SpawnMemory` - `RoomMemory` If you like the idea of typed memory, but aren't ready to just jump fully in, you only need to make sure you define an interface for the above four types. Then you can extend them at a later time. Example: ```TypeScript interface CreepMemory { [name: string]: any }; interface FlagMemory { [name: string]: any }; interface SpawnMemory { [name: string]: any }; interface RoomMemory { [name: string]: any }; ``` If you don't want to add types to the global `Memory` object, you will need to add the following interface along with the four above. Example: ```Typescript interface Memory { [key: string]: any }; ``` - Any place in code that uses a constant (ex `STRUCTURE_EXTENSION` or `FIND_MY_SPAWNS` is now constrained to use literal types. Here is the list of the new types: ``` BodyPartConstant BuildableStructureConstant (this is a subset of StructureConstant) StructureConstant FindConstant LookConstant DirectionConstant ResourceConstant MineralConstant (this is a subset of ResourceConstant) ColorConstant ScreepsReturnCode Terrain ``` To update your code, you just need to change any `string` types to match one of the above. For example, if your code had: ```TypeScript function getBody(): string[] { return [ WORK, MOVE, CARRY ]; } ``` Change it to: ```TypeScript function getBody(): BodyPartConstant[] { // this line changed return [ WORK, MOVE, CARRY ]; } ``` - Some original functions were incorrectly typed to not include `null` as a possible return. You may need to update your code to reflect this update (ex. `findClosestByPath` or `findClosestByRange`) #### Game.getObjectById() - `Game.getObjectById()` now returns typed objects according to the type of the Id (ex. `Id` returns `StructureTower` type). Use of `string` typed Id, is deprecated and may be removed in the future. When using string Ids, the type of the returned game object is `unknown` which requires manual type assertion. Previously this function returned `any` typed objects which could accidently be left untyped; If you have code like this (un-type-asserted use of `Game.getObjectById`) ```TypeScript interface Memory{ towerIds: string[]; } Memory.towerIds.forEach((towerId) => { const tower = Game.getObjectById(towerId); // type of returned tower is 'unknown' instead of 'any' tower.attack(targetCreep); // Error Object is of type unknown ts(2571) }) ``` Change it store typed Ids: ```TypeScript interface Memory{ towerIds: Array>; } Memory.towerIds.forEach((towerId) => { const tower = Game.getObjectById(towerId); // type of returned tower is StructureTower tower.attack(targetCreep); }) ``` If you're already manually asserting the type of the game object, you're not required to change anything immediately however this is deprecated and may be removed in the future. ```TypeScript const towerId: Id = "" as Id; const tower1 = Game.getObjectById(towerId); // recommended use, returns StructureTower type const tower2 = Game.getObjectById(""); // @deprecated returns StructureTower type const tower3 = Game.getObjectById("") as StructureTower; // @deprecated returns StructureTower type ``` `Id` types are assignable to `string` but the reverse is not allowed implicitly. To assign a `string` type to an `Id` type, you must explicitly assert the type. ```TypeScript const typedId: Id = "123" as Id; // assertion required const untypedId1: string = typedId; // no assertion required ``` - Game objects have typed id properties `id: Id`. These typed ids can by passed to `Game.getObjectById()` to receive typed game objects matching the type of the Id. See above bullet for more details. ```TypeScript creep.id // has type Id copy = Game.getObjectById(creep.id) // returns type Creep tower.id // has type Id ``` ### Additional (non-breaking) Features: - `ConstructionSite` can be optionally constrained by a structure type (ex. `ConstructionSite`). TypeScript will enforce that the `type` property of the `ConstructionSite` appropriately matches - `Resource` can optionally be constrained (ex. `Resource`) - `Mineral` can optionally be constrained by `MineralConstant` (ex. `Mineral`) - `Structure` can optionally be constrained (ex `Structure`) - Screeps classes derived from `Structure` (ex `StructureContainer`) have their `type` property correspondingly constrained - `LookAt` results are now constrained to the type looked for - Results from `Find`-type functions are now constrained to have a `RoomPosition` - Typings for new RawMemory and RoomVisuals - New union type `AnyCreep` to represent `Creep` and `PowerCreep` ## Contribute Issues and Pull Requests are welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md) beforehand. ================================================ FILE: build/concat.js ================================================ const fs = require("fs"); const path = require("path"); const HEADER = `// Please contribute types to https://github.com/screepers/typed-screeps` fs.readdir(path.join(__dirname, "..", "src"), function (err, files) { files = files.map(function (value) { return path.join("src", value); }); Promise.all(files.map((name) => fs.promises.readFile(name))).then( (fileContents) => { fs.writeFileSync(path.join(__dirname, "..", "dist", "index.d.ts"), HEADER + "\n\n" + Buffer.concat(fileContents)); }, (reason) => { console.log(reason); }, ); }); ================================================ FILE: dist/.eslintrc.json ================================================ { "rules": { "@definitelytyped/no-any-union": "off", "@definitelytyped/no-unnecessary-generics": "off", "@typescript-eslint/no-empty-interface": "off", "@typescript-eslint/no-misused-new": "off" } } ================================================ FILE: dist/.npmignore ================================================ * !**/*.d.ts !**/*.d.cts !**/*.d.mts !**/*.d.*.ts ================================================ FILE: dist/index.d.ts ================================================ // Please contribute types to https://github.com/screepers/typed-screeps // Game Constants declare const OK: OK; declare const ERR_NOT_OWNER: ERR_NOT_OWNER; declare const ERR_NO_PATH: ERR_NO_PATH; declare const ERR_NAME_EXISTS: ERR_NAME_EXISTS; declare const ERR_BUSY: ERR_BUSY; declare const ERR_NOT_FOUND: ERR_NOT_FOUND; declare const ERR_NOT_ENOUGH_RESOURCES: ERR_NOT_ENOUGH_RESOURCES; declare const ERR_NOT_ENOUGH_ENERGY: ERR_NOT_ENOUGH_ENERGY; declare const ERR_INVALID_TARGET: ERR_INVALID_TARGET; declare const ERR_FULL: ERR_FULL; declare const ERR_NOT_IN_RANGE: ERR_NOT_IN_RANGE; declare const ERR_INVALID_ARGS: ERR_INVALID_ARGS; declare const ERR_TIRED: ERR_TIRED; declare const ERR_NO_BODYPART: ERR_NO_BODYPART; declare const ERR_NOT_ENOUGH_EXTENSIONS: ERR_NOT_ENOUGH_EXTENSIONS; declare const ERR_RCL_NOT_ENOUGH: ERR_RCL_NOT_ENOUGH; declare const ERR_GCL_NOT_ENOUGH: ERR_GCL_NOT_ENOUGH; declare const ERR_ACCESS_DENIED: ERR_ACCESS_DENIED; declare const FIND_EXIT_TOP: FIND_EXIT_TOP; declare const FIND_EXIT_RIGHT: FIND_EXIT_RIGHT; declare const FIND_EXIT_BOTTOM: FIND_EXIT_BOTTOM; declare const FIND_EXIT_LEFT: FIND_EXIT_LEFT; declare const FIND_EXIT: FIND_EXIT; declare const FIND_CREEPS: FIND_CREEPS; declare const FIND_MY_CREEPS: FIND_MY_CREEPS; declare const FIND_HOSTILE_CREEPS: FIND_HOSTILE_CREEPS; declare const FIND_SOURCES_ACTIVE: FIND_SOURCES_ACTIVE; declare const FIND_SOURCES: FIND_SOURCES; declare const FIND_DROPPED_RESOURCES: FIND_DROPPED_RESOURCES; declare const FIND_STRUCTURES: FIND_STRUCTURES; declare const FIND_MY_STRUCTURES: FIND_MY_STRUCTURES; declare const FIND_HOSTILE_STRUCTURES: FIND_HOSTILE_STRUCTURES; declare const FIND_FLAGS: FIND_FLAGS; declare const FIND_CONSTRUCTION_SITES: FIND_CONSTRUCTION_SITES; declare const FIND_MY_SPAWNS: FIND_MY_SPAWNS; declare const FIND_HOSTILE_SPAWNS: FIND_HOSTILE_SPAWNS; declare const FIND_MY_CONSTRUCTION_SITES: FIND_MY_CONSTRUCTION_SITES; declare const FIND_HOSTILE_CONSTRUCTION_SITES: FIND_HOSTILE_CONSTRUCTION_SITES; declare const FIND_MINERALS: FIND_MINERALS; declare const FIND_NUKES: FIND_NUKES; declare const FIND_TOMBSTONES: FIND_TOMBSTONES; declare const FIND_POWER_CREEPS: FIND_POWER_CREEPS; declare const FIND_MY_POWER_CREEPS: FIND_MY_POWER_CREEPS; declare const FIND_HOSTILE_POWER_CREEPS: FIND_HOSTILE_POWER_CREEPS; declare const FIND_DEPOSITS: FIND_DEPOSITS; declare const FIND_RUINS: FIND_RUINS; declare const TOP: TOP; declare const TOP_RIGHT: TOP_RIGHT; declare const RIGHT: RIGHT; declare const BOTTOM_RIGHT: BOTTOM_RIGHT; declare const BOTTOM: BOTTOM; declare const BOTTOM_LEFT: BOTTOM_LEFT; declare const LEFT: LEFT; declare const TOP_LEFT: TOP_LEFT; declare const COLOR_RED: COLOR_RED; declare const COLOR_PURPLE: COLOR_PURPLE; declare const COLOR_BLUE: COLOR_BLUE; declare const COLOR_CYAN: COLOR_CYAN; declare const COLOR_GREEN: COLOR_GREEN; declare const COLOR_YELLOW: COLOR_YELLOW; declare const COLOR_ORANGE: COLOR_ORANGE; declare const COLOR_BROWN: COLOR_BROWN; declare const COLOR_GREY: COLOR_GREY; declare const COLOR_WHITE: COLOR_WHITE; declare const COLORS_ALL: ColorConstant[]; declare const CREEP_SPAWN_TIME: 3; declare const CREEP_LIFE_TIME: 1500; declare const CREEP_CLAIM_LIFE_TIME: 600; declare const CREEP_CORPSE_RATE: 0.2; declare const OBSTACLE_OBJECT_TYPES: [ "spawn", "creep", "powerCreep", "source", "mineral", "deposit", "controller", "constructedWall", "extension", "link", "storage", "tower", "observer", "powerSpawn", "powerBank", "lab", "terminal", "nuker", "factory", "invaderCore", ]; 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: { [rcl: number]: number; 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: { [rcl: number]: number; 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_WEAROUT_POWER_CREEP: 100; 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 FACTORY_HITS: 1000; declare const FACTORY_CAPACITY: 50000; declare const BODYPART_COST: Record; declare const BODYPARTS_ALL: BodyPartConstant[]; declare const CARRY_CAPACITY: 50; declare const HARVEST_POWER: 2; declare const HARVEST_MINERAL_POWER: 1; declare const HARVEST_DEPOSIT_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: Record; declare const CONSTRUCTION_COST_ROAD_SWAMP_RATIO: 5; declare const CONSTRUCTION_COST_ROAD_WALL_RATIO: 150; declare const STRUCTURE_EXTENSION: STRUCTURE_EXTENSION; declare const STRUCTURE_RAMPART: STRUCTURE_RAMPART; declare const STRUCTURE_ROAD: STRUCTURE_ROAD; declare const STRUCTURE_SPAWN: STRUCTURE_SPAWN; declare const STRUCTURE_LINK: STRUCTURE_LINK; declare const STRUCTURE_WALL: STRUCTURE_WALL; declare const STRUCTURE_KEEPER_LAIR: STRUCTURE_KEEPER_LAIR; declare const STRUCTURE_CONTROLLER: STRUCTURE_CONTROLLER; declare const STRUCTURE_STORAGE: STRUCTURE_STORAGE; declare const STRUCTURE_TOWER: STRUCTURE_TOWER; declare const STRUCTURE_OBSERVER: STRUCTURE_OBSERVER; declare const STRUCTURE_POWER_BANK: STRUCTURE_POWER_BANK; declare const STRUCTURE_POWER_SPAWN: STRUCTURE_POWER_SPAWN; declare const STRUCTURE_EXTRACTOR: STRUCTURE_EXTRACTOR; declare const STRUCTURE_LAB: STRUCTURE_LAB; declare const STRUCTURE_TERMINAL: STRUCTURE_TERMINAL; declare const STRUCTURE_CONTAINER: STRUCTURE_CONTAINER; declare const STRUCTURE_NUKER: STRUCTURE_NUKER; declare const STRUCTURE_FACTORY: STRUCTURE_FACTORY; declare const STRUCTURE_INVADER_CORE: STRUCTURE_INVADER_CORE; declare const STRUCTURE_PORTAL: STRUCTURE_PORTAL; declare const RESOURCE_ENERGY: RESOURCE_ENERGY; declare const RESOURCE_POWER: RESOURCE_POWER; declare const RESOURCE_OPS: RESOURCE_OPS; declare const RESOURCE_UTRIUM: RESOURCE_UTRIUM; declare const RESOURCE_LEMERGIUM: RESOURCE_LEMERGIUM; declare const RESOURCE_KEANIUM: RESOURCE_KEANIUM; declare const RESOURCE_GHODIUM: RESOURCE_GHODIUM; declare const RESOURCE_ZYNTHIUM: RESOURCE_ZYNTHIUM; declare const RESOURCE_OXYGEN: RESOURCE_OXYGEN; declare const RESOURCE_HYDROGEN: RESOURCE_HYDROGEN; declare const RESOURCE_CATALYST: RESOURCE_CATALYST; declare const RESOURCE_HYDROXIDE: RESOURCE_HYDROXIDE; declare const RESOURCE_ZYNTHIUM_KEANITE: RESOURCE_ZYNTHIUM_KEANITE; declare const RESOURCE_UTRIUM_LEMERGITE: RESOURCE_UTRIUM_LEMERGITE; declare const RESOURCE_UTRIUM_HYDRIDE: RESOURCE_UTRIUM_HYDRIDE; declare const RESOURCE_UTRIUM_OXIDE: RESOURCE_UTRIUM_OXIDE; declare const RESOURCE_KEANIUM_HYDRIDE: RESOURCE_KEANIUM_HYDRIDE; declare const RESOURCE_KEANIUM_OXIDE: RESOURCE_KEANIUM_OXIDE; declare const RESOURCE_LEMERGIUM_HYDRIDE: RESOURCE_LEMERGIUM_HYDRIDE; declare const RESOURCE_LEMERGIUM_OXIDE: RESOURCE_LEMERGIUM_OXIDE; declare const RESOURCE_ZYNTHIUM_HYDRIDE: RESOURCE_ZYNTHIUM_HYDRIDE; declare const RESOURCE_ZYNTHIUM_OXIDE: RESOURCE_ZYNTHIUM_OXIDE; declare const RESOURCE_GHODIUM_HYDRIDE: RESOURCE_GHODIUM_HYDRIDE; declare const RESOURCE_GHODIUM_OXIDE: RESOURCE_GHODIUM_OXIDE; declare const RESOURCE_UTRIUM_ACID: RESOURCE_UTRIUM_ACID; declare const RESOURCE_UTRIUM_ALKALIDE: RESOURCE_UTRIUM_ALKALIDE; declare const RESOURCE_KEANIUM_ACID: RESOURCE_KEANIUM_ACID; declare const RESOURCE_KEANIUM_ALKALIDE: RESOURCE_KEANIUM_ALKALIDE; declare const RESOURCE_LEMERGIUM_ACID: RESOURCE_LEMERGIUM_ACID; declare const RESOURCE_LEMERGIUM_ALKALIDE: RESOURCE_LEMERGIUM_ALKALIDE; declare const RESOURCE_ZYNTHIUM_ACID: RESOURCE_ZYNTHIUM_ACID; declare const RESOURCE_ZYNTHIUM_ALKALIDE: RESOURCE_ZYNTHIUM_ALKALIDE; declare const RESOURCE_GHODIUM_ACID: RESOURCE_GHODIUM_ACID; declare const RESOURCE_GHODIUM_ALKALIDE: RESOURCE_GHODIUM_ALKALIDE; declare const RESOURCE_CATALYZED_UTRIUM_ACID: RESOURCE_CATALYZED_UTRIUM_ACID; declare const RESOURCE_CATALYZED_UTRIUM_ALKALIDE: RESOURCE_CATALYZED_UTRIUM_ALKALIDE; declare const RESOURCE_CATALYZED_KEANIUM_ACID: RESOURCE_CATALYZED_KEANIUM_ACID; declare const RESOURCE_CATALYZED_KEANIUM_ALKALIDE: RESOURCE_CATALYZED_KEANIUM_ALKALIDE; declare const RESOURCE_CATALYZED_LEMERGIUM_ACID: RESOURCE_CATALYZED_LEMERGIUM_ACID; declare const RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE: RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE; declare const RESOURCE_CATALYZED_ZYNTHIUM_ACID: RESOURCE_CATALYZED_ZYNTHIUM_ACID; declare const RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE; declare const RESOURCE_CATALYZED_GHODIUM_ACID: RESOURCE_CATALYZED_GHODIUM_ACID; declare const RESOURCE_CATALYZED_GHODIUM_ALKALIDE: RESOURCE_CATALYZED_GHODIUM_ALKALIDE; declare const RESOURCE_BIOMASS: RESOURCE_BIOMASS; declare const RESOURCE_METAL: RESOURCE_METAL; declare const RESOURCE_MIST: RESOURCE_MIST; declare const RESOURCE_SILICON: RESOURCE_SILICON; declare const RESOURCE_UTRIUM_BAR: RESOURCE_UTRIUM_BAR; declare const RESOURCE_LEMERGIUM_BAR: RESOURCE_LEMERGIUM_BAR; declare const RESOURCE_ZYNTHIUM_BAR: RESOURCE_ZYNTHIUM_BAR; declare const RESOURCE_KEANIUM_BAR: RESOURCE_KEANIUM_BAR; declare const RESOURCE_GHODIUM_MELT: RESOURCE_GHODIUM_MELT; declare const RESOURCE_OXIDANT: RESOURCE_OXIDANT; declare const RESOURCE_REDUCTANT: RESOURCE_REDUCTANT; declare const RESOURCE_PURIFIER: RESOURCE_PURIFIER; declare const RESOURCE_BATTERY: RESOURCE_BATTERY; declare const RESOURCE_COMPOSITE: RESOURCE_COMPOSITE; declare const RESOURCE_CRYSTAL: RESOURCE_CRYSTAL; declare const RESOURCE_LIQUID: RESOURCE_LIQUID; declare const RESOURCE_WIRE: RESOURCE_WIRE; declare const RESOURCE_SWITCH: RESOURCE_SWITCH; declare const RESOURCE_TRANSISTOR: RESOURCE_TRANSISTOR; declare const RESOURCE_MICROCHIP: RESOURCE_MICROCHIP; declare const RESOURCE_CIRCUIT: RESOURCE_CIRCUIT; declare const RESOURCE_DEVICE: RESOURCE_DEVICE; declare const RESOURCE_CELL: RESOURCE_CELL; declare const RESOURCE_PHLEGM: RESOURCE_PHLEGM; declare const RESOURCE_TISSUE: RESOURCE_TISSUE; declare const RESOURCE_MUSCLE: RESOURCE_MUSCLE; declare const RESOURCE_ORGANOID: RESOURCE_ORGANOID; declare const RESOURCE_ORGANISM: RESOURCE_ORGANISM; declare const RESOURCE_ALLOY: RESOURCE_ALLOY; declare const RESOURCE_TUBE: RESOURCE_TUBE; declare const RESOURCE_FIXTURES: RESOURCE_FIXTURES; declare const RESOURCE_FRAME: RESOURCE_FRAME; declare const RESOURCE_HYDRAULICS: RESOURCE_HYDRAULICS; declare const RESOURCE_MACHINE: RESOURCE_MACHINE; declare const RESOURCE_CONDENSATE: RESOURCE_CONDENSATE; declare const RESOURCE_CONCENTRATE: RESOURCE_CONCENTRATE; declare const RESOURCE_EXTRACT: RESOURCE_EXTRACT; declare const RESOURCE_SPIRIT: RESOURCE_SPIRIT; declare const RESOURCE_EMANATION: RESOURCE_EMANATION; declare const RESOURCE_ESSENCE: RESOURCE_ESSENCE; declare const RESOURCES_ALL: ResourceConstant[]; declare const SUBSCRIPTION_TOKEN: SUBSCRIPTION_TOKEN; declare const CPU_UNLOCK: CPU_UNLOCK; declare const PIXEL: PIXEL; declare const ACCESS_KEY: ACCESS_KEY; declare const PIXEL_CPU_COST: 10000; declare const CONTROLLER_LEVELS: { [level: number]: number }; declare const CONTROLLER_STRUCTURES: Record; declare const CONTROLLER_DOWNGRADE: { [level: number]: number }; declare const CONTROLLER_DOWNGRADE_RESTORE: number; declare const CONTROLLER_DOWNGRADE_SAFEMODE_THRESHOLD: 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 CONTROLLER_NUKE_BLOCKED_UPGRADE: number; declare const SAFE_MODE_DURATION: 20000; declare const SAFE_MODE_COOLDOWN: 50000; declare const SAFE_MODE_COST: 1000; 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 EXTRACTOR_COOLDOWN: 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: null; declare const MODE_WORLD: null; declare const TERRAIN_MASK_WALL: TERRAIN_MASK_WALL; declare const TERRAIN_MASK_SWAMP: TERRAIN_MASK_SWAMP; declare const TERRAIN_MASK_LAVA: TERRAIN_MASK_LAVA; declare const MAX_CONSTRUCTION_SITES: number; declare const MAX_CREEP_SIZE: number; declare const MINERAL_REGEN_TIME: number; declare const MINERAL_MIN_AMOUNT: Record; declare const MINERAL_RANDOM_FACTOR: number; declare const MINERAL_DENSITY: { [level: number]: number; 1: number; 2: number; 3: number; 4: number; }; declare const MINERAL_DENSITY_PROBABILITY: { [level: number]: number; 1: number; 2: number; 3: number; 4: number; }; declare const MINERAL_DENSITY_CHANGE: number; declare const DENSITY_LOW: DENSITY_LOW; declare const DENSITY_MODERATE: DENSITY_MODERATE; declare const DENSITY_HIGH: DENSITY_HIGH; declare const DENSITY_ULTRA: DENSITY_ULTRA; declare const DEPOSIT_EXHAUST_MULTIPLY: number; declare const DEPOSIT_EXHAUST_POW: number; declare const DEPOSIT_DECAY_TIME: number; declare const TERMINAL_CAPACITY: number; declare const TERMINAL_COOLDOWN: number; declare const TERMINAL_HITS: number; declare const TERMINAL_SEND_COST: number; declare const TERMINAL_MIN_SEND: 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: { [range: number]: number; 0: number; 1: number; 4: number; }; declare const REACTIONS: { [resource: string]: { [resource: string]: string }; H: { O: "OH"; L: "LH"; K: "KH"; U: "UH"; Z: "ZH"; G: "GH"; }; O: { H: "OH"; L: "LO"; K: "KO"; U: "UO"; Z: "ZO"; G: "GO"; }; Z: { K: "ZK"; H: "ZH"; O: "ZO"; }; L: { U: "UL"; H: "LH"; O: "LO"; }; K: { Z: "ZK"; H: "KH"; O: "KO"; }; G: { H: "GH"; O: "GO"; }; U: { L: "UL"; H: "UH"; O: "UO"; }; OH: { UH: "UH2O"; UO: "UHO2"; ZH: "ZH2O"; ZO: "ZHO2"; KH: "KH2O"; KO: "KHO2"; LH: "LH2O"; LO: "LHO2"; GH: "GH2O"; GO: "GHO2"; }; X: { UH2O: "XUH2O"; UHO2: "XUHO2"; LH2O: "XLH2O"; LHO2: "XLHO2"; KH2O: "XKH2O"; KHO2: "XKHO2"; ZH2O: "XZH2O"; ZHO2: "XZHO2"; GH2O: "XGH2O"; GHO2: "XGHO2"; }; ZK: { UL: "G"; }; UL: { ZK: "G"; }; LH: { OH: "LH2O"; }; ZH: { OH: "ZH2O"; }; GH: { OH: "GH2O"; }; KH: { OH: "KH2O"; }; UH: { OH: "UH2O"; }; LO: { OH: "LHO2"; }; ZO: { OH: "ZHO2"; }; KO: { OH: "KHO2"; }; UO: { OH: "UHO2"; }; GO: { OH: "GHO2"; }; LH2O: { X: "XLH2O"; }; KH2O: { X: "XKH2O"; }; ZH2O: { X: "XZH2O"; }; UH2O: { X: "XUH2O"; }; GH2O: { X: "XGH2O"; }; LHO2: { X: "XLHO2"; }; UHO2: { X: "XUHO2"; }; KHO2: { X: "XKHO2"; }; ZHO2: { X: "XZHO2"; }; GHO2: { X: "XGHO2"; }; }; declare const REACTION_TIME: { OH: 20; ZK: 5; UL: 5; G: 5; UH: 10; UH2O: 5; XUH2O: 60; UO: 10; UHO2: 5; XUHO2: 60; KH: 10; KH2O: 5; XKH2O: 60; KO: 10; KHO2: 5; XKHO2: 60; LH: 15; LH2O: 10; XLH2O: 65; LO: 10; LHO2: 5; XLHO2: 60; ZH: 20; ZH2O: 40; XZH2O: 160; ZO: 10; ZHO2: 5; XZHO2: 60; GH: 10; GH2O: 15; XGH2O: 80; GO: 10; GHO2: 30; XGHO2: 150; }; declare const BOOSTS: { [part: string]: { [boost: string]: { [action: string]: number } }; work: { UO: { harvest: 3; }; UHO2: { harvest: 5; }; XUHO2: { harvest: 7; }; LH: { build: 1.5; repair: 1.5; }; LH2O: { build: 1.8; repair: 1.8; }; XLH2O: { build: 2; repair: 2; }; ZH: { dismantle: 2; }; ZH2O: { dismantle: 3; }; XZH2O: { dismantle: 4; }; GH: { upgradeController: 1.5; }; GH2O: { upgradeController: 1.8; }; XGH2O: { upgradeController: 2; }; }; attack: { UH: { attack: 2; }; UH2O: { attack: 3; }; XUH2O: { attack: 4; }; }; ranged_attack: { KO: { rangedAttack: 2; rangedMassAttack: 2; }; KHO2: { rangedAttack: 3; rangedMassAttack: 3; }; XKHO2: { rangedAttack: 4; rangedMassAttack: 4; }; }; heal: { LO: { heal: 2; rangedHeal: 2; }; LHO2: { heal: 3; rangedHeal: 3; }; XLHO2: { heal: 4; rangedHeal: 4; }; }; carry: { KH: { capacity: 2; }; KH2O: { capacity: 3; }; XKH2O: { capacity: 4; }; }; move: { ZO: { fatigue: 2; }; ZHO2: { fatigue: 3; }; XZHO2: { fatigue: 4; }; }; tough: { GO: { damage: 0.7; }; GHO2: { damage: 0.5; }; XGHO2: { damage: 0.3; }; }; }; declare const INTERSHARD_RESOURCES: InterShardResourceConstant[]; type CommoditiesTypes = CommodityConstant | MineralConstant | RESOURCE_GHODIUM | RESOURCE_ENERGY; interface CommodityEntry { level?: number; amount: number; cooldown: number; components: Record; } declare const COMMODITIES: Record; declare const LOOK_CREEPS: LOOK_CREEPS; declare const LOOK_ENERGY: LOOK_ENERGY; declare const LOOK_RESOURCES: LOOK_RESOURCES; declare const LOOK_SOURCES: LOOK_SOURCES; declare const LOOK_MINERALS: LOOK_MINERALS; declare const LOOK_DEPOSITS: LOOK_DEPOSITS; declare const LOOK_STRUCTURES: LOOK_STRUCTURES; declare const LOOK_FLAGS: LOOK_FLAGS; declare const LOOK_CONSTRUCTION_SITES: LOOK_CONSTRUCTION_SITES; declare const LOOK_NUKES: LOOK_NUKES; declare const LOOK_TERRAIN: LOOK_TERRAIN; declare const LOOK_TOMBSTONES: LOOK_TOMBSTONES; declare const LOOK_POWER_CREEPS: LOOK_POWER_CREEPS; declare const LOOK_RUINS: LOOK_RUINS; declare const ORDER_SELL: ORDER_SELL; declare const ORDER_BUY: ORDER_BUY; declare const MARKET_FEE: 0.05; declare const MARKET_MAX_ORDERS: 300; declare const MARKET_ORDER_LIFE_TIME: 2592000000; // 1000*60*60*24*30 declare const INVADERS_ENERGY_GOAL: number; declare const SYSTEM_USERNAME: string; declare const TOMBSTONE_DECAY_PER_PART: 5; declare const TOMBSTONE_DECAY_POWER_CREEP: 500; declare const RUIN_DECAY: 500; declare const RUIN_DECAY_STRUCTURES: { powerBank: 10; }; declare const EVENT_ATTACK: EVENT_ATTACK; declare const EVENT_OBJECT_DESTROYED: EVENT_OBJECT_DESTROYED; declare const EVENT_ATTACK_CONTROLLER: EVENT_ATTACK_CONTROLLER; declare const EVENT_BUILD: EVENT_BUILD; declare const EVENT_HARVEST: EVENT_HARVEST; declare const EVENT_HEAL: EVENT_HEAL; declare const EVENT_REPAIR: EVENT_REPAIR; declare const EVENT_RESERVE_CONTROLLER: EVENT_RESERVE_CONTROLLER; declare const EVENT_UPGRADE_CONTROLLER: EVENT_UPGRADE_CONTROLLER; declare const EVENT_EXIT: EVENT_EXIT; declare const EVENT_POWER: EVENT_POWER; declare const EVENT_TRANSFER: EVENT_TRANSFER; declare const EVENT_ATTACK_TYPE_MELEE: EVENT_ATTACK_TYPE_MELEE; declare const EVENT_ATTACK_TYPE_RANGED: EVENT_ATTACK_TYPE_RANGED; declare const EVENT_ATTACK_TYPE_RANGED_MASS: EVENT_ATTACK_TYPE_RANGED_MASS; declare const EVENT_ATTACK_TYPE_DISMANTLE: EVENT_ATTACK_TYPE_DISMANTLE; declare const EVENT_ATTACK_TYPE_HIT_BACK: EVENT_ATTACK_TYPE_HIT_BACK; declare const EVENT_ATTACK_TYPE_NUKE: EVENT_ATTACK_TYPE_NUKE; declare const EVENT_HEAL_TYPE_MELEE: EVENT_HEAL_TYPE_MELEE; declare const EVENT_HEAL_TYPE_RANGED: EVENT_HEAL_TYPE_RANGED; declare const POWER_LEVEL_MULTIPLY: 1000; declare const POWER_LEVEL_POW: 2; declare const POWER_CREEP_SPAWN_COOLDOWN: 28800000; // 8 * 3600 * 1000 declare const POWER_CREEP_DELETE_COOLDOWN: 86400000; // 24 * 3600 * 1000 declare const POWER_CREEP_MAX_LEVEL: 25; declare const POWER_CREEP_LIFE_TIME: 5000; declare const POWER_CLASS: { OPERATOR: "operator"; }; declare const PWR_GENERATE_OPS: PWR_GENERATE_OPS; declare const PWR_OPERATE_SPAWN: PWR_OPERATE_SPAWN; declare const PWR_OPERATE_TOWER: PWR_OPERATE_TOWER; declare const PWR_OPERATE_STORAGE: PWR_OPERATE_STORAGE; declare const PWR_OPERATE_LAB: PWR_OPERATE_LAB; declare const PWR_OPERATE_EXTENSION: PWR_OPERATE_EXTENSION; declare const PWR_OPERATE_OBSERVER: PWR_OPERATE_OBSERVER; declare const PWR_OPERATE_TERMINAL: PWR_OPERATE_TERMINAL; declare const PWR_DISRUPT_SPAWN: PWR_DISRUPT_SPAWN; declare const PWR_DISRUPT_TOWER: PWR_DISRUPT_TOWER; declare const PWR_DISRUPT_SOURCE: PWR_DISRUPT_SOURCE; declare const PWR_SHIELD: PWR_SHIELD; declare const PWR_REGEN_SOURCE: PWR_REGEN_SOURCE; declare const PWR_REGEN_MINERAL: PWR_REGEN_MINERAL; declare const PWR_DISRUPT_TERMINAL: PWR_DISRUPT_TERMINAL; declare const PWR_OPERATE_POWER: PWR_OPERATE_POWER; declare const PWR_FORTIFY: PWR_FORTIFY; declare const PWR_OPERATE_CONTROLLER: PWR_OPERATE_CONTROLLER; declare const PWR_OPERATE_FACTORY: PWR_OPERATE_FACTORY; declare const EFFECT_INVULNERABILITY: EFFECT_INVULNERABILITY; declare const EFFECT_COLLAPSE_TIMER: EFFECT_COLLAPSE_TIMER; declare const INVADER_CORE_HITS: 100000; declare const INVADER_CORE_CREEP_SPAWN_TIME: { 0: 0; 1: 0; 2: 6; 3: 3; 4: 2; 5: 1; }; declare const INVADER_CORE_EXPAND_TIME: { 1: 4000; 2: 3500; 3: 3000; 4: 2500; 5: 2000; }; declare const INVADER_CORE_CONTROLLER_POWER: 2; declare const INVADER_CORE_CONTROLLER_DOWNGRADE: 5000; declare const STRONGHOLD_RAMPART_HITS: { 0: 0; 1: 100000; 2: 200000; 3: 500000; 4: 1000000; 5: 2000000; }; declare const STRONGHOLD_DECAY_TICKS: 75000; declare const POWER_INFO: { [powerID: number]: { className: PowerClassConstant; level: number[]; cooldown: number; effect?: number[]; range?: number; ops?: number | number[]; duration?: number | number[]; }; [PWR_GENERATE_OPS]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; effect: [1, 2, 4, 6, 8]; }; [PWR_OPERATE_SPAWN]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 300; duration: 1000; range: 3; ops: 100; effect: [0.9, 0.7, 0.5, 0.35, 0.2]; }; [PWR_OPERATE_TOWER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 10; duration: 100; range: 3; ops: 10; effect: [1.1, 1.2, 1.3, 1.4, 1.5]; }; [PWR_OPERATE_STORAGE]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 800; duration: 1000; range: 3; ops: 100; effect: [500000, 1000000, 2000000, 4000000, 7000000]; }; [PWR_OPERATE_LAB]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; duration: 1000; range: 3; ops: 10; effect: [2, 4, 6, 8, 10]; }; [PWR_OPERATE_EXTENSION]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; range: 3; ops: 2; effect: [0.2, 0.4, 0.6, 0.8, 1.0]; }; [PWR_OPERATE_OBSERVER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 400; duration: [200, 400, 600, 800, 1000]; range: 3; ops: 10; }; [PWR_OPERATE_TERMINAL]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 500; duration: 1000; range: 3; ops: 100; effect: [0.9, 0.8, 0.7, 0.6, 0.5]; }; [PWR_DISRUPT_SPAWN]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 5; range: 20; ops: 10; duration: [1, 2, 3, 4, 5]; }; [PWR_DISRUPT_TOWER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 0; duration: 5; range: 50; ops: 10; effect: [0.9, 0.8, 0.7, 0.6, 0.5]; }; [PWR_DISRUPT_SOURCE]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 100; range: 3; ops: 100; duration: [100, 200, 300, 400, 500]; }; [PWR_SHIELD]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; effect: [5000, 10000, 15000, 20000, 25000]; duration: 50; cooldown: 20; energy: 100; }; [PWR_REGEN_SOURCE]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 100; duration: 300; range: 3; effect: [50, 100, 150, 200, 250]; period: 15; }; [PWR_REGEN_MINERAL]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 100; duration: 100; range: 3; effect: [2, 4, 6, 8, 10]; period: 10; }; [PWR_DISRUPT_TERMINAL]: { className: POWER_CLASS["OPERATOR"]; level: [20, 21, 22, 23, 24]; cooldown: 8; duration: 10; range: 50; ops: [50, 40, 30, 20, 10]; }; [PWR_FORTIFY]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 5; range: 3; ops: 5; duration: [1, 2, 3, 4, 5]; }; [PWR_OPERATE_POWER]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 800; range: 3; duration: 1000; ops: 200; effect: [1, 2, 3, 4, 5]; }; [PWR_OPERATE_CONTROLLER]: { className: POWER_CLASS["OPERATOR"]; level: [20, 21, 22, 23, 24]; cooldown: 800; range: 3; duration: 1000; ops: 200; effect: [10, 20, 30, 40, 50]; }; [PWR_OPERATE_FACTORY]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 1000; range: 3; duration: 1000; ops: 100; }; }; /** * 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 {@link Room.createConstructionSite} method. * * To build a structure on the construction site, give a worker creep some amount of energy and perform {@link Creep.build} action. * * You can remove enemy construction sites by moving a creep on it. */ interface ConstructionSite extends RoomObject { readonly prototype: ConstructionSite; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * 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 {@link StructureConstant STRUCTURE_*} constants. */ structureType: T; /** * Remove the construction site. * @returns Result Code: OK, ERR_NOT_OWNER */ remove(): number; } interface ConstructionSiteConstructor extends _Constructor, _ConstructorById {} declare const ConstructionSite: ConstructionSiteConstructor; /** * 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 represented by {@link BodyPartConstant}:. * * | Body part | Build cost | Effect per one body part * | :-------------- | :--------: | :----------------------- * | MOVE | 50 | Decreases fatigue by 2 points per tick. * | WORK | 100 | Harvests 2 energy units from a source per tick. * | | | Harvests 1 resource unit from a mineral or a deposit per tick. * | | | Builds a structure for 5 energy units per tick. * | | | Repairs a structure for 100 hits per tick consuming 1 energy unit per tick. * | | | Dismantles a structure for 50 hits per tick returning 0.25 energy unit per tick. * | | | Upgrades a controller for 1 energy unit per tick. * | CARRY | 50 | Can contain up to 50 resource units. * | ATTACK | 80 | Attacks another creep/structure with 30 hits per tick in a short-ranged attack. * | RANGED_ATTACK | 150 | Attacks another single creep/structure with 10 hits per tick in a long-range attack up to 3 squares long. * | | | Attacks all hostile creeps/structures within 3 squares range with 1-4-10 hits (depending on the range). * | HEAL | 250 | Heals self or another creep restoring 12 hits per tick in short range or 4 hits per tick at a distance. * | CLAIM | 600 | Claims a neutral room controller. * | | | Reserves a neutral room controller for 1 tick per body part. * | | | Attacks a hostile room controller downgrading its timer by 300 ticks per body parts. * | | | Attacks a neutral room controller reservation timer by 1 tick per body parts. * | | | A creep with this body part will have a reduced life time of 600 ticks and cannot be renewed. * | TOUGH | 10 | No effect, just additional hit points to the creep's body. Can be boosted to resist damage. */ interface Creep extends RoomObject { readonly prototype: Creep; /** * An array describing the creep's body. */ body: BodyPartDefinition[]; /** * An object with the creep's cargo contents. * @deprecated Is an alias for Creep.store */ carry: StoreDefinition; /** * The total amount of resources the creep can carry. * @deprecated alias for {@link Creep.store.getCapacity} */ 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 {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * A shorthand to `Memory.creeps[creep.name]`. * * You can use it for quick access the creep’s specific memory data object. */ memory: CreepMemory; /** * Whether it is your creep or foe. */ my: boolean; /** * The 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 {@link Game.creeps} object. */ name: string; /** * An object with the creep’s owner info. */ owner: Owner; /** * The {@link Room} the creep is in. * * 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; /** * A Store object that contains cargo of this creep. */ store: StoreDefinition; /** * The remaining amount of game ticks after which the creep will die. * * Will be `undefined` if the creep is still spawning. */ ticksToLive: number | undefined; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no ATTACK body parts in this creep’s body. */ attack(target: AnyCreep | Structure): CreepActionReturnCode; /** * Attack a controller. * * Decreases the controller's downgrade or reservation timer for 1 tick per every 5 `CLAIM` body parts (so the creep must have at least 5x`CLAIM`). * * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid owned or reserved controller object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: You have to wait until the next attack is possible. * - ERR_NO_BODYPART: There are not enough CLAIM body parts in this creep’s body. */ attackController(target: StructureController): CreepActionReturnCode; /** * 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 construction site to be built. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have any carried energy. * - ERR_INVALID_TARGET: The target is not a valid construction site object or the structure cannot be built here (probably because of a creep at the same square). * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ build(target: ConstructionSite): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; /** * Cancel the order given during the current game tick. * @param methodName The name of a creep's method to be cancelled. * @returns One of the following codes: * - OK: The operation has been cancelled successfully. * - ERR_NOT_FOUND: The order with the specified name is not found. */ cancelOrder(methodName: string): OK | ERR_NOT_FOUND; /** * Claim a controller. * * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid neutral controller object. * - ERR_FULL: You cannot claim more than 3 rooms in the Novice Area. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_GCL_NOT_ENOUGH: Your Global Control Level is not enough. * - ERR_ACCESS_DENIED: The shard access is restricted. */ claimController(target: StructureController): CreepActionReturnCode | ERR_FULL | ERR_GCL_NOT_ENOUGH | ERR_ACCESS_DENIED; /** * Dismantles any structure that can be constructed (even hostile) 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid structure object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ dismantle(target: Structure): CreepActionReturnCode; /** * Drop this resource on the ground. * * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_ARGS: The resourceType is not a valid RESOURCE_* constants. */ drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have enough ghodium. * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ generateSafeMode(target: StructureController): CreepActionReturnCode; /** * 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 {@link BodyPartConstant} constants. */ getActiveBodyparts(type: BodyPartConstant): number; /** * Harvest energy from the source or resource from minerals or deposits. * * Needs the WORK body part. * * If the creep has an empty CARRY body part, the harvested resource 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. * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or the room controller is owned or reserved by another player. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_FOUND: Extractor not found. You must build an extractor structure to harvest minerals. Learn more * - ERR_NOT_ENOUGH_RESOURCES: The target does not contain any harvestable energy or mineral. * - ERR_INVALID_TARGET: The target is not a valid source or mineral object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: The extractor or the deposit is still cooling down. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ harvest(target: Source | Mineral | Deposit): CreepActionReturnCode | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ heal(target: AnyCreep): CreepActionReturnCode; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * * Requires the MOVE body part if not being pulled. * @param direction The direction to move in ({@link DirectionConstant `TOP`, `TOP_LEFT`...}). * @param creep A creep nearby. * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. * - ERR_TIRED: The fatigue indicator of the creep is non-zero. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ move(direction: DirectionConstant): CreepMoveReturnCode; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. * * Needs the MOVE body part. * @param path A path value as returned from {@link Room.findPath} or {@link RoomPosition.findPathTo} methods. Both array form and serialized string form are accepted. */ moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * 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): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET; /** * 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, ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid object to pick up. * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CARRY body parts in this creep’s body. */ pickup(target: Resource): CreepActionReturnCode | ERR_FULL; /** * Allow another creep to follow this creep. * * Requires the MOVE body part. * * The fatigue generated for the target's move will be added to the creep instead of the target. * The target must be adjacent to the creep. The creep must move elsewhere, and the target must move towards the creep. * @param target The target creep to be pulled. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target provided is invalid. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ pull(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ rangedAttack(target: AnyCreep | Structure): CreepActionReturnCode; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ rangedHeal(target: AnyCreep): CreepActionReturnCode; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ rangedMassAttack(): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NO_BODYPART; /** * 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 The target structure to be repaired. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not carry any energy. * - ERR_INVALID_TARGET: The target is not a valid structure object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ repair(target: Structure): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid neutral controller object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_ACCESS_DENIED: The shard access is restricted. */ reserveController(target: StructureController): CreepActionReturnCode | ERR_ACCESS_DENIED; /** * 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 unless toPublic is true. * @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'. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. */ say(message: string, toPublic?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ signController(target: StructureController, text: string): OK | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Kill the creep immediately. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. */ suicide(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 {@link ResourceConstant RESOURCE_*} constants * @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The target cannot receive any more resources. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; /** * 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 over 15 energy units per tick regardless of creeps abilities. * 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. * * Upgrading the controller raises its ticksToDowngrade timer by 100. The timer must be full in order for controller to be levelled up. * @param target The target controller object to be upgraded. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep or the target controller. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have any carried energy. * - ERR_INVALID_TARGET: The target is not a valid controller object, or the controller upgrading is blocked. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. * - ERR_ACCESS_DENIED: The shard access is restricted. */ upgradeController(target: StructureController): ScreepsReturnCode | ERR_ACCESS_DENIED; /** * Withdraw resources from a structure, a tombstone or a ruin. * * The target has to be at adjacent square to the creep. Multiple creeps can withdraw from the same object in the same tick. * Your creeps can withdraw resources from hostile structures/tombstones as well, in case if there is no hostile rampart on top of it. * * This method should not be used to transfer resources between creeps. * To transfer between creeps, use the {@link Creep.transfer} method on the original creep. * * @param target The target object. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be transferred. If omitted, all the available amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or there is a hostile rampart on top of the target. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The target does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The creep's carry is full. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; } interface CreepConstructor extends _Constructor, _ConstructorById {} declare const Creep: CreepConstructor; /** * A rare resource deposit needed for producing commodities. * * Can be harvested by creeps with a WORK body part. Each harvest operation triggers a cooldown period, which becomes longer and longer over time. * * Learn more about deposits from [this article](https://docs.screeps.com/resources.html). * * | | | * | ------------ | ----------- | * | **Cooldown** | 0.001 * totalHarvested ^ 1.2 * | **Decay** | 50,000 ticks after appearing or last harvest operation */ interface Deposit extends RoomObject { /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The deposit type, one of the {@link DepositConstant}: * - `RESOURCE_MIST` * - `RESOURCE_BIOMASS` * - `RESOURCE_METAL` * - `RESOURCE_SILICON` */ depositType: DepositConstant; /** * The amount of game ticks until the next harvest action is possible. */ cooldown: number; /** * The cooldown of the last harvest operation on this deposit. */ lastCooldown: number; /** * The amount of game ticks when this deposit will disappear. */ ticksToDecay: number; } interface DepositConstructor extends _Constructor, _ConstructorById {} declare const Deposit: DepositConstructor; /** * A flag. * * Flags can be used to mark particular spots in a room. Flags are visible to their owners only. You cannot have more than 10,000 flags. */ interface Flag extends RoomObject { readonly prototype: Flag; /** * Flag color. One of the {@link ColorConstant COLOR_*} constants. */ color: ColorConstant; /** * The flag's memory. * * A shorthand to Memory.flags[flag.name]. You can use it for quick access the flag's specific memory data object. */ memory: FlagMemory; /** * The 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 flag via the {@link Game.flags} object. The maximum name length is 60 characters. */ name: string; /** * Flag secondary color. One of the {@link ColorConstant COLOR_*} constants. */ secondaryColor: ColorConstant; /** * Remove the flag. * @returns Result Code: OK */ remove(): OK; /** * Set new color of the flag. * @param color One of the {@link ColorConstant COLOR_*} constants. * @param secondaryColor Secondary color of the flag. One of the {@link ColorConstant COLOR_*} constants. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: color or secondaryColor is not a valid color constant. */ setColor(color: ColorConstant, secondaryColor?: ColorConstant): OK | ERR_INVALID_ARGS; /** * Set new position of the flag. * @param x The X position in the room. * @param y The Y position in the room. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_TARGET: The target provided is invalid. */ setPosition(x: number, y: number): OK | ERR_INVALID_ARGS; /** * Set new position of the flag. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_TARGET: The target provided is invalid. */ setPosition(pos: RoomPosition | { pos: RoomPosition }): OK | ERR_INVALID_ARGS; } interface FlagConstructor extends _Constructor { new (name: string, color: ColorConstant, secondaryColor: ColorConstant, roomName: string, x: number, y: number): Flag; (name: string, color: ColorConstant, secondaryColor: ColorConstant, 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. */ 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. */ gcl: GlobalControlLevel; /** * Your clobal Power Level */ gpl: GlobalPowerLevel; /** * A global object representing world GameMap. */ map: GameMap; /** * A global object representing the in-game market. */ market: Market; /** * A hash containing all your power creeps with their names as hash keys. * * Even power creeps not spawned in the world can be accessed here. */ powerCreeps: { [creepName: string]: PowerCreep }; /** * An object with your global resources that are bound to the account, like pixels or cpu unlocks. * * Each object key is a resource constant, values are resources amounts. */ resources: { [key: string]: any }; /** * A hash containing all the rooms available to you with room names as hash keys. * * A room is visible if you have a creep or an owned structure in it. */ rooms: { [roomName: string]: Room }; /** * A hash containing all your spawns with spawn names as hash keys. */ spawns: { [spawnName: string]: StructureSpawn }; /** * A hash containing all your structures with structure id as hash keys. */ structures: { [structureId: string]: OwnedStructure }; /** * A hash containing all your construction sites with their id as hash keys. */ constructionSites: { [constructionSiteId: string]: ConstructionSite }; /** * An object describing the world shard where your script is currently being executed in. */ shard: Shard; /** * 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>(id: T): fromId | null; getObjectById(id: Id): T | null; /** * 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. * @deprecated Use Id, instead of strings, to increase type safety. * * If you are using JavaScript, just ignore this deprecation warning. * * If you are using TypeScript, and you are using strings as IDs, you should change your code to use Id instead. * * see [this section of README](https://github.com/screepers/typed-screeps?tab=readme-ov-file#Game.getObjectById()) for more information. */ getObjectById(id: string): 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 Simulator. * @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. * @returns One of the following codes: * - OK: The message has been sent successfully. * - ERR_FULL: More than 20 notifications sent this tick. */ notify(message: string, groupInterval?: number): OK | ERR_FULL; } declare var Game: Game; interface _HasId { id: Id; } interface _HasRoomPosition { pos: RoomPosition; } interface GlobalControlLevel { /** * The current level. */ level: number; /** * The current progress to the next level. */ progress: number; /** * The progress required to reach the next level. */ progressTotal: number; } interface GlobalPowerLevel { /** * The current level. */ level: number; /** * The current progress to the next level. */ progress: number; /** * The progress required to reach the next level. */ progressTotal: number; } interface Shard { /** * The name of the shard. */ name: string; /** * Currently always equals to normal. */ type: "normal"; /** * Whether this shard belongs to the PTR. */ ptr: boolean; /** * Whether you currently have access to this shard. * * Always true on non-restricted shards. On restricted shards, requires either an active ACCESS_KEY resource or an unlimited access subscription. * Use {@link Game.shard.activateAccess} to activate access. */ access?: boolean; /** * The time in milliseconds since UNIX epoch time until access to this restricted shard is active. * This property is not defined when access is unlimited or when access is not currently active. */ accessTime?: number; /** * Activate access to the current restricted shard for additional 30 days. * * This method will consume 1 ACCESS_KEY resource bound to your account (See Game.resources). * This method is only available on restricted shards (when {@link Game.shard.access} is defined). * * @returns One of the following codes: * - OK:The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your account does not have enough ACCESS_KEY resources. * - ERR_INVALID_TARGET: This shard is not restricted. * - ERR_FULL: Your access is unlimited. */ activateAccess?(): OK | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_ENOUGH_RESOURCES; } interface CPU { /** * Your assigned CPU limit for the current shard. */ limit: number; /** * An amount of available CPU time at the current game tick. * * Usually it is higher than {@link Game.cpu.limit}. */ tickLimit: number; /** * An amount of unused CPU accumulated in your bucket. * * @see http://docs.screeps.com/cpu-limit.html#Bucket */ bucket: number; /** * An object with limits for each shard with shard names as keys. * * You can use {@link Game.cpu.setShardLimits} method to re-assign them. */ shardLimits: CPUShardLimits; /** * Whether full CPU is currently unlocked for your account. */ unlocked: boolean; /** * The time in milliseconds since UNIX epoch time until full CPU is unlocked for your account. * * This property is not defined when full CPU is not unlocked for your account or it's unlocked with a subscription. */ unlockedTime: number | undefined; /** * Get amount of CPU time used from the beginning of the current game tick. * * Always returns 0 in the simulator. */ getUsed(): number; /** * Allocate CPU limits to different shards. * * Total amount of CPU should remain equal to {@link Game.cpu.shardLimits}. * This method can be used only once per 12 hours. * * @param limits An object with CPU values for each shard in the same format as {@link Game.cpu.shardLimits}. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_BUSY: 12-hours cooldown period is not over yet. * - ERR_INVALID_ARGS: The argument is not a valid shard limits object. */ setShardLimits(limits: CPUShardLimits): OK | ERR_BUSY | ERR_INVALID_ARGS; /** * Use this method to get heap statistics for your virtual machine. * * This method will be undefined if you are not using IVM. * * The return value is almost identical to Node's [v8.getHeapStatistics()](https://nodejs.org/docs/latest-v10.x/api/v8.html#v8_v8_getheapstatistics). * * This function returns one additional property: externally_allocated_size which is the total amount of currently * allocated memory which is not included in the v8 heap but counts against this isolate's memory limit. * ArrayBuffer instances over a certain size are externally allocated and will be counted here. */ getHeapStatistics?(): HeapStatistics; /** * This method will be undefined if you are not using IVM. * * Reset your runtime environment and wipe all data in heap memory. * Player code execution stops immediately. */ halt?(): never; /** * Generate 1 pixel resource unit for 10000 CPU from your bucket. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your bucket does not have enough CPU. */ generatePixel(): OK | ERR_NOT_ENOUGH_RESOURCES; /** * Unlock full CPU for your account for additional 24 hours. * * This method will consume 1 CPU unlock bound to your account (See {@link Game.resources}). * If full CPU is not currently unlocked for your account, it may take some time (up to 5 minutes) before unlock is applied to your account. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your account does not have enough cpuUnlock resource. * - ERR_FULL: Your CPU is unlocked with a subscription. */ unlock(): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL; } 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; } /** * Describes one part of a creep’s body. */ type BodyPartDefinition = T extends any ? { /** * One of the {@link ResourceConstant RESOURCE_*} constants. * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ boost?: keyof (typeof BOOSTS)[T]; /** * One of the body part types constants. */ type: T; /** * The remaining amount of hit points of this body part. */ hits: number; } : never; interface Owner { /** * The name of the owner user. */ username: string; } interface ReservationDefinition { username: string; ticksToEnd: number; } interface SignDefinition { username: string; text: string; time: number; datetime: Date; } interface CPUShardLimits { [shard: string]: number; } /** A general purpose Store, which has a limited capacity */ type StoreDefinition = Store; /** A general purpose Store, which has an unlimited capacity */ type StoreDefinitionUnlimited = Store; /** * @example * { * "1": "W8N4", // TOP * "3": "W7N3", // RIGHT * // "5": "W8N2", // BOTTOM * "7": "W9N3" // LEFT * } */ type ExitsInformation = Partial>; interface AllLookAtTypes { [LOOK_CONSTRUCTION_SITES]: ConstructionSite; [LOOK_CREEPS]: Creep; [LOOK_ENERGY]: Resource; [LOOK_FLAGS]: Flag; [LOOK_MINERALS]: Mineral; [LOOK_DEPOSITS]: Deposit; [LOOK_NUKES]: Nuke; [LOOK_RESOURCES]: Resource; [LOOK_SOURCES]: Source; [LOOK_STRUCTURES]: AnyStructure; [LOOK_TERRAIN]: Terrain; [LOOK_TOMBSTONES]: Tombstone; [LOOK_POWER_CREEPS]: PowerCreep; [LOOK_RUINS]: Ruin; } type LookAtTypes = Partial; type LookAtResult = Pick & { type: K }; type LookAtResultWithPos = LookAtResult & { x: number; y: number; }; interface LookAtResultMatrix { [y: number]: { [x: number]: Array>; }; } interface LookForAtAreaResultMatrix { [y: number]: { [x: number]: T[]; }; } type LookForAtAreaResult = { type: K } & { [P in K]: T }; type LookForAtAreaResultWithPos = LookForAtAreaResult & { x: number; y: number }; type LookForAtAreaResultArray = Array>; interface FindTypes { [key: number]: | RoomPosition | AnyCreep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke | Tombstone | Deposit | Ruin; [FIND_EXIT_TOP]: RoomPosition; [FIND_EXIT_RIGHT]: RoomPosition; [FIND_EXIT_BOTTOM]: RoomPosition; [FIND_EXIT_LEFT]: RoomPosition; [FIND_EXIT]: RoomPosition; [FIND_CREEPS]: Creep; [FIND_MY_CREEPS]: Creep; [FIND_HOSTILE_CREEPS]: Creep; [FIND_SOURCES_ACTIVE]: Source; [FIND_SOURCES]: Source; [FIND_DROPPED_RESOURCES]: Resource; [FIND_STRUCTURES]: AnyStructure; [FIND_MY_STRUCTURES]: AnyOwnedStructure; [FIND_HOSTILE_STRUCTURES]: AnyOwnedStructure; [FIND_FLAGS]: Flag; [FIND_CONSTRUCTION_SITES]: ConstructionSite; [FIND_MY_SPAWNS]: StructureSpawn; [FIND_HOSTILE_SPAWNS]: StructureSpawn; [FIND_MY_CONSTRUCTION_SITES]: ConstructionSite; [FIND_HOSTILE_CONSTRUCTION_SITES]: ConstructionSite; [FIND_MINERALS]: Mineral; [FIND_NUKES]: Nuke; [FIND_TOMBSTONES]: Tombstone; [FIND_POWER_CREEPS]: PowerCreep; [FIND_MY_POWER_CREEPS]: PowerCreep; [FIND_HOSTILE_POWER_CREEPS]: PowerCreep; [FIND_DEPOSITS]: Deposit; [FIND_RUINS]: Ruin; } interface FindPathOpts { /** * Treat squares with creeps as walkable. * * Can be useful with too many moving creeps around or in some other cases. * @default 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. * @default false */ ignoreDestructibleStructures?: boolean; /** * Ignore road structures. * * Enabling this option can speed up the search. This is only used when the new PathFinder is enabled. * * @default false */ 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 */ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type costCallback?: (roomName: string, costMatrix: CostMatrix) => void | 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. * @default 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! * @default 1.2 */ heuristicWeight?: number; /** * If true, the result path will be serialized using {@link Room.serializePath}. * @default false */ serialize?: boolean; /** * The maximum allowed rooms to search. * * This is only used when the new PathFinder is enabled. * @default 16 (also maximum) */ maxRooms?: number; /** * Path to within (range) tiles of target tile. * * The default is to path to the tile that the target is on. * * @default 0 */ range?: number; /** * Cost for walking on plain positions. * @default 1 */ plainCost?: number; /** * Cost for walking on swamp positions. * @default 5 */ swampCost?: 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. * Increase the amount to save more CPU, decrease to make the movement more consistent. * Set to 0 if you want to disable path reusing. * @default 5 */ 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 {@link Room.serializePath}. * @default true */ serializeMemory?: boolean; /** * Force the use of a cached path. * * 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. * @default false */ noPathFinding?: boolean; /** * Draw a line along the creep’s path using {@link 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: DirectionConstant; } interface _Constructor { readonly prototype: T; } interface _ConstructorById extends _Constructor { new (id: Id): T; (id: Id): T; } declare namespace Tag { const OpaqueTagSymbol: unique symbol; class OpaqueTag { private [OpaqueTagSymbol]: T; } } type Id = string & Tag.OpaqueTag; type fromId = T extends Id ? R : never; /** * `InterShardMemory` object provides an interface for communicating between shards. * * Your script is executed separatedly on each shard, and their {@link Memory} objects are isolated from each other. * In order to pass messages and data between shards, you need to use {@link InterShardMemory} instead. * * Every shard can have its own data string that can be accessed by all other shards. * A shard can write only to its own data, other shards' data is read-only. * * This data has nothing to do with `Memory` contents, it's a separate data container. */ interface InterShardMemory { /** * Returns the string contents of the current shard's data. */ getLocal(): string; /** * Replace the current shard's data with the new value. * * @param value New data value in string format. * @throws if `value` isn't a string or contains more than `100 * 2014` characters. */ setLocal(value: string): void; /** * Returns the string contents of another shard's data, null if shard exists but data is not set. * * @param shard Shard name. * @throws if shard name is invalid */ getRemote(shard: string): string | null; } declare const InterShardMemory: InterShardMemory; /* * This file creates literal versions of many of the constants * It should be kept in sync with constants.ts */ // Extras type Terrain = "plain" | "swamp" | "wall"; type ExitKey = "1" | "3" | "5" | "7"; type AnyCreep = Creep | PowerCreep; type FindClosestByPathAlgorithm = "astar" | "dijkstra"; // Return Codes type ScreepsReturnCode = | OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NAME_EXISTS | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_NO_BODYPART | ERR_NOT_ENOUGH_EXTENSIONS | ERR_RCL_NOT_ENOUGH | ERR_GCL_NOT_ENOUGH; type OK = 0; type ERR_NOT_OWNER = -1; type ERR_NO_PATH = -2; type ERR_NAME_EXISTS = -3; type ERR_BUSY = -4; type ERR_NOT_FOUND = -5; type ERR_NOT_ENOUGH_RESOURCES = -6; type ERR_NOT_ENOUGH_ENERGY = -6; type ERR_INVALID_TARGET = -7; type ERR_FULL = -8; type ERR_NOT_IN_RANGE = -9; type ERR_INVALID_ARGS = -10; type ERR_TIRED = -11; type ERR_NO_BODYPART = -12; type ERR_NOT_ENOUGH_EXTENSIONS = -6; type ERR_RCL_NOT_ENOUGH = -14; type ERR_GCL_NOT_ENOUGH = -15; type ERR_ACCESS_DENIED = -16; type CreepActionReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART | ERR_TIRED; type CreepMoveReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_TIRED | ERR_NO_BODYPART; // Find Constants type ExitConstant = FIND_EXIT_TOP | FIND_EXIT_RIGHT | FIND_EXIT_BOTTOM | FIND_EXIT_LEFT; type FindConstant = | FIND_EXIT_TOP | FIND_EXIT_RIGHT | FIND_EXIT_BOTTOM | FIND_EXIT_LEFT | FIND_EXIT | FIND_CREEPS | FIND_MY_CREEPS | FIND_HOSTILE_CREEPS | FIND_SOURCES_ACTIVE | FIND_SOURCES | FIND_DROPPED_RESOURCES | FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES | FIND_FLAGS | FIND_CONSTRUCTION_SITES | FIND_MY_SPAWNS | FIND_HOSTILE_SPAWNS | FIND_MY_CONSTRUCTION_SITES | FIND_HOSTILE_CONSTRUCTION_SITES | FIND_MINERALS | FIND_NUKES | FIND_TOMBSTONES | FIND_POWER_CREEPS | FIND_MY_POWER_CREEPS | FIND_HOSTILE_POWER_CREEPS | FIND_DEPOSITS | FIND_RUINS; type FIND_EXIT_TOP = 1; type FIND_EXIT_RIGHT = 3; type FIND_EXIT_BOTTOM = 5; type FIND_EXIT_LEFT = 7; type FIND_EXIT = 10; type FIND_CREEPS = 101; type FIND_MY_CREEPS = 102; type FIND_HOSTILE_CREEPS = 103; type FIND_SOURCES_ACTIVE = 104; type FIND_SOURCES = 105; type FIND_DROPPED_RESOURCES = 106; type FIND_STRUCTURES = 107; type FIND_MY_STRUCTURES = 108; type FIND_HOSTILE_STRUCTURES = 109; type FIND_FLAGS = 110; type FIND_CONSTRUCTION_SITES = 111; type FIND_MY_SPAWNS = 112; type FIND_HOSTILE_SPAWNS = 113; type FIND_MY_CONSTRUCTION_SITES = 114; type FIND_HOSTILE_CONSTRUCTION_SITES = 115; type FIND_MINERALS = 116; type FIND_NUKES = 117; type FIND_TOMBSTONES = 118; type FIND_POWER_CREEPS = 119; type FIND_MY_POWER_CREEPS = 120; type FIND_HOSTILE_POWER_CREEPS = 121; type FIND_DEPOSITS = 122; type FIND_RUINS = 123; // Filter Options interface FilterOptions { filter?: PredicateFilterFunction | FilterFunction | FilterObject | string; } type PredicateFilterFunction = (object: T, index: number, collection: T[]) => object is S; type FilterFunction = (object: T, index: number, collection: T[]) => unknown; type FilterObject = DeepPartial; type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T; // Body Part Constants type BodyPartConstant = MOVE | WORK | CARRY | ATTACK | RANGED_ATTACK | TOUGH | HEAL | CLAIM; type MOVE = "move"; type WORK = "work"; type CARRY = "carry"; type ATTACK = "attack"; type RANGED_ATTACK = "ranged_attack"; type TOUGH = "tough"; type HEAL = "heal"; type CLAIM = "claim"; // Look Constants type LookConstant = | LOOK_CREEPS | LOOK_ENERGY | LOOK_RESOURCES | LOOK_SOURCES | LOOK_MINERALS | LOOK_DEPOSITS | LOOK_STRUCTURES | LOOK_FLAGS | LOOK_CONSTRUCTION_SITES | LOOK_NUKES | LOOK_TERRAIN | LOOK_TOMBSTONES | LOOK_POWER_CREEPS | LOOK_RUINS; type LOOK_CONSTRUCTION_SITES = "constructionSite"; type LOOK_CREEPS = "creep"; type LOOK_ENERGY = "energy"; type LOOK_FLAGS = "flag"; type LOOK_MINERALS = "mineral"; type LOOK_DEPOSITS = "deposit"; type LOOK_NUKES = "nuke"; type LOOK_RESOURCES = "resource"; type LOOK_SOURCES = "source"; type LOOK_STRUCTURES = "structure"; type LOOK_TERRAIN = "terrain"; type LOOK_TOMBSTONES = "tombstone"; type LOOK_POWER_CREEPS = "powerCreep"; type LOOK_RUINS = "ruin"; type ORDER_SELL = "sell"; type ORDER_BUY = "buy"; // Direction Constants type DirectionConstant = TOP | TOP_RIGHT | RIGHT | BOTTOM_RIGHT | BOTTOM | BOTTOM_LEFT | LEFT | TOP_LEFT; type TOP = 1; type TOP_RIGHT = 2; type RIGHT = 3; type BOTTOM_RIGHT = 4; type BOTTOM = 5; type BOTTOM_LEFT = 6; type LEFT = 7; type TOP_LEFT = 8; // Color Constants type ColorConstant = | COLOR_RED | COLOR_PURPLE | COLOR_BLUE | COLOR_CYAN | COLOR_GREEN | COLOR_YELLOW | COLOR_ORANGE | COLOR_BROWN | COLOR_GREY | COLOR_WHITE; type COLOR_RED = 1; type COLOR_PURPLE = 2; type COLOR_BLUE = 3; type COLOR_CYAN = 4; type COLOR_GREEN = 5; type COLOR_YELLOW = 6; type COLOR_ORANGE = 7; type COLOR_BROWN = 8; type COLOR_GREY = 9; type COLOR_WHITE = 10; // Structure Constants type BuildableStructureConstant = | STRUCTURE_EXTENSION | STRUCTURE_RAMPART | STRUCTURE_ROAD | STRUCTURE_SPAWN | STRUCTURE_LINK | STRUCTURE_WALL | STRUCTURE_STORAGE | STRUCTURE_TOWER | STRUCTURE_OBSERVER | STRUCTURE_POWER_SPAWN | STRUCTURE_EXTRACTOR | STRUCTURE_LAB | STRUCTURE_TERMINAL | STRUCTURE_CONTAINER | STRUCTURE_NUKER | STRUCTURE_FACTORY; type StructureConstant = | BuildableStructureConstant | STRUCTURE_KEEPER_LAIR | STRUCTURE_CONTROLLER | STRUCTURE_POWER_BANK | STRUCTURE_PORTAL | STRUCTURE_INVADER_CORE; type STRUCTURE_EXTENSION = "extension"; type STRUCTURE_RAMPART = "rampart"; type STRUCTURE_ROAD = "road"; type STRUCTURE_SPAWN = "spawn"; type STRUCTURE_LINK = "link"; type STRUCTURE_WALL = "constructedWall"; type STRUCTURE_KEEPER_LAIR = "keeperLair"; type STRUCTURE_CONTROLLER = "controller"; type STRUCTURE_STORAGE = "storage"; type STRUCTURE_TOWER = "tower"; type STRUCTURE_OBSERVER = "observer"; type STRUCTURE_POWER_BANK = "powerBank"; type STRUCTURE_POWER_SPAWN = "powerSpawn"; type STRUCTURE_EXTRACTOR = "extractor"; type STRUCTURE_LAB = "lab"; type STRUCTURE_TERMINAL = "terminal"; type STRUCTURE_CONTAINER = "container"; type STRUCTURE_NUKER = "nuker"; type STRUCTURE_FACTORY = "factory"; type STRUCTURE_INVADER_CORE = "invaderCore"; type STRUCTURE_PORTAL = "portal"; // Terrain mask constants type TERRAIN_MASK_WALL = 1; type TERRAIN_MASK_SWAMP = 2; type TERRAIN_MASK_LAVA = 4; // Resource Constants type ResourceConstant = | RESOURCE_ENERGY | RESOURCE_POWER | RESOURCE_OPS | MineralConstant | MineralCompoundConstant | DepositConstant | CommodityConstant; type _ResourceConstantSansEnergy = Exclude; /** The raw harvestable minerals */ type MineralConstant = | RESOURCE_UTRIUM | RESOURCE_LEMERGIUM | RESOURCE_KEANIUM | RESOURCE_ZYNTHIUM | RESOURCE_OXYGEN | RESOURCE_HYDROGEN | RESOURCE_CATALYST; /** The compounds which can't boost */ type MineralBaseCompoundsConstant = RESOURCE_HYDROXIDE | RESOURCE_ZYNTHIUM_KEANITE | RESOURCE_UTRIUM_LEMERGITE | RESOURCE_GHODIUM; /** The boosts (from tier 1 to tier 3) */ type MineralBoostConstant = | RESOURCE_UTRIUM_HYDRIDE | RESOURCE_UTRIUM_OXIDE | RESOURCE_KEANIUM_HYDRIDE | RESOURCE_KEANIUM_OXIDE | RESOURCE_LEMERGIUM_HYDRIDE | RESOURCE_LEMERGIUM_OXIDE | RESOURCE_ZYNTHIUM_HYDRIDE | RESOURCE_ZYNTHIUM_OXIDE | RESOURCE_GHODIUM_HYDRIDE | RESOURCE_GHODIUM_OXIDE | RESOURCE_UTRIUM_ACID | RESOURCE_UTRIUM_ALKALIDE | RESOURCE_KEANIUM_ACID | RESOURCE_KEANIUM_ALKALIDE | RESOURCE_LEMERGIUM_ACID | RESOURCE_LEMERGIUM_ALKALIDE | RESOURCE_ZYNTHIUM_ACID | RESOURCE_ZYNTHIUM_ALKALIDE | RESOURCE_GHODIUM_ACID | RESOURCE_GHODIUM_ALKALIDE | RESOURCE_CATALYZED_UTRIUM_ACID | RESOURCE_CATALYZED_UTRIUM_ALKALIDE | RESOURCE_CATALYZED_KEANIUM_ACID | RESOURCE_CATALYZED_KEANIUM_ALKALIDE | RESOURCE_CATALYZED_LEMERGIUM_ACID | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE | RESOURCE_CATALYZED_ZYNTHIUM_ACID | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE | RESOURCE_CATALYZED_GHODIUM_ACID | RESOURCE_CATALYZED_GHODIUM_ALKALIDE; /** All the mineral compounds */ type MineralCompoundConstant = MineralBaseCompoundsConstant | MineralBoostConstant; /** The raw deposits */ type DepositConstant = RESOURCE_MIST | RESOURCE_BIOMASS | RESOURCE_METAL | RESOURCE_SILICON; /** The commodities, produced by the Factory */ type CommodityConstant = | RESOURCE_UTRIUM_BAR | RESOURCE_LEMERGIUM_BAR | RESOURCE_ZYNTHIUM_BAR | RESOURCE_KEANIUM_BAR | RESOURCE_GHODIUM_MELT | RESOURCE_OXIDANT | RESOURCE_REDUCTANT | RESOURCE_PURIFIER | RESOURCE_BATTERY | RESOURCE_COMPOSITE | RESOURCE_CRYSTAL | RESOURCE_LIQUID | RESOURCE_WIRE | RESOURCE_SWITCH | RESOURCE_TRANSISTOR | RESOURCE_MICROCHIP | RESOURCE_CIRCUIT | RESOURCE_DEVICE | RESOURCE_CELL | RESOURCE_PHLEGM | RESOURCE_TISSUE | RESOURCE_MUSCLE | RESOURCE_ORGANOID | RESOURCE_ORGANISM | RESOURCE_ALLOY | RESOURCE_TUBE | RESOURCE_FIXTURES | RESOURCE_FRAME | RESOURCE_HYDRAULICS | RESOURCE_MACHINE | RESOURCE_CONDENSATE | RESOURCE_CONCENTRATE | RESOURCE_EXTRACT | RESOURCE_SPIRIT | RESOURCE_EMANATION | RESOURCE_ESSENCE; type InterShardResourceConstant = SUBSCRIPTION_TOKEN | CPU_UNLOCK | PIXEL | ACCESS_KEY; type MarketResourceConstant = ResourceConstant | InterShardResourceConstant; type RESOURCE_ENERGY = "energy"; type RESOURCE_POWER = "power"; type RESOURCE_OPS = "ops"; type RESOURCE_BIOMASS = "biomass"; type RESOURCE_METAL = "metal"; type RESOURCE_MIST = "mist"; type RESOURCE_SILICON = "silicon"; type RESOURCE_UTRIUM = "U"; type RESOURCE_LEMERGIUM = "L"; type RESOURCE_KEANIUM = "K"; type RESOURCE_ZYNTHIUM = "Z"; type RESOURCE_OXYGEN = "O"; type RESOURCE_HYDROGEN = "H"; type RESOURCE_CATALYST = "X"; type RESOURCE_HYDROXIDE = "OH"; type RESOURCE_ZYNTHIUM_KEANITE = "ZK"; type RESOURCE_UTRIUM_LEMERGITE = "UL"; type RESOURCE_GHODIUM = "G"; type RESOURCE_UTRIUM_HYDRIDE = "UH"; type RESOURCE_UTRIUM_OXIDE = "UO"; type RESOURCE_KEANIUM_HYDRIDE = "KH"; type RESOURCE_KEANIUM_OXIDE = "KO"; type RESOURCE_LEMERGIUM_HYDRIDE = "LH"; type RESOURCE_LEMERGIUM_OXIDE = "LO"; type RESOURCE_ZYNTHIUM_HYDRIDE = "ZH"; type RESOURCE_ZYNTHIUM_OXIDE = "ZO"; type RESOURCE_GHODIUM_HYDRIDE = "GH"; type RESOURCE_GHODIUM_OXIDE = "GO"; type RESOURCE_UTRIUM_ACID = "UH2O"; type RESOURCE_UTRIUM_ALKALIDE = "UHO2"; type RESOURCE_KEANIUM_ACID = "KH2O"; type RESOURCE_KEANIUM_ALKALIDE = "KHO2"; type RESOURCE_LEMERGIUM_ACID = "LH2O"; type RESOURCE_LEMERGIUM_ALKALIDE = "LHO2"; type RESOURCE_ZYNTHIUM_ACID = "ZH2O"; type RESOURCE_ZYNTHIUM_ALKALIDE = "ZHO2"; type RESOURCE_GHODIUM_ACID = "GH2O"; type RESOURCE_GHODIUM_ALKALIDE = "GHO2"; type RESOURCE_CATALYZED_UTRIUM_ACID = "XUH2O"; type RESOURCE_CATALYZED_UTRIUM_ALKALIDE = "XUHO2"; type RESOURCE_CATALYZED_KEANIUM_ACID = "XKH2O"; type RESOURCE_CATALYZED_KEANIUM_ALKALIDE = "XKHO2"; type RESOURCE_CATALYZED_LEMERGIUM_ACID = "XLH2O"; type RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE = "XLHO2"; type RESOURCE_CATALYZED_ZYNTHIUM_ACID = "XZH2O"; type RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE = "XZHO2"; type RESOURCE_CATALYZED_GHODIUM_ACID = "XGH2O"; type RESOURCE_CATALYZED_GHODIUM_ALKALIDE = "XGHO2"; type RESOURCE_UTRIUM_BAR = "utrium_bar"; type RESOURCE_LEMERGIUM_BAR = "lemergium_bar"; type RESOURCE_ZYNTHIUM_BAR = "zynthium_bar"; type RESOURCE_KEANIUM_BAR = "keanium_bar"; type RESOURCE_GHODIUM_MELT = "ghodium_melt"; type RESOURCE_OXIDANT = "oxidant"; type RESOURCE_REDUCTANT = "reductant"; type RESOURCE_PURIFIER = "purifier"; type RESOURCE_BATTERY = "battery"; type RESOURCE_COMPOSITE = "composite"; type RESOURCE_CRYSTAL = "crystal"; type RESOURCE_LIQUID = "liquid"; type RESOURCE_WIRE = "wire"; type RESOURCE_SWITCH = "switch"; type RESOURCE_TRANSISTOR = "transistor"; type RESOURCE_MICROCHIP = "microchip"; type RESOURCE_CIRCUIT = "circuit"; type RESOURCE_DEVICE = "device"; type RESOURCE_CELL = "cell"; type RESOURCE_PHLEGM = "phlegm"; type RESOURCE_TISSUE = "tissue"; type RESOURCE_MUSCLE = "muscle"; type RESOURCE_ORGANOID = "organoid"; type RESOURCE_ORGANISM = "organism"; type RESOURCE_ALLOY = "alloy"; type RESOURCE_TUBE = "tube"; type RESOURCE_FIXTURES = "fixtures"; type RESOURCE_FRAME = "frame"; type RESOURCE_HYDRAULICS = "hydraulics"; type RESOURCE_MACHINE = "machine"; type RESOURCE_CONDENSATE = "condensate"; type RESOURCE_CONCENTRATE = "concentrate"; type RESOURCE_EXTRACT = "extract"; type RESOURCE_SPIRIT = "spirit"; type RESOURCE_EMANATION = "emanation"; type RESOURCE_ESSENCE = "essence"; type SUBSCRIPTION_TOKEN = "token"; type CPU_UNLOCK = "cpuUnlock"; type PIXEL = "pixel"; type ACCESS_KEY = "accessKey"; type TOMBSTONE_DECAY_PER_PART = 5; type EventConstant = | EVENT_ATTACK | EVENT_OBJECT_DESTROYED | EVENT_ATTACK_CONTROLLER | EVENT_BUILD | EVENT_HARVEST | EVENT_HEAL | EVENT_REPAIR | EVENT_RESERVE_CONTROLLER | EVENT_UPGRADE_CONTROLLER | EVENT_EXIT | EVENT_POWER | EVENT_TRANSFER; type EVENT_ATTACK = 1; type EVENT_OBJECT_DESTROYED = 2; type EVENT_ATTACK_CONTROLLER = 3; type EVENT_BUILD = 4; type EVENT_HARVEST = 5; type EVENT_HEAL = 6; type EVENT_REPAIR = 7; type EVENT_RESERVE_CONTROLLER = 8; type EVENT_UPGRADE_CONTROLLER = 9; type EVENT_EXIT = 10; type EVENT_POWER = 11; type EVENT_TRANSFER = 12; type EventAttackType = | EVENT_ATTACK_TYPE_MELEE | EVENT_ATTACK_TYPE_RANGED | EVENT_ATTACK_TYPE_RANGED_MASS | EVENT_ATTACK_TYPE_DISMANTLE | EVENT_ATTACK_TYPE_HIT_BACK | EVENT_ATTACK_TYPE_NUKE; type EVENT_ATTACK_TYPE_MELEE = 1; type EVENT_ATTACK_TYPE_RANGED = 2; type EVENT_ATTACK_TYPE_RANGED_MASS = 3; type EVENT_ATTACK_TYPE_DISMANTLE = 4; type EVENT_ATTACK_TYPE_HIT_BACK = 5; type EVENT_ATTACK_TYPE_NUKE = 6; type EventHealType = EVENT_HEAL_TYPE_MELEE | EVENT_HEAL_TYPE_RANGED; type EVENT_HEAL_TYPE_MELEE = 1; type EVENT_HEAL_TYPE_RANGED = 2; type EventDestroyType = "creep" | StructureConstant; type EventItem = | { event: EVENT_ATTACK; objectId: string; data: EventData[EVENT_ATTACK]; } | { event: EVENT_OBJECT_DESTROYED; objectId: string; data: EventData[EVENT_OBJECT_DESTROYED]; } | { event: EVENT_ATTACK_CONTROLLER; objectId: string; data: EventData[EVENT_ATTACK_CONTROLLER]; } | { event: EVENT_BUILD; objectId: string; data: EventData[EVENT_BUILD]; } | { event: EVENT_HARVEST; objectId: string; data: EventData[EVENT_HARVEST]; } | { event: EVENT_HEAL; objectId: string; data: EventData[EVENT_HEAL]; } | { event: EVENT_REPAIR; objectId: string; data: EventData[EVENT_REPAIR]; } | { event: EVENT_RESERVE_CONTROLLER; objectId: string; data: EventData[EVENT_RESERVE_CONTROLLER]; } | { event: EVENT_UPGRADE_CONTROLLER; objectId: string; data: EventData[EVENT_UPGRADE_CONTROLLER]; } | { event: EVENT_EXIT; objectId: string; data: EventData[EVENT_EXIT]; } | { event: EVENT_POWER; objectId: string; data: EventData[EVENT_POWER]; } | { event: EVENT_TRANSFER; objectId: string; data: EventData[EVENT_TRANSFER]; }; interface EventData { [EVENT_ATTACK]: { targetId: string; damage: number; attackType: EventAttackType; }; [EVENT_OBJECT_DESTROYED]: { type: EventDestroyType; }; [EVENT_ATTACK_CONTROLLER]: null; [EVENT_BUILD]: { targetId: string; amount: number; structureType: BuildableStructureConstant; x: number; y: number; incomplete: boolean; }; [EVENT_HARVEST]: { targetId: string; amount: number; }; [EVENT_HEAL]: { targetId: string; amount: number; healType: EventHealType; }; [EVENT_REPAIR]: { targetId: string; amount: number; energySpent: number; }; [EVENT_RESERVE_CONTROLLER]: { amount: number; }; [EVENT_UPGRADE_CONTROLLER]: { amount: number; energySpent: number; }; [EVENT_EXIT]: { room: string; x: number; y: number; }; [EVENT_POWER]: { targetId: string; power: PowerConstant; }; [EVENT_TRANSFER]: { targetId: string; resourceType: ResourceConstant; amount: number; }; } type PowerClassConstant = POWER_CLASS["OPERATOR"]; interface POWER_CLASS { OPERATOR: "operator"; } type PowerConstant = | PWR_GENERATE_OPS | PWR_OPERATE_SPAWN | PWR_OPERATE_TOWER | PWR_OPERATE_STORAGE | PWR_OPERATE_LAB | PWR_OPERATE_EXTENSION | PWR_OPERATE_OBSERVER | PWR_OPERATE_TERMINAL | PWR_DISRUPT_SPAWN | PWR_DISRUPT_TOWER | PWR_DISRUPT_SOURCE | PWR_SHIELD | PWR_REGEN_SOURCE | PWR_REGEN_MINERAL | PWR_DISRUPT_TERMINAL | PWR_OPERATE_POWER | PWR_FORTIFY | PWR_OPERATE_CONTROLLER | PWR_OPERATE_FACTORY; type PWR_GENERATE_OPS = 1; type PWR_OPERATE_SPAWN = 2; type PWR_OPERATE_TOWER = 3; type PWR_OPERATE_STORAGE = 4; type PWR_OPERATE_LAB = 5; type PWR_OPERATE_EXTENSION = 6; type PWR_OPERATE_OBSERVER = 7; type PWR_OPERATE_TERMINAL = 8; type PWR_DISRUPT_SPAWN = 9; type PWR_DISRUPT_TOWER = 10; type PWR_DISRUPT_SOURCE = 11; type PWR_SHIELD = 12; type PWR_REGEN_SOURCE = 13; type PWR_REGEN_MINERAL = 14; type PWR_DISRUPT_TERMINAL = 15; type PWR_OPERATE_POWER = 16; type PWR_FORTIFY = 17; type PWR_OPERATE_CONTROLLER = 18; type PWR_OPERATE_FACTORY = 19; type EffectConstant = EFFECT_INVULNERABILITY | EFFECT_COLLAPSE_TIMER; type EFFECT_INVULNERABILITY = 1001; type EFFECT_COLLAPSE_TIMER = 1002; type DENSITY_LOW = 1; type DENSITY_MODERATE = 2; type DENSITY_HIGH = 3; type DENSITY_ULTRA = 4; type DensityConstant = DENSITY_LOW | DENSITY_MODERATE | DENSITY_HIGH | DENSITY_ULTRA; /** * The options that can be accepted by `findRoute()` and friends. */ interface RouteOptions { /** * This callback 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. * @param roomName The room being considered * @param fromRoomName The room we're coming from * @returns a floating point to steer the route toward a given room, or Infinity to block it entirely. */ routeCallback: (roomName: string, fromRoomName: string) => number; } interface RoomStatusPermanent { status: "normal" | "closed"; timestamp: null; } interface RoomStatusTemporary { status: "novice" | "respawn"; timestamp: number; } type RoomStatus = RoomStatusPermanent | RoomStatusTemporary; /** * A global object representing world map. * * Use it to navigate between rooms. The object is accessible via the {@link 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. */ describeExits(roomName: string): ExitsInformation | null; /** * Find the exit direction from the given room en route to another room. * @param fromRoom Start room name or room object. * @param toRoom Finish room name or room object. * @param opts (optional) An object with the pathfinding options. * @returns The room direction constant, one of the following: * FIND_EXIT_TOP, FIND_EXIT_RIGHT, FIND_EXIT_BOTTOM, FIND_EXIT_LEFT * Or one of the following Result codes: * ERR_NO_PATH, ERR_INVALID_ARGS */ findExit(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; /** * Find route from the given room to another room. * @param fromRoom Start room name or room object. * @param toRoom Finish room name or room object. * @param opts (optional) An object with the pathfinding options. * @returns either an array of room exits / room name, or ERR_NO_PATH if the destination room cannot be reached. */ findRoute(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): { exit: ExitConstant; room: string }[] | ERR_NO_PATH; /** * Get the linear distance (in rooms) between two rooms. * * You can use this function to estimate the energy cost of sending resources through terminals, or using observers and nukes. * @param roomName1 The name of the first room. * @param roomName2 The name of the second room. * @param continuous Whether to treat the world map continuous on borders. Set to true if you * want to calculate the trade or terminal send cost. Default is false. */ getRoomLinearDistance(roomName1: string, roomName2: string, continuous?: boolean): number; /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param x X position in the room. * @param y Y position in the room. * @param roomName The room name. * @deprecated use {@link Game.map.getRoomTerrain} instead */ getTerrainAt(x: number, y: number, roomName: string): Terrain; /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param pos The position object. * @deprecated use {@link Game.map.getRoomTerrain} instead */ getTerrainAt(pos: RoomPosition): Terrain; /** * Get room terrain for the specified room. * * This method works for any room in the world even if you have no access to it. * @param roomName String name of the room. */ getRoomTerrain(roomName: string): RoomTerrain; /** * Returns the world size as a number of rooms between world corners. * * For example, for a world with rooms from W50N50 to E50S50 this method will return 102. */ getWorldSize(): number; /** * Check if the room is available to move into. * @param roomName The room name. * @returns A boolean value. * @deprecated Use `Game.map.getRoomStatus` instead */ isRoomAvailable(roomName: string): boolean; /** * Get the room status to determine if it's available, or in a reserved area. * @param roomName The room name. * @returns A {@link RoomStatus} object. */ getRoomStatus(roomName: string): RoomStatus; /** * Map visuals provide a way to show various visual debug info on the game map. * You can use the {@link Game.map.visual} object to draw simple shapes that are visible only to you. * * Map visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. * All `Game.map.visual` calls have no added CPU cost (their cost is natural and mostly related to simple JSON.serialize calls). * However, there is a usage limit: you cannot post more than 1000 KB of serialized data. * * All draw coordinates are measured in global game coordinates (`RoomPosition`). */ visual: MapVisual; } /** * Map visuals provide a way to show various visual debug info on the game map. * * You can use the {@link Game.map.visual} object to draw simple shapes that are visible only to you. * * Map visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. * All `Game.map.visual` calls have no added CPU cost (their cost is natural and mostly related to simple `JSON.serialize` calls). * However, there is a usage limit: you cannot post more than 1000 KB of serialized data. * * All draw coordinates are measured in global game coordinates ({@link RoomPosition}). */ interface MapVisual { /** * Draw a line. * @param pos1 The start position object. * @param pos2 The finish position object. * @param style The optional style * @returns The MapVisual object, for chaining. */ line(pos1: RoomPosition, pos2: RoomPosition, style?: MapLineStyle): MapVisual; /** * Draw a circle. * @param pos The position object of the center. * @param style The optional style * @returns The MapVisual object, for chaining. */ circle(pos: RoomPosition, style?: MapCircleStyle): MapVisual; /** * Draw a rectangle. * @param topLeftPos The position object of the top-left corner. * @param width The width of the rectangle. * @param height The height of the rectangle. * @param style The optional style * @returns The MapVisual object, for chaining. */ rect(topLeftPos: RoomPosition, width: number, height: number, style?: MapPolyStyle): MapVisual; /** * Draw a polyline. * @param points An array of points. Every item should be a `RoomPosition` object. * @param style The optional style * @returns The MapVisual object, for chaining. */ poly(points: RoomPosition[], style?: MapPolyStyle): MapVisual; /** * Draw a text label. You can use any valid Unicode characters, including emoji. * @param text The text message. * @param pos The position object of the label baseline. * @param style The optional style * @returns The MapVisual object, for chaining */ text(text: string, pos: RoomPosition, style?: MapTextStyle): MapVisual; /** * Remove all visuals from the map. * @returns The MapVisual object, for chaining */ clear(): MapVisual; /** * Get the stored size of all visuals added on the map in the current tick. * * It must not exceed 1024,000 (1000 KB). * @returns The size of the visuals in bytes. */ getSize(): number; /** * Returns a compact representation of all visuals added on the map in the current tick. * @returns A string with visuals data. There's not much you can do with the string besides store them for later. */ export(): string; /** * Add previously exported (with {@link Game.map.visual.export}) map visuals to the map visual data of the current tick. * @param data The string returned from `Game.map.visual.export`. * @returns The MapVisual object itself, so that you can chain calls. */ import(data: string): MapVisual; } interface MapLineStyle { /** * Line width. * @default 0.1 */ width?: number; /** * Line color in the following format: #ffffff (hex triplet). * @default #ffffff */ color?: string; /** * Opacity value * @default 0.5 */ opacity?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined. */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface MapPolyStyle { /** * Fill color in the following format: #ffffff (hex triplet). * @default undefined (no fill). */ fill?: string | undefined; /** * Opacity value * @default 0.5 */ opacity?: number; /** * Stroke color in the following format: #ffffff (hex triplet). * @default #ffffff */ stroke?: string; /** * Stroke line width. * @default 0.5 */ strokeWidth?: number; /** * Either undefined (solid line), dashed, or dotted. * @default is undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface MapCircleStyle extends MapPolyStyle { /** * Circle radius. * @default 10 */ radius?: number; } interface MapTextStyle { /** * Font color in the following format: #ffffff (hex triplet). * @default #ffffff */ color?: string; /** * The font family. * @default sans-serif */ fontFamily?: string; /** * The font size in game coordinates. * @default 10 */ fontSize?: number; /** * The font style ('normal', 'italic' or 'oblique') */ fontStyle?: string; /** * The font variant ('normal' or 'small-caps') */ fontVariant?: string; /** * Stroke color in the following format: #ffffff (hex triplet) * @default undefined (no stroke). */ stroke?: string | undefined; /** * Stroke width. * @default 0.15 */ strokeWidth?: number; /** * Background color in the following format: #ffffff (hex triplet). * * When background is enabled, text vertical align is set to middle (default is baseline). * @default undefined (no background). */ backgroundColor?: string | undefined; /** * Background rectangle padding. * @default 2 */ backgroundPadding?: number; /** * Text align, either center, left, or right. * @default center */ align?: "center" | "left" | "right"; /** * Opacity value. * @default 0.5 */ opacity?: number; } /** * A global object representing the in-game market. * * You can use this object to track resource transactions to/from your terminals, and your buy/sell orders. * The object is accessible via the singleton {@link Game.market} property. * * Learn more about the market system from [this article](https://docs.screeps.com/market.html). */ interface Market { /** * Your current credits balance. */ credits: number; /** * An array of the last 100 incoming transactions to your terminals */ incomingTransactions: Transaction[]; /** * An object with your active and inactive buy/sell orders on the market. */ orders: { [key: string]: Order }; /** * An array of the last 100 outgoing transactions from your terminals */ outgoingTransactions: Transaction[]; /** * Estimate the energy transaction cost of {@link StructureTerminal.send} and {@link Market.deal} methods. * * The formula: * * ``` * Math.ceil(amount * (1 - Math.exp(-linearDistanceBetweenRooms / 30))) * ``` * * @param amount Amount of resources to be sent. * @param roomName1 The name of the first room. * @param roomName2 The name of the second room. * @returns The amount of energy required to perform the transaction. */ calcTransactionCost(amount: number, roomName1: string, roomName2: string): number; /** * Cancel a previously created order. * * The 5% fee is not returned. * @param orderId The order ID as provided in Game.market.orders * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: The order ID is not valid. */ cancelOrder(orderId: string): ScreepsReturnCode; /** * Change the price of an existing order. * * If `newPrice` is greater than old price, you will be charged `(newPrice-oldPrice)*remainingAmount*0.05` credits. * @param orderId The order ID as provided in Game.market.orders * @param newPrice The new order price. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ changeOrderPrice(orderId: string, newPrice: number): ScreepsReturnCode; /** * Create a market order in your terminal. * * You will be charged `price*amount*0.05` credits when the order is placed. * * The maximum orders count is 300 per player. You can create an order at any time with any amount, * it will be automatically activated and deactivated depending on the resource/credits availability. * * An order expires in 30 days after its creation, and the remaining market fee is returned. * * @param params A object describing the order. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_FULL: You cannot create more than 50 orders. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ createOrder(params: CreateOrderParam): ScreepsReturnCode; /** * Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order. * * Your Terminal will be charged energy units of transfer cost regardless of the order resource type. * You can use {@link Game.market.calcTransactionCost} method to estimate it. * * When multiple players try to execute the same deal, the one with the shortest distance takes precedence. * * You cannot execute more than 10 deals during one tick. * * @param orderId The order ID as provided in Game.market.orders * @param amount The amount of resources to transfer. * @param yourRoomName The name of your room which has to contain an active Terminal with enough amount of energy. * This argument is not used when the order resource type is one of account-bound resources (@see {@link InterShardResourceConstant}). * * @returns One of the following error codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have a terminal in the target room. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits or resource units. * - ERR_FULL: You cannot execute more than 10 deals during one tick. * - ERR_INVALID_ARGS: The arguments provided are invalid. * - ERR_TIRED: The target terminal is still cooling down. */ deal(orderId: string, amount: number, yourRoomName?: string): ScreepsReturnCode; /** * Add more capacity to an existing order. * * It will affect `remainingAmount` and `totalAmount` properties. You will be charged `price*addAmount*0.05` credits. * Extending the order doesn't update its expiration time. * * @param orderId The order ID as provided in Game.market.orders * @param addAmount How much capacity to add. Cannot be a negative value. * @returns One of the following error codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ extendOrder(orderId: string, addAmount: number): ScreepsReturnCode; /** * Get other players' orders currently active on the market. * @param filter (optional) An object or function that will filter the resulting list using the lodash.filter method. * @returns An array of objects containing order information. */ getAllOrders(filter?: OrderFilter | ((o: Order) => boolean)): Order[]; /** * Get daily price history of the specified resource on the market for the last 14 days. * @param resource One of the {@link MarketResourceConstant RESOURCE_*} constants. If undefined, returns history data for all resources. Optional * @returns An array of objects with resource info. */ getHistory(resource?: MarketResourceConstant): PriceHistory[]; /** * Retrieve info for specific market order. * @param orderId The order ID. * @returns An object with the order info. See {@link Order}. */ getOrderById(id: string): Order | null; } // No static is available interface Transaction { transactionId: string; time: number; sender?: { username: string }; recipient?: { username: string }; resourceType: MarketResourceConstant; amount: number; from: string; to: string; description: string; order?: TransactionOrder; } interface Order { /** The unique order ID. */ id: string; /** * The order creation time in milliseconds since UNIX epoch time. * * This property is absent for old orders. */ created: number; /** Whether the order is active or not. * * Only exists for your own orders. */ active?: boolean; /** The order type. */ type: ORDER_BUY | ORDER_SELL; /** * The type of resource requested by the order. See {@link MarketResourceConstant}. */ resourceType: MarketResourceConstant; /** The room where this order is placed. */ roomName?: string; /** Currently available quantity of resource to trade. */ amount: number; /** Remaining quantity of resources to trade. */ remainingAmount: number; /** Total quantity of resources traded */ totalAmount?: number; /** The current price per unit. */ price: number; } interface TransactionOrder { id: string; type: string; price: number; } interface OrderFilter { id?: string; created?: number; type?: string; resourceType?: MarketResourceConstant; roomName?: string; amount?: number; remainingAmount?: number; price?: number; } interface PriceHistory { resourceType: MarketResourceConstant; date: string; transactions: number; volume: number; avgPrice: number; stddevPrice: number; } /** Parameters to {@link Game.market.createOrder} */ interface CreateOrderParam { /** * The order type. */ type: ORDER_BUY | ORDER_SELL; /** * The resource type to trade. * * If your Terminal doesn't have the specified resource, the order will be temporary inactive. */ resourceType: MarketResourceConstant; /** * The price for one resource unit in credits. * * Can be a decimal number. */ price: number; /** * The amount of resources to be traded in total. */ totalAmount: number; /** * The room where your order will be created. * * You must have your own Terminal structure in this room, otherwise the created order will be temporary inactive. * This argument is not used when `resourceType` is one of the {@link InterShardResourceConstant} resources. */ roomName?: string; } interface Memory { creeps: { [name: string]: CreepMemory }; powerCreeps: { [name: string]: PowerCreepMemory }; flags: { [name: string]: FlagMemory }; rooms: { [name: string]: RoomMemory }; spawns: { [name: string]: SpawnMemory }; } interface CreepMemory {} interface FlagMemory {} interface PowerCreepMemory {} interface RoomMemory {} interface SpawnMemory {} declare const Memory: Memory; /** * A mineral deposit. * * Can be harvested by creeps with a WORK body part using the extractor structure. * Learn more about minerals from [this article](http://docs.screeps.com/api/#Mineral). * * * | | | * | ---------------------------| ---------------------------- | * | Regeneration amount | DENSITY_LOW: 15,000 * | | DENSITY_MODERATE: 35,000 * | | DENSITY_HIGH: 70,000 * | | DENSITY_ULTRA: 100,000 * | Regeneration time | 50,000 ticks * | Density change probability | DENSITY_LOW: 100% chance * | | DENSITY_MODERATE: 5% chance * | | DENSITY_HIGH: 5% chance * | | DENSITY_ULTRA: 100% chance* */ interface Mineral extends RoomObject { /** * The prototype is stored in the Mineral.prototype global object. You can use it to extend game objects behaviour globally. */ readonly prototype: Mineral; /** * The density of this mineral deposit, one of the {@link DensityConstant DENSITY_*} constants. */ density: DensityConstant; /** * The remaining amount of resources. */ mineralAmount: number; /** * The resource type, one of the {@link MineralConstant RESOURCE_*} constants. */ mineralType: T; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * The remaining time after which the deposit will be refilled if is recharging, otherwise undefined. */ ticksToRegeneration?: number; } interface MineralConstructor extends _Constructor, _ConstructorById {} declare const Mineral: MineralConstructor; /** * A nuke landing position. * * This object cannot be removed or modified. You can find incoming nukes in the room using the {@link FIND_NUKES} constant. * * Landing time: 50,000 ticks * All creeps, construction sites and dropped resources in the room are removed immediately, even inside ramparts. * * Damage to structures: * - 10,000,000 hits at the landing position; * - 5,000,000 hits to all structures in 5x5 area. * * Note that you can stack multiple nukes from different rooms at the same target position to increase damage. * * Nuke landing does not generate tombstones and ruins, and destroys all existing tombstones and ruins in the room. * * If the room is in safe mode, then the safe mode is cancelled immediately, and the safe mode cooldown is reset to 0. * * The room controller is hit by triggering {@link StructureController.upgradeBlocked} period, which means it is unavailable to activate safe mode again within the next 200 ticks. */ interface Nuke extends RoomObject { readonly prototype: Nuke; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The name of the room where this nuke has been launched from. */ launchRoomName: string; /** * The remaining landing time. */ timeToLand: number; } interface NukeConstructor extends _Constructor, _ConstructorById {} declare const Nuke: NukeConstructor; /** * Contains powerful methods for pathfinding in the game world. * * This module is written in fast native C++ code and supports custom navigation costs and paths which span multiple rooms. * * Additionally PathFinder can search for paths through rooms you can't see, although you won't be able to detect any dynamic obstacles like creeps or buildings. */ interface PathFinder { /** * Creates a new {@link CostMatrix} containing 0's for all positions. */ CostMatrix: CostMatrixConstructor; /** * Find an optimal path between origin and goal. * * @param origin The start position. * @param goal goal A RoomPosition, an object containing a RoomPosition and range or an array of either. * @param opts An object containing additional pathfinding flags. */ search( origin: RoomPosition, goal: RoomPosition | { pos: RoomPosition; range: number } | Array, opts?: PathFinderOpts, ): PathFinderPath; /** * Specify whether to use this new experimental pathfinder in game objects methods. * This method should be invoked every tick. It affects the following methods behavior: * - {@link Room.findPath} * - {@link RoomPosition.findPathTo} * - {@link RoomPosition.findClosestByPath} * - {@link Creep.moveTo} * * @deprecated This method is deprecated and will be removed soon. * @param isEnabled Whether to activate the new pathfinder or deactivate. */ use(isEnabled: boolean): undefined; } /** * An object containing: * path - An array of RoomPosition objects. * ops - Total number of operations performed before this path was calculated. * cost - The total cost of the path as derived from `plainCost`, `swampCost` and any given CostMatrix instances. * incomplete - 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. */ interface PathFinderPath { /** * An array of {@link RoomPosition} objects. */ path: RoomPosition[]; /** * Total number of operations performed before this path was calculated. */ ops: number; /** * The total cost of the path as derived from `plainCost`, `swampCost` and any given {@link CostMatrix} instances. */ cost: number; /** * 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. */ incomplete: boolean; } /** * An object containing additional pathfinding flags. */ interface PathFinderOpts { /** * Cost for walking on plain positions. * @default 1 */ plainCost?: number; /** * Cost for walking on swamp positions. * @default 5 */ swampCost?: number; /** * 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. * @default false */ flee?: boolean; /** * The maximum allowed pathfinding operations. * * You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU. * @default 2000 */ maxOps?: number; /** * The maximum allowed rooms to search. * @default 16 (also maximum) */ maxRooms?: number; /** * 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. * @default Infinity */ maxCost?: 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! * @default 1.2 */ heuristicWeight?: number; /** * 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 {@link CostMatrix} to speed up your code. * Please read the {@link CostMatrix} documentation below for more information on CostMatrix. * * @param roomName The name of the room the pathfinder needs a cost matrix for. */ roomCallback?(roomName: string): boolean | CostMatrix; } interface CostMatrixConstructor extends _Constructor { new (): CostMatrix; /** * Static method which deserializes a new CostMatrix using the return value of serialize. * @param val Whatever serialize returned */ deserialize(val: number[]): CostMatrix; } /** * 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 {@link PathFinderOpts.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 {@link 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. */ interface CostMatrix { /** * Set the cost of a position in this CostMatrix. * @param x X position in the room. * @param y Y position in the room. * @param cost Cost of this position. Must be a whole number. A cost of 0 will use the terrain cost for that tile. A cost greater than or equal to 255 will be treated as unwalkable. */ set(x: number, y: number, cost: number): undefined; /** * Get the cost of a position in this CostMatrix. * @param x X position in the room. * @param y Y position in the room. */ get(x: number, y: number): number; /** * Copy this CostMatrix into a new CostMatrix with the same data. */ clone(): CostMatrix; /** * Returns a compact representation of this CostMatrix which can be stored via JSON.stringify. */ serialize(): number[]; } declare const PathFinder: PathFinder; /** * Power Creeps are immortal "heroes" that are tied to your account and can be respawned in any PowerSpawn after death. * * You can upgrade their abilities ("powers") up to your account Global Power Level (see {@link Game.gpl}). * * | | | * | ----------------- | ---------------- | * | **Time to live** | 5,000 * | **Hits** | 1,000 per level * | **Capacity** | 100 per level * * [Full list of available powers](https://docs.screeps.com/power.html#Powers) */ interface PowerCreep extends RoomObject { /** * An object with the creep's cargo contents. * @deprecated An alias for Creep.store. */ carry: StoreDefinition; /** * The total amount of resources the creep can carry. * @deprecated An alias for Creep.store.getCapacity(). */ carryCapacity: number; /** * The power creep's class, one of the {@link PowerClassConstant POWER_CLASS} constants. */ className: PowerClassConstant; /** * A timestamp when this creeep is marked to be permanently deleted from the account, or undefined otherwise. */ deleteTime: number | undefined; /** * The current amount of hit points of the creep. */ hits: number; /** * The maximum amount of hit points of the creep. */ hitsMax: number; /** * A unique identifier. * * You can use the {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The power creep's level. */ level: number; /** * The power creep's memory. * * A shorthand to `Memory.powerCreeps[creep.name]`. * * You can use it for quick access to the creep's specific memory data object. */ memory: PowerCreepMemory; /** * Whether it is your creep or foe. */ my: boolean; /** * The power creep name. * * You can choose the name while creating a new power creep, and `rename` it while unspawned. * This name is a hash key to access the creep via the {@link Game.powerCreeps} object. */ name: string; /** * An object with the creep's owner information. */ owner: Owner; /** * A Store object that contains cargo of this creep. */ store: StoreDefinition; /** * An object with the creep's available powers. */ powers: PowerCreepPowers; /** * The text message that the creep was saying at the last tick. */ saying: string; /** * The name of the shard where the power creeps is spawned, or undefined. */ shard: string | undefined; /** * The timestamp when spawning or deleting this creep will become available. * * Undefined if the power creep is spawned in the world. * * Note: This is a timestamp, not ticks as powerCreeps are not shard dependent. */ spawnCooldownTime: number | undefined; /** * The remaining amount of game ticks after which the creep will die and become unspawned. * * Undefined if the creep is not spawned in the world. */ ticksToLive: number | undefined; /** * Cancel the order given during the current game tick. * @param methodName Cancel the order given during the current game tick. * @returns One of the following codes: * - OK: The operation has been cancelled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The order with the specified name is not found. */ cancelOrder(methodName: string): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND; /** * 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-hour delete time is started (see {@link PowerCreep.deleteTime}). * You can cancel deletion by calling `delete(true)`. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The power creep is spawned in the world. */ delete(cancel?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Drop this resource on the ground. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of energy. * - ERR_INVALID_ARGS: The resourceType is not a valid {@link ResourceConstant RESOURCE_*} constants. */ drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; /** * Enable power usage in this room. * * The room controller should be at adjacent tile. * @param controller The room controller * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_INVALID_TARGET: The target is not a controller structure. * - ERR_NOT_IN_RANGE: The target is too far away. */ enableRoom(controller: StructureController): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * * Requires the MOVE body part if not being pulled. * @param direction The direction to move in ({@link DirectionConstant `TOP`, `TOP_LEFT`...}) * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. */ move(direction: DirectionConstant): CreepMoveReturnCode; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. * * @param path A path value as returned from {@link Room.findPath} or {@link RoomPosition.findPathTo} methods. * Both array form and serialized string form are accepted. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The specified path doesn't match the creep's location. * - ERR_INVALID_ARGS: path is not a valid path array. */ moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * Find the optimal path to the target within the same room and move to it. * * A shorthand to consequent calls of {@link RoomPosition.findPathTo()} and {@link Creep.move()} methods. * If the target is in another room, then the corresponding exit will be used as a target. * * @param x X position of the target in the room. * @param y Y position of the target in the room. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more info) or one of the following: reusePath, serializeMemory, noPathFinding * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_NO_PATH: No path to the target could be found. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The creep has no memorized path to reuse. * - ERR_INVALID_TARGET: The target provided is invalid. */ moveTo(x: number, y: number, opts?: MoveToOpts): OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_TARGET; moveTo( target: RoomPosition | { pos: RoomPosition }, opts?: MoveToOpts, ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; /** * 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. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS; /** * 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. * @param target The target object to be picked up. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_TARGET: The target is not a valid object to pick up. * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. */ pickup(target: Resource): CreepActionReturnCode | ERR_FULL; /** * Rename the power creep. * * It must not be spawned in the world. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_NAME_EXISTS: A power creep with the specified name already exists. * - ERR_BUSY: The power creep is spawned in the world. */ rename(name: string): OK | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY; /** * Instantly restore time to live to the maximum using a Power Spawn or a Power Bank nearby. * * It has to be at adjacent tile. * @param target The target structure * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_TARGET: The target is not a valid power bank or power spawn. * - ERR_NOT_IN_RANGE: The target is too far away. */ renew(target: StructurePowerBank | StructurePowerSpawn): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * 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 unless toPublic is true. * @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'. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. */ say(message: string, toPublic?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Spawn this power creep in the specified Power Spawn. * @param powerSpawn Your Power Spawn structure * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep or the spawn. * - ERR_BUSY: The power creep is already spawned in the world. * - ERR_INVALID_TARGET: The specified object is not a Power Spawn. * - ERR_TIRED: The power creep cannot be spawned because of the cooldown. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use the spawn. */ spawn(powerSpawn: StructurePowerSpawn): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Kill the power creep immediately. * * It will not be destroyed permanently, but will become unspawned, so that you can `spawn` it again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. */ suicide(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 {@link ResourceConstant RESOURCE_*} constants * @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The target cannot receive any more resources. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; /** * Upgrade the creep, adding a new power ability to it or increasing the level of the existing power. * * You need one free Power Level in your account to perform this action. * @param power The power ability to upgrade, one of the {@link PowerConstant PWR_*} constants. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_NOT_ENOUGH_RESOURCES: You account Power Level is not enough. * - ERR_FULL: The specified power cannot be upgraded on this creep's level, or the creep reached the maximum level. * - ERR_INVALID_ARGS: The specified power ID is not valid. */ upgrade(power: PowerConstant): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL | ERR_INVALID_ARGS; /** * Apply one of the creep's powers on the specified target. * * @param power The power ability to use, one of the {@link PowerConstant PWR_*} constants. * @param target A target object in the room. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep doesn't have enough resources to use the power. * - ERR_INVALID_TARGET: The specified target is not valid. * - ERR_FULL: The target has the same active effect of a higher level. * - ERR_NOT_IN_RANGE: The specified target is too far away. * - ERR_INVALID_ARGS: Using powers is not enabled on the Room Controller. * - ERR_TIRED: The power ability is still on cooldown. * - ERR_NO_BODYPART: The creep doesn't have the specified power ability. */ usePower(power: PowerConstant, target?: RoomObject): ScreepsReturnCode; /** * Withdraw resources from a structure, tombstone, or ruin. * * 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 {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be transferred. If omitted, all the available amount is used. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or there is a hostile rampart on top of the target. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The target does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The creep's carry is full. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; } interface PowerCreepConstructor extends _Constructor, _ConstructorById { /** * A static method to create new Power Creep instance in your account. * * It will be added in an unspawned state, use the {@link PowerCreep.spawn} method to spawn it in the world. * * You need one free Power Level in your account to perform this action. * * @param name The name of the power creep. * @param className The class of the new power creep, one of the {@link PowerClassConstant POWER_CLASS} constants */ create(name: string, className: PowerClassConstant): OK | ERR_NAME_EXISTS | ERR_NOT_ENOUGH_RESOURCES; } declare const PowerCreep: PowerCreepConstructor; /** * Available powers, an object with power ID as a key, and the following properties */ interface PowerCreepPowers { [powerID: number]: { /** * Current level of the power */ level: number; /** * Cooldown ticks remaining * * Will be undefined if the power creep is not spawned in the world. */ cooldown: number | undefined; }; } /** * RawMemory object allows to implement your own memory stringifier instead of built-in serializer based on JSON.stringify. * * It also allows to request up to 10 MB of additional memory using asynchronous memory segments feature. * * You can also access memory segments of other players using methods below. */ interface RawMemory { /** * An object with asynchronous memory segments available on this tick. * * Each object key is the segment ID with data in string values. * Use {@link RawMemory.setActiveSegments} to fetch segments on the next tick. Segments data is saved automatically in the end of the tick. */ segments: { [segmentId: number]: string }; /** * An object with a memory segment of another player available on this tick. Use {@link RawMemory.setActiveForeignSegment} to fetch segments on the next tick. */ foreignSegment: { username: string; id: number; data: string; }; /** * @deprecated Use `InterShardMemory` instead. * * A string with a shared memory segment available on every world shard. Maximum string length is 100 KB. * * **Warning:** this segment is not safe for concurrent usage! All shards have shared access to the same instance of * data. When the segment contents is changed by two shards simultaneously, you may lose some data, since the segment * string value is written all at once atomically. You must implement your own system to determine when each shard is * allowed to rewrite the inter-shard memory, e.g. based on mutual exclusions. * */ interShardSegment: string; /** * Get a raw string representation of the Memory object. */ get(): string; /** * Set new memory value. * @param value New memory value as a string. * @throws if the new value is not a string or contains more than `2 * 1024 * 1024` characters. */ set(value: string): undefined; /** * Request memory segments using the list of their IDs. * * Memory segments will become available on the next tick in {@link RawMemory.segments} object. * Segment IDs are a number from 0 to 99. A maximum of 10 segments can be active at the same time. * Subsequent calls to {@link RawMemory.setActiveSegments} overrides previous ones. * * @param ids An array of segment IDs. * @throws if `ids` isn't an array, more than 10 segments are active, or the ids aren't all integers. */ setActiveSegments(ids: number[]): undefined; /** * Request a memory segment of another user. * * The segment should be marked by its owner as public using {@link RawMemory.setPublicSegments}. * * The segment data will become available on the next tick in {@link foreignSegment} object. * * You can only have access to one foreign segment at the same time. * * @param username The name of another user. Pass `null` to clear the foreign segment. * @param id The ID of the requested segment from 0 to 99. If undefined, the user's default public segment is requested as set by {@link RawMemory.setDefaultPublicSegment}. * @throws if `id` is passed and isn't an integer. */ setActiveForeignSegment(username: string | null, id?: number): undefined; /** * Set the specified segment as your default public segment. * * It will be returned if no id parameter is passed to {@link RawMemory.setActiveForeignSegment} by another user. * * @param id The ID of the requested segment from 0 to 99. Pass `null` to clear the foreign segment. * @throws if `id` is passed and isn't an integer. */ setDefaultPublicSegment(id: number | null): undefined; /** * Set specified segments as public. * * Other users will be able to request access to them using {@link setActiveForeignSegment}. * * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Subsequent calls of {@link RawMemory.setPublicSegments} override previous ones. * @throws if `ids` isn't an array or the ids aren't all integers. */ setPublicSegments(ids: number[]): undefined; } declare const RawMemory: RawMemory; /** * A dropped piece of resource. * * It will decay after a while if not picked up. * Dropped resource pile decays for `ceil(amount/1000)` units per tick. */ interface Resource extends RoomObject { readonly prototype: Resource; /** * The amount of resource units containing. */ amount: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * One of the {@link ResourceConstant RESOURCE_*} constants. */ resourceType: T; } interface ResourceConstructor extends _Constructor, _ConstructorById {} declare const Resource: ResourceConstructor; /** * Any object with a position in a room. * * Almost all game objects prototypes are derived from RoomObject. */ interface RoomObject { readonly prototype: RoomObject; /** * Effects currently being applied to the object. */ effects?: RoomObjectEffect[]; /** * An object representing the position of this object in the room. */ pos: RoomPosition; /** * The link to the {@link Room} object. * * May be `undefined` if the object is a {@link Flag} or a {@link ConstructionSite} and is placed in a room that is not visible * to you. */ room: Room | undefined; } interface RoomObjectConstructor extends _Constructor { new (x: number, y: number, roomName: string): RoomObject; (x: number, y: number, roomName: string): RoomObject; } declare const RoomObject: RoomObjectConstructor; /** * Discriminated union of possible effects on `effect` */ type RoomObjectEffect = NaturalEffect | PowerEffect; /** * Natural effect applied to room object */ interface NaturalEffect { /** * Effect ID of the applied effect. * * One of the {@link EffectConstant EFFECT_*} constants. */ effect: EffectConstant; /** * How many ticks will the effect last. */ ticksRemaining: number; } /** * Effect applied to room object as result of a {@link PowerCreep.usePower}. */ interface PowerEffect { /** * Power level of the applied effect. */ level: number; /** * Effect ID of the applied effect. * * One of the {@link PowerConstant PWR_*} constants. */ effect: PowerConstant; /** * Power ID of the applied effect. * * @deprecated Use {@link PowerEffect.effect} instead. * * One of the {@link PowerConstant PWR_*} constants. */ power: PowerConstant; /** * How many ticks will the effect last. */ ticksRemaining: number; } /** * An object representing the specified position in the room. * * Every object in the room contains one of these as its `pos` property. * * The position object of a custom location can be obtained using the {@link Room.getPositionAt()} method or using the constructor. */ interface RoomPosition { readonly prototype: RoomPosition; /** * The name of the room. */ roomName: string; /** * X position in the room. */ x: number; /** * Y position in the room. */ y: number; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have ownership of the targetted room. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(structureType: BuildableStructureConstant): ScreepsReturnCode; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @param name The name of the structure, for structures that support it (currently only spawns). The name length limit is 100 characters. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have ownership of the targetted room. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create a new {@link Flag} at the specified location. * @param name The name of a new flag. * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * If not defined, a random name will be generated. * @param color The color of a new flag. Should be one of the {@link ColorConstant COLOR_*} constants * @param secondaryColor The secondary color of a new flag. Should be one of the {@link ColorConstant COLOR_*} constants. The default value is equal to color. * @returns The name of the flag if created, or one of the following error codes: ERR_NAME_EXISTS, ERR_INVALID_ARGS */ createFlag(name?: string, color?: ColorConstant, secondaryColor?: ColorConstant): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Find the object with the shortest path from the given position. * * Uses A* search algorithm and Dijkstra's algorithm. * @param type Any of the {@link FindConstant FIND_*} constants. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm * @returns An instance of a RoomObject. */ findClosestByPath( type: K, opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm }, ): S | null; findClosestByPath( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm }, ): S | null; /** * Find the object with the shortest path from the given position. * * Uses A* search algorithm and Dijkstra's algorithm. * @param objects An array of RoomPositions or objects with a RoomPosition * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm * @returns One of the supplied objects */ findClosestByPath( objects: T[], opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm; }, ): S | null; /** * Find the object with the shortest linear distance from the given position. * @param type Any of the {@link FindConstant FIND_*} constants. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm */ findClosestByRange(type: K, opts?: FilterOptions): S | null; findClosestByRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FilterOptions, ): S | null; /** * Find the object with the shortest linear distance from the given position. * @param objects An array of RoomPositions or objects with a RoomPosition. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm */ findClosestByRange(objects: T[], opts?: FilterOptions): S | null; /** * Find all objects in the specified linear range. * @param type Any of the {@link FindConstant FIND_*} constants. * @param range The range distance. * @param opts See Room.find. */ findInRange(type: K, range: number, opts?: FilterOptions): S[]; findInRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, range: number, opts?: FilterOptions, ): S[]; /** * Find all objects in the specified linear range. * @param objects An array of room's objects or RoomPosition objects that the search should be executed against. * @param range The range distance. * @param opts See {@link Room.find}. */ findInRange(objects: T[], range: number, opts?: FilterOptions): S[]; /** * Find an optimal path to the specified position using A* search algorithm. * * This method is a shorthand for {@link Room.findPath}. If the target is in another room, then the corresponding exit will be used as a target. * @param x X position in the room. * @param y Y position in the room. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more details). */ findPathTo(x: number, y: number, opts?: FindPathOpts): PathStep[]; /** * Find an optimal path to the specified position using A* search algorithm. * * This method is a shorthand for {@link Room.findPath}. If the target is in another room, then the corresponding exit will be used as a target. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more details). */ findPathTo(target: RoomPosition | _HasRoomPosition, opts?: FindPathOpts): PathStep[]; /** * Get linear direction to the specified position. * @param x X position in the room. * @param y Y position in the room. */ getDirectionTo(x: number, y: number): DirectionConstant; /** * Get linear direction to the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ getDirectionTo(target: RoomPosition | _HasRoomPosition): DirectionConstant; /** * Get linear range to the specified position. * @param x X position in the room. * @param y Y position in the room. */ getRangeTo(x: number, y: number): number; /** * Get linear range to the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ getRangeTo(target: RoomPosition | { pos: RoomPosition }): number; /** * Check whether this position is in the given range of another position. * @param x X position in the room. * @param y Y position in the room. * @param range The range distance. */ inRangeTo(x: number, y: number, range: number): boolean; /** * Check whether this position is in the given range of another position. * @param toPos The target position. * @param range The range distance. */ inRangeTo(target: RoomPosition | { pos: RoomPosition }, range: number): boolean; /** * Check whether this position is the same as the specified position. * @param x X position in the room. * @param y Y position in the room. */ isEqualTo(x: number, y: number): boolean; /** * Check whether this position is the same as the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ isEqualTo(target: RoomPosition | { pos: RoomPosition }): boolean; /** * Check whether this position is on the adjacent square to the specified position. * * Equivalent to `inRangeTo(target, 1)`. * @param x X position in the room. * @param y Y position in the room. */ isNearTo(x: number, y: number): boolean; /** * Check whether this position is on the adjacent square to the specified position. * * Equivalent to inRangeTo(target, 1). * @param target Can be a RoomPosition object or any object containing RoomPosition. */ isNearTo(target: RoomPosition | { pos: RoomPosition }): boolean; /** * Get the list of objects at the specified room position. */ look(): LookAtResult[]; /** * Get an object with the given type at the specified room position. * @param type One of the following string constants: constructionSite, creep, exit, flag, resource, source, structure, terrain */ lookFor(type: T): Array; } interface RoomPositionConstructor extends _Constructor { /** * You can create new RoomPosition object using its constructor. * @param x X position in the room. * @param y Y position in the room. * @param roomName The room name. * @throws if `x` or `y` are out of bounds, or `roomName` isn't a valid room name. */ new (x: number, y: number, roomName: string): RoomPosition; (x: number, y: number, roomName: string): RoomPosition; } declare const RoomPosition: RoomPositionConstructor; /** * 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. */ interface RoomTerrain { /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param x X position in the room. * @param y Y position in the room. * @return A bitmask of {@link TERRAIN_MASK_WALL}, {@link TERRAIN_MASK_SWAMP}. */ get(x: number, y: number): 0 | TERRAIN_MASK_WALL | TERRAIN_MASK_SWAMP; /** * Get a copy of the underlying static terrain buffer. * @param destinationArray (optional) A typed array view in which terrain will be copied to. * @throws {RangeError} if `destinationArray` is provided, it must have a length of at least 2500 (`50*50`). * @return Copy of underlying room terrain as a new typed array of size 2500. */ getRawBuffer< T extends | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array, >( destinationArray: T, ): T; getRawBuffer(): Uint8Array; } interface RoomTerrainConstructor extends _Constructor { /** * Get room terrain for the specified room. * * This method works for any room in the world even if you have no access to it. * @param roomName String name of the room. */ new (roomName: string): RoomTerrain; } /** * Room visuals provide a way to show various visual debug info in game rooms. * * You can use the RoomVisual object to draw simple shapes that are visible only to you. * Every existing Room object already contains the visual property, but you also can create new RoomVisual objects for any room (even without visibility) using the constructor. * * Room visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. All RoomVisual API calls have no added CPU cost (their cost is natural and mostly related to simple `JSON.serialize` calls). * However, there is a usage limit: you cannot post more than 500 KB of serialized data per one room (see {@link RoomVisual.getSize} method). * * All draw coordinates are measured in game coordinates and centered to tile centers, i.e. (10,10) will point to the center of the creep at x:10; y:10 position. * Fractional coordinates are allowed. */ declare class RoomVisual { /** * You can create new RoomVisual object using its constructor. * @param roomName The room name. If undefined, visuals will be posted to all rooms simultaneously. */ constructor(roomName?: string); /** * The name of the room. */ roomName: string; /** * Draw a line. * @param x1 The start X coordinate. * @param y1 The start Y coordinate. * @param x2 The finish X coordinate. * @param y2 The finish Y coordinate. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ line(x1: number, y1: number, x2: number, y2: number, style?: LineStyle): RoomVisual; /** * Draw a line. * @param pos1 The start position object. * @param pos2 The finish position object. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ line(pos1: RoomPosition, pos2: RoomPosition, style?: LineStyle): RoomVisual; /** * Draw a circle. * @param x The X coordinate of the center. * @param y The Y coordinate of the center. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ circle(x: number, y: number, style?: CircleStyle): RoomVisual; /** * Draw a circle. * @param pos The position object of the center. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ circle(pos: RoomPosition, style?: CircleStyle): RoomVisual; /** * Draw a rectangle. * @param x The X coordinate of the top-left corner. * @param y The Y coordinate of the top-left corner. * @param w The width of the rectangle. * @param h The height of the rectangle. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ rect(x: number, y: number, w: number, h: number, style?: PolyStyle): RoomVisual; /** * Draw a line. * @param topLeftPos The position object of the top-left corner. * @param width The width of the rectangle. * @param height The height of the rectangle. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ rect(topLeftPos: RoomPosition, width: number, height: number, style?: PolyStyle): RoomVisual; /** * Draw a polygon. * @param points An array of points. Every array item should be either an array with 2 numbers (i.e. [10,15]), or a RoomPosition object. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ poly(points: Array<[number, number] | RoomPosition>, style?: PolyStyle): RoomVisual; /** * Draw a text label. * @param text The text message. * @param x The X coordinate of the label baseline center point. * @param y The Y coordinate of the label baseline center point. * @param style The (optional) text style. * @returns The RoomVisual object, for chaining. */ text(text: string, x: number, y: number, style?: TextStyle): RoomVisual; /** * Draw a text label. * * You can use any valid Unicode characters, including emoji. * @param text The text message. * @param pos The position object of the center. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ text(text: string, pos: RoomPosition, style?: TextStyle): RoomVisual; /** * Remove all visuals from the room. * @returns The RoomVisual object, for chaining. */ clear(): RoomVisual; /** * Get the stored size of all visuals added in the room in the current tick. * It must not exceed 512,000 (500 KB). * @returns The size of the visuals in bytes. */ getSize(): number; /** * Returns a compact representation of all visuals added in the room in the current tick. * @returns A string with visuals data. There's not much you can do with the string besides store them for later. */ export(): string; /** * Add previously exported (with {@link RoomVisual.export}) room visuals to the room visual data of the current tick. * @param data The string returned from `RoomVisual.export`. * @returns The RoomVisual object itself, so that you can chain calls. */ import(data: string): RoomVisual; } interface LineStyle { /** * Line width. * @default 0.1 */ width?: number; /** * Line color in any web format. * @default #ffffff (white) */ color?: string; /** * Opacity value. * @default 0.5 */ opacity?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface PolyStyle { /** * Fill color in any web format. * @default undefined (no fill). */ fill?: string | undefined; /** * Opacity value, default is 0.5. */ opacity?: number; /** * Stroke color in any web format. * @default #ffffff (white) */ stroke?: string; /** * Stroke line width. * @default 0.1 */ strokeWidth?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface CircleStyle extends PolyStyle { /** * Circle radius. * @default 0.15 */ radius?: number; } interface TextStyle { /** * Font color in any web format. * @default #ffffff (white) */ color?: string; /** * Either a number or a string in one of the following forms: * - 0.7 - relative size in game coordinates * - 20px - absolute size in pixels * - 0.7 serif * - bold italic 1.5 Times New Roman */ font?: number | string; /** * Stroke color in any web format. * @default undefined (no stroke) */ stroke?: string | undefined; /** * Stroke width. * @default 0.15 */ strokeWidth?: number; /** * Background color in any web format. * When background is enabled, text vertical align is set to middle (default is baseline). * @default undefined (no background) */ backgroundColor?: string | undefined; /** * Background rectangle padding * @default 0.3 */ backgroundPadding?: number; align?: "center" | "left" | "right"; /** * Opacity value. * @default 1.0 */ opacity?: number; } /** * An object representing the room in which your units and structures are in. * * It can be used to look around, find paths, etc. * * Every object in the room contains its linked Room instance in the {@link RoomObject.room} property. */ interface Room { readonly prototype: Room; /** * The Controller structure of this room, if present, otherwise undefined. */ controller?: StructureController; /** * Total amount of energy available in all spawns and extensions in the room. */ energyAvailable: number; /** * Total amount of energyCapacity of all spawns and extensions in the room. */ energyCapacityAvailable: number; /** * Returns an array of events happened on the previous tick in this room. */ getEventLog(raw?: false): EventItem[]; /** * Returns an raw JSON string of events happened on the previous tick in this room. */ getEventLog(raw: true): string; /** * The room's memory. * * A shorthand to `Memory.rooms[room.name]`. You can use it for quick access the room’s specific memory data object. */ memory: RoomMemory; /** * The name of the room. */ readonly name: string; /** * The {@link StructureStorage} of this room, if present, otherwise undefined. */ storage?: StructureStorage; /** * The {@link StructureTerminal} of this room, if present, otherwise undefined. */ terminal?: StructureTerminal; /** * A {@link RoomVisual} object for this room. * * You can use this object to draw simple shapes (lines, circles, text labels) in the room. */ visual: RoomVisual; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position * @param y The Y position * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(x: number, y: number, structureType: BuildableStructureConstant): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: StructureConstant): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position * @param y The Y position * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(x: number, y: number, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create new {@link Flag} at the specified location. * @param x The X position. * @param y The Y position. * @param name (optional) The name of a new flag. * * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * * If not defined, a random name will be generated. * * The maximum length is 60 characters. * @param color The color of a new flag. Should be one of the COLOR_* constants. The default value is COLOR_WHITE. * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: * - ERR_NAME_EXISTS: There is a flag with the same name already. * - ERR_FULL: You have too many flags. The maximum number of flags per player is 10000. * - ERR_INVALID_ARGS: The location or the name or the color constant is incorrect. */ createFlag( x: number, y: number, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Create new {@link Flag} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param name (optional) The name of a new flag. * * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * * If not defined, a random name will be generated. * * The maximum length is 60 characters. * @param color The color of a new flag. Should be one of the COLOR_* constants. The default value is COLOR_WHITE. * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: * - ERR_NAME_EXISTS: There is a flag with the same name already. * - ERR_FULL: You have too many flags. The maximum number of flags per player is 10000. * - ERR_INVALID_ARGS: The location or the name or the color constant is incorrect. */ createFlag( pos: RoomPosition | { pos: RoomPosition }, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Find all objects of the specified type in the room. * @param type One of the {@link FindConstant FIND_*} constants. * @param opts An object with additional options * @returns An array with the objects found. */ find(type: K, opts?: FilterOptions): S[]; find( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FilterOptions, ): S[]; /** * Find the exit direction en route to another room. * @param room Another room name or room object. * @returns The room direction constant, one of the following: FIND_EXIT_TOP, FIND_EXIT_RIGHT, FIND_EXIT_BOTTOM, FIND_EXIT_LEFT * Or one of the following error codes: ERR_NO_PATH, ERR_INVALID_ARGS */ findExitTo(room: string | Room): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; /** * Find an optimal path inside the room between fromPos and toPos using A* search algorithm. * @param fromPos The start position. * @param toPos The end position. * @param opts (optional) An object containing additional pathfinding flags * @returns An array with path steps */ findPath(fromPos: RoomPosition, toPos: RoomPosition, opts?: FindPathOpts): PathStep[]; /** * Creates a {@link RoomPosition} object at the specified location. * @param x The X position. * @param y The Y position. * @returns A RoomPosition object or null if it cannot be obtained. */ getPositionAt(x: number, y: number): RoomPosition | null; /** * Get a {@link RoomTerrain} object which provides fast access to static terrain data. * * This method works for any room in the world even if you have no access to it. */ getTerrain(): RoomTerrain; /** * Get the list of objects at the specified room position. * @param x The X position. * @param y The Y position. * @returns An array with objects at the specified position * @throws if `x` or `y` are out of bounds. */ lookAt(x: number, y: number): LookAtResult[]; /** * Get the list of objects at the specified room position. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @returns An array with objects at the specified position */ lookAt(target: RoomPosition | { pos: RoomPosition }): LookAtResult[]; /** * Get the list of objects at the specified room area. * * This method is more CPU efficient in comparison to multiple {@link Room.lookAt} calls. * @param top The top Y boundary of the area. * @param left The left X boundary of the area. * @param bottom The bottom Y boundary of the area. * @param right The right X boundary of the area. * @param asArray Set to true if you want to get the result as a plain array. * @returns An object with all the objects in the specified area */ lookAtArea(top: number, left: number, bottom: number, right: number, asArray?: false): LookAtResultMatrix; lookAtArea(top: number, left: number, bottom: number, right: number, asArray: true): LookAtResultWithPos[]; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param x The X position. * @param y The Y position. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ lookForAt(type: T, x: number, y: number): Array; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param target A RoomPosition. Its room name will be ignored. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ lookForAt(type: T, target: RoomPosition | _HasRoomPosition): Array; /** * Get the given objects in the supplied area. * @param type One of the {@link LookConstant LOOK_*} constants * @param top The top (Y) boundary of the area. * @param left The left (X) boundary of the area. * @param bottom The bottom (Y) boundary of the area. * @param right The right(X) boundary of the area. * @param asArray Flatten the results into an array? * @returns Either an array of found objects with an x & y property or a nested object keyed by x, then y coordinate. */ lookForAtArea( type: T, top: number, left: number, bottom: number, right: number, asArray?: false, ): LookForAtAreaResultMatrix; lookForAtArea( type: T, top: number, left: number, bottom: number, right: number, asArray: true, ): LookForAtAreaResultArray; } interface RoomConstructor extends _Constructor { new (id: string): Room; Terrain: RoomTerrainConstructor; /** * Serialize a path array into a short string representation, which is suitable to store in memory. * @param path A path array retrieved from {@link Room.findPath}. * @returns A serialized string form of the given path. */ serializePath(path: PathStep[]): string; /** * Deserialize a short string path representation into an array form. * @param path A serialized path string. * @returns A path array. */ deserializePath(path: string): PathStep[]; } declare const Room: RoomConstructor; /** * A destroyed structure. * * This is a walkable object. * * Usually decays in 500 ticks except some special cases. */ interface Ruin extends RoomObject { /** * A unique object identifier. * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * Time of destruction. */ destroyTime: number; /** * An object with the ruin contents. */ store: StoreDefinitionUnlimited; /** * The amount of game ticks before this ruin decays. */ ticksToDecay: number; /** * An object containing the destroyed structure. */ structure: AnyStructure; } interface RuinConstructor extends _Constructor, _ConstructorById {} declare const Ruin: RuinConstructor; /** * An energy source object. * * Can be harvested by creeps with a WORK body part. * * | | | * | ------------------- | ---------------------------------- | * | Energy amount | 4000 in center rooms * | | 3000 in an owned or reserved room * | | 1500 in an unreserved room * | Energy regeneration | Every 300 game ticks */ interface Source extends RoomObject { /** * The prototype is stored in the Source.prototype global object. You can use it to extend game objects behaviour globally: */ readonly prototype: Source; /** * The remaining amount of energy. */ energy: number; /** * The total amount of energy in the source. * * Equals to 3000 in most cases. */ energyCapacity: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The room the source is in. */ room: Room; /** * The remaining time after which the source will be refilled. */ ticksToRegeneration: number; } interface SourceConstructor extends _Constructor, _ConstructorById {} declare const Source: SourceConstructor; /** * Spawns are your colony centers. * * This structure can create, renew, and recycle creeps. * All your spawns are accessible through {@link Game.spawns} hash list. * Spawns auto-regenerate a little amount of energy each tick, so that you can easily recover even if all your creeps died. * * | Controller level | | * | ---------------- | -------- | * | 1-6 | 1 spawn | * | 7 | 2 spawns | * | 8 | 3 spawns | * * | | | * | ----------------------------- | ------------- | * | **Cost** | 15,000 * | **Hits** | 5,000 * | **Capacity** | 300 * | **Spawn time** | 3 ticks per each body part * | **Energy auto-regeneration** | 1 energy unit per tick while energy available | in the room (in all spawns and extensions) is less than 300 */ interface StructureSpawn extends OwnedStructure { readonly prototype: StructureSpawn; /** * The amount of energy containing in the spawn. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the spawn can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The spawn memory. * * A shorthand to `Memory.spawns[spawn.name]`. You can use it for quick access the spawn’s specific memory data object. * * @see http://docs.screeps.com/global-objects.html#Memory-object */ memory: SpawnMemory; /** * The spawn name. * * You choose the name upon creating a new spawn, and it cannot be changed later. * This name is a hash key to access the spawn via the {@link Game.spawns} object. */ name: string; /** * If the spawn is in process of spawning a new creep, this object will contain the new creep’s information, or null otherwise. */ spawning: Spawning | null; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Check if a creep can be created. * * @deprecated This method is deprecated and will be removed soon. Please use {@link StructureSpawn.spawnCreep} with `dryRun` flag instead. * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. * * It should be unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * * If not defined, a random name will be generated. * @returns One of the following codes: * - OK: A creep with the given body and name can be created. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ canCreateCreep(body: BodyPartConstant[], name?: string): ScreepsReturnCode; /** * Start the creep spawning process. * * @deprecated This method is deprecated and will be removed soon. Please use {@link StructureSpawn.spawnCreep} instead. * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. * * It should be unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * * If not defined, a random name will be generated. * @param memory The memory of a new creep. If provided, it will be immediately stored into Memory.creeps[name]. * @returns The name of a new creep or one of these error codes: * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is not enough to use this spawn. */ createCreep(body: BodyPartConstant[], name?: string, memory?: CreepMemory): ScreepsReturnCode | string; /** * Start the creep spawning process. The required energy amount can be withdrawn from all spawns and extensions in the room. * * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. It must be a unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * @param opts An object with additional options for the spawning process. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described or name was not provided. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ spawnCreep(body: BodyPartConstant[], name: string, opts?: SpawnOptions): ScreepsReturnCode; /** * Increase the remaining time to live of the target creep. * * The target should be at adjacent square. * * The spawn should not be busy with the spawning process. * * Each execution increases the creep's timer by amount of ticks according to this formula: `floor(600/body_size)`. * * Energy required for each execution is determined using this formula: `ceil(creep_cost/2.5/body_size)`. * @param target The target creep object. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the spawn, or the creep. * - ERR_BUSY: The spawn is spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn does not have enough energy. * - ERR_INVALID_TARGET: The specified target object is not a creep, or the creep has CLAIM body part. * - ERR_FULL: The target creep's time to live timer is full. * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ renewCreep(target: Creep): ScreepsReturnCode; /** * Kill the creep and drop up to 100% of resources spent on its spawning and boosting depending on remaining life time. * * The target should be at adjacent square. Energy return is limited to 125 units per body part. * * @param target The target creep object. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn or the target creep. * - ERR_INVALID_TARGET: The specified target object is not a creep. * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ recycleCreep(target: Creep): ScreepsReturnCode; } interface StructureSpawnConstructor extends _Constructor, _ConstructorById { Spawning: SpawningConstructor; } declare const StructureSpawn: StructureSpawnConstructor; declare const Spawn: StructureSpawnConstructor; // legacy alias // declare type Spawn = StructureSpawn; interface Spawning { readonly prototype: Spawning; /** * An array with the spawn directions * * @see http://docs.screeps.com/api/#StructureSpawn.Spawning.setDirections */ directions?: DirectionConstant[]; /** * The name of the creep */ name: string; /** * Time needed in total to complete the spawning. */ needTime: number; /** * Remaining time to go. */ remainingTime: number; /** * A link to the spawn */ spawn: StructureSpawn; /** * Cancel spawning immediately. * * Energy spent on spawning is not returned. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. */ cancel(): ScreepsReturnCode & (OK | ERR_NOT_OWNER); /** * Set allowed directions the creep can move when spawned. * * @param directions An array with the spawn directions * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_INVALID_ARGS: The directions is array is invalid. */ setDirections(directions: DirectionConstant[]): ScreepsReturnCode & (OK | ERR_NOT_OWNER | ERR_INVALID_ARGS); } /** * An object with additional options for the spawning process. */ interface SpawnOptions { /** * Memory of the new creep. * * If provided, it will be immediately stored into Memory.creeps[name]. */ memory?: CreepMemory; /** * Array of spawns/extensions from which to draw energy for the spawning process. * * Structures will be used according to the array order. */ energyStructures?: Array; /** * If dryRun is `true`, the operation will only check if it is possible to create a creep. */ dryRun?: boolean; /** * Set allowed directions the creep can move when spawned. */ directions?: DirectionConstant[]; } interface SpawningConstructor extends _Constructor { new (id: Id): Spawning; (id: Id): Spawning; } interface StoreBase { /** * Returns capacity of this store for the specified resource. * * For a general purpose store, it returns total capacity if `resource` is undefined. * @param resource The type of the resource. * @returns Returns capacity number, or `null` in case of an invalid `resource` for this store type. */ getCapacity( resource?: R, ): UNLIMITED_STORE extends true ? null : R extends undefined ? ResourceConstant extends POSSIBLE_RESOURCES ? number : null : R extends POSSIBLE_RESOURCES ? number : null; /** * Returns the capacity used by the specified resource, or total used capacity for general purpose stores if `resource` is undefined. * @param resource The type of the resource. * @returns Returns used capacity number, or `null` in case of a not valid `resource` for this store type. */ getUsedCapacity( resource?: R, ): R extends undefined ? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null) : R extends POSSIBLE_RESOURCES ? number : null; /** * Returns free capacity for the store. * * For a limited store, it returns the capacity available for the specified resource if `resource` is defined and valid for this store. * @param resource The type of the resource. * @returns Returns available capacity number, or `null` in case of an invalid `resource` for this store type. */ getFreeCapacity( resource?: R, ): UNLIMITED_STORE extends true ? null : R extends undefined ? ResourceConstant extends POSSIBLE_RESOURCES ? number : null : R extends POSSIBLE_RESOURCES ? number : null; } type Store = StoreBase< POSSIBLE_RESOURCES, UNLIMITED_STORE > & { [P in POSSIBLE_RESOURCES]: number } & { [P in Exclude]: 0 }; /** * An object that can contain resources in its cargo. * * There are two types of stores in the game: general purpose stores and limited stores. * * General purpose stores can contain any resource within its capacity (e.g. creeps, containers, storages, terminals). * * Limited stores can contain only a few types of resources needed for that particular object (e.g. spawns, extensions, labs, nukers). * * The Store prototype is the same for both types of stores, but they have different behavior depending on the resource argument in its methods. * * You can get specific resources from the store by addressing them as object properties: * ``` * console.log(creep.store[RESOURCE_ENERGY]); * ``` */ interface GenericStoreBase { /** * Returns capacity of this store for the specified resource. * * For a general purpose store, it returns total capacity if `resource` is undefined. * @param resource The type of the resource. * @returns Returns capacity number, or `null` in case of an invalid `resource` for this store type. */ getCapacity(resource?: ResourceConstant): number | null; /** * Returns the capacity used by the specified resource, or total used capacity for general purpose stores if `resource` is undefined. * @param resource The type of the resource. * @returns Returns used capacity number, or `null` in case of a not valid `resource` for this store type. */ getUsedCapacity(resource?: ResourceConstant): number | null; /** * Returns free capacity for the store. * * For a limited store, it returns the capacity available for the specified resource if `resource` is defined and valid for this store. * @param resource The type of the resource. * @returns Returns available capacity number, or `null` in case of an invalid `resource` for this store type. */ getFreeCapacity(resource?: ResourceConstant): number | null; } type GenericStore = GenericStoreBase & { [P in ResourceConstant]: number }; /** * The base prototype object of all structures. */ interface Structure extends RoomObject { readonly prototype: Structure; /** * The current amount of hit points of the structure. */ hits: number; /** * The total amount of hit points of the structure. */ hitsMax: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The room the structure is in. * * If you can get an instance of a Structure, you can see it. * If you can see the Structure, you can see the room it's in. */ room: Room; /** * One of the {@link StructureConstant STRUCTURE_*} constants. */ structureType: T; /** * Destroy this structure immediately. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: Hostile creeps are in the room. */ destroy(): ScreepsReturnCode; /** * 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. */ isActive(): boolean; /** * Toggle auto notification when the structure is under attack. The notification will be sent to your account email. Turned on by default. * @param enabled Whether to enable notification or disable. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): ScreepsReturnCode; } interface StructureConstructor extends _Constructor, _ConstructorById {} declare const Structure: StructureConstructor; /** * The base prototype for a structure that has an owner. * * Such structures can be found using {@link Room.find} and the {@link FIND_MY_STRUCTURES} & {@link FIND_HOSTILE_STRUCTURES} constants. */ interface OwnedStructure extends Structure { readonly prototype: OwnedStructure; /** * Whether this is your own structure. * * Walls and roads don't have this property as they are considered neutral structures. */ my: boolean; /** * An object with the structure’s owner info (if present). */ owner: T extends STRUCTURE_CONTROLLER ? Owner | undefined : Owner; /** * The link to the Room object. * * Is always present because owned structures give visibility. */ room: Room; } interface OwnedStructureConstructor extends _Constructor, _ConstructorById {} declare const OwnedStructure: OwnedStructureConstructor; /** * Claim this structure to take control over the room. * * The controller structure cannot be damaged or destroyed. * It can be addressed by {@link Room.controller} property. */ interface StructureController extends OwnedStructure { readonly prototype: StructureController; /** * Whether using power is enabled in this room. * * Use {@link PowerCreep.enableRoom()} to turn powers on. */ isPowerEnabled: boolean; /** * Current controller level, from 0 to 8. */ level: number; /** * The current progress of upgrading the controller to the next level. */ progress: number; /** * The progress needed to reach the next level. */ progressTotal: number; /** * The reservation info for the controller. * * Can be undefined if the controller isn't reserved. */ reservation: ReservationDefinition | undefined; /** * How many ticks of safe mode are remaining, or undefined. */ safeMode?: number; /** * Safe mode activations available to use. */ safeModeAvailable: number; /** * During this period in ticks new safe mode activations will be blocked, undefined if cooldown is inactive. */ safeModeCooldown?: number; /** * An object with the controller sign info if present */ sign: SignDefinition | undefined; /** * The amount of game ticks when this controller will lose one level. * * This timer can be reset by using {@link Creep.upgradeController} */ ticksToDowngrade: number; /** * The amount of game ticks while this controller cannot be upgraded due to attack. */ upgradeBlocked: number; /** * Activate safe mode if available. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. * - ERR_BUSY: There is another room in safe mode already. * - ERR_NOT_ENOUGH_RESOURCES: There is no safe mode activations available. * - ERR_TIRED: The previous safe mode is still cooling down, or the controller is upgradeBlocked, or the controller is downgraded for 50% plus 5000 ticks or more. */ activateSafeMode(): ScreepsReturnCode; /** * Make your claimed controller neutral again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. */ unclaim(): ScreepsReturnCode; } interface StructureControllerConstructor extends _Constructor, _ConstructorById {} declare const StructureController: StructureControllerConstructor; /** * Contains energy which can be spent on spawning bigger creeps. * * Extensions can be placed anywhere in the room, any spawns will be able to use them regardless of distance. */ interface StructureExtension extends OwnedStructure { readonly prototype: StructureExtension; /** * The amount of energy containing in the extension. * * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the extension can contain. * * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; } interface StructureExtensionConstructor extends _Constructor, _ConstructorById {} declare const StructureExtension: StructureExtensionConstructor; /** * Remotely transfers energy to another Link in the same room. */ interface StructureLink extends OwnedStructure { readonly prototype: StructureLink; /** * The amount of game ticks the link has to wait until the next transfer is possible. */ cooldown: number; /** * The amount of energy containing in the link. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the link can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Transfer energy from the link to another link. * * The target link can be at any position within the room. * * Remote transfer process implies 3% energy loss and cooldown delay depending on the distance. * @param target The target object. * @param amount The amount of energy to be transferred. If omitted, all the available energy is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this link. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the given amount of energy. * - ERR_INVALID_TARGET: The target is not a valid StructureLink object. * - ERR_FULL: The target cannot receive any more energy. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The energy amount is incorrect. * - ERR_TIRED: The link is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this link. */ transferEnergy(target: StructureLink, amount?: number): ScreepsReturnCode; } interface StructureLinkConstructor extends _Constructor, _ConstructorById {} declare const StructureLink: StructureLinkConstructor; /** * Non-player structure. * * Spawns NPC Source Keepers that guards energy sources and minerals in some rooms. * This structure cannot be destroyed. */ interface StructureKeeperLair extends OwnedStructure { readonly prototype: StructureKeeperLair; /** * Time to spawning of the next Source Keeper. */ ticksToSpawn?: number; } interface StructureKeeperLairConstructor extends _Constructor, _ConstructorById {} declare const StructureKeeperLair: StructureKeeperLairConstructor; /** * Provides visibility into a distant room from your script. */ interface StructureObserver extends OwnedStructure { readonly prototype: StructureObserver; /** * Provide visibility into a distant room from your script. * * The target room object will be available on the next tick. The maximum range is 5 rooms. * @param roomName The room to observe. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_IN_RANGE: Room roomName is not in observing range. * - ERR_INVALID_ARGS: roomName argument is not a valid room name value. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ observeRoom(roomName: string): ScreepsReturnCode; } interface StructureObserverConstructor extends _Constructor, _ConstructorById {} declare const StructureObserver: StructureObserverConstructor; /** * Non-player structure. * * Contains power resource which can be obtained by destroying the structure. * Hits the attacker creep back on each attack. */ interface StructurePowerBank extends OwnedStructure { readonly prototype: StructurePowerBank; /** * The amount of power containing. */ power: number; /** * The amount of game ticks when this structure will disappear. */ ticksToDecay: number; } interface StructurePowerBankConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerBank: StructurePowerBankConstructor; /** * Non-player structure. * * Contains power resource which can be obtained by destroying the structure. * Hits the attacker creep back on each attack. */ interface StructurePowerSpawn extends OwnedStructure { readonly prototype: StructurePowerSpawn; /** * The amount of energy containing in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of power containing in this structure. * @deprecated An alias for .store[RESOURCE_POWER]. */ power: number; /** * The total amount of power this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_POWER). */ powerCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Register power resource units into your account. * * Registered power allows to develop power creeps skills. Consumes 1 power resource unit and 50 energy resource units. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy or power resource units. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ processPower(): ScreepsReturnCode; } interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerSpawn: StructurePowerSpawnConstructor; /** * A rampart structure. * * Blocks movement of hostile creeps, and defends your creeps and structures on * the same tile. Can be used as a controllable gate. */ interface StructureRampart extends OwnedStructure { readonly prototype: StructureRampart; /** * The amount of game ticks when this rampart will lose some hit points. */ ticksToDecay: number; /** * Whether the rampart is open to the public or not. * * If false (default), only your creeps can step on the same square. * If true, any hostile creeps can pass through. */ isPublic: boolean; /** * Make this rampart public to allow other players' creeps to pass through. * @param isPublic Whether this rampart should be public or non-public * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. */ setPublic(isPublic: boolean): undefined; } interface StructureRampartConstructor extends _Constructor, _ConstructorById {} declare const StructureRampart: StructureRampartConstructor; /** * Decreases movement cost to 1. * * Using roads allows creating creeps with less `MOVE` body parts. */ interface StructureRoad extends Structure { readonly prototype: StructureRoad; /** * The amount of game ticks when this road will lose some hit points. */ ticksToDecay: number; } interface StructureRoadConstructor extends _Constructor, _ConstructorById {} declare const StructureRoad: StructureRoadConstructor; /** * A structure that can store huge amount of resource units. * * Only one structure per room is allowed that can be addressed by {@link Room.storage} property. */ interface StructureStorage extends OwnedStructure { readonly prototype: StructureStorage; /** * An object with the storage contents. */ store: StoreDefinition; /** * The total amount of resources the storage can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; } interface StructureStorageConstructor extends _Constructor, _ConstructorById {} declare const StructureStorage: StructureStorageConstructor; /** * Remotely attacks or heals creeps, or repairs structures. * * Can be targeted to any object in the room. However, its effectiveness highly depends on the * distance. Each action consumes energy. */ interface StructureTower extends OwnedStructure { readonly prototype: StructureTower; /** * The amount of energy containing in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Remotely attack any creep or structure in the room. * * Consumes 10 energy units per tick. Attack power depends on the distance to the target: from 600 hits at range 10 to 300 hits at range 40. * @param target The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ attack(target: AnyCreep | Structure): ScreepsReturnCode; /** * Remotely heal any creep in the room. * * Consumes 10 energy units per tick. Heal power depends on the distance to the target: from 400 hits at range 10 to 200 hits at range 40. * @param target The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ heal(target: AnyCreep): ScreepsReturnCode; /** * Remotely repair any structure in the room. * * Consumes 10 energy units per tick. Repair power depends on the distance to the target: from 600 hits at range 10 to 300 hits at range 40. * @param target The target structure. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ repair(target: Structure): ScreepsReturnCode; } interface StructureTowerConstructor extends _Constructor, _ConstructorById {} declare const StructureTower: StructureTowerConstructor; /** * Blocks movement of all creeps. */ interface StructureWall extends Structure { readonly prototype: StructureWall; /** * The amount of game ticks when the wall will disappear (only for automatically placed border walls at the start of the game). */ ticksToLive: number; } interface StructureWallConstructor extends _Constructor, _ConstructorById {} declare const StructureWall: StructureWallConstructor; /** * Allows to harvest mineral deposits. */ interface StructureExtractor extends OwnedStructure { readonly prototype: StructureExtractor; /** * The amount of game ticks until the next harvest action is possible. */ cooldown: number; } interface StructureExtractorConstructor extends _Constructor, _ConstructorById {} declare const StructureExtractor: StructureExtractorConstructor; /** * Produces mineral compounds from base minerals and boosts creeps. */ interface StructureLab extends OwnedStructure { readonly prototype: StructureLab; /** * The amount of game ticks the lab has to wait until the next reaction is possible. */ cooldown: number; /** * The amount of energy containing in the lab. Energy is used for boosting creeps. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the lab can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of mineral resources containing in the lab. * @deprecated An alias for lab.store[lab.mineralType]. */ mineralAmount: number; /** * The type of minerals containing in the lab. * * Labs can contain only one mineral type at the same time. * Null in case there is no mineral resource in the lab. */ mineralType: MineralConstant | MineralCompoundConstant | null; /** * The total amount of minerals the lab can contain. * @deprecated An alias for lab.store.getCapacity(lab.mineralType || yourMineral). */ mineralCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Boosts creep body part using the containing mineral compound. * * The creep has to be at adjacent square to the lab. Boosting one body part consumes 30 mineral units and 20 energy units. * @param creep The target creep. * @param bodyPartsCount The number of body parts of the corresponding type to be boosted. * Body parts are always counted left-to-right for TOUGH, and right-to-left for other types. * If undefined, all the eligible body parts are boosted. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_FOUND: The mineral containing in the lab cannot boost any of the creep's body parts. * - ERR_NOT_ENOUGH_RESOURCES: The lab does not have enough energy or minerals. * - ERR_INVALID_TARGET: The targets is not valid creep object. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ boostCreep(creep: Creep, bodyPartsCount?: number): ScreepsReturnCode; /** * Unboost a creep. * * Immediately remove boosts from the creep and drop 50% of the mineral compounds used to boost it onto the ground regardless of the creep's remaining time to live. * The creep has to be at adjacent square to the lab. * Unboosting requires cooldown time equal to the total sum of the reactions needed to produce all the compounds applied to the creep. * @param creep The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab, or the target creep. * - ERR_NOT_FOUND: The target has no boosted parts. * - ERR_INVALID_TARGET: The target is not a valid Creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ unboostCreep(creep: Creep): ScreepsReturnCode; /** * Breaks mineral compounds back into reagents. * * The same output labs can be used by many source labs. * @param lab1 The first result lab. * @param lab2 The second result lab. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_ENOUGH_RESOURCES: The source lab do not have enough resources. * - ERR_INVALID_TARGET: The targets are not valid lab objects. * - ERR_FULL: One of targets cannot receive any more resource. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_INVALID_ARGS: The reaction cannot be reversed into this resources. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ reverseReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; /** * Produce mineral compounds using reagents from two another labs. * * Each lab has to be within 2 squares range. The same input labs can be used by many output labs * @param lab1 The first source lab. * @param lab2 The second source lab. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_ENOUGH_RESOURCES: The source lab do not have enough resources. * - ERR_INVALID_TARGET: The targets are not valid lab objects. * - ERR_FULL: The target cannot receive any more resource. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_INVALID_ARGS: The reaction cannot be run using this resources. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ runReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; } interface StructureLabConstructor extends _Constructor, _ConstructorById {} declare const StructureLab: StructureLabConstructor; /** * Sends any resources to a Terminal in another room. */ interface StructureTerminal extends OwnedStructure { readonly prototype: StructureTerminal; /** * The remaining amount of ticks while this terminal cannot be used to make {@link StructureTerminal.send} or {@link Game.market.deal} calls. */ cooldown: number; /** * A Store object that contains cargo of this structure. */ store: StoreDefinition; /** * The total amount of resources the storage can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; /** * Sends resource to a Terminal in another room with the specified name. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be sent. * @param destination The name of the target room. You don't have to gain visibility in this room. * @param description The description of the transaction. It is visible to the recipient. The maximum length is 100 characters. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the required amount of resources. * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The terminal is still cooling down. */ send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): ScreepsReturnCode; } interface StructureTerminalConstructor extends _Constructor, _ConstructorById {} declare const StructureTerminal: StructureTerminalConstructor; /** * A small resource store. * * Contains up to 2,000 resource units. Can be constructed in neutral rooms. Decays for 5,000 hits per 100 ticks. */ interface StructureContainer extends Structure { readonly prototype: StructureContainer; /** * An object with the structure contents. * * Each object key is one of the {@link ResourceConstant RESOURCE_*} constants, values are resources * amounts. Use `_.sum(structure.store)` to get the total amount of contents. */ store: StoreDefinition; /** * The total amount of resources the structure can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; /** * The amount of game ticks when this container will lose some hit points. */ ticksToDecay: number; } interface StructureContainerConstructor extends _Constructor, _ConstructorById {} declare const StructureContainer: StructureContainerConstructor; /** * Launches a nuke to another room dealing huge damage to the landing area. * * Each launch has a cooldown and requires energy and ghodium resources. Launching * creates a Nuke object at the target room position which is visible to any player * until it is landed. Incoming nuke cannot be moved or cancelled. Nukes cannot * be launched from or to novice rooms. */ interface StructureNuker extends OwnedStructure { readonly prototype: StructureNuker; /** * The amount of energy contained in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of energy contained in this structure. * @deprecated An alias for .store[RESOURCE_GHODIUM]. */ ghodium: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_GHODIUM). */ ghodiumCapacity: number; /** * The amount of game ticks the link has to wait until the next transfer is possible. */ cooldown: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Launch a nuke to the specified position. * @param pos The target room position. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy and/or ghodium. * - ERR_INVALID_TARGET: The nuke can't be launched to the specified RoomPosition (see Start Areas). * - ERR_NOT_IN_RANGE: The target room is out of range. * - ERR_INVALID_ARGS: The target is not a valid RoomPosition. * - ERR_TIRED: This structure is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ launchNuke(pos: RoomPosition): ScreepsReturnCode; } interface StructureNukerConstructor extends _Constructor, _ConstructorById {} declare const StructureNuker: StructureNukerConstructor; /** * A non-player structure. * * Instantly teleports your creeps to a distant room acting as a room exit tile. * Portals appear randomly in the central room of each sector. */ interface StructurePortal extends Structure { readonly prototype: StructurePortal; /** * The portal's destination. * * If this is an inter-room portal, then this property contains a {@link RoomPosition} object leading to the point in the destination room. * If this is an inter-shard portal, then this property contains an object with shard and room string properties. * Exact coordinates are undetermined, the creep will appear at any free spot in the destination room. */ destination: RoomPosition | { shard: string; room: string }; /** * The amount of game ticks when the portal disappears, or undefined when the portal is stable. */ ticksToDecay: number | undefined; } interface StructurePortalConstructor extends _Constructor, _ConstructorById {} declare const StructurePortal: StructurePortalConstructor; /** * A structure which produces trade commodities from base minerals and other commodities. */ interface StructureFactory extends OwnedStructure { readonly prototype: StructureFactory; /** * The amount of game ticks the factory has to wait until the next produce is possible. */ cooldown: number; /** * The level of the factory. * * Can be set by applying the {@link PWR_OPERATE_FACTORY} power to a newly built factory. * Once set, the level cannot be changed. */ level?: number; /** * An object with the structure contents. */ store: StoreDefinition; /** * Produces the specified commodity. * * All ingredients should be available in the factory store. * @param resource One of the {@link CommoditiesTypes producible RESOURCE_*} constants. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: The factory is not operated by the PWR_OPERATE_FACTORY power. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the required amount of resources. * - ERR_INVALID_TARGET: The factory cannot produce the commodity of this level. * - ERR_FULL: The factory cannot contain the produce. * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The factory is still cooling down. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use the factory. */ produce(resource: CommoditiesTypes): ScreepsReturnCode; } interface StructureFactoryConstructor extends _Constructor, _ConstructorById {} declare const StructureFactory: StructureFactoryConstructor; /** * A structure which is a control center of NPC Strongholds, and also rules all invaders in the sector. */ interface StructureInvaderCore extends OwnedStructure { readonly prototype: StructureInvaderCore; /** * The level of the stronghold. * * The amount and quality of the loot depends on the level. */ level: number; /** * Shows the timer for a not yet deployed stronghold, undefined otherwise. */ ticksToDeploy: number; /** * If the core is in process of spawning a new creep, this object will contain a {@link StructureSpawn.Spawning} object, or `null` otherwise. */ spawning: Spawning | null; } interface StructureInvaderCoreConstructor extends _Constructor, _ConstructorById {} declare const StructureInvaderCore: StructureInvaderCoreConstructor; /** * A discriminated union on Structure.type of all owned structure types */ type AnyOwnedStructure = | StructureController | StructureExtension | StructureExtractor | StructureFactory | StructureInvaderCore | StructureKeeperLair | StructureLab | StructureLink | StructureNuker | StructureObserver | StructurePowerBank | StructurePowerSpawn | StructureRampart | StructureSpawn | StructureStorage | StructureTerminal | StructureTower; type AnyStoreStructure = | StructureExtension | StructureFactory | StructureLab | StructureLink | StructureNuker | StructurePowerSpawn | StructureSpawn | StructureStorage | StructureTerminal | StructureTower | StructureContainer; /** * A discriminated union on {@link Structure.structureType} of all structure types */ type AnyStructure = AnyOwnedStructure | StructureContainer | StructurePortal | StructureRoad | StructureWall; /** * Map of structure constant to the concrete structure class */ interface ConcreteStructureMap { [STRUCTURE_EXTENSION]: StructureExtension; [STRUCTURE_RAMPART]: StructureRampart; [STRUCTURE_ROAD]: StructureRoad; [STRUCTURE_SPAWN]: StructureSpawn; [STRUCTURE_LINK]: StructureLink; [STRUCTURE_WALL]: StructureWall; [STRUCTURE_STORAGE]: StructureStorage; [STRUCTURE_TOWER]: StructureTower; [STRUCTURE_OBSERVER]: StructureObserver; [STRUCTURE_POWER_SPAWN]: StructurePowerSpawn; [STRUCTURE_EXTRACTOR]: StructureExtractor; [STRUCTURE_LAB]: StructureLab; [STRUCTURE_TERMINAL]: StructureTerminal; [STRUCTURE_CONTAINER]: StructureContainer; [STRUCTURE_NUKER]: StructureNuker; [STRUCTURE_FACTORY]: StructureFactory; [STRUCTURE_KEEPER_LAIR]: StructureKeeperLair; [STRUCTURE_CONTROLLER]: StructureController; [STRUCTURE_POWER_BANK]: StructurePowerBank; [STRUCTURE_PORTAL]: StructurePortal; [STRUCTURE_INVADER_CORE]: StructureInvaderCore; } /** * Conditional type for all concrete implementations of Structure. * * Unlike {@link Structure}, {@link ConcreteStructure} gives you the actual concrete class that extends {@link Structure}. */ type ConcreteStructure = ConcreteStructureMap[T]; /** * A creep's final resting place. * * This is a walkable structure. * Will decay 5 ticks per body part of the deceased creep. */ interface Tombstone extends RoomObject { /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * Time of death. */ deathTime: number; /** * An object with the tombstone contents. * * Each object key is one of the {@link ResourceConstant RESOURCE_*} constants, values are resources amounts. * {@link RESOURCE_ENERGY} is always defined and equals to 0 when empty, other resources are undefined when empty. * You can use `_.sum(tombstone.store)` to get the total amount of contents. */ store: StoreDefinitionUnlimited; /** * The amount of game ticks before this tombstone decays. */ ticksToDecay: number; /** * An object containing the deceased creep. */ creep: AnyCreep; } interface TombstoneConstructor extends _Constructor, _ConstructorById {} declare const Tombstone: TombstoneConstructor; ================================================ FILE: dist/package.json ================================================ { "private": true, "name": "@types/screeps", "version": "3.4.9999", "projects": [ "https://github.com/screeps/screeps" ], "devDependencies": { "@types/screeps": "workspace:." }, "owners": [ { "name": "Nhan Ho", "githubUsername": "NhanHo" }, { "name": "Bryan", "githubUsername": "bryanbecker" }, { "name": "Resi Respati", "githubUsername": "resir014" }, { "name": "Adam Laycock", "githubUsername": "Arcath" }, { "name": "Dominic Marcuse", "githubUsername": "dmarcuse" }, { "name": "Skyler Kehren", "githubUsername": "pyrodogg" }, { "name": "Kieran Carnegie", "githubUsername": "kotarou" }, { "name": "Mofeng", "githubUsername": "DiamondMofeng" } ] } ================================================ FILE: dist/screeps-tests.ts ================================================ // This file exists solely to test whether or not the typings actually work. // After working on your changes, make sure to run `npm run compile` to build // the declarations before opening this file. // // If you open this file and see no red squiggly lines, then you're good! // Feel free to add more test cases in the form of a sample code. // `$ExpectType` is supported by the linter, you can use it to check the type of an expression or a variable. // See https://github.com/JoshuaKGoldberg/eslint-plugin-expect-type for more details. // TODO: add more test cases. // Sample inputs const creep: Creep = Game.creeps.sampleCreep; const room: Room = Game.rooms.W10S10; const flag: Flag = Game.flags.Flag1; const powerCreep: PowerCreep = Game.powerCreeps.samplePowerCreep; const spawn: StructureSpawn = Game.spawns.Spawn1; const body: BodyPartConstant[] = [WORK, WORK, CARRY, MOVE]; // Sample inputs for Game.map.findRoute testing const anotherRoomName: Room = Game.rooms.W10S11; // Sample memory extensions interface CreepMemory { sourceId: Id; lastHits: number; } // Typescript always uses 'string' as the type of a key inside 'for in' loops. // In case of objects with a restricted set of properties (e.g. ResourceConstant as key in StoreDefinition) // the type of the key should be narrowed down in order to prevent casting (key as ResourceConstant). // This helper function provides strongly typed keys for such objects. // See discussion (https://github.com/Microsoft/TypeScript/pull/12253) why Object.keys does not return typed keys. function keys>(o: T): Array { return Object.keys(o) as Array; } function resources(o: GenericStore): ResourceConstant[] { return Object.keys(o) as ResourceConstant[]; } // Game object Id types { const creepId: Id = "1" as Id; const creepOne: Creep | null = Game.getObjectById(creepId); const creepThree: Creep = new Creep(creepId); // Works with typed ID if (creepOne) { creepOne.hits; const recycle = Game.getObjectById(creepOne.id); } type StoreStructure = StructureContainer | StructureStorage | StructureLink; const storeUnionID: Id = "1234" as Id; // Strict assertion required const storeIdUnion: StoreStructure["id"] = "1234" as StoreStructure["id"]; const stringID: string = storeUnionID; // Id assignable implicitly to string const stringID2: string = storeIdUnion; // Id assignable implicitly to string const storeObject = Game.getObjectById(storeUnionID)!; const storeObject2 = Game.getObjectById(storeIdUnion)!; // Object recognized switch (storeObject.structureType) { case STRUCTURE_CONTAINER: storeObject.structureType === "container"; case STRUCTURE_STORAGE: storeObject.structureType === "storage"; default: storeObject.structureType === "link"; } } // Game.creeps { for (const creepName of Object.keys(Game.creeps)) { Game.creeps[creepName].moveTo(flag); } } // Game.flags { creep.moveTo(Game.flags.Flag1); } // Game.powerCreeps { PowerCreep.create("steve", POWER_CLASS.OPERATOR) === OK; for (const i of Object.keys(Game.powerCreeps)) { const powerCreep = Game.powerCreeps[i]; if (powerCreep.ticksToLive === undefined) { // Not spawned in world; spawn creep const spawn = Game.getObjectById("powerSpawnID" as Id)!; powerCreep.spawn(spawn); } else { // Generate Ops if ( powerCreep.powers[PWR_GENERATE_OPS] && powerCreep.powers[PWR_GENERATE_OPS].cooldown === 0 && (powerCreep.carry.ops || 0) < 10 ) { Game.powerCreeps[i].usePower(PWR_GENERATE_OPS); } else { // Boost resource const targetSource = Game.getObjectById("targetSourceID" as Id)!; const sourceEffect = targetSource.effects?.find((effect) => effect.effect === PWR_REGEN_SOURCE && effect.level > 0); if (!sourceEffect && powerCreep.powers[PWR_REGEN_SOURCE] && powerCreep.powers[PWR_REGEN_SOURCE].cooldown === 0) { powerCreep.usePower(PWR_REGEN_SOURCE, targetSource); } } } // AnyCreep type checks creep.attack(powerCreep); creep.heal(powerCreep); creep.rangedAttack(powerCreep); creep.rangedHeal(powerCreep); creep.transfer(powerCreep, RESOURCE_ENERGY); powerCreep.transfer(creep, RESOURCE_ENERGY); // Upgrading powerCreep.upgrade(PWR_GENERATE_OPS); } const myPowaCreeps = Game.rooms.sim.find(FIND_MY_POWER_CREEPS); // Constant type checking POWER_INFO[PWR_GENERATE_OPS].className === POWER_CLASS.OPERATOR; typeof POWER_INFO[PWR_GENERATE_OPS].level[0] === "number"; } // Game.spawns { for (const i of Object.keys(Game.spawns)) { Game.spawns[i].createCreep(body); // Test StructureSpawn.Spawning const creep: Spawning | null = Game.spawns[i].spawning; if (creep) { const name: string = creep.name; const needTime: number = creep.needTime; const remainingTime: number = creep.remainingTime; const creepSpawn: StructureSpawn = creep.spawn; const cancelStatus: OK | ERR_NOT_OWNER = creep.cancel(); const setDirectionStatus: OK | ERR_NOT_OWNER | ERR_INVALID_ARGS = creep.setDirections([TOP, BOTTOM, LEFT, RIGHT]); } const invaderCore = new StructureInvaderCore("" as Id); const invader = invaderCore.spawning; if (invader) { const name = invader.name; } } } // Game.time { let time = Game.time; time += 1; } // Game.cpu.getUsed() { if (Game.cpu.getUsed() > Game.cpu.tickLimit / 2) { // Half CPU Usged } } { for (const name of Object.keys(Game.creeps)) { const startCpu = Game.cpu.getUsed(); // creep logic goes here const elapsed = Game.cpu.getUsed() - startCpu; } } // Game.cpu.setShardLimits() { Game.cpu.setShardLimits({ shard0: 20, shard1: 10 }); } // Game.cpu.halt() { if (Game.cpu.hasOwnProperty("halt")) { Game.cpu.halt!(); } } // Game.cpu.unlock() { if (!Game.cpu.unlocked) { if (!Game.cpu.unlockedTime) { const unlock_state = Game.cpu.unlock(); if (unlock_state === OK) { // Unlimited cosmic power! } } } } // Game.getObjectById(id) { creep.memory.sourceId = creep.pos.findClosestByRange(FIND_SOURCES)!.id; const source = Game.getObjectById(creep.memory.sourceId); } // Game.notify(message, [groupInterval]) { if (creep.hits < creep.memory.lastHits) { Game.notify(`Creep ${creep.toString()} has been attacked at ${creep.pos.toString()}!`); } creep.memory.lastHits = creep.hits; } { if (Game.spawns["Spawn1"].energy === 0) { Game.notify( "Spawn1 is out of energy", 180, // group these notifications for 3 hours ); } } // Game.map.describeExits() { const exits = Game.map.describeExits("W8N3"); if (exits) { keys(exits).map((exitKey) => { const nextRoom = exits[exitKey]; const exitDir = +exitKey as ExitConstant; const exitPos = creep.pos.findClosestByRange(exitDir); return { nextRoom, exitPos }; }); } } // Game.map.findExit() { if (creep.room.name !== anotherRoomName.name) { const exitDir = Game.map.findExit(creep.room, anotherRoomName); if (exitDir !== ERR_NO_PATH && exitDir !== ERR_INVALID_ARGS) { const exit = creep.pos.findClosestByRange(exitDir); if (exit !== null) { creep.moveTo(exit); } } } else { // go to some place in another room } } { creep.moveTo(new RoomPosition(25, 25, anotherRoomName.name)); } // Game.map.findRoute() { const route = Game.map.findRoute(creep.room, anotherRoomName); if (route !== ERR_NO_PATH && route.length > 0) { const exit = creep.pos.findClosestByRange(route[0].exit); if (exit !== null) { creep.moveTo(exit); } } } { const route = Game.map.findRoute(creep.room, anotherRoomName, { routeCallback(roomName, fromRoomName) { if (roomName === "W10S10") { // avoid this room return Infinity; } return 1; }, }); } { const from = new RoomPosition(25, 25, "E1N1"); const to = new RoomPosition(25, 25, "E4N1"); // Use `findRoute` to calculate a high-level plan for this path, // prioritizing highways and owned rooms const allowedRooms = { [from.roomName]: true }; const route = Game.map.findRoute(from.roomName, to.roomName, { routeCallback(roomName) { const parsed = /^[WE]([0-9]+)[NS]([0-9]+)$/.exec(roomName); if (parsed !== null) { const isHighway = parseInt(parsed[1], 10) % 10 === 0 || parseInt(parsed[2], 10) % 10 === 0; const isMyRoom = Game.rooms[roomName] && Game.rooms[roomName].controller && Game.rooms[roomName].controller?.my; if (isHighway || isMyRoom) { return 1; } else { return 2.5; } } else { return 2.5; } }, }); if (route !== ERR_NO_PATH) { route.forEach((info) => { allowedRooms[info.room] = true; }); } // Invoke PathFinder, allowing access only to rooms from `findRoute` const ret = PathFinder.search(from, [to], { roomCallback: (roomName) => { if (allowedRooms[roomName] === undefined) { return false; } else { return true; } }, }); } // Game.map.getRoomLinearDistance(roomName1, roomName2, [continuous]) { Game.map.getRoomLinearDistance("W1N1", "W4N2"); // 3 Game.map.getRoomLinearDistance("E65S55", "W65S55", false); // 131 Game.map.getRoomLinearDistance("E65S55", "W65S55", true); // 11 } // Game.map.getTerrainAt(x, y, roomName) // Game.map.getTerrainAt(pos) { Game.map.getTerrainAt(25, 20, "W10N10"); } { Game.map.getTerrainAt(new RoomPosition(25, 20, "W10N10")); } // Game.map.getRoomStatus(roomName) { const roomStatus = Game.map.getRoomStatus(room.name); if (roomStatus.status === "normal") { creep.moveTo(room.getPositionAt(25, 25)!); } } // Game.market { // Game.market.calcTransactionCost(amount, roomName1, roomName2) const cost = Game.market.calcTransactionCost(1000, "W0N0", "W10N5"); // Game.market.cancelOrder(orderId) for (const id of Object.keys(Game.market.orders)) { Game.market.cancelOrder(id); } // Game.market.changeOrderPrice(orderId, newPrice) Game.market.changeOrderPrice("57bec1bf77f4d17c4c011960", 9.95); // Game.market.createOrder({type, resourceType, price, totalAmount, [roomName]}) Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000, roomName: "W1N1" }); Game.market.createOrder({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 }); // Testing the hardcoded string literal value of the `type` field { // error Game.market.createOrder({ // @ts-expect-error type: "BUY", resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000, }); // okay Game.market.createOrder({ type: "buy", resourceType: RESOURCE_GHODIUM, price: 9.95, totalAmount: 10000 }); } // Game.market.deal(orderId, amount, [yourRoomName]) Game.market.deal("57cd2b12cda69a004ae223a3", 1000, "W1N1"); const amountToBuy = 2000; const maxTransferEnergyCost = 500; const orders = Game.market.getAllOrders({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM }); for (const i of orders) { if (i.roomName) { const transferEnergyCost = Game.market.calcTransactionCost(amountToBuy, "W1N1", i.roomName); if (transferEnergyCost < maxTransferEnergyCost) { Game.market.deal(i.id, amountToBuy, "W1N1"); break; } } } // Game.market.extendOrder(orderId, addAmount) Game.market.extendOrder("57bec1bf77f4d17c4c011960", 10000); // Game.market.getAllOrders([filter]) Game.market.getAllOrders(); Game.market.getAllOrders({ type: ORDER_SELL, resourceType: RESOURCE_GHODIUM }); const targetRoom = "W1N1"; Game.market.getAllOrders( (currentOrder) => currentOrder.resourceType === RESOURCE_GHODIUM && currentOrder.type === ORDER_SELL && Game.market.calcTransactionCost(1000, targetRoom, currentOrder.roomName!) < 500, ); // Game.market.getOrderById(id) const order = Game.market.getOrderById("55c34a6b5be41a0a6e80c123"); // Subscription tokens Game.market.getAllOrders({ type: ORDER_SELL, resourceType: SUBSCRIPTION_TOKEN }); Game.market.createOrder({ type: ORDER_BUY, resourceType: SUBSCRIPTION_TOKEN, totalAmount: 10000000, price: 1 }); const priceHistory = Game.market.getHistory(RESOURCE_FIXTURES); const avgPrice: number = priceHistory[0].avgPrice; const stddevPrice: number = priceHistory[0].stddevPrice; const volume: number = priceHistory[0].volume; // Game.market.getHistory([resourceType]) const energyHistory = Game.market.getHistory(RESOURCE_ENERGY); const pixelHistory = Game.market.getHistory(PIXEL); } // PathFinder { const pfCreep = Game.creeps.John; const goals = pfCreep.room.find(FIND_SOURCES).map((source) => { // We can't actually walk on sources-- set `range` to 1 // so we path next to it. return { pos: source.pos, range: 1 }; }); const ret = PathFinder.search(pfCreep.pos, goals, { // We need to set the defaults costs higher so that we // can set the road cost lower in `roomCallback` plainCost: 2, swampCost: 10, roomCallback(roomName) { const curRoom = Game.rooms[roomName]; // In this example `room` will always exist, but since // PathFinder supports searches which span multiple rooms // you should be careful! if (!curRoom) { return false; } const costs = new PathFinder.CostMatrix(); curRoom.find(FIND_STRUCTURES).forEach((struct) => { if (struct.structureType === STRUCTURE_ROAD) { // Favor roads over plain tiles costs.set(struct.pos.x, struct.pos.y, 1); } else if ( struct.structureType !== STRUCTURE_CONTAINER && (struct.structureType !== STRUCTURE_RAMPART || !(struct as OwnedStructure).my) ) { // Can't walk through non-walkable buildings costs.set(struct.pos.x, struct.pos.y, 0xff); } }); // Avoid creeps in the room curRoom.find(FIND_CREEPS).forEach((thisCreep) => { costs.set(thisCreep.pos.x, thisCreep.pos.y, 0xff); }); return costs; }, }); // Room.findPath const _path1 = pfCreep.room.findPath(pfCreep.pos, goals[0].pos, { // costCallback may return nothing (void) costCallback(roomName, costMatrix) { return; }, }); const pos = ret.path[0]; pfCreep.move(pfCreep.pos.getDirectionTo(pos)); // CostMatrix Creation const costs = new PathFinder.CostMatrix(); costs.set(20, 20, 42); // Serialization const toStoreInMemory = costs.serialize(); const costsFromMemory = PathFinder.CostMatrix.deserialize([]); } // RawMemory { // RawMemory.segments RawMemory.setActiveSegments([0, 3]); // on the next tick const segmentZero = RawMemory.segments[0]; RawMemory.segments[3] = '{"foo": "bar", "counter": 15}'; // RawMemory.foreignSegment RawMemory.setActiveForeignSegment("player"); // on the next tick const playerSegment = RawMemory.foreignSegment; // --> {"username": "player", "id": 40, "data": "Hello!"} // RawMemory.interShardSegment RawMemory.interShardSegment = JSON.stringify({ creeps: { Bob: { role: "claimer" }, }, }); // on another shard const interShardData = JSON.parse(RawMemory.interShardSegment); if (interShardData.creeps[creep.name]) { creep.memory = interShardData[creep.name]; delete interShardData.creeps[creep.name]; } RawMemory.interShardSegment = JSON.stringify(interShardData); // RawMemory.get() const myMemory = JSON.parse(RawMemory.get()); // RawMemory.set(value) RawMemory.set(JSON.stringify(myMemory)); // RawMemory.setActiveSegments(ids) RawMemory.setActiveSegments([0, 3]); // RawMemory.setActiveForeignSegment(username, [id]) RawMemory.setActiveForeignSegment("player"); RawMemory.setActiveForeignSegment("player", 10); RawMemory.setActiveForeignSegment(null); // RawMemory.setDefaultPublicSegment(id) RawMemory.setPublicSegments([5, 20, 21]); RawMemory.setDefaultPublicSegment(5); RawMemory.setDefaultPublicSegment(null); // RawMemory.setPublicSegments(ids) RawMemory.setPublicSegments([5, 3]); RawMemory.setPublicSegments([]); } // InterShardMemory { let localShardData = ""; InterShardMemory.setLocal(localShardData); localShardData = InterShardMemory.getLocal(); const remoteShardData: string = InterShardMemory.getRemote("shard2") || ""; } // Find Overloads { const creeps = room.find(FIND_HOSTILE_CREEPS); creeps[0].say(creeps[1].name); const flags = room.find(FIND_FLAGS); flags[0].remove(); const spawns = room.find(FIND_HOSTILE_SPAWNS); spawns[0].spawning; const sources = room.find(FIND_SOURCES); sources[0].ticksToRegeneration; const resources = room.find(FIND_DROPPED_RESOURCES); resources[0].resourceType; const sites = room.find(FIND_CONSTRUCTION_SITES); sites[0].remove(); const extensionsites = room.find(FIND_CONSTRUCTION_SITES, { filter: (site): site is ConstructionSite => { return site.structureType === STRUCTURE_EXTENSION; }, }); // Should always be true. needs proper testing extensionsites[0].structureType === STRUCTURE_EXTENSION; // Should have type (_HasRoomPosition | RoomPosition)[] const exits = room.find(FIND_EXIT); const creepsHere = room.lookForAt(LOOK_CREEPS, 10, 10); creepsHere[0].getActiveBodyparts(ATTACK); const towers = room.find(FIND_MY_STRUCTURES, { filter: (structure) => { return structure.structureType === STRUCTURE_TOWER; }, }); towers[0].attack(creeps[0]); towers[0].attack(creeps[0] as AnyCreep); towers[0].attack(powerCreep); towers[0].attack(spawns[0]); towers[0].heal(powerCreep); const isTower = (structure: AnyStructure): structure is StructureTower => { return structure.structureType === STRUCTURE_TOWER; }; const tower = room.find(FIND_MY_STRUCTURES, { filter: isTower, })[0]; tower.attack(creeps[0]); tower.attack(creeps[0] as AnyCreep); tower.attack(powerCreep); tower.attack(spawns[0]); tower.heal(powerCreep); // All the params in filter callback should be automatically inferred room.find(FIND_STRUCTURES, { filter: (s, idx, array) => { s; // $ExpectType AnyStructure idx; // $ExpectType number array; // $ExpectType AnyStructure[] return true; }, }); } // RoomPosition Finds { // Should have type Creep const hostileCreep = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS); if (hostileCreep !== null) { creep.say(hostileCreep.name); } const tower = creep.pos.findClosestByPath(FIND_HOSTILE_STRUCTURES, { // ? s should be AnyOwnedStructure in the future filter: (structure) => { return structure.structureType === STRUCTURE_TOWER; }, algorithm: "astar", }); if (tower !== null) { tower.attack(creep); tower.attack(powerCreep); } // Generic type predicate filter const isStructureType = >(structureType: T) => { return (structure: AnyStructure): structure is S => { return structure.structureType === (structureType as string); }; }; const tower2 = creep.pos.findClosestByPath(FIND_HOSTILE_STRUCTURES, { filter: isStructureType(STRUCTURE_TOWER), algorithm: "astar", }); if (tower2 !== null) { tower2.attack(creep); tower2.attack(powerCreep); } const creepWithEnergy = creep.pos.findClosestByPath(creep.room.find(FIND_CREEPS), { filter: (c) => c.store.energy > 0 }); const creepAbove = creep.pos.findClosestByPath( creep.room.find(FIND_CREEPS).map((c) => c.pos), { // $ExpectType (p: RoomPosition) => boolean filter: (p) => p.getDirectionTo(creep) === TOP, }, ); const rampart = creep.pos.findClosestByRange(FIND_HOSTILE_STRUCTURES, { // ? s should be AnyOwnedStructure in the future filter: (structure) => { return structure.structureType === STRUCTURE_RAMPART; }, }); if (rampart !== null) { rampart.isPublic; } // $ExpectType Creep[] const hostileCreeps = creep.pos.findInRange(FIND_HOSTILE_CREEPS, 10); hostileCreeps[0].saying; const labs = creep.pos.findInRange(FIND_MY_STRUCTURES, 4, { // ? s should be AnyOwnedStructure in the future filter: (structure) => { return structure.structureType === STRUCTURE_LAB; }, }); labs[0].boostCreep(creep); // Should be able to automatically infer the type of params in the filter function creep.pos.findClosestByPath(FIND_STRUCTURES, { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); creep.pos.findClosestByPath([] as AnyStructure[], { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); creep.pos.findClosestByRange([] as AnyStructure[], { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); creep.pos.findInRange(FIND_STRUCTURES, 10, { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); creep.pos.findInRange([] as AnyStructure[], 10, { filter: (s) => s.structureType === STRUCTURE_EXTENSION, }); // All the params in filter callback should be automatically inferred creep.pos.findClosestByPath(FIND_STRUCTURES, { filter: (s, idx, array) => { s; // $ExpectType AnyStructure idx; // $ExpectType number array; // $ExpectType AnyStructure[] return true; }, }); creep.pos.findClosestByPath([] as AnyStructure[], { filter: (s, idx, array) => { s; // $ExpectType AnyStructure idx; // $ExpectType number array; // $ExpectType AnyStructure[] return true; }, }); // `findInRange, findClosestByRange, findClosestByPath` should be able to accept filter callback's type predicate // when using FIND_* constants { // $ExpectType StructureTower[] const towers = creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: isStructureType(STRUCTURE_TOWER), }); towers[0].attack(creep); } { // $ExpectType StructureTower | null const tower = creep.pos.findClosestByPath(FIND_STRUCTURES, { filter: isStructureType(STRUCTURE_TOWER), }); tower?.attack(creep); } { // $ExpectType StructureTower | null const tower = creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: isStructureType(STRUCTURE_TOWER), }); tower?.attack(creep); } // when pass in an array of room objects { // $ExpectType StructureTower[] const towers = creep.pos.findInRange([] as AnyStructure[], 2, { filter: isStructureType(STRUCTURE_TOWER), }); towers[0].attack(creep); } { // $ExpectType StructureTower | null const tower = creep.pos.findClosestByPath([] as AnyStructure[], { filter: isStructureType(STRUCTURE_TOWER), }); tower?.attack(creep); } { // $ExpectType StructureTower | null const tower = creep.pos.findClosestByRange([] as AnyStructure[], { filter: isStructureType(STRUCTURE_TOWER), }); tower?.attack(creep); } // Lodash's object style filter predicate // Currently do not support narrowing. { // $ExpectType AnyStructure[] const towers = room.find(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_TOWER }, }); } { // $ExpectType AnyStructure[] const towers = creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: { structureType: STRUCTURE_TOWER }, }); // $ExpectType AnyStructure[] const towers2 = creep.pos.findInRange([] as AnyStructure[], 2, { filter: { structureType: STRUCTURE_TOWER }, }); } { // $ExpectType AnyStructure | null const tower = creep.pos.findClosestByPath(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_TOWER }, }); // $ExpectType AnyStructure | null const towers2 = creep.pos.findClosestByPath([] as AnyStructure[], { filter: { structureType: STRUCTURE_TOWER }, }); } { // $ExpectType AnyStructure | null const tower = creep.pos.findClosestByRange(FIND_STRUCTURES, { filter: { structureType: STRUCTURE_TOWER }, }); // $ExpectType AnyStructure | null const towers2 = creep.pos.findClosestByRange([] as AnyStructure[], { filter: { structureType: STRUCTURE_TOWER }, }); } // should throw error if the property is not exist in the object { // @ts-expect-error creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: { foo: "bar" }, }); } // should throw error if type of values are not match { // @ts-expect-error creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: { structureType: "foobar" }, }); // @ts-expect-error creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: { structureType: 123 }, }); } // should support deep property { // $ExpectType AnyOwnedStructure | null const tower1 = creep.pos.findClosestByPath(FIND_MY_STRUCTURES, { filter: { owner: { username: "foo" } }, }); // @ts-expect-error const tower2 = creep.pos.findClosestByPath(FIND_MY_STRUCTURES, { filter: { owner: { yourname: "Mitsuha" } }, }); } // Lodash's path string style filter predicate // Currently do not support narrowing, and maybe never will. { // $ExpectType AnyStructure[] const towers = creep.pos.findInRange(FIND_STRUCTURES, 2, { filter: "my", }); } } // LookAt Finds { const matrix = room.lookAtArea(10, 10, 20, 20, false); for (const y of Object.keys(matrix)) { const row = matrix[y as unknown as number]; for (const x of Object.keys(row)) { const pos = new RoomPosition(+x, +y, room.name); const objects = row[x as unknown as number]; if (objects.length > 0) { objects.map((o) => o.type); } } } const nukes = room.lookForAt(LOOK_NUKES, creep.pos); nukes[0].launchRoomName; const flags = room.lookForAtArea(LOOK_FLAGS, 10, 10, 20, 20); const x = flags[10]; const y = x[11]; const entry = y[0]; entry.remove(); const creeps = room.lookForAtArea(LOOK_CREEPS, 10, 10, 20, 20, true); creeps[0].x; creeps[0].y; creeps[0].creep.move(TOP); // #252 const structuresMatrix = room.lookForAtArea(LOOK_STRUCTURES, 10, 10, 20, 20); structuresMatrix[15][15].find((s) => s.structureType === STRUCTURE_CONTROLLER); // #252 with explicit isArray=false const structuresMatrix2 = room.lookForAtArea(LOOK_STRUCTURES, 10, 10, 20, 20, false); structuresMatrix2[15][15].find((s) => s.structureType === STRUCTURE_CONTROLLER); } // StoreDefinition { for (const resourceType of resources(creep.carry)) { const amount = creep.carry[resourceType]; creep.drop(resourceType, amount); } const extension = new StructureExtension("" as Id); const e1: number = extension.store.getUsedCapacity(RESOURCE_ENERGY); const e2: number = extension.store[RESOURCE_ENERGY]; // Invalid resource type for extension const eg1: null = extension.store.getUsedCapacity(RESOURCE_GHODIUM); const eg2: null = extension.store.getFreeCapacity(RESOURCE_GHODIUM); const eg3: null = extension.store.getCapacity(RESOURCE_GHODIUM); const eg4: 0 = extension.store.G; const storage = new StructureStorage("" as Id); const sg1: number = storage.store.getUsedCapacity(RESOURCE_GHODIUM); const sg2: number = storage.store.getFreeCapacity(RESOURCE_GHODIUM); const sg3: number = storage.store.getCapacity(RESOURCE_GHODIUM); } // Advanced Structure types { const owned = Game.getObjectById("blah" as Id)!; const owner = owned.owner && owned.owner.username; owned.notifyWhenAttacked(false); const structs = room.find(FIND_MY_STRUCTURES); structs.forEach((struct) => { switch (struct.structureType) { case STRUCTURE_CONTROLLER: const usernameOptional: string | undefined = struct.owner && struct.owner.username; break; default: const usernameRequired: string = struct.owner.username; break; } }); const unowned = Game.getObjectById("blah2" as Id)!; const hp = unowned.hits / unowned.hitsMax; // test discriminated union switch (unowned.structureType) { case STRUCTURE_TOWER: unowned.heal(Game.creeps.myCreep); break; case STRUCTURE_CONTAINER: case STRUCTURE_STORAGE: case STRUCTURE_TERMINAL: const energyPercent = unowned.store.energy / unowned.storeCapacity; break; case STRUCTURE_WALL: case STRUCTURE_RAMPART: const wallHp = unowned.hits / unowned.hitsMax; break; } // test discriminated union using filter functions on find // $ExpectType AnyStructure const from = Game.rooms.myRoom.find(FIND_STRUCTURES, { filter: (s) => (s.structureType === STRUCTURE_CONTAINER || s.structureType === STRUCTURE_STORAGE) && s.store.energy > 0, })[0]; // $ExpectType AnyOwnedStructure | null const to = from.pos.findClosestByPath(FIND_MY_STRUCTURES, { filter: (s) => (s.structureType === STRUCTURE_SPAWN || s.structureType === STRUCTURE_EXTENSION) && s.energy < s.energyCapacity, }); Game.rooms.myRoom .find(FIND_MY_STRUCTURES, { filter: (s) => s.structureType === STRUCTURE_RAMPART, }) .forEach((r) => r.notifyWhenAttacked(false)); } { // Test that you can use signatures EXTENSION_ENERGY_CAPACITY[Game.rooms.myRoom.controller!.level]; REACTIONS[Object.keys(creep.carry)[0]]; BOOSTS[creep.body[0].type]; } // Tombstones { const tombstone = room.find(FIND_TOMBSTONES)[0]; (tombstone.creep as PowerCreep).spawnCooldownTime; (tombstone.creep as Creep).my; tombstone.store.energy; tombstone.id; const creep = Game.creeps["dave"]; creep.withdraw(tombstone, RESOURCE_ENERGY); } // Ruin { const ruin = room.find(FIND_RUINS)[0]; creep.withdraw(ruin, RESOURCE_ENERGY); powerCreep.withdraw(ruin, RESOURCE_ENERGY); } { if (Game.cpu.hasOwnProperty("getHeapStatistics")) { const heap = Game.cpu.getHeapStatistics!(); heap.total_heap_size; } } // StructurePortal { const portals = room.find(FIND_STRUCTURES, { filter: (s) => s.structureType === STRUCTURE_PORTAL }); portals.forEach((p: StructurePortal) => { const state = p.ticksToDecay === undefined ? "stable" : "unstable"; if (p.destination instanceof RoomPosition) { Game.notify(`Found ${state} inter-room portal to ${p.destination.toString()}`); } else { Game.notify(`Found ${state} inter-shard portal to ${p.destination.shard} ${p.destination.room}`); } }); } // ConstructionSite { room.createConstructionSite(10, 10, STRUCTURE_EXTENSION); room.createConstructionSite(10, 11, STRUCTURE_SPAWN, "mySpawn"); const pos = new RoomPosition(10, 10, room.name); room.createConstructionSite(pos, STRUCTURE_EXTENSION); room.createConstructionSite(pos, STRUCTURE_SPAWN, "mySpawn"); pos.createConstructionSite(STRUCTURE_EXTENSION); pos.createConstructionSite(STRUCTURE_SPAWN, "mySpawn"); } // StructureLab { const lab0 = Game.getObjectById("lab" as Id); const lab1 = Game.getObjectById("lab" as Id); const lab2 = Game.getObjectById("lab" as Id); if (lab0 !== null && lab1 !== null && lab2 !== null) { if (lab1.mineralAmount >= LAB_REACTION_AMOUNT && lab2.mineralAmount >= LAB_REACTION_AMOUNT && lab0.mineralType === null) { lab0.runReaction(lab1, lab2); } // nevermind, reverse that lab0.reverseReaction(lab1, lab2); } } // Room event log { room.getEventLog(); const eventStr = room.getEventLog(true); if (eventStr.includes(`build:4`)) { // Build occured on last tick. } const events = room.getEventLog(); const event = events[0]; switch (event.event) { case EVENT_ATTACK: const attackType: EventAttackType = event.data.attackType; break; case EVENT_BUILD: const incomplete: boolean = event.data.incomplete; break; case EVENT_POWER: const power = event.data.power; break; } } // Room.Terrain { const room = Game.rooms[""]; const myTerrain = room.getTerrain(); const otherTerrain = new Room.Terrain("E2S7"); const anotherTerrain = Game.map.getRoomTerrain("W2N5"); const ret = myTerrain.get(5, 5); if (ret === 0) { /*plain*/ } if (ret === TERRAIN_MASK_SWAMP) { /*swamp*/ } if (ret === TERRAIN_MASK_WALL) { /*wall*/ } const myRawTerrain = myTerrain.getRawBuffer(); const otherRawTerrain = otherTerrain.getRawBuffer(new Int8Array(2500)); const anotherRawTerrain = anotherTerrain.getRawBuffer(new Uint16Array(2500)); for (const rawTerrain of [myRawTerrain, otherRawTerrain, anotherRawTerrain]) { for (let y = 0; y < 50; y++) { for (let x = 0; x < 50; x++) { const code = rawTerrain[y * 50 + x]; if (code === 0) { /*plain*/ } if (code & TERRAIN_MASK_SWAMP) { /*swamp*/ } if (code & TERRAIN_MASK_WALL) { /*wall*/ } } } } } // Creep.body function atackPower(creep: Creep) { return creep.body .map((part) => { if (part.type === ATTACK) { const multiplier = part.boost ? BOOSTS[part.type][part.boost].attack : 1; return multiplier * ATTACK_POWER; } return 0; }) .reduce((a, b) => a + b); } // Factories and Commodities { const factory = new StructureFactory("" as Id); if (!factory.level) { powerCreep.usePower(PWR_OPERATE_FACTORY, factory); } creep.transfer(factory, RESOURCE_CELL, 20); creep.transfer(factory, RESOURCE_OXIDANT, 36); creep.transfer(factory, RESOURCE_LEMERGIUM_BAR, 16); creep.transfer(factory, RESOURCE_ENERGY, 8); factory.produce(RESOURCE_PHLEGM); factory.produce(RESOURCE_BATTERY); factory.produce(RESOURCE_ENERGY); factory.produce(RESOURCE_GHODIUM); factory.produce(RESOURCE_GHODIUM_MELT); creep.withdraw(factory, RESOURCE_PHLEGM); // Energy and ghodium commodities COMMODITIES[RESOURCE_ENERGY]; COMMODITIES[RESOURCE_GHODIUM]; // Mineral commodities COMMODITIES[RESOURCE_UTRIUM]; COMMODITIES[RESOURCE_LEMERGIUM]; COMMODITIES[RESOURCE_KEANIUM]; COMMODITIES[RESOURCE_ZYNTHIUM]; COMMODITIES[RESOURCE_OXYGEN]; COMMODITIES[RESOURCE_HYDROGEN]; COMMODITIES[RESOURCE_CATALYST]; // Commodity commodities COMMODITIES[RESOURCE_UTRIUM_BAR]; COMMODITIES[RESOURCE_LEMERGIUM_BAR]; COMMODITIES[RESOURCE_ZYNTHIUM_BAR]; COMMODITIES[RESOURCE_KEANIUM_BAR]; COMMODITIES[RESOURCE_GHODIUM_MELT]; COMMODITIES[RESOURCE_OXIDANT]; COMMODITIES[RESOURCE_REDUCTANT]; COMMODITIES[RESOURCE_PURIFIER]; COMMODITIES[RESOURCE_BATTERY]; COMMODITIES[RESOURCE_COMPOSITE]; COMMODITIES[RESOURCE_CRYSTAL]; COMMODITIES[RESOURCE_LIQUID]; COMMODITIES[RESOURCE_WIRE]; COMMODITIES[RESOURCE_SWITCH]; COMMODITIES[RESOURCE_TRANSISTOR]; COMMODITIES[RESOURCE_MICROCHIP]; COMMODITIES[RESOURCE_CIRCUIT]; COMMODITIES[RESOURCE_DEVICE]; COMMODITIES[RESOURCE_CELL]; COMMODITIES[RESOURCE_PHLEGM]; COMMODITIES[RESOURCE_TISSUE]; COMMODITIES[RESOURCE_MUSCLE]; COMMODITIES[RESOURCE_ORGANOID]; COMMODITIES[RESOURCE_ORGANISM]; COMMODITIES[RESOURCE_ALLOY]; COMMODITIES[RESOURCE_TUBE]; COMMODITIES[RESOURCE_FIXTURES]; COMMODITIES[RESOURCE_FRAME]; COMMODITIES[RESOURCE_HYDRAULICS]; COMMODITIES[RESOURCE_MACHINE]; COMMODITIES[RESOURCE_CONDENSATE]; COMMODITIES[RESOURCE_CONCENTRATE]; COMMODITIES[RESOURCE_EXTRACT]; COMMODITIES[RESOURCE_SPIRIT]; COMMODITIES[RESOURCE_EMANATION]; COMMODITIES[RESOURCE_ESSENCE]; } // Horse armor!Pixels! { const ret: OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL = Game.cpu.generatePixel(); } // Game.map.visual { const mapVis = Game.map.visual; const point1 = new RoomPosition(1, 1, "E1N1"); const point2 = new RoomPosition(1, 1, "E1N8"); const point3 = new RoomPosition(1, 1, "E8N8"); const point4 = new RoomPosition(1, 1, "E1N8"); mapVis.line(point1, point2).circle(point3, { fill: "#f2f2f2" }).poly([point1, point2, point3, point4]).rect(point3, 50, 50); const size: number = mapVis.getSize(); const visData = mapVis.export(); mapVis.clear(); mapVis.import(visData); } // Store { // Store definitions of structures are well typed with their capable resources { const energyOnlyStores = [ new StructureSpawn("" as Id).store, new StructureExtension("" as Id).store, new StructureTower("" as Id).store, new StructureLink("" as Id).store, ]; for (const store of energyOnlyStores) { // should be number for capabale resources const shouldBeNumber = store.getCapacity(RESOURCE_ENERGY); // $ExpectType number const shouldBeNumber2 = store.getFreeCapacity(RESOURCE_ENERGY); // $ExpectType number const shouldBeNumber3 = store.getUsedCapacity(RESOURCE_ENERGY); // $ExpectType number // should be null for non-capabale resources const shouldBeNull1 = store.getCapacity(RESOURCE_HYDROGEN); // $ExpectType null const shouldBeNull2 = store.getFreeCapacity(RESOURCE_HYDROGEN); // $ExpectType null const shouldBeNull3 = store.getUsedCapacity(RESOURCE_HYDROGEN); // $ExpectType null const shouldBeZero = store[RESOURCE_HYDROGEN]; // $ExpectType 0 } const nukerStore = new StructureNuker("" as Id).store; // should be number for capabale resources const shouldBeNumber = nukerStore.getCapacity(RESOURCE_ENERGY); // $ExpectType number const shouldBeNumber2 = nukerStore.getFreeCapacity(RESOURCE_ENERGY); // $ExpectType number const shouldBeNumber3 = nukerStore.getUsedCapacity(RESOURCE_ENERGY); // $ExpectType number const shouldBeNumber4 = nukerStore.getCapacity(RESOURCE_GHODIUM); // $ExpectType number const shouldBeNumber5 = nukerStore.getFreeCapacity(RESOURCE_GHODIUM); // $ExpectType number const shouldBeNumber6 = nukerStore.getUsedCapacity(RESOURCE_GHODIUM); // $ExpectType number // should be null for non-capabale resources const shouldBeNull1 = nukerStore.getCapacity(RESOURCE_HYDROGEN); // $ExpectType null const shouldBeNull2 = nukerStore.getFreeCapacity(RESOURCE_HYDROGEN); // $ExpectType null const shouldBeNull3 = nukerStore.getUsedCapacity(RESOURCE_HYDROGEN); // $ExpectType null } // Unlimited store have no notion of capacity and free capacity { const ruinStore = new Ruin("" as Id).store; for (const resourceType of RESOURCES_ALL) { const shouldBeNull1 = ruinStore.getCapacity(resourceType); // $ExpectType null const shouldBeNull2 = ruinStore.getFreeCapacity(resourceType); // $ExpectType null const shouldNotBeNull = ruinStore.getUsedCapacity(resourceType); // $ExpectType number const shouldNotBeNull2 = ruinStore[resourceType]; // $ExpectType number } const tombstoneStore = new Tombstone("" as Id).store; for (const resourceType of RESOURCES_ALL) { const shouldBeNull1 = tombstoneStore.getCapacity(resourceType); // $ExpectType null const shouldBeNull2 = tombstoneStore.getFreeCapacity(resourceType); // $ExpectType null const shouldNotBeNull = tombstoneStore.getUsedCapacity(resourceType); // $ExpectType number const shouldNotBeNull2 = tombstoneStore[resourceType]; // $ExpectType number } } // test return type of `get*Capacity()` with no resourceType specified { // should be null for structures that only accept certain resource types { const spawnStore = new StructureSpawn("" as Id).store; const shouldBeNull1 = spawnStore.getCapacity(); // $ExpectType null const shouldBeNull2 = spawnStore.getFreeCapacity(); // $ExpectType null const shouldBeNull3 = spawnStore.getUsedCapacity(); // $ExpectType null } { const nukeStore = new StructureNuker("" as Id).store; const shouldBeNull1 = nukeStore.getCapacity(); // $ExpectType null const shouldBeNull2 = nukeStore.getFreeCapacity(); // $ExpectType null const shouldBeNull3 = nukeStore.getUsedCapacity(); // $ExpectType null } { const labStore = new StructureLab("" as Id).store; const shouldBeNull1 = labStore.getCapacity(); // $ExpectType null const shouldBeNull2 = labStore.getFreeCapacity(); // $ExpectType null const shouldBeNull3 = labStore.getUsedCapacity(); // $ExpectType null } // should be number for structures that accept all resource types { const containerStore = new StructureContainer("" as Id).store; const shouldBeNumber1 = containerStore.getCapacity(); // $ExpectType number const shouldBeNumber2 = containerStore.getFreeCapacity(); // $ExpectType number const shouldBeNumber3 = containerStore.getUsedCapacity(); // $ExpectType number } { const storageStore = new StructureStorage("" as Id).store; const shouldBeNumber1 = storageStore.getCapacity(); // $ExpectType number const shouldBeNumber2 = storageStore.getFreeCapacity(); // $ExpectType number const shouldBeNumber3 = storageStore.getUsedCapacity(); // $ExpectType number } { const terminalStore = new StructureTerminal("" as Id).store; const shouldBeNumber1 = terminalStore.getCapacity(); // $ExpectType number const shouldBeNumber2 = terminalStore.getFreeCapacity(); // $ExpectType number const shouldBeNumber3 = terminalStore.getUsedCapacity(); // $ExpectType number } { const factoryStore = new StructureFactory("" as Id).store; const shouldBeNumber1 = factoryStore.getCapacity(); // $ExpectType number const shouldBeNumber2 = factoryStore.getFreeCapacity(); // $ExpectType number const shouldBeNumber3 = factoryStore.getUsedCapacity(); // $ExpectType number } } } // Room Object { // `RoomObject.effects` can be undefined { const source = new Source("" as Id); // @ts-expect-error source.effects.find((effect) => effect.effect === PWR_REGEN_SOURCE); // no error with optional chaining operator source.effects?.find((effect) => effect.effect === PWR_REGEN_SOURCE); } } // Id { /// @ts-expect-error Rooms don't have `id` property const roomId = "" as Id; const creep = Game.getObjectById("" as Id); // No error, but deprecated warning const foo = Game.getObjectById("" as Id); } // Shard access { Game.shard.access; Game.shard.activateAccess?.(); } ================================================ FILE: dist/tsconfig.json ================================================ { "compilerOptions": { "module": "commonjs", "lib": [ "es6" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, "esModuleInterop": true }, "files": [ "index.d.ts", "screeps-tests.ts" ] } ================================================ FILE: eslint.config.mjs ================================================ // @ts-check import tseslint, { parser } from 'typescript-eslint'; import expectType from "eslint-plugin-expect-type/configs/recommended"; export const sharedOpts = tseslint.config( tseslint.configs.base, expectType, // global ignore { ignores: ["build/*", "eslint.config.*"], }, { rules: { "@typescript-eslint/no-invalid-void-type": "error", } } ); export default tseslint.config( ...sharedOpts, { files: ['src/**/*.ts', 'dist/screeps-tests.ts'], }, { languageOptions: { ecmaVersion: 2022, sourceType: "module", parserOptions: { parser: parser, project: ["./tsconfig.json", './dist/tsconfig.json'], }, }, }, ) ================================================ FILE: eslint.config.test.mjs ================================================ // @ts-check // only used for 'dist/screeps-tests.ts' import tseslint, { parser } from 'typescript-eslint'; import { sharedOpts } from "./eslint.config.mjs"; export default tseslint.config( ...sharedOpts, { files: ['dist/screeps-tests.ts'], }, { languageOptions: { ecmaVersion: 2022, sourceType: "module", parserOptions: { parser: parser, project: ['./dist/tsconfig.json'], }, }, }, ) ================================================ FILE: package.json ================================================ { "name": "typed-screeps", "version": "3.4.0", "description": "Strong TypeScript declarations for the game Screeps.", "repository": "screepers/typed-screeps", "types": "./dist/index.d.ts", "files": [ "dist/index.d.ts" ], "scripts": { "compile": "node ./build/concat.js", "format": "npm run format:build && npm run format:src", "format:build": "prettier --write 'build/**/*.js'", "format:src": "prettier --write 'src/**/*.ts'", "test": "npm run compile && npm run lint:test", "lint": "eslint -c eslint.config.mjs", "lint:test": "eslint -c eslint.config.test.mjs dist/screeps-tests.ts", "pre-commit": "npm run compile && git add dist/index.d.ts", "prepare": "husky install && npm test" }, "keywords": [ "Screeps", "API", "Typescript", "Autocomplete" ], "author": "Marko Sulamagi ", "license": "MIT", "devDependencies": { "eslint": "^9.7.0", "eslint-plugin-expect-type": "^0.4.0", "husky": "^7.0.4", "lint-staged": "^12.3.8", "prettier": "^2.6.2", "typescript": "^5.5.0", "typescript-eslint": "^7.16.1" }, "lint-staged": { "*.{ts,tsx}": [ "prettier --write" ] } } ================================================ FILE: src/constants.ts ================================================ // Game Constants declare const OK: OK; declare const ERR_NOT_OWNER: ERR_NOT_OWNER; declare const ERR_NO_PATH: ERR_NO_PATH; declare const ERR_NAME_EXISTS: ERR_NAME_EXISTS; declare const ERR_BUSY: ERR_BUSY; declare const ERR_NOT_FOUND: ERR_NOT_FOUND; declare const ERR_NOT_ENOUGH_RESOURCES: ERR_NOT_ENOUGH_RESOURCES; declare const ERR_NOT_ENOUGH_ENERGY: ERR_NOT_ENOUGH_ENERGY; declare const ERR_INVALID_TARGET: ERR_INVALID_TARGET; declare const ERR_FULL: ERR_FULL; declare const ERR_NOT_IN_RANGE: ERR_NOT_IN_RANGE; declare const ERR_INVALID_ARGS: ERR_INVALID_ARGS; declare const ERR_TIRED: ERR_TIRED; declare const ERR_NO_BODYPART: ERR_NO_BODYPART; declare const ERR_NOT_ENOUGH_EXTENSIONS: ERR_NOT_ENOUGH_EXTENSIONS; declare const ERR_RCL_NOT_ENOUGH: ERR_RCL_NOT_ENOUGH; declare const ERR_GCL_NOT_ENOUGH: ERR_GCL_NOT_ENOUGH; declare const ERR_ACCESS_DENIED: ERR_ACCESS_DENIED; declare const FIND_EXIT_TOP: FIND_EXIT_TOP; declare const FIND_EXIT_RIGHT: FIND_EXIT_RIGHT; declare const FIND_EXIT_BOTTOM: FIND_EXIT_BOTTOM; declare const FIND_EXIT_LEFT: FIND_EXIT_LEFT; declare const FIND_EXIT: FIND_EXIT; declare const FIND_CREEPS: FIND_CREEPS; declare const FIND_MY_CREEPS: FIND_MY_CREEPS; declare const FIND_HOSTILE_CREEPS: FIND_HOSTILE_CREEPS; declare const FIND_SOURCES_ACTIVE: FIND_SOURCES_ACTIVE; declare const FIND_SOURCES: FIND_SOURCES; declare const FIND_DROPPED_RESOURCES: FIND_DROPPED_RESOURCES; declare const FIND_STRUCTURES: FIND_STRUCTURES; declare const FIND_MY_STRUCTURES: FIND_MY_STRUCTURES; declare const FIND_HOSTILE_STRUCTURES: FIND_HOSTILE_STRUCTURES; declare const FIND_FLAGS: FIND_FLAGS; declare const FIND_CONSTRUCTION_SITES: FIND_CONSTRUCTION_SITES; declare const FIND_MY_SPAWNS: FIND_MY_SPAWNS; declare const FIND_HOSTILE_SPAWNS: FIND_HOSTILE_SPAWNS; declare const FIND_MY_CONSTRUCTION_SITES: FIND_MY_CONSTRUCTION_SITES; declare const FIND_HOSTILE_CONSTRUCTION_SITES: FIND_HOSTILE_CONSTRUCTION_SITES; declare const FIND_MINERALS: FIND_MINERALS; declare const FIND_NUKES: FIND_NUKES; declare const FIND_TOMBSTONES: FIND_TOMBSTONES; declare const FIND_POWER_CREEPS: FIND_POWER_CREEPS; declare const FIND_MY_POWER_CREEPS: FIND_MY_POWER_CREEPS; declare const FIND_HOSTILE_POWER_CREEPS: FIND_HOSTILE_POWER_CREEPS; declare const FIND_DEPOSITS: FIND_DEPOSITS; declare const FIND_RUINS: FIND_RUINS; declare const TOP: TOP; declare const TOP_RIGHT: TOP_RIGHT; declare const RIGHT: RIGHT; declare const BOTTOM_RIGHT: BOTTOM_RIGHT; declare const BOTTOM: BOTTOM; declare const BOTTOM_LEFT: BOTTOM_LEFT; declare const LEFT: LEFT; declare const TOP_LEFT: TOP_LEFT; declare const COLOR_RED: COLOR_RED; declare const COLOR_PURPLE: COLOR_PURPLE; declare const COLOR_BLUE: COLOR_BLUE; declare const COLOR_CYAN: COLOR_CYAN; declare const COLOR_GREEN: COLOR_GREEN; declare const COLOR_YELLOW: COLOR_YELLOW; declare const COLOR_ORANGE: COLOR_ORANGE; declare const COLOR_BROWN: COLOR_BROWN; declare const COLOR_GREY: COLOR_GREY; declare const COLOR_WHITE: COLOR_WHITE; declare const COLORS_ALL: ColorConstant[]; declare const CREEP_SPAWN_TIME: 3; declare const CREEP_LIFE_TIME: 1500; declare const CREEP_CLAIM_LIFE_TIME: 600; declare const CREEP_CORPSE_RATE: 0.2; declare const OBSTACLE_OBJECT_TYPES: [ "spawn", "creep", "powerCreep", "source", "mineral", "deposit", "controller", "constructedWall", "extension", "link", "storage", "tower", "observer", "powerSpawn", "powerBank", "lab", "terminal", "nuker", "factory", "invaderCore", ]; 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: { [rcl: number]: number; 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: { [rcl: number]: number; 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_WEAROUT_POWER_CREEP: 100; 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 FACTORY_HITS: 1000; declare const FACTORY_CAPACITY: 50000; declare const BODYPART_COST: Record; declare const BODYPARTS_ALL: BodyPartConstant[]; declare const CARRY_CAPACITY: 50; declare const HARVEST_POWER: 2; declare const HARVEST_MINERAL_POWER: 1; declare const HARVEST_DEPOSIT_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: Record; declare const CONSTRUCTION_COST_ROAD_SWAMP_RATIO: 5; declare const CONSTRUCTION_COST_ROAD_WALL_RATIO: 150; declare const STRUCTURE_EXTENSION: STRUCTURE_EXTENSION; declare const STRUCTURE_RAMPART: STRUCTURE_RAMPART; declare const STRUCTURE_ROAD: STRUCTURE_ROAD; declare const STRUCTURE_SPAWN: STRUCTURE_SPAWN; declare const STRUCTURE_LINK: STRUCTURE_LINK; declare const STRUCTURE_WALL: STRUCTURE_WALL; declare const STRUCTURE_KEEPER_LAIR: STRUCTURE_KEEPER_LAIR; declare const STRUCTURE_CONTROLLER: STRUCTURE_CONTROLLER; declare const STRUCTURE_STORAGE: STRUCTURE_STORAGE; declare const STRUCTURE_TOWER: STRUCTURE_TOWER; declare const STRUCTURE_OBSERVER: STRUCTURE_OBSERVER; declare const STRUCTURE_POWER_BANK: STRUCTURE_POWER_BANK; declare const STRUCTURE_POWER_SPAWN: STRUCTURE_POWER_SPAWN; declare const STRUCTURE_EXTRACTOR: STRUCTURE_EXTRACTOR; declare const STRUCTURE_LAB: STRUCTURE_LAB; declare const STRUCTURE_TERMINAL: STRUCTURE_TERMINAL; declare const STRUCTURE_CONTAINER: STRUCTURE_CONTAINER; declare const STRUCTURE_NUKER: STRUCTURE_NUKER; declare const STRUCTURE_FACTORY: STRUCTURE_FACTORY; declare const STRUCTURE_INVADER_CORE: STRUCTURE_INVADER_CORE; declare const STRUCTURE_PORTAL: STRUCTURE_PORTAL; declare const RESOURCE_ENERGY: RESOURCE_ENERGY; declare const RESOURCE_POWER: RESOURCE_POWER; declare const RESOURCE_OPS: RESOURCE_OPS; declare const RESOURCE_UTRIUM: RESOURCE_UTRIUM; declare const RESOURCE_LEMERGIUM: RESOURCE_LEMERGIUM; declare const RESOURCE_KEANIUM: RESOURCE_KEANIUM; declare const RESOURCE_GHODIUM: RESOURCE_GHODIUM; declare const RESOURCE_ZYNTHIUM: RESOURCE_ZYNTHIUM; declare const RESOURCE_OXYGEN: RESOURCE_OXYGEN; declare const RESOURCE_HYDROGEN: RESOURCE_HYDROGEN; declare const RESOURCE_CATALYST: RESOURCE_CATALYST; declare const RESOURCE_HYDROXIDE: RESOURCE_HYDROXIDE; declare const RESOURCE_ZYNTHIUM_KEANITE: RESOURCE_ZYNTHIUM_KEANITE; declare const RESOURCE_UTRIUM_LEMERGITE: RESOURCE_UTRIUM_LEMERGITE; declare const RESOURCE_UTRIUM_HYDRIDE: RESOURCE_UTRIUM_HYDRIDE; declare const RESOURCE_UTRIUM_OXIDE: RESOURCE_UTRIUM_OXIDE; declare const RESOURCE_KEANIUM_HYDRIDE: RESOURCE_KEANIUM_HYDRIDE; declare const RESOURCE_KEANIUM_OXIDE: RESOURCE_KEANIUM_OXIDE; declare const RESOURCE_LEMERGIUM_HYDRIDE: RESOURCE_LEMERGIUM_HYDRIDE; declare const RESOURCE_LEMERGIUM_OXIDE: RESOURCE_LEMERGIUM_OXIDE; declare const RESOURCE_ZYNTHIUM_HYDRIDE: RESOURCE_ZYNTHIUM_HYDRIDE; declare const RESOURCE_ZYNTHIUM_OXIDE: RESOURCE_ZYNTHIUM_OXIDE; declare const RESOURCE_GHODIUM_HYDRIDE: RESOURCE_GHODIUM_HYDRIDE; declare const RESOURCE_GHODIUM_OXIDE: RESOURCE_GHODIUM_OXIDE; declare const RESOURCE_UTRIUM_ACID: RESOURCE_UTRIUM_ACID; declare const RESOURCE_UTRIUM_ALKALIDE: RESOURCE_UTRIUM_ALKALIDE; declare const RESOURCE_KEANIUM_ACID: RESOURCE_KEANIUM_ACID; declare const RESOURCE_KEANIUM_ALKALIDE: RESOURCE_KEANIUM_ALKALIDE; declare const RESOURCE_LEMERGIUM_ACID: RESOURCE_LEMERGIUM_ACID; declare const RESOURCE_LEMERGIUM_ALKALIDE: RESOURCE_LEMERGIUM_ALKALIDE; declare const RESOURCE_ZYNTHIUM_ACID: RESOURCE_ZYNTHIUM_ACID; declare const RESOURCE_ZYNTHIUM_ALKALIDE: RESOURCE_ZYNTHIUM_ALKALIDE; declare const RESOURCE_GHODIUM_ACID: RESOURCE_GHODIUM_ACID; declare const RESOURCE_GHODIUM_ALKALIDE: RESOURCE_GHODIUM_ALKALIDE; declare const RESOURCE_CATALYZED_UTRIUM_ACID: RESOURCE_CATALYZED_UTRIUM_ACID; declare const RESOURCE_CATALYZED_UTRIUM_ALKALIDE: RESOURCE_CATALYZED_UTRIUM_ALKALIDE; declare const RESOURCE_CATALYZED_KEANIUM_ACID: RESOURCE_CATALYZED_KEANIUM_ACID; declare const RESOURCE_CATALYZED_KEANIUM_ALKALIDE: RESOURCE_CATALYZED_KEANIUM_ALKALIDE; declare const RESOURCE_CATALYZED_LEMERGIUM_ACID: RESOURCE_CATALYZED_LEMERGIUM_ACID; declare const RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE: RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE; declare const RESOURCE_CATALYZED_ZYNTHIUM_ACID: RESOURCE_CATALYZED_ZYNTHIUM_ACID; declare const RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE: RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE; declare const RESOURCE_CATALYZED_GHODIUM_ACID: RESOURCE_CATALYZED_GHODIUM_ACID; declare const RESOURCE_CATALYZED_GHODIUM_ALKALIDE: RESOURCE_CATALYZED_GHODIUM_ALKALIDE; declare const RESOURCE_BIOMASS: RESOURCE_BIOMASS; declare const RESOURCE_METAL: RESOURCE_METAL; declare const RESOURCE_MIST: RESOURCE_MIST; declare const RESOURCE_SILICON: RESOURCE_SILICON; declare const RESOURCE_UTRIUM_BAR: RESOURCE_UTRIUM_BAR; declare const RESOURCE_LEMERGIUM_BAR: RESOURCE_LEMERGIUM_BAR; declare const RESOURCE_ZYNTHIUM_BAR: RESOURCE_ZYNTHIUM_BAR; declare const RESOURCE_KEANIUM_BAR: RESOURCE_KEANIUM_BAR; declare const RESOURCE_GHODIUM_MELT: RESOURCE_GHODIUM_MELT; declare const RESOURCE_OXIDANT: RESOURCE_OXIDANT; declare const RESOURCE_REDUCTANT: RESOURCE_REDUCTANT; declare const RESOURCE_PURIFIER: RESOURCE_PURIFIER; declare const RESOURCE_BATTERY: RESOURCE_BATTERY; declare const RESOURCE_COMPOSITE: RESOURCE_COMPOSITE; declare const RESOURCE_CRYSTAL: RESOURCE_CRYSTAL; declare const RESOURCE_LIQUID: RESOURCE_LIQUID; declare const RESOURCE_WIRE: RESOURCE_WIRE; declare const RESOURCE_SWITCH: RESOURCE_SWITCH; declare const RESOURCE_TRANSISTOR: RESOURCE_TRANSISTOR; declare const RESOURCE_MICROCHIP: RESOURCE_MICROCHIP; declare const RESOURCE_CIRCUIT: RESOURCE_CIRCUIT; declare const RESOURCE_DEVICE: RESOURCE_DEVICE; declare const RESOURCE_CELL: RESOURCE_CELL; declare const RESOURCE_PHLEGM: RESOURCE_PHLEGM; declare const RESOURCE_TISSUE: RESOURCE_TISSUE; declare const RESOURCE_MUSCLE: RESOURCE_MUSCLE; declare const RESOURCE_ORGANOID: RESOURCE_ORGANOID; declare const RESOURCE_ORGANISM: RESOURCE_ORGANISM; declare const RESOURCE_ALLOY: RESOURCE_ALLOY; declare const RESOURCE_TUBE: RESOURCE_TUBE; declare const RESOURCE_FIXTURES: RESOURCE_FIXTURES; declare const RESOURCE_FRAME: RESOURCE_FRAME; declare const RESOURCE_HYDRAULICS: RESOURCE_HYDRAULICS; declare const RESOURCE_MACHINE: RESOURCE_MACHINE; declare const RESOURCE_CONDENSATE: RESOURCE_CONDENSATE; declare const RESOURCE_CONCENTRATE: RESOURCE_CONCENTRATE; declare const RESOURCE_EXTRACT: RESOURCE_EXTRACT; declare const RESOURCE_SPIRIT: RESOURCE_SPIRIT; declare const RESOURCE_EMANATION: RESOURCE_EMANATION; declare const RESOURCE_ESSENCE: RESOURCE_ESSENCE; declare const RESOURCES_ALL: ResourceConstant[]; declare const SUBSCRIPTION_TOKEN: SUBSCRIPTION_TOKEN; declare const CPU_UNLOCK: CPU_UNLOCK; declare const PIXEL: PIXEL; declare const ACCESS_KEY: ACCESS_KEY; declare const PIXEL_CPU_COST: 10000; declare const CONTROLLER_LEVELS: { [level: number]: number }; declare const CONTROLLER_STRUCTURES: Record; declare const CONTROLLER_DOWNGRADE: { [level: number]: number }; declare const CONTROLLER_DOWNGRADE_RESTORE: number; declare const CONTROLLER_DOWNGRADE_SAFEMODE_THRESHOLD: 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 CONTROLLER_NUKE_BLOCKED_UPGRADE: number; declare const SAFE_MODE_DURATION: 20000; declare const SAFE_MODE_COOLDOWN: 50000; declare const SAFE_MODE_COST: 1000; 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 EXTRACTOR_COOLDOWN: 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: null; declare const MODE_WORLD: null; declare const TERRAIN_MASK_WALL: TERRAIN_MASK_WALL; declare const TERRAIN_MASK_SWAMP: TERRAIN_MASK_SWAMP; declare const TERRAIN_MASK_LAVA: TERRAIN_MASK_LAVA; declare const MAX_CONSTRUCTION_SITES: number; declare const MAX_CREEP_SIZE: number; declare const MINERAL_REGEN_TIME: number; declare const MINERAL_MIN_AMOUNT: Record; declare const MINERAL_RANDOM_FACTOR: number; declare const MINERAL_DENSITY: { [level: number]: number; 1: number; 2: number; 3: number; 4: number; }; declare const MINERAL_DENSITY_PROBABILITY: { [level: number]: number; 1: number; 2: number; 3: number; 4: number; }; declare const MINERAL_DENSITY_CHANGE: number; declare const DENSITY_LOW: DENSITY_LOW; declare const DENSITY_MODERATE: DENSITY_MODERATE; declare const DENSITY_HIGH: DENSITY_HIGH; declare const DENSITY_ULTRA: DENSITY_ULTRA; declare const DEPOSIT_EXHAUST_MULTIPLY: number; declare const DEPOSIT_EXHAUST_POW: number; declare const DEPOSIT_DECAY_TIME: number; declare const TERMINAL_CAPACITY: number; declare const TERMINAL_COOLDOWN: number; declare const TERMINAL_HITS: number; declare const TERMINAL_SEND_COST: number; declare const TERMINAL_MIN_SEND: 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: { [range: number]: number; 0: number; 1: number; 4: number; }; declare const REACTIONS: { [resource: string]: { [resource: string]: string }; H: { O: "OH"; L: "LH"; K: "KH"; U: "UH"; Z: "ZH"; G: "GH"; }; O: { H: "OH"; L: "LO"; K: "KO"; U: "UO"; Z: "ZO"; G: "GO"; }; Z: { K: "ZK"; H: "ZH"; O: "ZO"; }; L: { U: "UL"; H: "LH"; O: "LO"; }; K: { Z: "ZK"; H: "KH"; O: "KO"; }; G: { H: "GH"; O: "GO"; }; U: { L: "UL"; H: "UH"; O: "UO"; }; OH: { UH: "UH2O"; UO: "UHO2"; ZH: "ZH2O"; ZO: "ZHO2"; KH: "KH2O"; KO: "KHO2"; LH: "LH2O"; LO: "LHO2"; GH: "GH2O"; GO: "GHO2"; }; X: { UH2O: "XUH2O"; UHO2: "XUHO2"; LH2O: "XLH2O"; LHO2: "XLHO2"; KH2O: "XKH2O"; KHO2: "XKHO2"; ZH2O: "XZH2O"; ZHO2: "XZHO2"; GH2O: "XGH2O"; GHO2: "XGHO2"; }; ZK: { UL: "G"; }; UL: { ZK: "G"; }; LH: { OH: "LH2O"; }; ZH: { OH: "ZH2O"; }; GH: { OH: "GH2O"; }; KH: { OH: "KH2O"; }; UH: { OH: "UH2O"; }; LO: { OH: "LHO2"; }; ZO: { OH: "ZHO2"; }; KO: { OH: "KHO2"; }; UO: { OH: "UHO2"; }; GO: { OH: "GHO2"; }; LH2O: { X: "XLH2O"; }; KH2O: { X: "XKH2O"; }; ZH2O: { X: "XZH2O"; }; UH2O: { X: "XUH2O"; }; GH2O: { X: "XGH2O"; }; LHO2: { X: "XLHO2"; }; UHO2: { X: "XUHO2"; }; KHO2: { X: "XKHO2"; }; ZHO2: { X: "XZHO2"; }; GHO2: { X: "XGHO2"; }; }; declare const REACTION_TIME: { OH: 20; ZK: 5; UL: 5; G: 5; UH: 10; UH2O: 5; XUH2O: 60; UO: 10; UHO2: 5; XUHO2: 60; KH: 10; KH2O: 5; XKH2O: 60; KO: 10; KHO2: 5; XKHO2: 60; LH: 15; LH2O: 10; XLH2O: 65; LO: 10; LHO2: 5; XLHO2: 60; ZH: 20; ZH2O: 40; XZH2O: 160; ZO: 10; ZHO2: 5; XZHO2: 60; GH: 10; GH2O: 15; XGH2O: 80; GO: 10; GHO2: 30; XGHO2: 150; }; declare const BOOSTS: { [part: string]: { [boost: string]: { [action: string]: number } }; work: { UO: { harvest: 3; }; UHO2: { harvest: 5; }; XUHO2: { harvest: 7; }; LH: { build: 1.5; repair: 1.5; }; LH2O: { build: 1.8; repair: 1.8; }; XLH2O: { build: 2; repair: 2; }; ZH: { dismantle: 2; }; ZH2O: { dismantle: 3; }; XZH2O: { dismantle: 4; }; GH: { upgradeController: 1.5; }; GH2O: { upgradeController: 1.8; }; XGH2O: { upgradeController: 2; }; }; attack: { UH: { attack: 2; }; UH2O: { attack: 3; }; XUH2O: { attack: 4; }; }; ranged_attack: { KO: { rangedAttack: 2; rangedMassAttack: 2; }; KHO2: { rangedAttack: 3; rangedMassAttack: 3; }; XKHO2: { rangedAttack: 4; rangedMassAttack: 4; }; }; heal: { LO: { heal: 2; rangedHeal: 2; }; LHO2: { heal: 3; rangedHeal: 3; }; XLHO2: { heal: 4; rangedHeal: 4; }; }; carry: { KH: { capacity: 2; }; KH2O: { capacity: 3; }; XKH2O: { capacity: 4; }; }; move: { ZO: { fatigue: 2; }; ZHO2: { fatigue: 3; }; XZHO2: { fatigue: 4; }; }; tough: { GO: { damage: 0.7; }; GHO2: { damage: 0.5; }; XGHO2: { damage: 0.3; }; }; }; declare const INTERSHARD_RESOURCES: InterShardResourceConstant[]; type CommoditiesTypes = CommodityConstant | MineralConstant | RESOURCE_GHODIUM | RESOURCE_ENERGY; interface CommodityEntry { level?: number; amount: number; cooldown: number; components: Record; } declare const COMMODITIES: Record; declare const LOOK_CREEPS: LOOK_CREEPS; declare const LOOK_ENERGY: LOOK_ENERGY; declare const LOOK_RESOURCES: LOOK_RESOURCES; declare const LOOK_SOURCES: LOOK_SOURCES; declare const LOOK_MINERALS: LOOK_MINERALS; declare const LOOK_DEPOSITS: LOOK_DEPOSITS; declare const LOOK_STRUCTURES: LOOK_STRUCTURES; declare const LOOK_FLAGS: LOOK_FLAGS; declare const LOOK_CONSTRUCTION_SITES: LOOK_CONSTRUCTION_SITES; declare const LOOK_NUKES: LOOK_NUKES; declare const LOOK_TERRAIN: LOOK_TERRAIN; declare const LOOK_TOMBSTONES: LOOK_TOMBSTONES; declare const LOOK_POWER_CREEPS: LOOK_POWER_CREEPS; declare const LOOK_RUINS: LOOK_RUINS; declare const ORDER_SELL: ORDER_SELL; declare const ORDER_BUY: ORDER_BUY; declare const MARKET_FEE: 0.05; declare const MARKET_MAX_ORDERS: 300; declare const MARKET_ORDER_LIFE_TIME: 2592000000; // 1000*60*60*24*30 declare const INVADERS_ENERGY_GOAL: number; declare const SYSTEM_USERNAME: string; declare const TOMBSTONE_DECAY_PER_PART: 5; declare const TOMBSTONE_DECAY_POWER_CREEP: 500; declare const RUIN_DECAY: 500; declare const RUIN_DECAY_STRUCTURES: { powerBank: 10; }; declare const EVENT_ATTACK: EVENT_ATTACK; declare const EVENT_OBJECT_DESTROYED: EVENT_OBJECT_DESTROYED; declare const EVENT_ATTACK_CONTROLLER: EVENT_ATTACK_CONTROLLER; declare const EVENT_BUILD: EVENT_BUILD; declare const EVENT_HARVEST: EVENT_HARVEST; declare const EVENT_HEAL: EVENT_HEAL; declare const EVENT_REPAIR: EVENT_REPAIR; declare const EVENT_RESERVE_CONTROLLER: EVENT_RESERVE_CONTROLLER; declare const EVENT_UPGRADE_CONTROLLER: EVENT_UPGRADE_CONTROLLER; declare const EVENT_EXIT: EVENT_EXIT; declare const EVENT_POWER: EVENT_POWER; declare const EVENT_TRANSFER: EVENT_TRANSFER; declare const EVENT_ATTACK_TYPE_MELEE: EVENT_ATTACK_TYPE_MELEE; declare const EVENT_ATTACK_TYPE_RANGED: EVENT_ATTACK_TYPE_RANGED; declare const EVENT_ATTACK_TYPE_RANGED_MASS: EVENT_ATTACK_TYPE_RANGED_MASS; declare const EVENT_ATTACK_TYPE_DISMANTLE: EVENT_ATTACK_TYPE_DISMANTLE; declare const EVENT_ATTACK_TYPE_HIT_BACK: EVENT_ATTACK_TYPE_HIT_BACK; declare const EVENT_ATTACK_TYPE_NUKE: EVENT_ATTACK_TYPE_NUKE; declare const EVENT_HEAL_TYPE_MELEE: EVENT_HEAL_TYPE_MELEE; declare const EVENT_HEAL_TYPE_RANGED: EVENT_HEAL_TYPE_RANGED; declare const POWER_LEVEL_MULTIPLY: 1000; declare const POWER_LEVEL_POW: 2; declare const POWER_CREEP_SPAWN_COOLDOWN: 28800000; // 8 * 3600 * 1000 declare const POWER_CREEP_DELETE_COOLDOWN: 86400000; // 24 * 3600 * 1000 declare const POWER_CREEP_MAX_LEVEL: 25; declare const POWER_CREEP_LIFE_TIME: 5000; declare const POWER_CLASS: { OPERATOR: "operator"; }; declare const PWR_GENERATE_OPS: PWR_GENERATE_OPS; declare const PWR_OPERATE_SPAWN: PWR_OPERATE_SPAWN; declare const PWR_OPERATE_TOWER: PWR_OPERATE_TOWER; declare const PWR_OPERATE_STORAGE: PWR_OPERATE_STORAGE; declare const PWR_OPERATE_LAB: PWR_OPERATE_LAB; declare const PWR_OPERATE_EXTENSION: PWR_OPERATE_EXTENSION; declare const PWR_OPERATE_OBSERVER: PWR_OPERATE_OBSERVER; declare const PWR_OPERATE_TERMINAL: PWR_OPERATE_TERMINAL; declare const PWR_DISRUPT_SPAWN: PWR_DISRUPT_SPAWN; declare const PWR_DISRUPT_TOWER: PWR_DISRUPT_TOWER; declare const PWR_DISRUPT_SOURCE: PWR_DISRUPT_SOURCE; declare const PWR_SHIELD: PWR_SHIELD; declare const PWR_REGEN_SOURCE: PWR_REGEN_SOURCE; declare const PWR_REGEN_MINERAL: PWR_REGEN_MINERAL; declare const PWR_DISRUPT_TERMINAL: PWR_DISRUPT_TERMINAL; declare const PWR_OPERATE_POWER: PWR_OPERATE_POWER; declare const PWR_FORTIFY: PWR_FORTIFY; declare const PWR_OPERATE_CONTROLLER: PWR_OPERATE_CONTROLLER; declare const PWR_OPERATE_FACTORY: PWR_OPERATE_FACTORY; declare const EFFECT_INVULNERABILITY: EFFECT_INVULNERABILITY; declare const EFFECT_COLLAPSE_TIMER: EFFECT_COLLAPSE_TIMER; declare const INVADER_CORE_HITS: 100000; declare const INVADER_CORE_CREEP_SPAWN_TIME: { 0: 0; 1: 0; 2: 6; 3: 3; 4: 2; 5: 1; }; declare const INVADER_CORE_EXPAND_TIME: { 1: 4000; 2: 3500; 3: 3000; 4: 2500; 5: 2000; }; declare const INVADER_CORE_CONTROLLER_POWER: 2; declare const INVADER_CORE_CONTROLLER_DOWNGRADE: 5000; declare const STRONGHOLD_RAMPART_HITS: { 0: 0; 1: 100000; 2: 200000; 3: 500000; 4: 1000000; 5: 2000000; }; declare const STRONGHOLD_DECAY_TICKS: 75000; declare const POWER_INFO: { [powerID: number]: { className: PowerClassConstant; level: number[]; cooldown: number; effect?: number[]; range?: number; ops?: number | number[]; duration?: number | number[]; }; [PWR_GENERATE_OPS]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; effect: [1, 2, 4, 6, 8]; }; [PWR_OPERATE_SPAWN]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 300; duration: 1000; range: 3; ops: 100; effect: [0.9, 0.7, 0.5, 0.35, 0.2]; }; [PWR_OPERATE_TOWER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 10; duration: 100; range: 3; ops: 10; effect: [1.1, 1.2, 1.3, 1.4, 1.5]; }; [PWR_OPERATE_STORAGE]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 800; duration: 1000; range: 3; ops: 100; effect: [500000, 1000000, 2000000, 4000000, 7000000]; }; [PWR_OPERATE_LAB]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; duration: 1000; range: 3; ops: 10; effect: [2, 4, 6, 8, 10]; }; [PWR_OPERATE_EXTENSION]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 50; range: 3; ops: 2; effect: [0.2, 0.4, 0.6, 0.8, 1.0]; }; [PWR_OPERATE_OBSERVER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 400; duration: [200, 400, 600, 800, 1000]; range: 3; ops: 10; }; [PWR_OPERATE_TERMINAL]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 500; duration: 1000; range: 3; ops: 100; effect: [0.9, 0.8, 0.7, 0.6, 0.5]; }; [PWR_DISRUPT_SPAWN]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 5; range: 20; ops: 10; duration: [1, 2, 3, 4, 5]; }; [PWR_DISRUPT_TOWER]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 0; duration: 5; range: 50; ops: 10; effect: [0.9, 0.8, 0.7, 0.6, 0.5]; }; [PWR_DISRUPT_SOURCE]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 100; range: 3; ops: 100; duration: [100, 200, 300, 400, 500]; }; [PWR_SHIELD]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; effect: [5000, 10000, 15000, 20000, 25000]; duration: 50; cooldown: 20; energy: 100; }; [PWR_REGEN_SOURCE]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 100; duration: 300; range: 3; effect: [50, 100, 150, 200, 250]; period: 15; }; [PWR_REGEN_MINERAL]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 100; duration: 100; range: 3; effect: [2, 4, 6, 8, 10]; period: 10; }; [PWR_DISRUPT_TERMINAL]: { className: POWER_CLASS["OPERATOR"]; level: [20, 21, 22, 23, 24]; cooldown: 8; duration: 10; range: 50; ops: [50, 40, 30, 20, 10]; }; [PWR_FORTIFY]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 5; range: 3; ops: 5; duration: [1, 2, 3, 4, 5]; }; [PWR_OPERATE_POWER]: { className: POWER_CLASS["OPERATOR"]; level: [10, 11, 12, 14, 22]; cooldown: 800; range: 3; duration: 1000; ops: 200; effect: [1, 2, 3, 4, 5]; }; [PWR_OPERATE_CONTROLLER]: { className: POWER_CLASS["OPERATOR"]; level: [20, 21, 22, 23, 24]; cooldown: 800; range: 3; duration: 1000; ops: 200; effect: [10, 20, 30, 40, 50]; }; [PWR_OPERATE_FACTORY]: { className: POWER_CLASS["OPERATOR"]; level: [0, 2, 7, 14, 22]; cooldown: 1000; range: 3; duration: 1000; ops: 100; }; }; ================================================ FILE: src/construction-site.ts ================================================ /** * 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 {@link Room.createConstructionSite} method. * * To build a structure on the construction site, give a worker creep some amount of energy and perform {@link Creep.build} action. * * You can remove enemy construction sites by moving a creep on it. */ interface ConstructionSite extends RoomObject { readonly prototype: ConstructionSite; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * 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 {@link StructureConstant STRUCTURE_*} constants. */ structureType: T; /** * Remove the construction site. * @returns Result Code: OK, ERR_NOT_OWNER */ remove(): number; } interface ConstructionSiteConstructor extends _Constructor, _ConstructorById {} declare const ConstructionSite: ConstructionSiteConstructor; ================================================ FILE: src/creep.ts ================================================ /** * 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 represented by {@link BodyPartConstant}:. * * | Body part | Build cost | Effect per one body part * | :-------------- | :--------: | :----------------------- * | MOVE | 50 | Decreases fatigue by 2 points per tick. * | WORK | 100 | Harvests 2 energy units from a source per tick. * | | | Harvests 1 resource unit from a mineral or a deposit per tick. * | | | Builds a structure for 5 energy units per tick. * | | | Repairs a structure for 100 hits per tick consuming 1 energy unit per tick. * | | | Dismantles a structure for 50 hits per tick returning 0.25 energy unit per tick. * | | | Upgrades a controller for 1 energy unit per tick. * | CARRY | 50 | Can contain up to 50 resource units. * | ATTACK | 80 | Attacks another creep/structure with 30 hits per tick in a short-ranged attack. * | RANGED_ATTACK | 150 | Attacks another single creep/structure with 10 hits per tick in a long-range attack up to 3 squares long. * | | | Attacks all hostile creeps/structures within 3 squares range with 1-4-10 hits (depending on the range). * | HEAL | 250 | Heals self or another creep restoring 12 hits per tick in short range or 4 hits per tick at a distance. * | CLAIM | 600 | Claims a neutral room controller. * | | | Reserves a neutral room controller for 1 tick per body part. * | | | Attacks a hostile room controller downgrading its timer by 300 ticks per body parts. * | | | Attacks a neutral room controller reservation timer by 1 tick per body parts. * | | | A creep with this body part will have a reduced life time of 600 ticks and cannot be renewed. * | TOUGH | 10 | No effect, just additional hit points to the creep's body. Can be boosted to resist damage. */ interface Creep extends RoomObject { readonly prototype: Creep; /** * An array describing the creep's body. */ body: BodyPartDefinition[]; /** * An object with the creep's cargo contents. * @deprecated Is an alias for Creep.store */ carry: StoreDefinition; /** * The total amount of resources the creep can carry. * @deprecated alias for {@link Creep.store.getCapacity} */ 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 {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * A shorthand to `Memory.creeps[creep.name]`. * * You can use it for quick access the creep’s specific memory data object. */ memory: CreepMemory; /** * Whether it is your creep or foe. */ my: boolean; /** * The 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 {@link Game.creeps} object. */ name: string; /** * An object with the creep’s owner info. */ owner: Owner; /** * The {@link Room} the creep is in. * * 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; /** * A Store object that contains cargo of this creep. */ store: StoreDefinition; /** * The remaining amount of game ticks after which the creep will die. * * Will be `undefined` if the creep is still spawning. */ ticksToLive: number | undefined; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no ATTACK body parts in this creep’s body. */ attack(target: AnyCreep | Structure): CreepActionReturnCode; /** * Attack a controller. * * Decreases the controller's downgrade or reservation timer for 1 tick per every 5 `CLAIM` body parts (so the creep must have at least 5x`CLAIM`). * * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid owned or reserved controller object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: You have to wait until the next attack is possible. * - ERR_NO_BODYPART: There are not enough CLAIM body parts in this creep’s body. */ attackController(target: StructureController): CreepActionReturnCode; /** * 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 construction site to be built. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have any carried energy. * - ERR_INVALID_TARGET: The target is not a valid construction site object or the structure cannot be built here (probably because of a creep at the same square). * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ build(target: ConstructionSite): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES | ERR_RCL_NOT_ENOUGH; /** * Cancel the order given during the current game tick. * @param methodName The name of a creep's method to be cancelled. * @returns One of the following codes: * - OK: The operation has been cancelled successfully. * - ERR_NOT_FOUND: The order with the specified name is not found. */ cancelOrder(methodName: string): OK | ERR_NOT_FOUND; /** * Claim a controller. * * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid neutral controller object. * - ERR_FULL: You cannot claim more than 3 rooms in the Novice Area. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_GCL_NOT_ENOUGH: Your Global Control Level is not enough. * - ERR_ACCESS_DENIED: The shard access is restricted. */ claimController(target: StructureController): CreepActionReturnCode | ERR_FULL | ERR_GCL_NOT_ENOUGH | ERR_ACCESS_DENIED; /** * Dismantles any structure that can be constructed (even hostile) 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid structure object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ dismantle(target: Structure): CreepActionReturnCode; /** * Drop this resource on the ground. * * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_ARGS: The resourceType is not a valid RESOURCE_* constants. */ drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have enough ghodium. * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ generateSafeMode(target: StructureController): CreepActionReturnCode; /** * 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 {@link BodyPartConstant} constants. */ getActiveBodyparts(type: BodyPartConstant): number; /** * Harvest energy from the source or resource from minerals or deposits. * * Needs the WORK body part. * * If the creep has an empty CARRY body part, the harvested resource 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. * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or the room controller is owned or reserved by another player. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_FOUND: Extractor not found. You must build an extractor structure to harvest minerals. Learn more * - ERR_NOT_ENOUGH_RESOURCES: The target does not contain any harvestable energy or mineral. * - ERR_INVALID_TARGET: The target is not a valid source or mineral object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: The extractor or the deposit is still cooling down. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ harvest(target: Source | Mineral | Deposit): CreepActionReturnCode | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ heal(target: AnyCreep): CreepActionReturnCode; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * * Requires the MOVE body part if not being pulled. * @param direction The direction to move in ({@link DirectionConstant `TOP`, `TOP_LEFT`...}). * @param creep A creep nearby. * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. * - ERR_TIRED: The fatigue indicator of the creep is non-zero. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ move(direction: DirectionConstant): CreepMoveReturnCode; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. * * Needs the MOVE body part. * @param path A path value as returned from {@link Room.findPath} or {@link RoomPosition.findPathTo} methods. Both array form and serialized string form are accepted. */ moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * 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): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET; /** * 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, ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid object to pick up. * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CARRY body parts in this creep’s body. */ pickup(target: Resource): CreepActionReturnCode | ERR_FULL; /** * Allow another creep to follow this creep. * * Requires the MOVE body part. * * The fatigue generated for the target's move will be added to the creep instead of the target. * The target must be adjacent to the creep. The creep must move elsewhere, and the target must move towards the creep. * @param target The target creep to be pulled. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target provided is invalid. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no MOVE body parts in this creep’s body. */ pull(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ rangedAttack(target: AnyCreep | Structure): CreepActionReturnCode; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no HEAL body parts in this creep’s body. */ rangedHeal(target: AnyCreep): CreepActionReturnCode; /** * 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. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NO_BODYPART: There are no RANGED_ATTACK body parts in this creep’s body. */ rangedMassAttack(): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NO_BODYPART; /** * 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 The target structure to be repaired. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not carry any energy. * - ERR_INVALID_TARGET: The target is not a valid structure object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. */ repair(target: Structure): CreepActionReturnCode | ERR_NOT_ENOUGH_RESOURCES; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid neutral controller object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no CLAIM body parts in this creep’s body. * - ERR_ACCESS_DENIED: The shard access is restricted. */ reserveController(target: StructureController): CreepActionReturnCode | ERR_ACCESS_DENIED; /** * 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 unless toPublic is true. * @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'. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. */ say(message: string, toPublic?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_BUSY: The creep is still being spawned. * - ERR_INVALID_TARGET: The target is not a valid controller object. * - ERR_NOT_IN_RANGE: The target is too far away. */ signController(target: StructureController, text: string): OK | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Kill the creep immediately. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. */ suicide(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 {@link ResourceConstant RESOURCE_*} constants * @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The target cannot receive any more resources. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; /** * 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 over 15 energy units per tick regardless of creeps abilities. * 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. * * Upgrading the controller raises its ticksToDowngrade timer by 100. The timer must be full in order for controller to be levelled up. * @param target The target controller object to be upgraded. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep or the target controller. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have any carried energy. * - ERR_INVALID_TARGET: The target is not a valid controller object, or the controller upgrading is blocked. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_NO_BODYPART: There are no WORK body parts in this creep’s body. * - ERR_ACCESS_DENIED: The shard access is restricted. */ upgradeController(target: StructureController): ScreepsReturnCode | ERR_ACCESS_DENIED; /** * Withdraw resources from a structure, a tombstone or a ruin. * * The target has to be at adjacent square to the creep. Multiple creeps can withdraw from the same object in the same tick. * Your creeps can withdraw resources from hostile structures/tombstones as well, in case if there is no hostile rampart on top of it. * * This method should not be used to transfer resources between creeps. * To transfer between creeps, use the {@link Creep.transfer} method on the original creep. * * @param target The target object. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be transferred. If omitted, all the available amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or there is a hostile rampart on top of the target. * - ERR_BUSY: The creep is still being spawned. * - ERR_NOT_ENOUGH_RESOURCES: The target does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The creep's carry is full. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; } interface CreepConstructor extends _Constructor, _ConstructorById {} declare const Creep: CreepConstructor; ================================================ FILE: src/deposit.ts ================================================ /** * A rare resource deposit needed for producing commodities. * * Can be harvested by creeps with a WORK body part. Each harvest operation triggers a cooldown period, which becomes longer and longer over time. * * Learn more about deposits from [this article](https://docs.screeps.com/resources.html). * * | | | * | ------------ | ----------- | * | **Cooldown** | 0.001 * totalHarvested ^ 1.2 * | **Decay** | 50,000 ticks after appearing or last harvest operation */ interface Deposit extends RoomObject { /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The deposit type, one of the {@link DepositConstant}: * - `RESOURCE_MIST` * - `RESOURCE_BIOMASS` * - `RESOURCE_METAL` * - `RESOURCE_SILICON` */ depositType: DepositConstant; /** * The amount of game ticks until the next harvest action is possible. */ cooldown: number; /** * The cooldown of the last harvest operation on this deposit. */ lastCooldown: number; /** * The amount of game ticks when this deposit will disappear. */ ticksToDecay: number; } interface DepositConstructor extends _Constructor, _ConstructorById {} declare const Deposit: DepositConstructor; ================================================ FILE: src/flag.ts ================================================ /** * A flag. * * Flags can be used to mark particular spots in a room. Flags are visible to their owners only. You cannot have more than 10,000 flags. */ interface Flag extends RoomObject { readonly prototype: Flag; /** * Flag color. One of the {@link ColorConstant COLOR_*} constants. */ color: ColorConstant; /** * The flag's memory. * * A shorthand to Memory.flags[flag.name]. You can use it for quick access the flag's specific memory data object. */ memory: FlagMemory; /** * The 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 flag via the {@link Game.flags} object. The maximum name length is 60 characters. */ name: string; /** * Flag secondary color. One of the {@link ColorConstant COLOR_*} constants. */ secondaryColor: ColorConstant; /** * Remove the flag. * @returns Result Code: OK */ remove(): OK; /** * Set new color of the flag. * @param color One of the {@link ColorConstant COLOR_*} constants. * @param secondaryColor Secondary color of the flag. One of the {@link ColorConstant COLOR_*} constants. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: color or secondaryColor is not a valid color constant. */ setColor(color: ColorConstant, secondaryColor?: ColorConstant): OK | ERR_INVALID_ARGS; /** * Set new position of the flag. * @param x The X position in the room. * @param y The Y position in the room. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_TARGET: The target provided is invalid. */ setPosition(x: number, y: number): OK | ERR_INVALID_ARGS; /** * Set new position of the flag. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_TARGET: The target provided is invalid. */ setPosition(pos: RoomPosition | { pos: RoomPosition }): OK | ERR_INVALID_ARGS; } interface FlagConstructor extends _Constructor { new (name: string, color: ColorConstant, secondaryColor: ColorConstant, roomName: string, x: number, y: number): Flag; (name: string, color: ColorConstant, secondaryColor: ColorConstant, roomName: string, x: number, y: number): Flag; } declare const Flag: FlagConstructor; ================================================ FILE: src/game.ts ================================================ /** * The main global game object containing all the gameplay information. */ interface Game { /** * An object containing information about your CPU usage. */ 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. */ gcl: GlobalControlLevel; /** * Your clobal Power Level */ gpl: GlobalPowerLevel; /** * A global object representing world GameMap. */ map: GameMap; /** * A global object representing the in-game market. */ market: Market; /** * A hash containing all your power creeps with their names as hash keys. * * Even power creeps not spawned in the world can be accessed here. */ powerCreeps: { [creepName: string]: PowerCreep }; /** * An object with your global resources that are bound to the account, like pixels or cpu unlocks. * * Each object key is a resource constant, values are resources amounts. */ resources: { [key: string]: any }; /** * A hash containing all the rooms available to you with room names as hash keys. * * A room is visible if you have a creep or an owned structure in it. */ rooms: { [roomName: string]: Room }; /** * A hash containing all your spawns with spawn names as hash keys. */ spawns: { [spawnName: string]: StructureSpawn }; /** * A hash containing all your structures with structure id as hash keys. */ structures: { [structureId: string]: OwnedStructure }; /** * A hash containing all your construction sites with their id as hash keys. */ constructionSites: { [constructionSiteId: string]: ConstructionSite }; /** * An object describing the world shard where your script is currently being executed in. */ shard: Shard; /** * 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>(id: T): fromId | null; getObjectById(id: Id): T | null; /** * 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. * @deprecated Use Id, instead of strings, to increase type safety. * * If you are using JavaScript, just ignore this deprecation warning. * * If you are using TypeScript, and you are using strings as IDs, you should change your code to use Id instead. * * see [this section of README](https://github.com/screepers/typed-screeps?tab=readme-ov-file#Game.getObjectById()) for more information. */ getObjectById(id: string): 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 Simulator. * @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. * @returns One of the following codes: * - OK: The message has been sent successfully. * - ERR_FULL: More than 20 notifications sent this tick. */ notify(message: string, groupInterval?: number): OK | ERR_FULL; } declare var Game: Game; ================================================ FILE: src/helpers.ts ================================================ interface _HasId { id: Id; } interface _HasRoomPosition { pos: RoomPosition; } interface GlobalControlLevel { /** * The current level. */ level: number; /** * The current progress to the next level. */ progress: number; /** * The progress required to reach the next level. */ progressTotal: number; } interface GlobalPowerLevel { /** * The current level. */ level: number; /** * The current progress to the next level. */ progress: number; /** * The progress required to reach the next level. */ progressTotal: number; } interface Shard { /** * The name of the shard. */ name: string; /** * Currently always equals to normal. */ type: "normal"; /** * Whether this shard belongs to the PTR. */ ptr: boolean; /** * Whether you currently have access to this shard. * * Always true on non-restricted shards. On restricted shards, requires either an active ACCESS_KEY resource or an unlimited access subscription. * Use {@link Game.shard.activateAccess} to activate access. */ access?: boolean; /** * The time in milliseconds since UNIX epoch time until access to this restricted shard is active. * This property is not defined when access is unlimited or when access is not currently active. */ accessTime?: number; /** * Activate access to the current restricted shard for additional 30 days. * * This method will consume 1 ACCESS_KEY resource bound to your account (See Game.resources). * This method is only available on restricted shards (when {@link Game.shard.access} is defined). * * @returns One of the following codes: * - OK:The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your account does not have enough ACCESS_KEY resources. * - ERR_INVALID_TARGET: This shard is not restricted. * - ERR_FULL: Your access is unlimited. */ activateAccess?(): OK | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_ENOUGH_RESOURCES; } interface CPU { /** * Your assigned CPU limit for the current shard. */ limit: number; /** * An amount of available CPU time at the current game tick. * * Usually it is higher than {@link Game.cpu.limit}. */ tickLimit: number; /** * An amount of unused CPU accumulated in your bucket. * * @see http://docs.screeps.com/cpu-limit.html#Bucket */ bucket: number; /** * An object with limits for each shard with shard names as keys. * * You can use {@link Game.cpu.setShardLimits} method to re-assign them. */ shardLimits: CPUShardLimits; /** * Whether full CPU is currently unlocked for your account. */ unlocked: boolean; /** * The time in milliseconds since UNIX epoch time until full CPU is unlocked for your account. * * This property is not defined when full CPU is not unlocked for your account or it's unlocked with a subscription. */ unlockedTime: number | undefined; /** * Get amount of CPU time used from the beginning of the current game tick. * * Always returns 0 in the simulator. */ getUsed(): number; /** * Allocate CPU limits to different shards. * * Total amount of CPU should remain equal to {@link Game.cpu.shardLimits}. * This method can be used only once per 12 hours. * * @param limits An object with CPU values for each shard in the same format as {@link Game.cpu.shardLimits}. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_BUSY: 12-hours cooldown period is not over yet. * - ERR_INVALID_ARGS: The argument is not a valid shard limits object. */ setShardLimits(limits: CPUShardLimits): OK | ERR_BUSY | ERR_INVALID_ARGS; /** * Use this method to get heap statistics for your virtual machine. * * This method will be undefined if you are not using IVM. * * The return value is almost identical to Node's [v8.getHeapStatistics()](https://nodejs.org/docs/latest-v10.x/api/v8.html#v8_v8_getheapstatistics). * * This function returns one additional property: externally_allocated_size which is the total amount of currently * allocated memory which is not included in the v8 heap but counts against this isolate's memory limit. * ArrayBuffer instances over a certain size are externally allocated and will be counted here. */ getHeapStatistics?(): HeapStatistics; /** * This method will be undefined if you are not using IVM. * * Reset your runtime environment and wipe all data in heap memory. * Player code execution stops immediately. */ halt?(): never; /** * Generate 1 pixel resource unit for 10000 CPU from your bucket. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your bucket does not have enough CPU. */ generatePixel(): OK | ERR_NOT_ENOUGH_RESOURCES; /** * Unlock full CPU for your account for additional 24 hours. * * This method will consume 1 CPU unlock bound to your account (See {@link Game.resources}). * If full CPU is not currently unlocked for your account, it may take some time (up to 5 minutes) before unlock is applied to your account. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: Your account does not have enough cpuUnlock resource. * - ERR_FULL: Your CPU is unlocked with a subscription. */ unlock(): OK | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL; } 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; } /** * Describes one part of a creep’s body. */ type BodyPartDefinition = T extends any ? { /** * One of the {@link ResourceConstant RESOURCE_*} constants. * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ boost?: keyof (typeof BOOSTS)[T]; /** * One of the body part types constants. */ type: T; /** * The remaining amount of hit points of this body part. */ hits: number; } : never; interface Owner { /** * The name of the owner user. */ username: string; } interface ReservationDefinition { username: string; ticksToEnd: number; } interface SignDefinition { username: string; text: string; time: number; datetime: Date; } interface CPUShardLimits { [shard: string]: number; } /** A general purpose Store, which has a limited capacity */ type StoreDefinition = Store; /** A general purpose Store, which has an unlimited capacity */ type StoreDefinitionUnlimited = Store; /** * @example * { * "1": "W8N4", // TOP * "3": "W7N3", // RIGHT * // "5": "W8N2", // BOTTOM * "7": "W9N3" // LEFT * } */ type ExitsInformation = Partial>; interface AllLookAtTypes { [LOOK_CONSTRUCTION_SITES]: ConstructionSite; [LOOK_CREEPS]: Creep; [LOOK_ENERGY]: Resource; [LOOK_FLAGS]: Flag; [LOOK_MINERALS]: Mineral; [LOOK_DEPOSITS]: Deposit; [LOOK_NUKES]: Nuke; [LOOK_RESOURCES]: Resource; [LOOK_SOURCES]: Source; [LOOK_STRUCTURES]: AnyStructure; [LOOK_TERRAIN]: Terrain; [LOOK_TOMBSTONES]: Tombstone; [LOOK_POWER_CREEPS]: PowerCreep; [LOOK_RUINS]: Ruin; } type LookAtTypes = Partial; type LookAtResult = Pick & { type: K }; type LookAtResultWithPos = LookAtResult & { x: number; y: number; }; interface LookAtResultMatrix { [y: number]: { [x: number]: Array>; }; } interface LookForAtAreaResultMatrix { [y: number]: { [x: number]: T[]; }; } type LookForAtAreaResult = { type: K } & { [P in K]: T }; type LookForAtAreaResultWithPos = LookForAtAreaResult & { x: number; y: number }; type LookForAtAreaResultArray = Array>; interface FindTypes { [key: number]: | RoomPosition | AnyCreep | Source | Resource | Structure | Flag | ConstructionSite | Mineral | Nuke | Tombstone | Deposit | Ruin; [FIND_EXIT_TOP]: RoomPosition; [FIND_EXIT_RIGHT]: RoomPosition; [FIND_EXIT_BOTTOM]: RoomPosition; [FIND_EXIT_LEFT]: RoomPosition; [FIND_EXIT]: RoomPosition; [FIND_CREEPS]: Creep; [FIND_MY_CREEPS]: Creep; [FIND_HOSTILE_CREEPS]: Creep; [FIND_SOURCES_ACTIVE]: Source; [FIND_SOURCES]: Source; [FIND_DROPPED_RESOURCES]: Resource; [FIND_STRUCTURES]: AnyStructure; [FIND_MY_STRUCTURES]: AnyOwnedStructure; [FIND_HOSTILE_STRUCTURES]: AnyOwnedStructure; [FIND_FLAGS]: Flag; [FIND_CONSTRUCTION_SITES]: ConstructionSite; [FIND_MY_SPAWNS]: StructureSpawn; [FIND_HOSTILE_SPAWNS]: StructureSpawn; [FIND_MY_CONSTRUCTION_SITES]: ConstructionSite; [FIND_HOSTILE_CONSTRUCTION_SITES]: ConstructionSite; [FIND_MINERALS]: Mineral; [FIND_NUKES]: Nuke; [FIND_TOMBSTONES]: Tombstone; [FIND_POWER_CREEPS]: PowerCreep; [FIND_MY_POWER_CREEPS]: PowerCreep; [FIND_HOSTILE_POWER_CREEPS]: PowerCreep; [FIND_DEPOSITS]: Deposit; [FIND_RUINS]: Ruin; } interface FindPathOpts { /** * Treat squares with creeps as walkable. * * Can be useful with too many moving creeps around or in some other cases. * @default 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. * @default false */ ignoreDestructibleStructures?: boolean; /** * Ignore road structures. * * Enabling this option can speed up the search. This is only used when the new PathFinder is enabled. * * @default false */ 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 */ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type costCallback?: (roomName: string, costMatrix: CostMatrix) => void | 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. * @default 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! * @default 1.2 */ heuristicWeight?: number; /** * If true, the result path will be serialized using {@link Room.serializePath}. * @default false */ serialize?: boolean; /** * The maximum allowed rooms to search. * * This is only used when the new PathFinder is enabled. * @default 16 (also maximum) */ maxRooms?: number; /** * Path to within (range) tiles of target tile. * * The default is to path to the tile that the target is on. * * @default 0 */ range?: number; /** * Cost for walking on plain positions. * @default 1 */ plainCost?: number; /** * Cost for walking on swamp positions. * @default 5 */ swampCost?: 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. * Increase the amount to save more CPU, decrease to make the movement more consistent. * Set to 0 if you want to disable path reusing. * @default 5 */ 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 {@link Room.serializePath}. * @default true */ serializeMemory?: boolean; /** * Force the use of a cached path. * * 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. * @default false */ noPathFinding?: boolean; /** * Draw a line along the creep’s path using {@link 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: DirectionConstant; } interface _Constructor { readonly prototype: T; } interface _ConstructorById extends _Constructor { new (id: Id): T; (id: Id): T; } declare namespace Tag { const OpaqueTagSymbol: unique symbol; class OpaqueTag { private [OpaqueTagSymbol]: T; } } type Id = string & Tag.OpaqueTag; type fromId = T extends Id ? R : never; ================================================ FILE: src/inter-shard-memory.ts ================================================ /** * `InterShardMemory` object provides an interface for communicating between shards. * * Your script is executed separatedly on each shard, and their {@link Memory} objects are isolated from each other. * In order to pass messages and data between shards, you need to use {@link InterShardMemory} instead. * * Every shard can have its own data string that can be accessed by all other shards. * A shard can write only to its own data, other shards' data is read-only. * * This data has nothing to do with `Memory` contents, it's a separate data container. */ interface InterShardMemory { /** * Returns the string contents of the current shard's data. */ getLocal(): string; /** * Replace the current shard's data with the new value. * * @param value New data value in string format. * @throws if `value` isn't a string or contains more than `100 * 2014` characters. */ setLocal(value: string): void; /** * Returns the string contents of another shard's data, null if shard exists but data is not set. * * @param shard Shard name. * @throws if shard name is invalid */ getRemote(shard: string): string | null; } declare const InterShardMemory: InterShardMemory; ================================================ FILE: src/literals.ts ================================================ /* * This file creates literal versions of many of the constants * It should be kept in sync with constants.ts */ // Extras type Terrain = "plain" | "swamp" | "wall"; type ExitKey = "1" | "3" | "5" | "7"; type AnyCreep = Creep | PowerCreep; type FindClosestByPathAlgorithm = "astar" | "dijkstra"; // Return Codes type ScreepsReturnCode = | OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NAME_EXISTS | ERR_NOT_FOUND | ERR_NOT_ENOUGH_RESOURCES | ERR_NOT_ENOUGH_ENERGY | ERR_INVALID_TARGET | ERR_FULL | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS | ERR_TIRED | ERR_NO_BODYPART | ERR_NOT_ENOUGH_EXTENSIONS | ERR_RCL_NOT_ENOUGH | ERR_GCL_NOT_ENOUGH; type OK = 0; type ERR_NOT_OWNER = -1; type ERR_NO_PATH = -2; type ERR_NAME_EXISTS = -3; type ERR_BUSY = -4; type ERR_NOT_FOUND = -5; type ERR_NOT_ENOUGH_RESOURCES = -6; type ERR_NOT_ENOUGH_ENERGY = -6; type ERR_INVALID_TARGET = -7; type ERR_FULL = -8; type ERR_NOT_IN_RANGE = -9; type ERR_INVALID_ARGS = -10; type ERR_TIRED = -11; type ERR_NO_BODYPART = -12; type ERR_NOT_ENOUGH_EXTENSIONS = -6; type ERR_RCL_NOT_ENOUGH = -14; type ERR_GCL_NOT_ENOUGH = -15; type ERR_ACCESS_DENIED = -16; type CreepActionReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE | ERR_NO_BODYPART | ERR_TIRED; type CreepMoveReturnCode = OK | ERR_NOT_OWNER | ERR_BUSY | ERR_TIRED | ERR_NO_BODYPART; // Find Constants type ExitConstant = FIND_EXIT_TOP | FIND_EXIT_RIGHT | FIND_EXIT_BOTTOM | FIND_EXIT_LEFT; type FindConstant = | FIND_EXIT_TOP | FIND_EXIT_RIGHT | FIND_EXIT_BOTTOM | FIND_EXIT_LEFT | FIND_EXIT | FIND_CREEPS | FIND_MY_CREEPS | FIND_HOSTILE_CREEPS | FIND_SOURCES_ACTIVE | FIND_SOURCES | FIND_DROPPED_RESOURCES | FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES | FIND_FLAGS | FIND_CONSTRUCTION_SITES | FIND_MY_SPAWNS | FIND_HOSTILE_SPAWNS | FIND_MY_CONSTRUCTION_SITES | FIND_HOSTILE_CONSTRUCTION_SITES | FIND_MINERALS | FIND_NUKES | FIND_TOMBSTONES | FIND_POWER_CREEPS | FIND_MY_POWER_CREEPS | FIND_HOSTILE_POWER_CREEPS | FIND_DEPOSITS | FIND_RUINS; type FIND_EXIT_TOP = 1; type FIND_EXIT_RIGHT = 3; type FIND_EXIT_BOTTOM = 5; type FIND_EXIT_LEFT = 7; type FIND_EXIT = 10; type FIND_CREEPS = 101; type FIND_MY_CREEPS = 102; type FIND_HOSTILE_CREEPS = 103; type FIND_SOURCES_ACTIVE = 104; type FIND_SOURCES = 105; type FIND_DROPPED_RESOURCES = 106; type FIND_STRUCTURES = 107; type FIND_MY_STRUCTURES = 108; type FIND_HOSTILE_STRUCTURES = 109; type FIND_FLAGS = 110; type FIND_CONSTRUCTION_SITES = 111; type FIND_MY_SPAWNS = 112; type FIND_HOSTILE_SPAWNS = 113; type FIND_MY_CONSTRUCTION_SITES = 114; type FIND_HOSTILE_CONSTRUCTION_SITES = 115; type FIND_MINERALS = 116; type FIND_NUKES = 117; type FIND_TOMBSTONES = 118; type FIND_POWER_CREEPS = 119; type FIND_MY_POWER_CREEPS = 120; type FIND_HOSTILE_POWER_CREEPS = 121; type FIND_DEPOSITS = 122; type FIND_RUINS = 123; // Filter Options interface FilterOptions { filter?: PredicateFilterFunction | FilterFunction | FilterObject | string; } type PredicateFilterFunction = (object: T, index: number, collection: T[]) => object is S; type FilterFunction = (object: T, index: number, collection: T[]) => unknown; type FilterObject = DeepPartial; type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial } : T; // Body Part Constants type BodyPartConstant = MOVE | WORK | CARRY | ATTACK | RANGED_ATTACK | TOUGH | HEAL | CLAIM; type MOVE = "move"; type WORK = "work"; type CARRY = "carry"; type ATTACK = "attack"; type RANGED_ATTACK = "ranged_attack"; type TOUGH = "tough"; type HEAL = "heal"; type CLAIM = "claim"; // Look Constants type LookConstant = | LOOK_CREEPS | LOOK_ENERGY | LOOK_RESOURCES | LOOK_SOURCES | LOOK_MINERALS | LOOK_DEPOSITS | LOOK_STRUCTURES | LOOK_FLAGS | LOOK_CONSTRUCTION_SITES | LOOK_NUKES | LOOK_TERRAIN | LOOK_TOMBSTONES | LOOK_POWER_CREEPS | LOOK_RUINS; type LOOK_CONSTRUCTION_SITES = "constructionSite"; type LOOK_CREEPS = "creep"; type LOOK_ENERGY = "energy"; type LOOK_FLAGS = "flag"; type LOOK_MINERALS = "mineral"; type LOOK_DEPOSITS = "deposit"; type LOOK_NUKES = "nuke"; type LOOK_RESOURCES = "resource"; type LOOK_SOURCES = "source"; type LOOK_STRUCTURES = "structure"; type LOOK_TERRAIN = "terrain"; type LOOK_TOMBSTONES = "tombstone"; type LOOK_POWER_CREEPS = "powerCreep"; type LOOK_RUINS = "ruin"; type ORDER_SELL = "sell"; type ORDER_BUY = "buy"; // Direction Constants type DirectionConstant = TOP | TOP_RIGHT | RIGHT | BOTTOM_RIGHT | BOTTOM | BOTTOM_LEFT | LEFT | TOP_LEFT; type TOP = 1; type TOP_RIGHT = 2; type RIGHT = 3; type BOTTOM_RIGHT = 4; type BOTTOM = 5; type BOTTOM_LEFT = 6; type LEFT = 7; type TOP_LEFT = 8; // Color Constants type ColorConstant = | COLOR_RED | COLOR_PURPLE | COLOR_BLUE | COLOR_CYAN | COLOR_GREEN | COLOR_YELLOW | COLOR_ORANGE | COLOR_BROWN | COLOR_GREY | COLOR_WHITE; type COLOR_RED = 1; type COLOR_PURPLE = 2; type COLOR_BLUE = 3; type COLOR_CYAN = 4; type COLOR_GREEN = 5; type COLOR_YELLOW = 6; type COLOR_ORANGE = 7; type COLOR_BROWN = 8; type COLOR_GREY = 9; type COLOR_WHITE = 10; // Structure Constants type BuildableStructureConstant = | STRUCTURE_EXTENSION | STRUCTURE_RAMPART | STRUCTURE_ROAD | STRUCTURE_SPAWN | STRUCTURE_LINK | STRUCTURE_WALL | STRUCTURE_STORAGE | STRUCTURE_TOWER | STRUCTURE_OBSERVER | STRUCTURE_POWER_SPAWN | STRUCTURE_EXTRACTOR | STRUCTURE_LAB | STRUCTURE_TERMINAL | STRUCTURE_CONTAINER | STRUCTURE_NUKER | STRUCTURE_FACTORY; type StructureConstant = | BuildableStructureConstant | STRUCTURE_KEEPER_LAIR | STRUCTURE_CONTROLLER | STRUCTURE_POWER_BANK | STRUCTURE_PORTAL | STRUCTURE_INVADER_CORE; type STRUCTURE_EXTENSION = "extension"; type STRUCTURE_RAMPART = "rampart"; type STRUCTURE_ROAD = "road"; type STRUCTURE_SPAWN = "spawn"; type STRUCTURE_LINK = "link"; type STRUCTURE_WALL = "constructedWall"; type STRUCTURE_KEEPER_LAIR = "keeperLair"; type STRUCTURE_CONTROLLER = "controller"; type STRUCTURE_STORAGE = "storage"; type STRUCTURE_TOWER = "tower"; type STRUCTURE_OBSERVER = "observer"; type STRUCTURE_POWER_BANK = "powerBank"; type STRUCTURE_POWER_SPAWN = "powerSpawn"; type STRUCTURE_EXTRACTOR = "extractor"; type STRUCTURE_LAB = "lab"; type STRUCTURE_TERMINAL = "terminal"; type STRUCTURE_CONTAINER = "container"; type STRUCTURE_NUKER = "nuker"; type STRUCTURE_FACTORY = "factory"; type STRUCTURE_INVADER_CORE = "invaderCore"; type STRUCTURE_PORTAL = "portal"; // Terrain mask constants type TERRAIN_MASK_WALL = 1; type TERRAIN_MASK_SWAMP = 2; type TERRAIN_MASK_LAVA = 4; // Resource Constants type ResourceConstant = | RESOURCE_ENERGY | RESOURCE_POWER | RESOURCE_OPS | MineralConstant | MineralCompoundConstant | DepositConstant | CommodityConstant; type _ResourceConstantSansEnergy = Exclude; /** The raw harvestable minerals */ type MineralConstant = | RESOURCE_UTRIUM | RESOURCE_LEMERGIUM | RESOURCE_KEANIUM | RESOURCE_ZYNTHIUM | RESOURCE_OXYGEN | RESOURCE_HYDROGEN | RESOURCE_CATALYST; /** The compounds which can't boost */ type MineralBaseCompoundsConstant = RESOURCE_HYDROXIDE | RESOURCE_ZYNTHIUM_KEANITE | RESOURCE_UTRIUM_LEMERGITE | RESOURCE_GHODIUM; /** The boosts (from tier 1 to tier 3) */ type MineralBoostConstant = | RESOURCE_UTRIUM_HYDRIDE | RESOURCE_UTRIUM_OXIDE | RESOURCE_KEANIUM_HYDRIDE | RESOURCE_KEANIUM_OXIDE | RESOURCE_LEMERGIUM_HYDRIDE | RESOURCE_LEMERGIUM_OXIDE | RESOURCE_ZYNTHIUM_HYDRIDE | RESOURCE_ZYNTHIUM_OXIDE | RESOURCE_GHODIUM_HYDRIDE | RESOURCE_GHODIUM_OXIDE | RESOURCE_UTRIUM_ACID | RESOURCE_UTRIUM_ALKALIDE | RESOURCE_KEANIUM_ACID | RESOURCE_KEANIUM_ALKALIDE | RESOURCE_LEMERGIUM_ACID | RESOURCE_LEMERGIUM_ALKALIDE | RESOURCE_ZYNTHIUM_ACID | RESOURCE_ZYNTHIUM_ALKALIDE | RESOURCE_GHODIUM_ACID | RESOURCE_GHODIUM_ALKALIDE | RESOURCE_CATALYZED_UTRIUM_ACID | RESOURCE_CATALYZED_UTRIUM_ALKALIDE | RESOURCE_CATALYZED_KEANIUM_ACID | RESOURCE_CATALYZED_KEANIUM_ALKALIDE | RESOURCE_CATALYZED_LEMERGIUM_ACID | RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE | RESOURCE_CATALYZED_ZYNTHIUM_ACID | RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE | RESOURCE_CATALYZED_GHODIUM_ACID | RESOURCE_CATALYZED_GHODIUM_ALKALIDE; /** All the mineral compounds */ type MineralCompoundConstant = MineralBaseCompoundsConstant | MineralBoostConstant; /** The raw deposits */ type DepositConstant = RESOURCE_MIST | RESOURCE_BIOMASS | RESOURCE_METAL | RESOURCE_SILICON; /** The commodities, produced by the Factory */ type CommodityConstant = | RESOURCE_UTRIUM_BAR | RESOURCE_LEMERGIUM_BAR | RESOURCE_ZYNTHIUM_BAR | RESOURCE_KEANIUM_BAR | RESOURCE_GHODIUM_MELT | RESOURCE_OXIDANT | RESOURCE_REDUCTANT | RESOURCE_PURIFIER | RESOURCE_BATTERY | RESOURCE_COMPOSITE | RESOURCE_CRYSTAL | RESOURCE_LIQUID | RESOURCE_WIRE | RESOURCE_SWITCH | RESOURCE_TRANSISTOR | RESOURCE_MICROCHIP | RESOURCE_CIRCUIT | RESOURCE_DEVICE | RESOURCE_CELL | RESOURCE_PHLEGM | RESOURCE_TISSUE | RESOURCE_MUSCLE | RESOURCE_ORGANOID | RESOURCE_ORGANISM | RESOURCE_ALLOY | RESOURCE_TUBE | RESOURCE_FIXTURES | RESOURCE_FRAME | RESOURCE_HYDRAULICS | RESOURCE_MACHINE | RESOURCE_CONDENSATE | RESOURCE_CONCENTRATE | RESOURCE_EXTRACT | RESOURCE_SPIRIT | RESOURCE_EMANATION | RESOURCE_ESSENCE; type InterShardResourceConstant = SUBSCRIPTION_TOKEN | CPU_UNLOCK | PIXEL | ACCESS_KEY; type MarketResourceConstant = ResourceConstant | InterShardResourceConstant; type RESOURCE_ENERGY = "energy"; type RESOURCE_POWER = "power"; type RESOURCE_OPS = "ops"; type RESOURCE_BIOMASS = "biomass"; type RESOURCE_METAL = "metal"; type RESOURCE_MIST = "mist"; type RESOURCE_SILICON = "silicon"; type RESOURCE_UTRIUM = "U"; type RESOURCE_LEMERGIUM = "L"; type RESOURCE_KEANIUM = "K"; type RESOURCE_ZYNTHIUM = "Z"; type RESOURCE_OXYGEN = "O"; type RESOURCE_HYDROGEN = "H"; type RESOURCE_CATALYST = "X"; type RESOURCE_HYDROXIDE = "OH"; type RESOURCE_ZYNTHIUM_KEANITE = "ZK"; type RESOURCE_UTRIUM_LEMERGITE = "UL"; type RESOURCE_GHODIUM = "G"; type RESOURCE_UTRIUM_HYDRIDE = "UH"; type RESOURCE_UTRIUM_OXIDE = "UO"; type RESOURCE_KEANIUM_HYDRIDE = "KH"; type RESOURCE_KEANIUM_OXIDE = "KO"; type RESOURCE_LEMERGIUM_HYDRIDE = "LH"; type RESOURCE_LEMERGIUM_OXIDE = "LO"; type RESOURCE_ZYNTHIUM_HYDRIDE = "ZH"; type RESOURCE_ZYNTHIUM_OXIDE = "ZO"; type RESOURCE_GHODIUM_HYDRIDE = "GH"; type RESOURCE_GHODIUM_OXIDE = "GO"; type RESOURCE_UTRIUM_ACID = "UH2O"; type RESOURCE_UTRIUM_ALKALIDE = "UHO2"; type RESOURCE_KEANIUM_ACID = "KH2O"; type RESOURCE_KEANIUM_ALKALIDE = "KHO2"; type RESOURCE_LEMERGIUM_ACID = "LH2O"; type RESOURCE_LEMERGIUM_ALKALIDE = "LHO2"; type RESOURCE_ZYNTHIUM_ACID = "ZH2O"; type RESOURCE_ZYNTHIUM_ALKALIDE = "ZHO2"; type RESOURCE_GHODIUM_ACID = "GH2O"; type RESOURCE_GHODIUM_ALKALIDE = "GHO2"; type RESOURCE_CATALYZED_UTRIUM_ACID = "XUH2O"; type RESOURCE_CATALYZED_UTRIUM_ALKALIDE = "XUHO2"; type RESOURCE_CATALYZED_KEANIUM_ACID = "XKH2O"; type RESOURCE_CATALYZED_KEANIUM_ALKALIDE = "XKHO2"; type RESOURCE_CATALYZED_LEMERGIUM_ACID = "XLH2O"; type RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE = "XLHO2"; type RESOURCE_CATALYZED_ZYNTHIUM_ACID = "XZH2O"; type RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE = "XZHO2"; type RESOURCE_CATALYZED_GHODIUM_ACID = "XGH2O"; type RESOURCE_CATALYZED_GHODIUM_ALKALIDE = "XGHO2"; type RESOURCE_UTRIUM_BAR = "utrium_bar"; type RESOURCE_LEMERGIUM_BAR = "lemergium_bar"; type RESOURCE_ZYNTHIUM_BAR = "zynthium_bar"; type RESOURCE_KEANIUM_BAR = "keanium_bar"; type RESOURCE_GHODIUM_MELT = "ghodium_melt"; type RESOURCE_OXIDANT = "oxidant"; type RESOURCE_REDUCTANT = "reductant"; type RESOURCE_PURIFIER = "purifier"; type RESOURCE_BATTERY = "battery"; type RESOURCE_COMPOSITE = "composite"; type RESOURCE_CRYSTAL = "crystal"; type RESOURCE_LIQUID = "liquid"; type RESOURCE_WIRE = "wire"; type RESOURCE_SWITCH = "switch"; type RESOURCE_TRANSISTOR = "transistor"; type RESOURCE_MICROCHIP = "microchip"; type RESOURCE_CIRCUIT = "circuit"; type RESOURCE_DEVICE = "device"; type RESOURCE_CELL = "cell"; type RESOURCE_PHLEGM = "phlegm"; type RESOURCE_TISSUE = "tissue"; type RESOURCE_MUSCLE = "muscle"; type RESOURCE_ORGANOID = "organoid"; type RESOURCE_ORGANISM = "organism"; type RESOURCE_ALLOY = "alloy"; type RESOURCE_TUBE = "tube"; type RESOURCE_FIXTURES = "fixtures"; type RESOURCE_FRAME = "frame"; type RESOURCE_HYDRAULICS = "hydraulics"; type RESOURCE_MACHINE = "machine"; type RESOURCE_CONDENSATE = "condensate"; type RESOURCE_CONCENTRATE = "concentrate"; type RESOURCE_EXTRACT = "extract"; type RESOURCE_SPIRIT = "spirit"; type RESOURCE_EMANATION = "emanation"; type RESOURCE_ESSENCE = "essence"; type SUBSCRIPTION_TOKEN = "token"; type CPU_UNLOCK = "cpuUnlock"; type PIXEL = "pixel"; type ACCESS_KEY = "accessKey"; type TOMBSTONE_DECAY_PER_PART = 5; type EventConstant = | EVENT_ATTACK | EVENT_OBJECT_DESTROYED | EVENT_ATTACK_CONTROLLER | EVENT_BUILD | EVENT_HARVEST | EVENT_HEAL | EVENT_REPAIR | EVENT_RESERVE_CONTROLLER | EVENT_UPGRADE_CONTROLLER | EVENT_EXIT | EVENT_POWER | EVENT_TRANSFER; type EVENT_ATTACK = 1; type EVENT_OBJECT_DESTROYED = 2; type EVENT_ATTACK_CONTROLLER = 3; type EVENT_BUILD = 4; type EVENT_HARVEST = 5; type EVENT_HEAL = 6; type EVENT_REPAIR = 7; type EVENT_RESERVE_CONTROLLER = 8; type EVENT_UPGRADE_CONTROLLER = 9; type EVENT_EXIT = 10; type EVENT_POWER = 11; type EVENT_TRANSFER = 12; type EventAttackType = | EVENT_ATTACK_TYPE_MELEE | EVENT_ATTACK_TYPE_RANGED | EVENT_ATTACK_TYPE_RANGED_MASS | EVENT_ATTACK_TYPE_DISMANTLE | EVENT_ATTACK_TYPE_HIT_BACK | EVENT_ATTACK_TYPE_NUKE; type EVENT_ATTACK_TYPE_MELEE = 1; type EVENT_ATTACK_TYPE_RANGED = 2; type EVENT_ATTACK_TYPE_RANGED_MASS = 3; type EVENT_ATTACK_TYPE_DISMANTLE = 4; type EVENT_ATTACK_TYPE_HIT_BACK = 5; type EVENT_ATTACK_TYPE_NUKE = 6; type EventHealType = EVENT_HEAL_TYPE_MELEE | EVENT_HEAL_TYPE_RANGED; type EVENT_HEAL_TYPE_MELEE = 1; type EVENT_HEAL_TYPE_RANGED = 2; type EventDestroyType = "creep" | StructureConstant; type EventItem = | { event: EVENT_ATTACK; objectId: string; data: EventData[EVENT_ATTACK]; } | { event: EVENT_OBJECT_DESTROYED; objectId: string; data: EventData[EVENT_OBJECT_DESTROYED]; } | { event: EVENT_ATTACK_CONTROLLER; objectId: string; data: EventData[EVENT_ATTACK_CONTROLLER]; } | { event: EVENT_BUILD; objectId: string; data: EventData[EVENT_BUILD]; } | { event: EVENT_HARVEST; objectId: string; data: EventData[EVENT_HARVEST]; } | { event: EVENT_HEAL; objectId: string; data: EventData[EVENT_HEAL]; } | { event: EVENT_REPAIR; objectId: string; data: EventData[EVENT_REPAIR]; } | { event: EVENT_RESERVE_CONTROLLER; objectId: string; data: EventData[EVENT_RESERVE_CONTROLLER]; } | { event: EVENT_UPGRADE_CONTROLLER; objectId: string; data: EventData[EVENT_UPGRADE_CONTROLLER]; } | { event: EVENT_EXIT; objectId: string; data: EventData[EVENT_EXIT]; } | { event: EVENT_POWER; objectId: string; data: EventData[EVENT_POWER]; } | { event: EVENT_TRANSFER; objectId: string; data: EventData[EVENT_TRANSFER]; }; interface EventData { [EVENT_ATTACK]: { targetId: string; damage: number; attackType: EventAttackType; }; [EVENT_OBJECT_DESTROYED]: { type: EventDestroyType; }; [EVENT_ATTACK_CONTROLLER]: null; [EVENT_BUILD]: { targetId: string; amount: number; structureType: BuildableStructureConstant; x: number; y: number; incomplete: boolean; }; [EVENT_HARVEST]: { targetId: string; amount: number; }; [EVENT_HEAL]: { targetId: string; amount: number; healType: EventHealType; }; [EVENT_REPAIR]: { targetId: string; amount: number; energySpent: number; }; [EVENT_RESERVE_CONTROLLER]: { amount: number; }; [EVENT_UPGRADE_CONTROLLER]: { amount: number; energySpent: number; }; [EVENT_EXIT]: { room: string; x: number; y: number; }; [EVENT_POWER]: { targetId: string; power: PowerConstant; }; [EVENT_TRANSFER]: { targetId: string; resourceType: ResourceConstant; amount: number; }; } type PowerClassConstant = POWER_CLASS["OPERATOR"]; interface POWER_CLASS { OPERATOR: "operator"; } type PowerConstant = | PWR_GENERATE_OPS | PWR_OPERATE_SPAWN | PWR_OPERATE_TOWER | PWR_OPERATE_STORAGE | PWR_OPERATE_LAB | PWR_OPERATE_EXTENSION | PWR_OPERATE_OBSERVER | PWR_OPERATE_TERMINAL | PWR_DISRUPT_SPAWN | PWR_DISRUPT_TOWER | PWR_DISRUPT_SOURCE | PWR_SHIELD | PWR_REGEN_SOURCE | PWR_REGEN_MINERAL | PWR_DISRUPT_TERMINAL | PWR_OPERATE_POWER | PWR_FORTIFY | PWR_OPERATE_CONTROLLER | PWR_OPERATE_FACTORY; type PWR_GENERATE_OPS = 1; type PWR_OPERATE_SPAWN = 2; type PWR_OPERATE_TOWER = 3; type PWR_OPERATE_STORAGE = 4; type PWR_OPERATE_LAB = 5; type PWR_OPERATE_EXTENSION = 6; type PWR_OPERATE_OBSERVER = 7; type PWR_OPERATE_TERMINAL = 8; type PWR_DISRUPT_SPAWN = 9; type PWR_DISRUPT_TOWER = 10; type PWR_DISRUPT_SOURCE = 11; type PWR_SHIELD = 12; type PWR_REGEN_SOURCE = 13; type PWR_REGEN_MINERAL = 14; type PWR_DISRUPT_TERMINAL = 15; type PWR_OPERATE_POWER = 16; type PWR_FORTIFY = 17; type PWR_OPERATE_CONTROLLER = 18; type PWR_OPERATE_FACTORY = 19; type EffectConstant = EFFECT_INVULNERABILITY | EFFECT_COLLAPSE_TIMER; type EFFECT_INVULNERABILITY = 1001; type EFFECT_COLLAPSE_TIMER = 1002; type DENSITY_LOW = 1; type DENSITY_MODERATE = 2; type DENSITY_HIGH = 3; type DENSITY_ULTRA = 4; type DensityConstant = DENSITY_LOW | DENSITY_MODERATE | DENSITY_HIGH | DENSITY_ULTRA; ================================================ FILE: src/map.ts ================================================ /** * The options that can be accepted by `findRoute()` and friends. */ interface RouteOptions { /** * This callback 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. * @param roomName The room being considered * @param fromRoomName The room we're coming from * @returns a floating point to steer the route toward a given room, or Infinity to block it entirely. */ routeCallback: (roomName: string, fromRoomName: string) => number; } interface RoomStatusPermanent { status: "normal" | "closed"; timestamp: null; } interface RoomStatusTemporary { status: "novice" | "respawn"; timestamp: number; } type RoomStatus = RoomStatusPermanent | RoomStatusTemporary; /** * A global object representing world map. * * Use it to navigate between rooms. The object is accessible via the {@link 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. */ describeExits(roomName: string): ExitsInformation | null; /** * Find the exit direction from the given room en route to another room. * @param fromRoom Start room name or room object. * @param toRoom Finish room name or room object. * @param opts (optional) An object with the pathfinding options. * @returns The room direction constant, one of the following: * FIND_EXIT_TOP, FIND_EXIT_RIGHT, FIND_EXIT_BOTTOM, FIND_EXIT_LEFT * Or one of the following Result codes: * ERR_NO_PATH, ERR_INVALID_ARGS */ findExit(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; /** * Find route from the given room to another room. * @param fromRoom Start room name or room object. * @param toRoom Finish room name or room object. * @param opts (optional) An object with the pathfinding options. * @returns either an array of room exits / room name, or ERR_NO_PATH if the destination room cannot be reached. */ findRoute(fromRoom: string | Room, toRoom: string | Room, opts?: RouteOptions): { exit: ExitConstant; room: string }[] | ERR_NO_PATH; /** * Get the linear distance (in rooms) between two rooms. * * You can use this function to estimate the energy cost of sending resources through terminals, or using observers and nukes. * @param roomName1 The name of the first room. * @param roomName2 The name of the second room. * @param continuous Whether to treat the world map continuous on borders. Set to true if you * want to calculate the trade or terminal send cost. Default is false. */ getRoomLinearDistance(roomName1: string, roomName2: string, continuous?: boolean): number; /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param x X position in the room. * @param y Y position in the room. * @param roomName The room name. * @deprecated use {@link Game.map.getRoomTerrain} instead */ getTerrainAt(x: number, y: number, roomName: string): Terrain; /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param pos The position object. * @deprecated use {@link Game.map.getRoomTerrain} instead */ getTerrainAt(pos: RoomPosition): Terrain; /** * Get room terrain for the specified room. * * This method works for any room in the world even if you have no access to it. * @param roomName String name of the room. */ getRoomTerrain(roomName: string): RoomTerrain; /** * Returns the world size as a number of rooms between world corners. * * For example, for a world with rooms from W50N50 to E50S50 this method will return 102. */ getWorldSize(): number; /** * Check if the room is available to move into. * @param roomName The room name. * @returns A boolean value. * @deprecated Use `Game.map.getRoomStatus` instead */ isRoomAvailable(roomName: string): boolean; /** * Get the room status to determine if it's available, or in a reserved area. * @param roomName The room name. * @returns A {@link RoomStatus} object. */ getRoomStatus(roomName: string): RoomStatus; /** * Map visuals provide a way to show various visual debug info on the game map. * You can use the {@link Game.map.visual} object to draw simple shapes that are visible only to you. * * Map visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. * All `Game.map.visual` calls have no added CPU cost (their cost is natural and mostly related to simple JSON.serialize calls). * However, there is a usage limit: you cannot post more than 1000 KB of serialized data. * * All draw coordinates are measured in global game coordinates (`RoomPosition`). */ visual: MapVisual; } /** * Map visuals provide a way to show various visual debug info on the game map. * * You can use the {@link Game.map.visual} object to draw simple shapes that are visible only to you. * * Map visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. * All `Game.map.visual` calls have no added CPU cost (their cost is natural and mostly related to simple `JSON.serialize` calls). * However, there is a usage limit: you cannot post more than 1000 KB of serialized data. * * All draw coordinates are measured in global game coordinates ({@link RoomPosition}). */ interface MapVisual { /** * Draw a line. * @param pos1 The start position object. * @param pos2 The finish position object. * @param style The optional style * @returns The MapVisual object, for chaining. */ line(pos1: RoomPosition, pos2: RoomPosition, style?: MapLineStyle): MapVisual; /** * Draw a circle. * @param pos The position object of the center. * @param style The optional style * @returns The MapVisual object, for chaining. */ circle(pos: RoomPosition, style?: MapCircleStyle): MapVisual; /** * Draw a rectangle. * @param topLeftPos The position object of the top-left corner. * @param width The width of the rectangle. * @param height The height of the rectangle. * @param style The optional style * @returns The MapVisual object, for chaining. */ rect(topLeftPos: RoomPosition, width: number, height: number, style?: MapPolyStyle): MapVisual; /** * Draw a polyline. * @param points An array of points. Every item should be a `RoomPosition` object. * @param style The optional style * @returns The MapVisual object, for chaining. */ poly(points: RoomPosition[], style?: MapPolyStyle): MapVisual; /** * Draw a text label. You can use any valid Unicode characters, including emoji. * @param text The text message. * @param pos The position object of the label baseline. * @param style The optional style * @returns The MapVisual object, for chaining */ text(text: string, pos: RoomPosition, style?: MapTextStyle): MapVisual; /** * Remove all visuals from the map. * @returns The MapVisual object, for chaining */ clear(): MapVisual; /** * Get the stored size of all visuals added on the map in the current tick. * * It must not exceed 1024,000 (1000 KB). * @returns The size of the visuals in bytes. */ getSize(): number; /** * Returns a compact representation of all visuals added on the map in the current tick. * @returns A string with visuals data. There's not much you can do with the string besides store them for later. */ export(): string; /** * Add previously exported (with {@link Game.map.visual.export}) map visuals to the map visual data of the current tick. * @param data The string returned from `Game.map.visual.export`. * @returns The MapVisual object itself, so that you can chain calls. */ import(data: string): MapVisual; } interface MapLineStyle { /** * Line width. * @default 0.1 */ width?: number; /** * Line color in the following format: #ffffff (hex triplet). * @default #ffffff */ color?: string; /** * Opacity value * @default 0.5 */ opacity?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined. */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface MapPolyStyle { /** * Fill color in the following format: #ffffff (hex triplet). * @default undefined (no fill). */ fill?: string | undefined; /** * Opacity value * @default 0.5 */ opacity?: number; /** * Stroke color in the following format: #ffffff (hex triplet). * @default #ffffff */ stroke?: string; /** * Stroke line width. * @default 0.5 */ strokeWidth?: number; /** * Either undefined (solid line), dashed, or dotted. * @default is undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface MapCircleStyle extends MapPolyStyle { /** * Circle radius. * @default 10 */ radius?: number; } interface MapTextStyle { /** * Font color in the following format: #ffffff (hex triplet). * @default #ffffff */ color?: string; /** * The font family. * @default sans-serif */ fontFamily?: string; /** * The font size in game coordinates. * @default 10 */ fontSize?: number; /** * The font style ('normal', 'italic' or 'oblique') */ fontStyle?: string; /** * The font variant ('normal' or 'small-caps') */ fontVariant?: string; /** * Stroke color in the following format: #ffffff (hex triplet) * @default undefined (no stroke). */ stroke?: string | undefined; /** * Stroke width. * @default 0.15 */ strokeWidth?: number; /** * Background color in the following format: #ffffff (hex triplet). * * When background is enabled, text vertical align is set to middle (default is baseline). * @default undefined (no background). */ backgroundColor?: string | undefined; /** * Background rectangle padding. * @default 2 */ backgroundPadding?: number; /** * Text align, either center, left, or right. * @default center */ align?: "center" | "left" | "right"; /** * Opacity value. * @default 0.5 */ opacity?: number; } ================================================ FILE: src/market.ts ================================================ /** * A global object representing the in-game market. * * You can use this object to track resource transactions to/from your terminals, and your buy/sell orders. * The object is accessible via the singleton {@link Game.market} property. * * Learn more about the market system from [this article](https://docs.screeps.com/market.html). */ interface Market { /** * Your current credits balance. */ credits: number; /** * An array of the last 100 incoming transactions to your terminals */ incomingTransactions: Transaction[]; /** * An object with your active and inactive buy/sell orders on the market. */ orders: { [key: string]: Order }; /** * An array of the last 100 outgoing transactions from your terminals */ outgoingTransactions: Transaction[]; /** * Estimate the energy transaction cost of {@link StructureTerminal.send} and {@link Market.deal} methods. * * The formula: * * ``` * Math.ceil(amount * (1 - Math.exp(-linearDistanceBetweenRooms / 30))) * ``` * * @param amount Amount of resources to be sent. * @param roomName1 The name of the first room. * @param roomName2 The name of the second room. * @returns The amount of energy required to perform the transaction. */ calcTransactionCost(amount: number, roomName1: string, roomName2: string): number; /** * Cancel a previously created order. * * The 5% fee is not returned. * @param orderId The order ID as provided in Game.market.orders * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_INVALID_ARGS: The order ID is not valid. */ cancelOrder(orderId: string): ScreepsReturnCode; /** * Change the price of an existing order. * * If `newPrice` is greater than old price, you will be charged `(newPrice-oldPrice)*remainingAmount*0.05` credits. * @param orderId The order ID as provided in Game.market.orders * @param newPrice The new order price. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ changeOrderPrice(orderId: string, newPrice: number): ScreepsReturnCode; /** * Create a market order in your terminal. * * You will be charged `price*amount*0.05` credits when the order is placed. * * The maximum orders count is 300 per player. You can create an order at any time with any amount, * it will be automatically activated and deactivated depending on the resource/credits availability. * * An order expires in 30 days after its creation, and the remaining market fee is returned. * * @param params A object describing the order. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the room's terminal or there is no terminal. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_FULL: You cannot create more than 50 orders. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ createOrder(params: CreateOrderParam): ScreepsReturnCode; /** * Execute a trade deal from your Terminal to another player's Terminal using the specified buy/sell order. * * Your Terminal will be charged energy units of transfer cost regardless of the order resource type. * You can use {@link Game.market.calcTransactionCost} method to estimate it. * * When multiple players try to execute the same deal, the one with the shortest distance takes precedence. * * You cannot execute more than 10 deals during one tick. * * @param orderId The order ID as provided in Game.market.orders * @param amount The amount of resources to transfer. * @param yourRoomName The name of your room which has to contain an active Terminal with enough amount of energy. * This argument is not used when the order resource type is one of account-bound resources (@see {@link InterShardResourceConstant}). * * @returns One of the following error codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have a terminal in the target room. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits or resource units. * - ERR_FULL: You cannot execute more than 10 deals during one tick. * - ERR_INVALID_ARGS: The arguments provided are invalid. * - ERR_TIRED: The target terminal is still cooling down. */ deal(orderId: string, amount: number, yourRoomName?: string): ScreepsReturnCode; /** * Add more capacity to an existing order. * * It will affect `remainingAmount` and `totalAmount` properties. You will be charged `price*addAmount*0.05` credits. * Extending the order doesn't update its expiration time. * * @param orderId The order ID as provided in Game.market.orders * @param addAmount How much capacity to add. Cannot be a negative value. * @returns One of the following error codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_ENOUGH_RESOURCES: You don't have enough credits to pay a fee. * - ERR_INVALID_ARGS: The arguments provided are invalid. */ extendOrder(orderId: string, addAmount: number): ScreepsReturnCode; /** * Get other players' orders currently active on the market. * @param filter (optional) An object or function that will filter the resulting list using the lodash.filter method. * @returns An array of objects containing order information. */ getAllOrders(filter?: OrderFilter | ((o: Order) => boolean)): Order[]; /** * Get daily price history of the specified resource on the market for the last 14 days. * @param resource One of the {@link MarketResourceConstant RESOURCE_*} constants. If undefined, returns history data for all resources. Optional * @returns An array of objects with resource info. */ getHistory(resource?: MarketResourceConstant): PriceHistory[]; /** * Retrieve info for specific market order. * @param orderId The order ID. * @returns An object with the order info. See {@link Order}. */ getOrderById(id: string): Order | null; } // No static is available interface Transaction { transactionId: string; time: number; sender?: { username: string }; recipient?: { username: string }; resourceType: MarketResourceConstant; amount: number; from: string; to: string; description: string; order?: TransactionOrder; } interface Order { /** The unique order ID. */ id: string; /** * The order creation time in milliseconds since UNIX epoch time. * * This property is absent for old orders. */ created: number; /** Whether the order is active or not. * * Only exists for your own orders. */ active?: boolean; /** The order type. */ type: ORDER_BUY | ORDER_SELL; /** * The type of resource requested by the order. See {@link MarketResourceConstant}. */ resourceType: MarketResourceConstant; /** The room where this order is placed. */ roomName?: string; /** Currently available quantity of resource to trade. */ amount: number; /** Remaining quantity of resources to trade. */ remainingAmount: number; /** Total quantity of resources traded */ totalAmount?: number; /** The current price per unit. */ price: number; } interface TransactionOrder { id: string; type: string; price: number; } interface OrderFilter { id?: string; created?: number; type?: string; resourceType?: MarketResourceConstant; roomName?: string; amount?: number; remainingAmount?: number; price?: number; } interface PriceHistory { resourceType: MarketResourceConstant; date: string; transactions: number; volume: number; avgPrice: number; stddevPrice: number; } /** Parameters to {@link Game.market.createOrder} */ interface CreateOrderParam { /** * The order type. */ type: ORDER_BUY | ORDER_SELL; /** * The resource type to trade. * * If your Terminal doesn't have the specified resource, the order will be temporary inactive. */ resourceType: MarketResourceConstant; /** * The price for one resource unit in credits. * * Can be a decimal number. */ price: number; /** * The amount of resources to be traded in total. */ totalAmount: number; /** * The room where your order will be created. * * You must have your own Terminal structure in this room, otherwise the created order will be temporary inactive. * This argument is not used when `resourceType` is one of the {@link InterShardResourceConstant} resources. */ roomName?: string; } ================================================ FILE: src/memory.ts ================================================ interface Memory { creeps: { [name: string]: CreepMemory }; powerCreeps: { [name: string]: PowerCreepMemory }; flags: { [name: string]: FlagMemory }; rooms: { [name: string]: RoomMemory }; spawns: { [name: string]: SpawnMemory }; } interface CreepMemory {} interface FlagMemory {} interface PowerCreepMemory {} interface RoomMemory {} interface SpawnMemory {} declare const Memory: Memory; ================================================ FILE: src/mineral.ts ================================================ /** * A mineral deposit. * * Can be harvested by creeps with a WORK body part using the extractor structure. * Learn more about minerals from [this article](http://docs.screeps.com/api/#Mineral). * * * | | | * | ---------------------------| ---------------------------- | * | Regeneration amount | DENSITY_LOW: 15,000 * | | DENSITY_MODERATE: 35,000 * | | DENSITY_HIGH: 70,000 * | | DENSITY_ULTRA: 100,000 * | Regeneration time | 50,000 ticks * | Density change probability | DENSITY_LOW: 100% chance * | | DENSITY_MODERATE: 5% chance * | | DENSITY_HIGH: 5% chance * | | DENSITY_ULTRA: 100% chance* */ interface Mineral extends RoomObject { /** * The prototype is stored in the Mineral.prototype global object. You can use it to extend game objects behaviour globally. */ readonly prototype: Mineral; /** * The density of this mineral deposit, one of the {@link DensityConstant DENSITY_*} constants. */ density: DensityConstant; /** * The remaining amount of resources. */ mineralAmount: number; /** * The resource type, one of the {@link MineralConstant RESOURCE_*} constants. */ mineralType: T; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * The remaining time after which the deposit will be refilled if is recharging, otherwise undefined. */ ticksToRegeneration?: number; } interface MineralConstructor extends _Constructor, _ConstructorById {} declare const Mineral: MineralConstructor; ================================================ FILE: src/nuke.ts ================================================ /** * A nuke landing position. * * This object cannot be removed or modified. You can find incoming nukes in the room using the {@link FIND_NUKES} constant. * * Landing time: 50,000 ticks * All creeps, construction sites and dropped resources in the room are removed immediately, even inside ramparts. * * Damage to structures: * - 10,000,000 hits at the landing position; * - 5,000,000 hits to all structures in 5x5 area. * * Note that you can stack multiple nukes from different rooms at the same target position to increase damage. * * Nuke landing does not generate tombstones and ruins, and destroys all existing tombstones and ruins in the room. * * If the room is in safe mode, then the safe mode is cancelled immediately, and the safe mode cooldown is reset to 0. * * The room controller is hit by triggering {@link StructureController.upgradeBlocked} period, which means it is unavailable to activate safe mode again within the next 200 ticks. */ interface Nuke extends RoomObject { readonly prototype: Nuke; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The name of the room where this nuke has been launched from. */ launchRoomName: string; /** * The remaining landing time. */ timeToLand: number; } interface NukeConstructor extends _Constructor, _ConstructorById {} declare const Nuke: NukeConstructor; ================================================ FILE: src/path-finder.ts ================================================ /** * Contains powerful methods for pathfinding in the game world. * * This module is written in fast native C++ code and supports custom navigation costs and paths which span multiple rooms. * * Additionally PathFinder can search for paths through rooms you can't see, although you won't be able to detect any dynamic obstacles like creeps or buildings. */ interface PathFinder { /** * Creates a new {@link CostMatrix} containing 0's for all positions. */ CostMatrix: CostMatrixConstructor; /** * Find an optimal path between origin and goal. * * @param origin The start position. * @param goal goal A RoomPosition, an object containing a RoomPosition and range or an array of either. * @param opts An object containing additional pathfinding flags. */ search( origin: RoomPosition, goal: RoomPosition | { pos: RoomPosition; range: number } | Array, opts?: PathFinderOpts, ): PathFinderPath; /** * Specify whether to use this new experimental pathfinder in game objects methods. * This method should be invoked every tick. It affects the following methods behavior: * - {@link Room.findPath} * - {@link RoomPosition.findPathTo} * - {@link RoomPosition.findClosestByPath} * - {@link Creep.moveTo} * * @deprecated This method is deprecated and will be removed soon. * @param isEnabled Whether to activate the new pathfinder or deactivate. */ use(isEnabled: boolean): undefined; } /** * An object containing: * path - An array of RoomPosition objects. * ops - Total number of operations performed before this path was calculated. * cost - The total cost of the path as derived from `plainCost`, `swampCost` and any given CostMatrix instances. * incomplete - 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. */ interface PathFinderPath { /** * An array of {@link RoomPosition} objects. */ path: RoomPosition[]; /** * Total number of operations performed before this path was calculated. */ ops: number; /** * The total cost of the path as derived from `plainCost`, `swampCost` and any given {@link CostMatrix} instances. */ cost: number; /** * 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. */ incomplete: boolean; } /** * An object containing additional pathfinding flags. */ interface PathFinderOpts { /** * Cost for walking on plain positions. * @default 1 */ plainCost?: number; /** * Cost for walking on swamp positions. * @default 5 */ swampCost?: number; /** * 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. * @default false */ flee?: boolean; /** * The maximum allowed pathfinding operations. * * You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU. * @default 2000 */ maxOps?: number; /** * The maximum allowed rooms to search. * @default 16 (also maximum) */ maxRooms?: number; /** * 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. * @default Infinity */ maxCost?: 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! * @default 1.2 */ heuristicWeight?: number; /** * 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 {@link CostMatrix} to speed up your code. * Please read the {@link CostMatrix} documentation below for more information on CostMatrix. * * @param roomName The name of the room the pathfinder needs a cost matrix for. */ roomCallback?(roomName: string): boolean | CostMatrix; } interface CostMatrixConstructor extends _Constructor { new (): CostMatrix; /** * Static method which deserializes a new CostMatrix using the return value of serialize. * @param val Whatever serialize returned */ deserialize(val: number[]): CostMatrix; } /** * 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 {@link PathFinderOpts.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 {@link 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. */ interface CostMatrix { /** * Set the cost of a position in this CostMatrix. * @param x X position in the room. * @param y Y position in the room. * @param cost Cost of this position. Must be a whole number. A cost of 0 will use the terrain cost for that tile. A cost greater than or equal to 255 will be treated as unwalkable. */ set(x: number, y: number, cost: number): undefined; /** * Get the cost of a position in this CostMatrix. * @param x X position in the room. * @param y Y position in the room. */ get(x: number, y: number): number; /** * Copy this CostMatrix into a new CostMatrix with the same data. */ clone(): CostMatrix; /** * Returns a compact representation of this CostMatrix which can be stored via JSON.stringify. */ serialize(): number[]; } declare const PathFinder: PathFinder; ================================================ FILE: src/power-creep.ts ================================================ /** * Power Creeps are immortal "heroes" that are tied to your account and can be respawned in any PowerSpawn after death. * * You can upgrade their abilities ("powers") up to your account Global Power Level (see {@link Game.gpl}). * * | | | * | ----------------- | ---------------- | * | **Time to live** | 5,000 * | **Hits** | 1,000 per level * | **Capacity** | 100 per level * * [Full list of available powers](https://docs.screeps.com/power.html#Powers) */ interface PowerCreep extends RoomObject { /** * An object with the creep's cargo contents. * @deprecated An alias for Creep.store. */ carry: StoreDefinition; /** * The total amount of resources the creep can carry. * @deprecated An alias for Creep.store.getCapacity(). */ carryCapacity: number; /** * The power creep's class, one of the {@link PowerClassConstant POWER_CLASS} constants. */ className: PowerClassConstant; /** * A timestamp when this creeep is marked to be permanently deleted from the account, or undefined otherwise. */ deleteTime: number | undefined; /** * The current amount of hit points of the creep. */ hits: number; /** * The maximum amount of hit points of the creep. */ hitsMax: number; /** * A unique identifier. * * You can use the {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The power creep's level. */ level: number; /** * The power creep's memory. * * A shorthand to `Memory.powerCreeps[creep.name]`. * * You can use it for quick access to the creep's specific memory data object. */ memory: PowerCreepMemory; /** * Whether it is your creep or foe. */ my: boolean; /** * The power creep name. * * You can choose the name while creating a new power creep, and `rename` it while unspawned. * This name is a hash key to access the creep via the {@link Game.powerCreeps} object. */ name: string; /** * An object with the creep's owner information. */ owner: Owner; /** * A Store object that contains cargo of this creep. */ store: StoreDefinition; /** * An object with the creep's available powers. */ powers: PowerCreepPowers; /** * The text message that the creep was saying at the last tick. */ saying: string; /** * The name of the shard where the power creeps is spawned, or undefined. */ shard: string | undefined; /** * The timestamp when spawning or deleting this creep will become available. * * Undefined if the power creep is spawned in the world. * * Note: This is a timestamp, not ticks as powerCreeps are not shard dependent. */ spawnCooldownTime: number | undefined; /** * The remaining amount of game ticks after which the creep will die and become unspawned. * * Undefined if the creep is not spawned in the world. */ ticksToLive: number | undefined; /** * Cancel the order given during the current game tick. * @param methodName Cancel the order given during the current game tick. * @returns One of the following codes: * - OK: The operation has been cancelled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The order with the specified name is not found. */ cancelOrder(methodName: string): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_FOUND; /** * 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-hour delete time is started (see {@link PowerCreep.deleteTime}). * You can cancel deletion by calling `delete(true)`. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The power creep is spawned in the world. */ delete(cancel?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Drop this resource on the ground. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resource units to be dropped. If omitted, all the available carried amount is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of energy. * - ERR_INVALID_ARGS: The resourceType is not a valid {@link ResourceConstant RESOURCE_*} constants. */ drop(resourceType: ResourceConstant, amount?: number): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_ENOUGH_RESOURCES; /** * Enable power usage in this room. * * The room controller should be at adjacent tile. * @param controller The room controller * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_INVALID_TARGET: The target is not a controller structure. * - ERR_NOT_IN_RANGE: The target is too far away. */ enableRoom(controller: StructureController): OK | ERR_NOT_OWNER | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * Move the creep one square in the specified direction or towards a creep that is pulling it. * * Requires the MOVE body part if not being pulled. * @param direction The direction to move in ({@link DirectionConstant `TOP`, `TOP_LEFT`...}) * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_IN_RANGE: The target creep is too far away * - ERR_INVALID_ARGS: The provided direction is incorrect. */ move(direction: DirectionConstant): CreepMoveReturnCode; move(target: Creep): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_NOT_IN_RANGE | ERR_INVALID_ARGS; /** * Move the creep using the specified predefined path. * * @param path A path value as returned from {@link Room.findPath} or {@link RoomPosition.findPathTo} methods. * Both array form and serialized string form are accepted. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The specified path doesn't match the creep's location. * - ERR_INVALID_ARGS: path is not a valid path array. */ moveByPath(path: PathStep[] | RoomPosition[] | string): CreepMoveReturnCode | ERR_NOT_FOUND | ERR_INVALID_ARGS; /** * Find the optimal path to the target within the same room and move to it. * * A shorthand to consequent calls of {@link RoomPosition.findPathTo()} and {@link Creep.move()} methods. * If the target is in another room, then the corresponding exit will be used as a target. * * @param x X position of the target in the room. * @param y Y position of the target in the room. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more info) or one of the following: reusePath, serializeMemory, noPathFinding * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_NO_PATH: No path to the target could be found. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_FOUND: The creep has no memorized path to reuse. * - ERR_INVALID_TARGET: The target provided is invalid. */ moveTo(x: number, y: number, opts?: MoveToOpts): OK | ERR_NOT_OWNER | ERR_NO_PATH | ERR_BUSY | ERR_NOT_FOUND | ERR_INVALID_TARGET; moveTo( target: RoomPosition | { pos: RoomPosition }, opts?: MoveToOpts, ): CreepMoveReturnCode | ERR_NO_PATH | ERR_INVALID_TARGET | ERR_NOT_FOUND; /** * 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. * * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_ARGS; /** * 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. * @param target The target object to be picked up. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_TARGET: The target is not a valid object to pick up. * - ERR_FULL: The creep cannot receive any more resource. * - ERR_NOT_IN_RANGE: The target is too far away. */ pickup(target: Resource): CreepActionReturnCode | ERR_FULL; /** * Rename the power creep. * * It must not be spawned in the world. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_NAME_EXISTS: A power creep with the specified name already exists. * - ERR_BUSY: The power creep is spawned in the world. */ rename(name: string): OK | ERR_NOT_OWNER | ERR_NAME_EXISTS | ERR_BUSY; /** * Instantly restore time to live to the maximum using a Power Spawn or a Power Bank nearby. * * It has to be at adjacent tile. * @param target The target structure * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_INVALID_TARGET: The target is not a valid power bank or power spawn. * - ERR_NOT_IN_RANGE: The target is too far away. */ renew(target: StructurePowerBank | StructurePowerSpawn): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_NOT_IN_RANGE; /** * 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 unless toPublic is true. * @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'. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. */ say(message: string, toPublic?: boolean): OK | ERR_NOT_OWNER | ERR_BUSY; /** * Spawn this power creep in the specified Power Spawn. * @param powerSpawn Your Power Spawn structure * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep or the spawn. * - ERR_BUSY: The power creep is already spawned in the world. * - ERR_INVALID_TARGET: The specified object is not a Power Spawn. * - ERR_TIRED: The power creep cannot be spawned because of the cooldown. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use the spawn. */ spawn(powerSpawn: StructurePowerSpawn): OK | ERR_NOT_OWNER | ERR_BUSY | ERR_INVALID_TARGET | ERR_TIRED | ERR_RCL_NOT_ENOUGH; /** * Kill the power creep immediately. * * It will not be destroyed permanently, but will become unspawned, so that you can `spawn` it again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. */ suicide(): OK | ERR_NOT_OWNER | ERR_BUSY; /** * 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 {@link ResourceConstant RESOURCE_*} constants * @param amount The amount of resources to be transferred. If omitted, all the available carried amount is used. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The target cannot receive any more resources. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ transfer(target: AnyCreep | Structure, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; /** * Upgrade the creep, adding a new power ability to it or increasing the level of the existing power. * * You need one free Power Level in your account to perform this action. * @param power The power ability to upgrade, one of the {@link PowerConstant PWR_*} constants. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_NOT_ENOUGH_RESOURCES: You account Power Level is not enough. * - ERR_FULL: The specified power cannot be upgraded on this creep's level, or the creep reached the maximum level. * - ERR_INVALID_ARGS: The specified power ID is not valid. */ upgrade(power: PowerConstant): OK | ERR_NOT_OWNER | ERR_NOT_ENOUGH_RESOURCES | ERR_FULL | ERR_INVALID_ARGS; /** * Apply one of the creep's powers on the specified target. * * @param power The power ability to use, one of the {@link PowerConstant PWR_*} constants. * @param target A target object in the room. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the creep. * - ERR_BUSY: The creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The creep doesn't have enough resources to use the power. * - ERR_INVALID_TARGET: The specified target is not valid. * - ERR_FULL: The target has the same active effect of a higher level. * - ERR_NOT_IN_RANGE: The specified target is too far away. * - ERR_INVALID_ARGS: Using powers is not enabled on the Room Controller. * - ERR_TIRED: The power ability is still on cooldown. * - ERR_NO_BODYPART: The creep doesn't have the specified power ability. */ usePower(power: PowerConstant, target?: RoomObject): ScreepsReturnCode; /** * Withdraw resources from a structure, tombstone, or ruin. * * 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 {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be transferred. If omitted, all the available amount is used. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this creep, or there is a hostile rampart on top of the target. * - ERR_BUSY: The power creep is not spawned in the world. * - ERR_NOT_ENOUGH_RESOURCES: The target does not have the given amount of resources. * - ERR_INVALID_TARGET: The target is not a valid object which can contain the specified resource. * - ERR_FULL: The creep's carry is full. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The resourceType is not one of the {@link ResourceConstant RESOURCE_*} constants, or the amount is incorrect. */ withdraw(target: Structure | Tombstone | Ruin, resourceType: ResourceConstant, amount?: number): ScreepsReturnCode; } interface PowerCreepConstructor extends _Constructor, _ConstructorById { /** * A static method to create new Power Creep instance in your account. * * It will be added in an unspawned state, use the {@link PowerCreep.spawn} method to spawn it in the world. * * You need one free Power Level in your account to perform this action. * * @param name The name of the power creep. * @param className The class of the new power creep, one of the {@link PowerClassConstant POWER_CLASS} constants */ create(name: string, className: PowerClassConstant): OK | ERR_NAME_EXISTS | ERR_NOT_ENOUGH_RESOURCES; } declare const PowerCreep: PowerCreepConstructor; /** * Available powers, an object with power ID as a key, and the following properties */ interface PowerCreepPowers { [powerID: number]: { /** * Current level of the power */ level: number; /** * Cooldown ticks remaining * * Will be undefined if the power creep is not spawned in the world. */ cooldown: number | undefined; }; } ================================================ FILE: src/raw-memory.ts ================================================ /** * RawMemory object allows to implement your own memory stringifier instead of built-in serializer based on JSON.stringify. * * It also allows to request up to 10 MB of additional memory using asynchronous memory segments feature. * * You can also access memory segments of other players using methods below. */ interface RawMemory { /** * An object with asynchronous memory segments available on this tick. * * Each object key is the segment ID with data in string values. * Use {@link RawMemory.setActiveSegments} to fetch segments on the next tick. Segments data is saved automatically in the end of the tick. */ segments: { [segmentId: number]: string }; /** * An object with a memory segment of another player available on this tick. Use {@link RawMemory.setActiveForeignSegment} to fetch segments on the next tick. */ foreignSegment: { username: string; id: number; data: string; }; /** * @deprecated Use `InterShardMemory` instead. * * A string with a shared memory segment available on every world shard. Maximum string length is 100 KB. * * **Warning:** this segment is not safe for concurrent usage! All shards have shared access to the same instance of * data. When the segment contents is changed by two shards simultaneously, you may lose some data, since the segment * string value is written all at once atomically. You must implement your own system to determine when each shard is * allowed to rewrite the inter-shard memory, e.g. based on mutual exclusions. * */ interShardSegment: string; /** * Get a raw string representation of the Memory object. */ get(): string; /** * Set new memory value. * @param value New memory value as a string. * @throws if the new value is not a string or contains more than `2 * 1024 * 1024` characters. */ set(value: string): undefined; /** * Request memory segments using the list of their IDs. * * Memory segments will become available on the next tick in {@link RawMemory.segments} object. * Segment IDs are a number from 0 to 99. A maximum of 10 segments can be active at the same time. * Subsequent calls to {@link RawMemory.setActiveSegments} overrides previous ones. * * @param ids An array of segment IDs. * @throws if `ids` isn't an array, more than 10 segments are active, or the ids aren't all integers. */ setActiveSegments(ids: number[]): undefined; /** * Request a memory segment of another user. * * The segment should be marked by its owner as public using {@link RawMemory.setPublicSegments}. * * The segment data will become available on the next tick in {@link foreignSegment} object. * * You can only have access to one foreign segment at the same time. * * @param username The name of another user. Pass `null` to clear the foreign segment. * @param id The ID of the requested segment from 0 to 99. If undefined, the user's default public segment is requested as set by {@link RawMemory.setDefaultPublicSegment}. * @throws if `id` is passed and isn't an integer. */ setActiveForeignSegment(username: string | null, id?: number): undefined; /** * Set the specified segment as your default public segment. * * It will be returned if no id parameter is passed to {@link RawMemory.setActiveForeignSegment} by another user. * * @param id The ID of the requested segment from 0 to 99. Pass `null` to clear the foreign segment. * @throws if `id` is passed and isn't an integer. */ setDefaultPublicSegment(id: number | null): undefined; /** * Set specified segments as public. * * Other users will be able to request access to them using {@link setActiveForeignSegment}. * * @param ids An array of segment IDs. Each ID should be a number from 0 to 99. Subsequent calls of {@link RawMemory.setPublicSegments} override previous ones. * @throws if `ids` isn't an array or the ids aren't all integers. */ setPublicSegments(ids: number[]): undefined; } declare const RawMemory: RawMemory; ================================================ FILE: src/resource.ts ================================================ /** * A dropped piece of resource. * * It will decay after a while if not picked up. * Dropped resource pile decays for `ceil(amount/1000)` units per tick. */ interface Resource extends RoomObject { readonly prototype: Resource; /** * The amount of resource units containing. */ amount: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its `id`. */ id: Id; /** * One of the {@link ResourceConstant RESOURCE_*} constants. */ resourceType: T; } interface ResourceConstructor extends _Constructor, _ConstructorById {} declare const Resource: ResourceConstructor; ================================================ FILE: src/room-object.ts ================================================ /** * Any object with a position in a room. * * Almost all game objects prototypes are derived from RoomObject. */ interface RoomObject { readonly prototype: RoomObject; /** * Effects currently being applied to the object. */ effects?: RoomObjectEffect[]; /** * An object representing the position of this object in the room. */ pos: RoomPosition; /** * The link to the {@link Room} object. * * May be `undefined` if the object is a {@link Flag} or a {@link ConstructionSite} and is placed in a room that is not visible * to you. */ room: Room | undefined; } interface RoomObjectConstructor extends _Constructor { new (x: number, y: number, roomName: string): RoomObject; (x: number, y: number, roomName: string): RoomObject; } declare const RoomObject: RoomObjectConstructor; /** * Discriminated union of possible effects on `effect` */ type RoomObjectEffect = NaturalEffect | PowerEffect; /** * Natural effect applied to room object */ interface NaturalEffect { /** * Effect ID of the applied effect. * * One of the {@link EffectConstant EFFECT_*} constants. */ effect: EffectConstant; /** * How many ticks will the effect last. */ ticksRemaining: number; } /** * Effect applied to room object as result of a {@link PowerCreep.usePower}. */ interface PowerEffect { /** * Power level of the applied effect. */ level: number; /** * Effect ID of the applied effect. * * One of the {@link PowerConstant PWR_*} constants. */ effect: PowerConstant; /** * Power ID of the applied effect. * * @deprecated Use {@link PowerEffect.effect} instead. * * One of the {@link PowerConstant PWR_*} constants. */ power: PowerConstant; /** * How many ticks will the effect last. */ ticksRemaining: number; } ================================================ FILE: src/room-position.ts ================================================ /** * An object representing the specified position in the room. * * Every object in the room contains one of these as its `pos` property. * * The position object of a custom location can be obtained using the {@link Room.getPositionAt()} method or using the constructor. */ interface RoomPosition { readonly prototype: RoomPosition; /** * The name of the room. */ roomName: string; /** * X position in the room. */ x: number; /** * Y position in the room. */ y: number; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have ownership of the targetted room. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(structureType: BuildableStructureConstant): ScreepsReturnCode; /** * Create a new {@link ConstructionSite} at the specified location. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @param name The name of the structure, for structures that support it (currently only spawns). The name length limit is 100 characters. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You don't have ownership of the targetted room. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create a new {@link Flag} at the specified location. * @param name The name of a new flag. * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * If not defined, a random name will be generated. * @param color The color of a new flag. Should be one of the {@link ColorConstant COLOR_*} constants * @param secondaryColor The secondary color of a new flag. Should be one of the {@link ColorConstant COLOR_*} constants. The default value is equal to color. * @returns The name of the flag if created, or one of the following error codes: ERR_NAME_EXISTS, ERR_INVALID_ARGS */ createFlag(name?: string, color?: ColorConstant, secondaryColor?: ColorConstant): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Find the object with the shortest path from the given position. * * Uses A* search algorithm and Dijkstra's algorithm. * @param type Any of the {@link FindConstant FIND_*} constants. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm * @returns An instance of a RoomObject. */ findClosestByPath( type: K, opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm }, ): S | null; findClosestByPath( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm }, ): S | null; /** * Find the object with the shortest path from the given position. * * Uses A* search algorithm and Dijkstra's algorithm. * @param objects An array of RoomPositions or objects with a RoomPosition * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm * @returns One of the supplied objects */ findClosestByPath( objects: T[], opts?: FindPathOpts & FilterOptions & { algorithm?: FindClosestByPathAlgorithm; }, ): S | null; /** * Find the object with the shortest linear distance from the given position. * @param type Any of the {@link FindConstant FIND_*} constants. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm */ findClosestByRange(type: K, opts?: FilterOptions): S | null; findClosestByRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FilterOptions, ): S | null; /** * Find the object with the shortest linear distance from the given position. * @param objects An array of RoomPositions or objects with a RoomPosition. * @param opts An object containing pathfinding options (see {@link Room.findPath}), or one of the following: filter, algorithm */ findClosestByRange(objects: T[], opts?: FilterOptions): S | null; /** * Find all objects in the specified linear range. * @param type Any of the {@link FindConstant FIND_*} constants. * @param range The range distance. * @param opts See Room.find. */ findInRange(type: K, range: number, opts?: FilterOptions): S[]; findInRange( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, range: number, opts?: FilterOptions, ): S[]; /** * Find all objects in the specified linear range. * @param objects An array of room's objects or RoomPosition objects that the search should be executed against. * @param range The range distance. * @param opts See {@link Room.find}. */ findInRange(objects: T[], range: number, opts?: FilterOptions): S[]; /** * Find an optimal path to the specified position using A* search algorithm. * * This method is a shorthand for {@link Room.findPath}. If the target is in another room, then the corresponding exit will be used as a target. * @param x X position in the room. * @param y Y position in the room. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more details). */ findPathTo(x: number, y: number, opts?: FindPathOpts): PathStep[]; /** * Find an optimal path to the specified position using A* search algorithm. * * This method is a shorthand for {@link Room.findPath}. If the target is in another room, then the corresponding exit will be used as a target. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @param opts An object containing pathfinding options flags (see {@link Room.findPath} for more details). */ findPathTo(target: RoomPosition | _HasRoomPosition, opts?: FindPathOpts): PathStep[]; /** * Get linear direction to the specified position. * @param x X position in the room. * @param y Y position in the room. */ getDirectionTo(x: number, y: number): DirectionConstant; /** * Get linear direction to the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ getDirectionTo(target: RoomPosition | _HasRoomPosition): DirectionConstant; /** * Get linear range to the specified position. * @param x X position in the room. * @param y Y position in the room. */ getRangeTo(x: number, y: number): number; /** * Get linear range to the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ getRangeTo(target: RoomPosition | { pos: RoomPosition }): number; /** * Check whether this position is in the given range of another position. * @param x X position in the room. * @param y Y position in the room. * @param range The range distance. */ inRangeTo(x: number, y: number, range: number): boolean; /** * Check whether this position is in the given range of another position. * @param toPos The target position. * @param range The range distance. */ inRangeTo(target: RoomPosition | { pos: RoomPosition }, range: number): boolean; /** * Check whether this position is the same as the specified position. * @param x X position in the room. * @param y Y position in the room. */ isEqualTo(x: number, y: number): boolean; /** * Check whether this position is the same as the specified position. * @param target Can be a RoomPosition object or any object containing RoomPosition. */ isEqualTo(target: RoomPosition | { pos: RoomPosition }): boolean; /** * Check whether this position is on the adjacent square to the specified position. * * Equivalent to `inRangeTo(target, 1)`. * @param x X position in the room. * @param y Y position in the room. */ isNearTo(x: number, y: number): boolean; /** * Check whether this position is on the adjacent square to the specified position. * * Equivalent to inRangeTo(target, 1). * @param target Can be a RoomPosition object or any object containing RoomPosition. */ isNearTo(target: RoomPosition | { pos: RoomPosition }): boolean; /** * Get the list of objects at the specified room position. */ look(): LookAtResult[]; /** * Get an object with the given type at the specified room position. * @param type One of the following string constants: constructionSite, creep, exit, flag, resource, source, structure, terrain */ lookFor(type: T): Array; } interface RoomPositionConstructor extends _Constructor { /** * You can create new RoomPosition object using its constructor. * @param x X position in the room. * @param y Y position in the room. * @param roomName The room name. * @throws if `x` or `y` are out of bounds, or `roomName` isn't a valid room name. */ new (x: number, y: number, roomName: string): RoomPosition; (x: number, y: number, roomName: string): RoomPosition; } declare const RoomPosition: RoomPositionConstructor; ================================================ FILE: src/room-terrain.ts ================================================ /** * 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. */ interface RoomTerrain { /** * Get terrain type at the specified room position. * * This method works for any room in the world even if you have no access to it. * @param x X position in the room. * @param y Y position in the room. * @return A bitmask of {@link TERRAIN_MASK_WALL}, {@link TERRAIN_MASK_SWAMP}. */ get(x: number, y: number): 0 | TERRAIN_MASK_WALL | TERRAIN_MASK_SWAMP; /** * Get a copy of the underlying static terrain buffer. * @param destinationArray (optional) A typed array view in which terrain will be copied to. * @throws {RangeError} if `destinationArray` is provided, it must have a length of at least 2500 (`50*50`). * @return Copy of underlying room terrain as a new typed array of size 2500. */ getRawBuffer< T extends | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array, >( destinationArray: T, ): T; getRawBuffer(): Uint8Array; } interface RoomTerrainConstructor extends _Constructor { /** * Get room terrain for the specified room. * * This method works for any room in the world even if you have no access to it. * @param roomName String name of the room. */ new (roomName: string): RoomTerrain; } ================================================ FILE: src/room-visual.ts ================================================ /** * Room visuals provide a way to show various visual debug info in game rooms. * * You can use the RoomVisual object to draw simple shapes that are visible only to you. * Every existing Room object already contains the visual property, but you also can create new RoomVisual objects for any room (even without visibility) using the constructor. * * Room visuals are not stored in the database, their only purpose is to display something in your browser. * All drawings will persist for one tick and will disappear if not updated. All RoomVisual API calls have no added CPU cost (their cost is natural and mostly related to simple `JSON.serialize` calls). * However, there is a usage limit: you cannot post more than 500 KB of serialized data per one room (see {@link RoomVisual.getSize} method). * * All draw coordinates are measured in game coordinates and centered to tile centers, i.e. (10,10) will point to the center of the creep at x:10; y:10 position. * Fractional coordinates are allowed. */ declare class RoomVisual { /** * You can create new RoomVisual object using its constructor. * @param roomName The room name. If undefined, visuals will be posted to all rooms simultaneously. */ constructor(roomName?: string); /** * The name of the room. */ roomName: string; /** * Draw a line. * @param x1 The start X coordinate. * @param y1 The start Y coordinate. * @param x2 The finish X coordinate. * @param y2 The finish Y coordinate. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ line(x1: number, y1: number, x2: number, y2: number, style?: LineStyle): RoomVisual; /** * Draw a line. * @param pos1 The start position object. * @param pos2 The finish position object. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ line(pos1: RoomPosition, pos2: RoomPosition, style?: LineStyle): RoomVisual; /** * Draw a circle. * @param x The X coordinate of the center. * @param y The Y coordinate of the center. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ circle(x: number, y: number, style?: CircleStyle): RoomVisual; /** * Draw a circle. * @param pos The position object of the center. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ circle(pos: RoomPosition, style?: CircleStyle): RoomVisual; /** * Draw a rectangle. * @param x The X coordinate of the top-left corner. * @param y The Y coordinate of the top-left corner. * @param w The width of the rectangle. * @param h The height of the rectangle. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ rect(x: number, y: number, w: number, h: number, style?: PolyStyle): RoomVisual; /** * Draw a line. * @param topLeftPos The position object of the top-left corner. * @param width The width of the rectangle. * @param height The height of the rectangle. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ rect(topLeftPos: RoomPosition, width: number, height: number, style?: PolyStyle): RoomVisual; /** * Draw a polygon. * @param points An array of points. Every array item should be either an array with 2 numbers (i.e. [10,15]), or a RoomPosition object. * @param style The (optional) style. * @returns The RoomVisual object, for chaining. */ poly(points: Array<[number, number] | RoomPosition>, style?: PolyStyle): RoomVisual; /** * Draw a text label. * @param text The text message. * @param x The X coordinate of the label baseline center point. * @param y The Y coordinate of the label baseline center point. * @param style The (optional) text style. * @returns The RoomVisual object, for chaining. */ text(text: string, x: number, y: number, style?: TextStyle): RoomVisual; /** * Draw a text label. * * You can use any valid Unicode characters, including emoji. * @param text The text message. * @param pos The position object of the center. * @param style An object describing the style. * @returns The RoomVisual object itself, so that you can chain calls. */ text(text: string, pos: RoomPosition, style?: TextStyle): RoomVisual; /** * Remove all visuals from the room. * @returns The RoomVisual object, for chaining. */ clear(): RoomVisual; /** * Get the stored size of all visuals added in the room in the current tick. * It must not exceed 512,000 (500 KB). * @returns The size of the visuals in bytes. */ getSize(): number; /** * Returns a compact representation of all visuals added in the room in the current tick. * @returns A string with visuals data. There's not much you can do with the string besides store them for later. */ export(): string; /** * Add previously exported (with {@link RoomVisual.export}) room visuals to the room visual data of the current tick. * @param data The string returned from `RoomVisual.export`. * @returns The RoomVisual object itself, so that you can chain calls. */ import(data: string): RoomVisual; } interface LineStyle { /** * Line width. * @default 0.1 */ width?: number; /** * Line color in any web format. * @default #ffffff (white) */ color?: string; /** * Opacity value. * @default 0.5 */ opacity?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface PolyStyle { /** * Fill color in any web format. * @default undefined (no fill). */ fill?: string | undefined; /** * Opacity value, default is 0.5. */ opacity?: number; /** * Stroke color in any web format. * @default #ffffff (white) */ stroke?: string; /** * Stroke line width. * @default 0.1 */ strokeWidth?: number; /** * Either undefined (solid line), dashed, or dotted. * @default undefined */ lineStyle?: "dashed" | "dotted" | "solid" | undefined; } interface CircleStyle extends PolyStyle { /** * Circle radius. * @default 0.15 */ radius?: number; } interface TextStyle { /** * Font color in any web format. * @default #ffffff (white) */ color?: string; /** * Either a number or a string in one of the following forms: * - 0.7 - relative size in game coordinates * - 20px - absolute size in pixels * - 0.7 serif * - bold italic 1.5 Times New Roman */ font?: number | string; /** * Stroke color in any web format. * @default undefined (no stroke) */ stroke?: string | undefined; /** * Stroke width. * @default 0.15 */ strokeWidth?: number; /** * Background color in any web format. * When background is enabled, text vertical align is set to middle (default is baseline). * @default undefined (no background) */ backgroundColor?: string | undefined; /** * Background rectangle padding * @default 0.3 */ backgroundPadding?: number; align?: "center" | "left" | "right"; /** * Opacity value. * @default 1.0 */ opacity?: number; } ================================================ FILE: src/room.ts ================================================ /** * An object representing the room in which your units and structures are in. * * It can be used to look around, find paths, etc. * * Every object in the room contains its linked Room instance in the {@link RoomObject.room} property. */ interface Room { readonly prototype: Room; /** * The Controller structure of this room, if present, otherwise undefined. */ controller?: StructureController; /** * Total amount of energy available in all spawns and extensions in the room. */ energyAvailable: number; /** * Total amount of energyCapacity of all spawns and extensions in the room. */ energyCapacityAvailable: number; /** * Returns an array of events happened on the previous tick in this room. */ getEventLog(raw?: false): EventItem[]; /** * Returns an raw JSON string of events happened on the previous tick in this room. */ getEventLog(raw: true): string; /** * The room's memory. * * A shorthand to `Memory.rooms[room.name]`. You can use it for quick access the room’s specific memory data object. */ memory: RoomMemory; /** * The name of the room. */ readonly name: string; /** * The {@link StructureStorage} of this room, if present, otherwise undefined. */ storage?: StructureStorage; /** * The {@link StructureTerminal} of this room, if present, otherwise undefined. */ terminal?: StructureTerminal; /** * A {@link RoomVisual} object for this room. * * You can use this object to draw simple shapes (lines, circles, text labels) in the room. */ visual: RoomVisual; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position * @param y The Y position * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(x: number, y: number, structureType: BuildableStructureConstant): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: StructureConstant): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param x The X position * @param y The Y position * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(x: number, y: number, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create new {@link ConstructionSite} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param structureType One of {@link BuildableStructureConstant Buildable STRUCTURE_*}. * @returns * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: The room is claimed or reserved by a hostile player. * - ERR_INVALID_TARGET: The structure cannot be placed at the specified location. * - ERR_FULL: You have too many construction sites. The maximum number of construction sites per player is 100. * - ERR_INVALID_ARGS: The location is incorrect. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient. */ createConstructionSite(pos: RoomPosition | _HasRoomPosition, structureType: STRUCTURE_SPAWN, name?: string): ScreepsReturnCode; /** * Create new {@link Flag} at the specified location. * @param x The X position. * @param y The Y position. * @param name (optional) The name of a new flag. * * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * * If not defined, a random name will be generated. * * The maximum length is 60 characters. * @param color The color of a new flag. Should be one of the COLOR_* constants. The default value is COLOR_WHITE. * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: * - ERR_NAME_EXISTS: There is a flag with the same name already. * - ERR_FULL: You have too many flags. The maximum number of flags per player is 10000. * - ERR_INVALID_ARGS: The location or the name or the color constant is incorrect. */ createFlag( x: number, y: number, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Create new {@link Flag} at the specified location. * @param pos Can be a {@link RoomPosition} object or any object containing RoomPosition. * @param name (optional) The name of a new flag. * * It should be unique, i.e. the Game.flags object should not contain another flag with the same name (hash key). * * If not defined, a random name will be generated. * * The maximum length is 60 characters. * @param color The color of a new flag. Should be one of the COLOR_* constants. The default value is COLOR_WHITE. * @param secondaryColor The secondary color of a new flag. Should be one of the COLOR_* constants. The default value is equal to color. * @returns The name of a new flag, or one of the following error codes: * - ERR_NAME_EXISTS: There is a flag with the same name already. * - ERR_FULL: You have too many flags. The maximum number of flags per player is 10000. * - ERR_INVALID_ARGS: The location or the name or the color constant is incorrect. */ createFlag( pos: RoomPosition | { pos: RoomPosition }, name?: string, color?: ColorConstant, secondaryColor?: ColorConstant, ): ERR_NAME_EXISTS | ERR_INVALID_ARGS | string; /** * Find all objects of the specified type in the room. * @param type One of the {@link FindConstant FIND_*} constants. * @param opts An object with additional options * @returns An array with the objects found. */ find(type: K, opts?: FilterOptions): S[]; find( type: FIND_STRUCTURES | FIND_MY_STRUCTURES | FIND_HOSTILE_STRUCTURES, opts?: FilterOptions, ): S[]; /** * Find the exit direction en route to another room. * @param room Another room name or room object. * @returns The room direction constant, one of the following: FIND_EXIT_TOP, FIND_EXIT_RIGHT, FIND_EXIT_BOTTOM, FIND_EXIT_LEFT * Or one of the following error codes: ERR_NO_PATH, ERR_INVALID_ARGS */ findExitTo(room: string | Room): ExitConstant | ERR_NO_PATH | ERR_INVALID_ARGS; /** * Find an optimal path inside the room between fromPos and toPos using A* search algorithm. * @param fromPos The start position. * @param toPos The end position. * @param opts (optional) An object containing additional pathfinding flags * @returns An array with path steps */ findPath(fromPos: RoomPosition, toPos: RoomPosition, opts?: FindPathOpts): PathStep[]; /** * Creates a {@link RoomPosition} object at the specified location. * @param x The X position. * @param y The Y position. * @returns A RoomPosition object or null if it cannot be obtained. */ getPositionAt(x: number, y: number): RoomPosition | null; /** * Get a {@link RoomTerrain} object which provides fast access to static terrain data. * * This method works for any room in the world even if you have no access to it. */ getTerrain(): RoomTerrain; /** * Get the list of objects at the specified room position. * @param x The X position. * @param y The Y position. * @returns An array with objects at the specified position * @throws if `x` or `y` are out of bounds. */ lookAt(x: number, y: number): LookAtResult[]; /** * Get the list of objects at the specified room position. * @param target Can be a RoomPosition object or any object containing RoomPosition. * @returns An array with objects at the specified position */ lookAt(target: RoomPosition | { pos: RoomPosition }): LookAtResult[]; /** * Get the list of objects at the specified room area. * * This method is more CPU efficient in comparison to multiple {@link Room.lookAt} calls. * @param top The top Y boundary of the area. * @param left The left X boundary of the area. * @param bottom The bottom Y boundary of the area. * @param right The right X boundary of the area. * @param asArray Set to true if you want to get the result as a plain array. * @returns An object with all the objects in the specified area */ lookAtArea(top: number, left: number, bottom: number, right: number, asArray?: false): LookAtResultMatrix; lookAtArea(top: number, left: number, bottom: number, right: number, asArray: true): LookAtResultWithPos[]; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param x The X position. * @param y The Y position. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ lookForAt(type: T, x: number, y: number): Array; /** * Get the objects at the given position. * * @param type One of the {@link LookConstant LOOK_*} constants. * @param target A RoomPosition. Its room name will be ignored. * @returns An array of objects of the requested type at the given position, or ERR_INVALID_ARGS. */ lookForAt(type: T, target: RoomPosition | _HasRoomPosition): Array; /** * Get the given objects in the supplied area. * @param type One of the {@link LookConstant LOOK_*} constants * @param top The top (Y) boundary of the area. * @param left The left (X) boundary of the area. * @param bottom The bottom (Y) boundary of the area. * @param right The right(X) boundary of the area. * @param asArray Flatten the results into an array? * @returns Either an array of found objects with an x & y property or a nested object keyed by x, then y coordinate. */ lookForAtArea( type: T, top: number, left: number, bottom: number, right: number, asArray?: false, ): LookForAtAreaResultMatrix; lookForAtArea( type: T, top: number, left: number, bottom: number, right: number, asArray: true, ): LookForAtAreaResultArray; } interface RoomConstructor extends _Constructor { new (id: string): Room; Terrain: RoomTerrainConstructor; /** * Serialize a path array into a short string representation, which is suitable to store in memory. * @param path A path array retrieved from {@link Room.findPath}. * @returns A serialized string form of the given path. */ serializePath(path: PathStep[]): string; /** * Deserialize a short string path representation into an array form. * @param path A serialized path string. * @returns A path array. */ deserializePath(path: string): PathStep[]; } declare const Room: RoomConstructor; ================================================ FILE: src/ruin.ts ================================================ /** * A destroyed structure. * * This is a walkable object. * * Usually decays in 500 ticks except some special cases. */ interface Ruin extends RoomObject { /** * A unique object identifier. * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * Time of destruction. */ destroyTime: number; /** * An object with the ruin contents. */ store: StoreDefinitionUnlimited; /** * The amount of game ticks before this ruin decays. */ ticksToDecay: number; /** * An object containing the destroyed structure. */ structure: AnyStructure; } interface RuinConstructor extends _Constructor, _ConstructorById {} declare const Ruin: RuinConstructor; ================================================ FILE: src/source.ts ================================================ /** * An energy source object. * * Can be harvested by creeps with a WORK body part. * * | | | * | ------------------- | ---------------------------------- | * | Energy amount | 4000 in center rooms * | | 3000 in an owned or reserved room * | | 1500 in an unreserved room * | Energy regeneration | Every 300 game ticks */ interface Source extends RoomObject { /** * The prototype is stored in the Source.prototype global object. You can use it to extend game objects behaviour globally: */ readonly prototype: Source; /** * The remaining amount of energy. */ energy: number; /** * The total amount of energy in the source. * * Equals to 3000 in most cases. */ energyCapacity: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The room the source is in. */ room: Room; /** * The remaining time after which the source will be refilled. */ ticksToRegeneration: number; } interface SourceConstructor extends _Constructor, _ConstructorById {} declare const Source: SourceConstructor; ================================================ FILE: src/spawn.ts ================================================ /** * Spawns are your colony centers. * * This structure can create, renew, and recycle creeps. * All your spawns are accessible through {@link Game.spawns} hash list. * Spawns auto-regenerate a little amount of energy each tick, so that you can easily recover even if all your creeps died. * * | Controller level | | * | ---------------- | -------- | * | 1-6 | 1 spawn | * | 7 | 2 spawns | * | 8 | 3 spawns | * * | | | * | ----------------------------- | ------------- | * | **Cost** | 15,000 * | **Hits** | 5,000 * | **Capacity** | 300 * | **Spawn time** | 3 ticks per each body part * | **Energy auto-regeneration** | 1 energy unit per tick while energy available | in the room (in all spawns and extensions) is less than 300 */ interface StructureSpawn extends OwnedStructure { readonly prototype: StructureSpawn; /** * The amount of energy containing in the spawn. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the spawn can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The spawn memory. * * A shorthand to `Memory.spawns[spawn.name]`. You can use it for quick access the spawn’s specific memory data object. * * @see http://docs.screeps.com/global-objects.html#Memory-object */ memory: SpawnMemory; /** * The spawn name. * * You choose the name upon creating a new spawn, and it cannot be changed later. * This name is a hash key to access the spawn via the {@link Game.spawns} object. */ name: string; /** * If the spawn is in process of spawning a new creep, this object will contain the new creep’s information, or null otherwise. */ spawning: Spawning | null; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Check if a creep can be created. * * @deprecated This method is deprecated and will be removed soon. Please use {@link StructureSpawn.spawnCreep} with `dryRun` flag instead. * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. * * It should be unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * * If not defined, a random name will be generated. * @returns One of the following codes: * - OK: A creep with the given body and name can be created. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ canCreateCreep(body: BodyPartConstant[], name?: string): ScreepsReturnCode; /** * Start the creep spawning process. * * @deprecated This method is deprecated and will be removed soon. Please use {@link StructureSpawn.spawnCreep} instead. * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. * * It should be unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * * If not defined, a random name will be generated. * @param memory The memory of a new creep. If provided, it will be immediately stored into Memory.creeps[name]. * @returns The name of a new creep or one of these error codes: * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is not enough to use this spawn. */ createCreep(body: BodyPartConstant[], name?: string, memory?: CreepMemory): ScreepsReturnCode | string; /** * Start the creep spawning process. The required energy amount can be withdrawn from all spawns and extensions in the room. * * @param body An array describing the new creep’s body. Should contain 1 to 50 elements with one of the {@link BodyPartConstant} constants: * - WORK * - MOVE * - CARRY * - ATTACK * - RANGED_ATTACK * - HEAL * - TOUGH * - CLAIM * @param name The name of a new creep. It must be a unique creep name, i.e. the Game.creeps object should not contain another creep with the same name (hash key). * @param opts An object with additional options for the spawning process. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_NAME_EXISTS: There is a creep with the same name already. * - ERR_BUSY: The spawn is already in process of spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn and its extensions contain not enough energy to create a creep with the given body. * - ERR_INVALID_ARGS: Body is not properly described or name was not provided. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ spawnCreep(body: BodyPartConstant[], name: string, opts?: SpawnOptions): ScreepsReturnCode; /** * Increase the remaining time to live of the target creep. * * The target should be at adjacent square. * * The spawn should not be busy with the spawning process. * * Each execution increases the creep's timer by amount of ticks according to this formula: `floor(600/body_size)`. * * Energy required for each execution is determined using this formula: `ceil(creep_cost/2.5/body_size)`. * @param target The target creep object. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of the spawn, or the creep. * - ERR_BUSY: The spawn is spawning another creep. * - ERR_NOT_ENOUGH_ENERGY: The spawn does not have enough energy. * - ERR_INVALID_TARGET: The specified target object is not a creep, or the creep has CLAIM body part. * - ERR_FULL: The target creep's time to live timer is full. * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ renewCreep(target: Creep): ScreepsReturnCode; /** * Kill the creep and drop up to 100% of resources spent on its spawning and boosting depending on remaining life time. * * The target should be at adjacent square. Energy return is limited to 125 units per body part. * * @param target The target creep object. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn or the target creep. * - ERR_INVALID_TARGET: The specified target object is not a creep. * - ERR_NOT_IN_RANGE: The target creep is too far away. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use this spawn. */ recycleCreep(target: Creep): ScreepsReturnCode; } interface StructureSpawnConstructor extends _Constructor, _ConstructorById { Spawning: SpawningConstructor; } declare const StructureSpawn: StructureSpawnConstructor; declare const Spawn: StructureSpawnConstructor; // legacy alias // declare type Spawn = StructureSpawn; interface Spawning { readonly prototype: Spawning; /** * An array with the spawn directions * * @see http://docs.screeps.com/api/#StructureSpawn.Spawning.setDirections */ directions?: DirectionConstant[]; /** * The name of the creep */ name: string; /** * Time needed in total to complete the spawning. */ needTime: number; /** * Remaining time to go. */ remainingTime: number; /** * A link to the spawn */ spawn: StructureSpawn; /** * Cancel spawning immediately. * * Energy spent on spawning is not returned. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. */ cancel(): ScreepsReturnCode & (OK | ERR_NOT_OWNER); /** * Set allowed directions the creep can move when spawned. * * @param directions An array with the spawn directions * @return One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this spawn. * - ERR_INVALID_ARGS: The directions is array is invalid. */ setDirections(directions: DirectionConstant[]): ScreepsReturnCode & (OK | ERR_NOT_OWNER | ERR_INVALID_ARGS); } /** * An object with additional options for the spawning process. */ interface SpawnOptions { /** * Memory of the new creep. * * If provided, it will be immediately stored into Memory.creeps[name]. */ memory?: CreepMemory; /** * Array of spawns/extensions from which to draw energy for the spawning process. * * Structures will be used according to the array order. */ energyStructures?: Array; /** * If dryRun is `true`, the operation will only check if it is possible to create a creep. */ dryRun?: boolean; /** * Set allowed directions the creep can move when spawned. */ directions?: DirectionConstant[]; } interface SpawningConstructor extends _Constructor { new (id: Id): Spawning; (id: Id): Spawning; } ================================================ FILE: src/store.ts ================================================ interface StoreBase { /** * Returns capacity of this store for the specified resource. * * For a general purpose store, it returns total capacity if `resource` is undefined. * @param resource The type of the resource. * @returns Returns capacity number, or `null` in case of an invalid `resource` for this store type. */ getCapacity( resource?: R, ): UNLIMITED_STORE extends true ? null : R extends undefined ? ResourceConstant extends POSSIBLE_RESOURCES ? number : null : R extends POSSIBLE_RESOURCES ? number : null; /** * Returns the capacity used by the specified resource, or total used capacity for general purpose stores if `resource` is undefined. * @param resource The type of the resource. * @returns Returns used capacity number, or `null` in case of a not valid `resource` for this store type. */ getUsedCapacity( resource?: R, ): R extends undefined ? (ResourceConstant extends POSSIBLE_RESOURCES ? number : null) : R extends POSSIBLE_RESOURCES ? number : null; /** * Returns free capacity for the store. * * For a limited store, it returns the capacity available for the specified resource if `resource` is defined and valid for this store. * @param resource The type of the resource. * @returns Returns available capacity number, or `null` in case of an invalid `resource` for this store type. */ getFreeCapacity( resource?: R, ): UNLIMITED_STORE extends true ? null : R extends undefined ? ResourceConstant extends POSSIBLE_RESOURCES ? number : null : R extends POSSIBLE_RESOURCES ? number : null; } type Store = StoreBase< POSSIBLE_RESOURCES, UNLIMITED_STORE > & { [P in POSSIBLE_RESOURCES]: number } & { [P in Exclude]: 0 }; /** * An object that can contain resources in its cargo. * * There are two types of stores in the game: general purpose stores and limited stores. * * General purpose stores can contain any resource within its capacity (e.g. creeps, containers, storages, terminals). * * Limited stores can contain only a few types of resources needed for that particular object (e.g. spawns, extensions, labs, nukers). * * The Store prototype is the same for both types of stores, but they have different behavior depending on the resource argument in its methods. * * You can get specific resources from the store by addressing them as object properties: * ``` * console.log(creep.store[RESOURCE_ENERGY]); * ``` */ interface GenericStoreBase { /** * Returns capacity of this store for the specified resource. * * For a general purpose store, it returns total capacity if `resource` is undefined. * @param resource The type of the resource. * @returns Returns capacity number, or `null` in case of an invalid `resource` for this store type. */ getCapacity(resource?: ResourceConstant): number | null; /** * Returns the capacity used by the specified resource, or total used capacity for general purpose stores if `resource` is undefined. * @param resource The type of the resource. * @returns Returns used capacity number, or `null` in case of a not valid `resource` for this store type. */ getUsedCapacity(resource?: ResourceConstant): number | null; /** * Returns free capacity for the store. * * For a limited store, it returns the capacity available for the specified resource if `resource` is defined and valid for this store. * @param resource The type of the resource. * @returns Returns available capacity number, or `null` in case of an invalid `resource` for this store type. */ getFreeCapacity(resource?: ResourceConstant): number | null; } type GenericStore = GenericStoreBase & { [P in ResourceConstant]: number }; ================================================ FILE: src/structure.ts ================================================ /** * The base prototype object of all structures. */ interface Structure extends RoomObject { readonly prototype: Structure; /** * The current amount of hit points of the structure. */ hits: number; /** * The total amount of hit points of the structure. */ hitsMax: number; /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * The room the structure is in. * * If you can get an instance of a Structure, you can see it. * If you can see the Structure, you can see the room it's in. */ room: Room; /** * One of the {@link StructureConstant STRUCTURE_*} constants. */ structureType: T; /** * Destroy this structure immediately. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: Hostile creeps are in the room. */ destroy(): ScreepsReturnCode; /** * 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. */ isActive(): boolean; /** * Toggle auto notification when the structure is under attack. The notification will be sent to your account email. Turned on by default. * @param enabled Whether to enable notification or disable. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_INVALID_ARGS: enable argument is not a boolean value. */ notifyWhenAttacked(enabled: boolean): ScreepsReturnCode; } interface StructureConstructor extends _Constructor, _ConstructorById {} declare const Structure: StructureConstructor; /** * The base prototype for a structure that has an owner. * * Such structures can be found using {@link Room.find} and the {@link FIND_MY_STRUCTURES} & {@link FIND_HOSTILE_STRUCTURES} constants. */ interface OwnedStructure extends Structure { readonly prototype: OwnedStructure; /** * Whether this is your own structure. * * Walls and roads don't have this property as they are considered neutral structures. */ my: boolean; /** * An object with the structure’s owner info (if present). */ owner: T extends STRUCTURE_CONTROLLER ? Owner | undefined : Owner; /** * The link to the Room object. * * Is always present because owned structures give visibility. */ room: Room; } interface OwnedStructureConstructor extends _Constructor, _ConstructorById {} declare const OwnedStructure: OwnedStructureConstructor; /** * Claim this structure to take control over the room. * * The controller structure cannot be damaged or destroyed. * It can be addressed by {@link Room.controller} property. */ interface StructureController extends OwnedStructure { readonly prototype: StructureController; /** * Whether using power is enabled in this room. * * Use {@link PowerCreep.enableRoom()} to turn powers on. */ isPowerEnabled: boolean; /** * Current controller level, from 0 to 8. */ level: number; /** * The current progress of upgrading the controller to the next level. */ progress: number; /** * The progress needed to reach the next level. */ progressTotal: number; /** * The reservation info for the controller. * * Can be undefined if the controller isn't reserved. */ reservation: ReservationDefinition | undefined; /** * How many ticks of safe mode are remaining, or undefined. */ safeMode?: number; /** * Safe mode activations available to use. */ safeModeAvailable: number; /** * During this period in ticks new safe mode activations will be blocked, undefined if cooldown is inactive. */ safeModeCooldown?: number; /** * An object with the controller sign info if present */ sign: SignDefinition | undefined; /** * The amount of game ticks when this controller will lose one level. * * This timer can be reset by using {@link Creep.upgradeController} */ ticksToDowngrade: number; /** * The amount of game ticks while this controller cannot be upgraded due to attack. */ upgradeBlocked: number; /** * Activate safe mode if available. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. * - ERR_BUSY: There is another room in safe mode already. * - ERR_NOT_ENOUGH_RESOURCES: There is no safe mode activations available. * - ERR_TIRED: The previous safe mode is still cooling down, or the controller is upgradeBlocked, or the controller is downgraded for 50% plus 5000 ticks or more. */ activateSafeMode(): ScreepsReturnCode; /** * Make your claimed controller neutral again. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this controller. */ unclaim(): ScreepsReturnCode; } interface StructureControllerConstructor extends _Constructor, _ConstructorById {} declare const StructureController: StructureControllerConstructor; /** * Contains energy which can be spent on spawning bigger creeps. * * Extensions can be placed anywhere in the room, any spawns will be able to use them regardless of distance. */ interface StructureExtension extends OwnedStructure { readonly prototype: StructureExtension; /** * The amount of energy containing in the extension. * * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the extension can contain. * * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; } interface StructureExtensionConstructor extends _Constructor, _ConstructorById {} declare const StructureExtension: StructureExtensionConstructor; /** * Remotely transfers energy to another Link in the same room. */ interface StructureLink extends OwnedStructure { readonly prototype: StructureLink; /** * The amount of game ticks the link has to wait until the next transfer is possible. */ cooldown: number; /** * The amount of energy containing in the link. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the link can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Transfer energy from the link to another link. * * The target link can be at any position within the room. * * Remote transfer process implies 3% energy loss and cooldown delay depending on the distance. * @param target The target object. * @param amount The amount of energy to be transferred. If omitted, all the available energy is used. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this link. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the given amount of energy. * - ERR_INVALID_TARGET: The target is not a valid StructureLink object. * - ERR_FULL: The target cannot receive any more energy. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_INVALID_ARGS: The energy amount is incorrect. * - ERR_TIRED: The link is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this link. */ transferEnergy(target: StructureLink, amount?: number): ScreepsReturnCode; } interface StructureLinkConstructor extends _Constructor, _ConstructorById {} declare const StructureLink: StructureLinkConstructor; /** * Non-player structure. * * Spawns NPC Source Keepers that guards energy sources and minerals in some rooms. * This structure cannot be destroyed. */ interface StructureKeeperLair extends OwnedStructure { readonly prototype: StructureKeeperLair; /** * Time to spawning of the next Source Keeper. */ ticksToSpawn?: number; } interface StructureKeeperLairConstructor extends _Constructor, _ConstructorById {} declare const StructureKeeperLair: StructureKeeperLairConstructor; /** * Provides visibility into a distant room from your script. */ interface StructureObserver extends OwnedStructure { readonly prototype: StructureObserver; /** * Provide visibility into a distant room from your script. * * The target room object will be available on the next tick. The maximum range is 5 rooms. * @param roomName The room to observe. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_IN_RANGE: Room roomName is not in observing range. * - ERR_INVALID_ARGS: roomName argument is not a valid room name value. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ observeRoom(roomName: string): ScreepsReturnCode; } interface StructureObserverConstructor extends _Constructor, _ConstructorById {} declare const StructureObserver: StructureObserverConstructor; /** * Non-player structure. * * Contains power resource which can be obtained by destroying the structure. * Hits the attacker creep back on each attack. */ interface StructurePowerBank extends OwnedStructure { readonly prototype: StructurePowerBank; /** * The amount of power containing. */ power: number; /** * The amount of game ticks when this structure will disappear. */ ticksToDecay: number; } interface StructurePowerBankConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerBank: StructurePowerBankConstructor; /** * Non-player structure. * * Contains power resource which can be obtained by destroying the structure. * Hits the attacker creep back on each attack. */ interface StructurePowerSpawn extends OwnedStructure { readonly prototype: StructurePowerSpawn; /** * The amount of energy containing in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of power containing in this structure. * @deprecated An alias for .store[RESOURCE_POWER]. */ power: number; /** * The total amount of power this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_POWER). */ powerCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Register power resource units into your account. * * Registered power allows to develop power creeps skills. Consumes 1 power resource unit and 50 energy resource units. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy or power resource units. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ processPower(): ScreepsReturnCode; } interface StructurePowerSpawnConstructor extends _Constructor, _ConstructorById {} declare const StructurePowerSpawn: StructurePowerSpawnConstructor; /** * A rampart structure. * * Blocks movement of hostile creeps, and defends your creeps and structures on * the same tile. Can be used as a controllable gate. */ interface StructureRampart extends OwnedStructure { readonly prototype: StructureRampart; /** * The amount of game ticks when this rampart will lose some hit points. */ ticksToDecay: number; /** * Whether the rampart is open to the public or not. * * If false (default), only your creeps can step on the same square. * If true, any hostile creeps can pass through. */ isPublic: boolean; /** * Make this rampart public to allow other players' creeps to pass through. * @param isPublic Whether this rampart should be public or non-public * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. */ setPublic(isPublic: boolean): undefined; } interface StructureRampartConstructor extends _Constructor, _ConstructorById {} declare const StructureRampart: StructureRampartConstructor; /** * Decreases movement cost to 1. * * Using roads allows creating creeps with less `MOVE` body parts. */ interface StructureRoad extends Structure { readonly prototype: StructureRoad; /** * The amount of game ticks when this road will lose some hit points. */ ticksToDecay: number; } interface StructureRoadConstructor extends _Constructor, _ConstructorById {} declare const StructureRoad: StructureRoadConstructor; /** * A structure that can store huge amount of resource units. * * Only one structure per room is allowed that can be addressed by {@link Room.storage} property. */ interface StructureStorage extends OwnedStructure { readonly prototype: StructureStorage; /** * An object with the storage contents. */ store: StoreDefinition; /** * The total amount of resources the storage can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; } interface StructureStorageConstructor extends _Constructor, _ConstructorById {} declare const StructureStorage: StructureStorageConstructor; /** * Remotely attacks or heals creeps, or repairs structures. * * Can be targeted to any object in the room. However, its effectiveness highly depends on the * distance. Each action consumes energy. */ interface StructureTower extends OwnedStructure { readonly prototype: StructureTower; /** * The amount of energy containing in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Remotely attack any creep or structure in the room. * * Consumes 10 energy units per tick. Attack power depends on the distance to the target: from 600 hits at range 10 to 300 hits at range 40. * @param target The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ attack(target: AnyCreep | Structure): ScreepsReturnCode; /** * Remotely heal any creep in the room. * * Consumes 10 energy units per tick. Heal power depends on the distance to the target: from 400 hits at range 10 to 200 hits at range 40. * @param target The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ heal(target: AnyCreep): ScreepsReturnCode; /** * Remotely repair any structure in the room. * * Consumes 10 energy units per tick. Repair power depends on the distance to the target: from 600 hits at range 10 to 300 hits at range 40. * @param target The target structure. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_ENERGY: The tower does not have enough energy. * - ERR_INVALID_TARGET: The target is not a valid attackable object. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ repair(target: Structure): ScreepsReturnCode; } interface StructureTowerConstructor extends _Constructor, _ConstructorById {} declare const StructureTower: StructureTowerConstructor; /** * Blocks movement of all creeps. */ interface StructureWall extends Structure { readonly prototype: StructureWall; /** * The amount of game ticks when the wall will disappear (only for automatically placed border walls at the start of the game). */ ticksToLive: number; } interface StructureWallConstructor extends _Constructor, _ConstructorById {} declare const StructureWall: StructureWallConstructor; /** * Allows to harvest mineral deposits. */ interface StructureExtractor extends OwnedStructure { readonly prototype: StructureExtractor; /** * The amount of game ticks until the next harvest action is possible. */ cooldown: number; } interface StructureExtractorConstructor extends _Constructor, _ConstructorById {} declare const StructureExtractor: StructureExtractorConstructor; /** * Produces mineral compounds from base minerals and boosts creeps. */ interface StructureLab extends OwnedStructure { readonly prototype: StructureLab; /** * The amount of game ticks the lab has to wait until the next reaction is possible. */ cooldown: number; /** * The amount of energy containing in the lab. Energy is used for boosting creeps. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy the lab can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of mineral resources containing in the lab. * @deprecated An alias for lab.store[lab.mineralType]. */ mineralAmount: number; /** * The type of minerals containing in the lab. * * Labs can contain only one mineral type at the same time. * Null in case there is no mineral resource in the lab. */ mineralType: MineralConstant | MineralCompoundConstant | null; /** * The total amount of minerals the lab can contain. * @deprecated An alias for lab.store.getCapacity(lab.mineralType || yourMineral). */ mineralCapacity: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Boosts creep body part using the containing mineral compound. * * The creep has to be at adjacent square to the lab. Boosting one body part consumes 30 mineral units and 20 energy units. * @param creep The target creep. * @param bodyPartsCount The number of body parts of the corresponding type to be boosted. * Body parts are always counted left-to-right for TOUGH, and right-to-left for other types. * If undefined, all the eligible body parts are boosted. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_FOUND: The mineral containing in the lab cannot boost any of the creep's body parts. * - ERR_NOT_ENOUGH_RESOURCES: The lab does not have enough energy or minerals. * - ERR_INVALID_TARGET: The targets is not valid creep object. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ boostCreep(creep: Creep, bodyPartsCount?: number): ScreepsReturnCode; /** * Unboost a creep. * * Immediately remove boosts from the creep and drop 50% of the mineral compounds used to boost it onto the ground regardless of the creep's remaining time to live. * The creep has to be at adjacent square to the lab. * Unboosting requires cooldown time equal to the total sum of the reactions needed to produce all the compounds applied to the creep. * @param creep The target creep. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab, or the target creep. * - ERR_NOT_FOUND: The target has no boosted parts. * - ERR_INVALID_TARGET: The target is not a valid Creep object. * - ERR_NOT_IN_RANGE: The target is too far away. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ unboostCreep(creep: Creep): ScreepsReturnCode; /** * Breaks mineral compounds back into reagents. * * The same output labs can be used by many source labs. * @param lab1 The first result lab. * @param lab2 The second result lab. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_ENOUGH_RESOURCES: The source lab do not have enough resources. * - ERR_INVALID_TARGET: The targets are not valid lab objects. * - ERR_FULL: One of targets cannot receive any more resource. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_INVALID_ARGS: The reaction cannot be reversed into this resources. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ reverseReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; /** * Produce mineral compounds using reagents from two another labs. * * Each lab has to be within 2 squares range. The same input labs can be used by many output labs * @param lab1 The first source lab. * @param lab2 The second source lab. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this lab. * - ERR_NOT_ENOUGH_RESOURCES: The source lab do not have enough resources. * - ERR_INVALID_TARGET: The targets are not valid lab objects. * - ERR_FULL: The target cannot receive any more resource. * - ERR_NOT_IN_RANGE: The targets are too far away. * - ERR_INVALID_ARGS: The reaction cannot be run using this resources. * - ERR_TIRED: The lab is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ runReaction(lab1: StructureLab, lab2: StructureLab): ScreepsReturnCode; } interface StructureLabConstructor extends _Constructor, _ConstructorById {} declare const StructureLab: StructureLabConstructor; /** * Sends any resources to a Terminal in another room. */ interface StructureTerminal extends OwnedStructure { readonly prototype: StructureTerminal; /** * The remaining amount of ticks while this terminal cannot be used to make {@link StructureTerminal.send} or {@link Game.market.deal} calls. */ cooldown: number; /** * A Store object that contains cargo of this structure. */ store: StoreDefinition; /** * The total amount of resources the storage can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; /** * Sends resource to a Terminal in another room with the specified name. * @param resourceType One of the {@link ResourceConstant RESOURCE_*} constants. * @param amount The amount of resources to be sent. * @param destination The name of the target room. You don't have to gain visibility in this room. * @param description The description of the transaction. It is visible to the recipient. The maximum length is 100 characters. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the required amount of resources. * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The terminal is still cooling down. */ send(resourceType: ResourceConstant, amount: number, destination: string, description?: string): ScreepsReturnCode; } interface StructureTerminalConstructor extends _Constructor, _ConstructorById {} declare const StructureTerminal: StructureTerminalConstructor; /** * A small resource store. * * Contains up to 2,000 resource units. Can be constructed in neutral rooms. Decays for 5,000 hits per 100 ticks. */ interface StructureContainer extends Structure { readonly prototype: StructureContainer; /** * An object with the structure contents. * * Each object key is one of the {@link ResourceConstant RESOURCE_*} constants, values are resources * amounts. Use `_.sum(structure.store)` to get the total amount of contents. */ store: StoreDefinition; /** * The total amount of resources the structure can contain. * @deprecated An alias for .store.getCapacity(). */ storeCapacity: number; /** * The amount of game ticks when this container will lose some hit points. */ ticksToDecay: number; } interface StructureContainerConstructor extends _Constructor, _ConstructorById {} declare const StructureContainer: StructureContainerConstructor; /** * Launches a nuke to another room dealing huge damage to the landing area. * * Each launch has a cooldown and requires energy and ghodium resources. Launching * creates a Nuke object at the target room position which is visible to any player * until it is landed. Incoming nuke cannot be moved or cancelled. Nukes cannot * be launched from or to novice rooms. */ interface StructureNuker extends OwnedStructure { readonly prototype: StructureNuker; /** * The amount of energy contained in this structure. * @deprecated An alias for .store[RESOURCE_ENERGY]. */ energy: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_ENERGY). */ energyCapacity: number; /** * The amount of energy contained in this structure. * @deprecated An alias for .store[RESOURCE_GHODIUM]. */ ghodium: number; /** * The total amount of energy this structure can contain. * @deprecated An alias for .store.getCapacity(RESOURCE_GHODIUM). */ ghodiumCapacity: number; /** * The amount of game ticks the link has to wait until the next transfer is possible. */ cooldown: number; /** * A Store object that contains cargo of this structure. */ store: Store; /** * Launch a nuke to the specified position. * @param pos The target room position. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have enough energy and/or ghodium. * - ERR_INVALID_TARGET: The nuke can't be launched to the specified RoomPosition (see Start Areas). * - ERR_NOT_IN_RANGE: The target room is out of range. * - ERR_INVALID_ARGS: The target is not a valid RoomPosition. * - ERR_TIRED: This structure is still cooling down. * - ERR_RCL_NOT_ENOUGH: Room Controller Level insufficient to use this structure. */ launchNuke(pos: RoomPosition): ScreepsReturnCode; } interface StructureNukerConstructor extends _Constructor, _ConstructorById {} declare const StructureNuker: StructureNukerConstructor; /** * A non-player structure. * * Instantly teleports your creeps to a distant room acting as a room exit tile. * Portals appear randomly in the central room of each sector. */ interface StructurePortal extends Structure { readonly prototype: StructurePortal; /** * The portal's destination. * * If this is an inter-room portal, then this property contains a {@link RoomPosition} object leading to the point in the destination room. * If this is an inter-shard portal, then this property contains an object with shard and room string properties. * Exact coordinates are undetermined, the creep will appear at any free spot in the destination room. */ destination: RoomPosition | { shard: string; room: string }; /** * The amount of game ticks when the portal disappears, or undefined when the portal is stable. */ ticksToDecay: number | undefined; } interface StructurePortalConstructor extends _Constructor, _ConstructorById {} declare const StructurePortal: StructurePortalConstructor; /** * A structure which produces trade commodities from base minerals and other commodities. */ interface StructureFactory extends OwnedStructure { readonly prototype: StructureFactory; /** * The amount of game ticks the factory has to wait until the next produce is possible. */ cooldown: number; /** * The level of the factory. * * Can be set by applying the {@link PWR_OPERATE_FACTORY} power to a newly built factory. * Once set, the level cannot be changed. */ level?: number; /** * An object with the structure contents. */ store: StoreDefinition; /** * Produces the specified commodity. * * All ingredients should be available in the factory store. * @param resource One of the {@link CommoditiesTypes producible RESOURCE_*} constants. * @returns One of the following codes: * - OK: The operation has been scheduled successfully. * - ERR_NOT_OWNER: You are not the owner of this structure. * - ERR_BUSY: The factory is not operated by the PWR_OPERATE_FACTORY power. * - ERR_NOT_ENOUGH_RESOURCES: The structure does not have the required amount of resources. * - ERR_INVALID_TARGET: The factory cannot produce the commodity of this level. * - ERR_FULL: The factory cannot contain the produce. * - ERR_INVALID_ARGS: The arguments provided are incorrect. * - ERR_TIRED: The factory is still cooling down. * - ERR_RCL_NOT_ENOUGH: Your Room Controller level is insufficient to use the factory. */ produce(resource: CommoditiesTypes): ScreepsReturnCode; } interface StructureFactoryConstructor extends _Constructor, _ConstructorById {} declare const StructureFactory: StructureFactoryConstructor; /** * A structure which is a control center of NPC Strongholds, and also rules all invaders in the sector. */ interface StructureInvaderCore extends OwnedStructure { readonly prototype: StructureInvaderCore; /** * The level of the stronghold. * * The amount and quality of the loot depends on the level. */ level: number; /** * Shows the timer for a not yet deployed stronghold, undefined otherwise. */ ticksToDeploy: number; /** * If the core is in process of spawning a new creep, this object will contain a {@link StructureSpawn.Spawning} object, or `null` otherwise. */ spawning: Spawning | null; } interface StructureInvaderCoreConstructor extends _Constructor, _ConstructorById {} declare const StructureInvaderCore: StructureInvaderCoreConstructor; /** * A discriminated union on Structure.type of all owned structure types */ type AnyOwnedStructure = | StructureController | StructureExtension | StructureExtractor | StructureFactory | StructureInvaderCore | StructureKeeperLair | StructureLab | StructureLink | StructureNuker | StructureObserver | StructurePowerBank | StructurePowerSpawn | StructureRampart | StructureSpawn | StructureStorage | StructureTerminal | StructureTower; type AnyStoreStructure = | StructureExtension | StructureFactory | StructureLab | StructureLink | StructureNuker | StructurePowerSpawn | StructureSpawn | StructureStorage | StructureTerminal | StructureTower | StructureContainer; /** * A discriminated union on {@link Structure.structureType} of all structure types */ type AnyStructure = AnyOwnedStructure | StructureContainer | StructurePortal | StructureRoad | StructureWall; /** * Map of structure constant to the concrete structure class */ interface ConcreteStructureMap { [STRUCTURE_EXTENSION]: StructureExtension; [STRUCTURE_RAMPART]: StructureRampart; [STRUCTURE_ROAD]: StructureRoad; [STRUCTURE_SPAWN]: StructureSpawn; [STRUCTURE_LINK]: StructureLink; [STRUCTURE_WALL]: StructureWall; [STRUCTURE_STORAGE]: StructureStorage; [STRUCTURE_TOWER]: StructureTower; [STRUCTURE_OBSERVER]: StructureObserver; [STRUCTURE_POWER_SPAWN]: StructurePowerSpawn; [STRUCTURE_EXTRACTOR]: StructureExtractor; [STRUCTURE_LAB]: StructureLab; [STRUCTURE_TERMINAL]: StructureTerminal; [STRUCTURE_CONTAINER]: StructureContainer; [STRUCTURE_NUKER]: StructureNuker; [STRUCTURE_FACTORY]: StructureFactory; [STRUCTURE_KEEPER_LAIR]: StructureKeeperLair; [STRUCTURE_CONTROLLER]: StructureController; [STRUCTURE_POWER_BANK]: StructurePowerBank; [STRUCTURE_PORTAL]: StructurePortal; [STRUCTURE_INVADER_CORE]: StructureInvaderCore; } /** * Conditional type for all concrete implementations of Structure. * * Unlike {@link Structure}, {@link ConcreteStructure} gives you the actual concrete class that extends {@link Structure}. */ type ConcreteStructure = ConcreteStructureMap[T]; ================================================ FILE: src/tombstone.ts ================================================ /** * A creep's final resting place. * * This is a walkable structure. * Will decay 5 ticks per body part of the deceased creep. */ interface Tombstone extends RoomObject { /** * A unique object identifier. * * You can use {@link Game.getObjectById} to retrieve an object instance by its id. */ id: Id; /** * Time of death. */ deathTime: number; /** * An object with the tombstone contents. * * Each object key is one of the {@link ResourceConstant RESOURCE_*} constants, values are resources amounts. * {@link RESOURCE_ENERGY} is always defined and equals to 0 when empty, other resources are undefined when empty. * You can use `_.sum(tombstone.store)` to get the total amount of contents. */ store: StoreDefinitionUnlimited; /** * The amount of game ticks before this tombstone decays. */ ticksToDecay: number; /** * An object containing the deceased creep. */ creep: AnyCreep; } interface TombstoneConstructor extends _Constructor, _ConstructorById {} declare const Tombstone: TombstoneConstructor; ================================================ FILE: tsconfig.json ================================================ { "compilerOptions": { "module": "esnext", "target": "es2017", "sourceMap": false, "declaration": true, "strict": true, "noEmit": true, "newLine": "LF", "removeComments": false }, "include": [ "./src/**/*.ts" ], "exclude": [ "node_modules", "dist", ], }