Advertisement
Fiskmans

Untitled

Oct 12th, 2021
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports.Update=function(colony)
  2. {
  3.     if(!colony.looting) { return; }
  4.  
  5.     let room = Game.rooms[colony.looting];
  6.     if(!room) { Empire.Scouting.WantsVision(colony.looting); return; }
  7.  
  8.     if(!colony.looter)
  9.     {  
  10.         let list = [];
  11.         Colony.Helpers.SpawnCreep(
  12.             colony,
  13.             list,
  14.             BODIES.LV4_HAULER,
  15.             ROLE_HAULER);
  16.         colony.looter = list.shift();    
  17.     }
  18.  
  19.     let colonyRoom = Game.rooms[colony.pos.roomName];
  20.     if(!colonyRoom.storage) { return; }
  21.  
  22.     let targets = room.find(FIND_STRUCTURES,{filter: (s) => { return ENEMY_STRUCTURES_WITH_LOOT.includes(s.structureType) && colony.disTargets.indexOf(s.id) === -1 && s.store.getUsedCapacity() > 0; }});
  23.  
  24.     if(targets.length == 0)
  25.     {
  26.         if(colony.looter)
  27.         {
  28.             console.log("Looting done in " + colony.looting);
  29.             colony.haulerpool.push(colony.looter);
  30.             colony.haulersensus.push(colony.looter);
  31.             delete colony.looter;
  32.             delete colony.looting;
  33.             return;
  34.         }
  35.     }
  36.  
  37.     if(colony.looter)
  38.     {
  39.         let creep = Game.creeps[colony.looter];
  40.         if(!creep) { delete colony.looter; return; }
  41.  
  42.         if (creep.store.getUsedCapacity() > 0)
  43.         {
  44.             creep.say('💰');
  45.             creep.do(CREEP_TRANSFER,colonyRoom.storage,Object.keys(creep.store)[0]);
  46.         }
  47.         else
  48.         {
  49.             creep.say('🏴‍☠️');
  50.             creep.do(CREEP_WITHDRAW,targets[0],Object.keys(targets[0].store)[0]);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement