Advertisement
nevrdid

Path algo1

Dec 7th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(creep.harvest(Game.getObjectById(creep.memory.targetId)) != OK){
  2.  
  3.     if(!creep.memory.path){                     /** if no path registered to source **/
  4.         getSourceId.run(creep);                     /** search an availlable source and lock creep on it **/
  5.         creep.memory.path = pathFind.run(creep); /** calculate Path to target or exit **/
  6.     }
  7.                
  8.     var Path = creep.memory.path;
  9.                
  10.     if(creep.pos == Path[Path.length-1]){        /** if creep is at end of path ( on exit or stuck by something) **/
  11.         creep.memory.path = pathFind.run(creep); /** recalculate path **/
  12.     }
  13.                
  14.     creep.moveByPath(Path);               follow path
  15.                  
  16.     /** var Path = pathFind.run(creep);  calculate path each tick
  17.                
  18.     if(Path[0] != undefined){           if Path exist
  19.         creep.move(Path[0].direction);  move
  20.     }
  21.     else{
  22.         getSourceId.run(creep);          find source
  23.     }
  24.     **/
  25.                    
  26.                
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement