Advertisement
purplemonday

Untitled

Oct 25th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1.  
  2.  
  3. module.exports =
  4. {
  5.  
  6.  
  7. run: function(creep,world)
  8. {
  9.  
  10.  
  11. //
  12. //var targetflag=Game.flags.Flag12
  13. var targetflag=Game.flags.Flag27
  14. var targetroom =""
  15. targetroom = targetflag.pos.roomName
  16. var currentroom = creep.pos.roomName
  17. console.log(targetroom)
  18. 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) }});
  19.  
  20. if (targetroom == currentroom)
  21. {
  22. console.log("TRUE")
  23.  
  24. var spawn = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_SPAWN)}})
  25. var move = creep.moveTo(spawn[0]) // try moving to spawn
  26. if (spawn.length > 0)
  27. {
  28. //combat tacktic
  29. if (move == ERR_NO_PATH)
  30. {
  31. var walls = creep.room.find(FIND_STRUCTURES, {filter: (structure) => {return (structure.structureType == STRUCTURE_WALL) }});
  32. if (walls.length <1)
  33. {
  34. var target = creep.pos.findClosestByPath(walls)
  35. creep.dismantle(target)
  36. creep.moveTo(target)
  37. } else {
  38.  
  39. creep.moveTo(targetflag.pos)
  40. }
  41.  
  42. } else {
  43. var target = creep.pos.findClosestByPath(walls)
  44. creep.say("X")
  45. creep.moveTo(spawn[0])
  46. creep.dismantle(spawn[0])
  47. }
  48. } else {
  49. // no spawns in room
  50.  
  51. if (targets != undefined && targets.length >0 )
  52. {
  53. var target = creep.pos.findClosestByPath( targets)
  54. creep.dismantle(target)
  55. creep.moveTo(target)
  56. } else {
  57. creep.moveTo(targetflag.pos)
  58. }
  59. }
  60.  
  61. } else {
  62. console.log("FALSE")
  63. creep.moveTo(targetflag.pos)
  64. }
  65.  
  66. }
  67. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement