Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var roleTransporter = require('role.transporter');
  2. var roleMiner = require('role.miner');
  3. var r_upgrader = require('role_upgrader');
  4. var roleBauer = require('role.bauer');
  5. var rolerattacker = require('role.rattacker');
  6. var rolemattacker = require('role.mattacker');
  7. var roleHealer = require('role.healer');
  8. var roleClaimer = require('role.claimer');
  9. var r_reserver = require('role_reserver');
  10. var generalfunctions = require('general.functions');
  11. var r_distancetransporter = require('role_distancetransporter');
  12. var r_cat = require('role_cattacker');
  13. var r_bha = require('role_bankhauler');
  14. var vg = require('general_var');
  15.  
  16. module.exports = {
  17.    
  18.     routine: function() {
  19.        
  20.         // Enter your very cool string for marking controllers here!
  21.         const signstring = 'Dolus Malus.';
  22.            
  23.        
  24.         for(var name in Game.creeps) {
  25.             var creep = Game.creeps[name];
  26.            
  27.             // Creep is still spawning? Give it some rest!
  28.             if(creep.spawning)
  29.                 continue;
  30.            
  31.             // Standing still? DenDens' STUCK DETECTOR
  32.             if(creep.memory.pos && creep.pos.x === creep.memory.pos.x && creep.pos.y === creep.memory.pos.y) {
  33.                 if(!creep.memory.stuck)
  34.                     creep.memory.stuck = 0;
  35.                 creep.memory.stuck++;
  36.             }
  37.             else {
  38.                 creep.memory.stuck = 0;
  39.             }
  40.             creep.memory.pos = creep.pos;
  41.             // Now we only need to use it in a smart way... to be continued!
  42.            
  43.            
  44.             // Healers can stand as a backline on edge in an attack so they don't need to mind the edge imho
  45.             if(creep.memory.role !== 'HEA')
  46.                 generalfunctions.mindedge(creep);
  47.            
  48.             // Enemy detection, or as i would call it... target detection!
  49.             if(creep.room.find(FIND_HOSTILE_CREEPS, {filter: (s) =>  (!vg.friends.includes(s.owner.username))}))
  50.                 var creeptarget = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS, {
  51.                     filter: (s) =>  (!vg.friends.includes(s.owner.username))});
  52.             if(creep.room.controller && creep.room.controller.owner && creep.room.controller.owner.username !== 'Kuja' && creep.room.find(FIND_HOSTILE_STRUCTURES, {filter: (s) =>  ((s.structureType === STRUCTURE_TOWER || s.structureType === STRUCTURE_SPAWN)&& (!vg.friends.includes(s.owner.username)))}))
  53.                 var tower = creep.pos.findClosestByRange(FIND_HOSTILE_STRUCTURES, {
  54.                     filter: (s) =>  ((s.structureType === STRUCTURE_TOWER || s.structureType === STRUCTURE_SPAWN)&& (!vg.friends.includes(s.owner.username)))});
  55.                
  56.             // This signs controllers with your signstring. Only if there are no enemies and stuff.
  57.             // Also no reservers, as they should get asap to a room and they would need extra time in rooms between to sign, which is not good as reserver.
  58.             if(creep.memory.role !== 'RSV' && !creeptarget && !tower && creep.room.controller && (!creep.room.controller.owner || !vg.friends.includes(creep.room.controller.owner.username)) && (!creep.room.controller.sign || creep.room.controller.sign
  59.             && !vg.friends.includes(creep.room.controller.sign.username) && creep.room.controller.sign.text != signstring)) {
  60.                 if(creep.signController(creep.room.controller, signstring) === ERR_NOT_IN_RANGE)
  61.                     creep.moveTo(creep.room.controller, {maxRooms: 1, range: 1, visualizePathStyle: {stroke: '#5f0c05', opacity: 0.8}});
  62.             }
  63.            
  64.             // DenDens very clever dodge script. And everyone uses it. Everyone escapes from bad guys. I love it!
  65.             // Imagine how strong kiting range attackers are with this single piece of code.
  66.             else if(creeptarget && (creeptarget.body.includes(RANGED_ATTACK) || creeptarget.body.includes(ATTACK)) && creep.memory.role !== 'MAT' && (creep.memory.role !== 'RAT' || creep.memory.role === 'RAT' && creep.pos.getRangeTo(creeptarget) < 3)&& creep.memory.role !== 'HEA' && creep.pos.getRangeTo(creeptarget) < 5) {
  67.                 let goal = {
  68.                    pos: creeptarget.pos,
  69.                    range: 5
  70.                 }
  71.                 var getawaypath = PathFinder.search(creep.pos, goal,  {flee: true});
  72.                 creep.move(creep.pos.getDirectionTo(getawaypath.path[0]));
  73.             }
  74.            
  75.            
  76.             // TSP gets back to DTP
  77.             // distance transporters will change role to local transporters if nothing to do, and vice versa
  78.             else if((creep.memory.role === 'TSP') && creep.memory.carryCapacity && Memory.rooms[creep.memory.home] && Memory.rooms[creep.memory.home].distancer > Memory.creepcounter[creep.memory.home]['DTP']) {
  79.                 creep.memory.role = 'DTP';
  80.                 Memory.creepcounter[creep.memory.target]['DTP'] += 1;
  81.                 Memory.creepcounter[creep.memory.target]['TSP'] -= 1;
  82.                 creep.say('>distanceTSP');
  83.                 creep.memory.recycle = false;
  84.             }
  85.            
  86.             // This creeper is not wanted anymore? Get some juicy last energy out of it.
  87.             else if(creep.memory.recycle) {
  88.                 var spawn = Game.rooms[creep.memory.home].find(FIND_MY_STRUCTURES, {
  89.                 filter: (s) => s.structureType === STRUCTURE_SPAWN});
  90.                 if(!spawn[0])
  91.                     continue;
  92.                
  93.                 creep.moveTo(spawn[0], {range: 1, maxRooms: 1, visualizePathStyle: {stroke: '#ff0c00', opacity: 0.8}});
  94.                 // the gf.recycle stuff should probably go here instead of in main.
  95.             }
  96.            
  97.             // Make sure creep isn't dismantling something important for the lord script operator who just pasted an objectID into an dismantle array
  98.             else if(creep.saying != 'DISMANTLE!') {
  99.                 if(creep.memory.role === 'TSP') {
  100.                     roleTransporter.run(creep);
  101.                 }
  102.                 else if(creep.memory.role === 'DTP') {
  103.                     r_distancetransporter(creep);
  104.                 }
  105.                 else if(creep.memory.role === 'MIN') {
  106.                    roleMiner.run(creep);
  107.                 }
  108.                 else if(creep.memory.role === 'UPG') {
  109.                     r_upgrader(creep);
  110.                 }
  111.                 else if(creep.memory.role === 'BAU') {
  112.                     roleBauer.run(creep);
  113.                 }
  114.                 else if(creep.memory.role === 'REP') {
  115.                     roleRepairer.run(creep);
  116.                 }
  117.                 else if(creep.memory.role === 'RAT') {
  118.                     rolerattacker.run(creep);
  119.                 }
  120.                 else if(creep.memory.role === 'MAT') {
  121.                     rolemattacker.run(creep);
  122.                 }
  123.                 else if(creep.memory.role === 'HEA') {
  124.                     roleHealer.run(creep);
  125.                 }
  126.                 else if(creep.memory.role === 'CLA') {
  127.                     roleClaimer.run(creep);
  128.                 }
  129.                 else if(creep.memory.role === 'RSV') {
  130.                     r_reserver(creep);
  131.                 }
  132.                 else if(creep.memory.role === 'CAT') {
  133.                     r_cat(creep);
  134.                 }
  135.                 else if(creep.memory.role === 'BHA') {
  136.                     r_bha.run(creep);
  137.                 }
  138.             }
  139.         }
  140.     }
  141. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement