Created
May 8, 2023 00:09
-
-
Save lethern/d054973614e29d7b7700f444279551a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If your creep needs to find... | |
(can be accessed as creep.pos, or any other RoomPosition) | |
creep.pos.findClosestByRange(type, options) -- returns one object, type is FIND_xx, for example: target = creep.pos.findClosestByRange(FIND_MY_SPAWNS); | |
creep.pos.findClosestByPath(type, options) -- as above, but more CPU costly (searches by real path, not distance) | |
creep.pos.findInRange(type, range, options) -- array, type is FIND_xx. Searches in square. All 8 adjacent tiles to creep are in range 1 | |
creep.pos.lookFor(type) -- array of objects that are at same position as creep. Type is LOOK_xx, for example LOOK_CONSTRUCTION_SITES | |
(can be accessed as creep.room, or any other Room) | |
creep.room.find(type, options) -- array, type is FIND_xx, for example FIND_DROPPED_RESOURCES. Options can have filter - as a function or object, like | |
creep.room.find(FIND_MY_STRUCTURES, { filter: { structureType: STRUCTURE_EXTENSION } }); | |
creep.room.find(FIND_MY_STRUCTURES, { filter: (s) => s.structureType==STRUCTURE_EXTENSION; }); | |
creep.room.lookForAt(type, x, y) -- array, type is LOOK_xx, for example | |
creep.room.lookForAt(LOOK_CREEPS, 10, 10 ) | |
If you need info of creep: | |
creep.name -- obvious | |
creep.body -- array, like [WORK, WORK, ...] | |
creep.carry -- object, like creep.carry.energy, creep.carry[RESOURCE_ZYNTHIUM] | |
creep.carryCapacity -- maximum amount of all resources able to carry | |
creep.hits, creep.hitsMax -- current / max hit points | |
creep.room.x, creep.room.y, creep.room.roomName -- position properties: x, y, room | |
creep.pos.getRangeTo(target) -- returns linear range to something. can be getRangeTo(x,y) | |
If you need info of room: | |
(can be accessed as creep.room, for example) | |
creep.room.energyAvailable -- how much energy available to spawn creep | |
creep.room.name -- name, like 'E1N1'. | |
creep.room.storage -- room's StructureStorage, if built | |
If your mastermind needs info: | |
Game.constructionSites -- hashmap, key is id, value is construction site | |
Game.creeps -- hashmap, key is name, value is Creep. Usage for example Game.creeps['Vincent'] | |
Game.flags -- hashmap, key is name, value is Flag. Usage: Game.flags.MyFlag1 or Game.flags['MyFlag1'] | |
Game.rooms -- hashmap, only rooms available (having your structure or creep, excluding walls, roads, containers) | |
Game.time -- tick counter | |
Actions for your creep: | |
creep.attack(target) -- attacks target (each ATTACK part does 30dmg in one tick) | |
creep.attack(build) -- builds a Construction Site | |
creep.claimController(target) -- tries to take ownage of target neutral controller (referenced as (creep.) room.controller) | |
creep.harvest(target) -- harvests Source or Mineral | |
creep.repair -- repairs a structure (each WORK part repairs a structure for 100 hits in one tick which costs 1 energy) | |
creep.transfer(target, RESOURCE_xxx, amount) -- transfer specific amount of resource, like RESOURCE_ENERGY. Careful, we can't transfer more than target has storage | |
creep.upgradeController(target) -- transfers energy into controller | |
Moving | |
creep.moveTo(target) -- moves to target Object, position, or moveTo(x,y) | |
Additional: | |
creep.spawning -- when Creep is not yet alive, this will be true | |
creep.ticksToLive -- how many ticks till creep dies | |
creep.say -- displays short message on top of creep for you (max 10 characters) | |
creep.room.controller -- the room's Controller | |
Game.getObjectById(id) -- returns object by its ID (you will use it when storing something in Memory - you can't store Object, but you can store id) | |
Notes: | |
-construction site's id is different from the completed building's later on | |
-using FIND_MY_STRUCTURES you will not get walls, roads, containers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment