Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports =
- {
- run: function(creep,world)
- {
- //
- //var targetflag=Game.flags.Flag12
- var targetflag=Game.flags.Flag27
- var targetroom =""
- targetroom = targetflag.pos.roomName
- var currentroom = creep.pos.roomName
- console.log(targetroom)
- var targets = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_CONTAINER || structure.structureType == STRUCTURE_ROAD ||structure.structureType == STRUCTURE_WALL ||structure.structureType == STRUCTURE_SPAWN) }});
- if (targetroom == currentroom)
- {
- console.log("TRUE")
- var spawn = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_SPAWN)}})
- var move = creep.moveTo(spawn[0]) // try moving to spawn
- if (spawn.length > 0)
- {
- //combat tacktic
- if (move == ERR_NO_PATH)
- {
- var walls = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_WALL) }});
- if (walls.length <1)
- {
- var target = creep.pos.findClosestByPath(walls)
- creep.dismantle(target)
- creep.moveTo(target)
- } else {
- creep.moveTo(targetflag.pos)
- }
- } else {
- var target = creep.pos.findClosestByPath(walls)
- creep.say("X")
- creep.moveTo(spawn[0])
- creep.dismantle(spawn[0])
- }
- } else {
- // no spawns in room
- if (targets != undefined && targets.length >0 )
- {
- var target = creep.pos.findClosestByPath( targets)
- creep.dismantle(target)
- creep.moveTo(target)
- } else {
- creep.moveTo(targetflag.pos)
- }
- }
- } else {
- console.log("FALSE")
- creep.moveTo(targetflag.pos)
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement