Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var roleTransporter = require('role.transporter');
- var roleMiner = require('role.miner');
- var r_upgrader = require('role_upgrader');
- var roleBauer = require('role.bauer');
- var rolerattacker = require('role.rattacker');
- var rolemattacker = require('role.mattacker');
- var roleHealer = require('role.healer');
- var roleClaimer = require('role.claimer');
- var r_reserver = require('role_reserver');
- var generalfunctions = require('general.functions');
- var r_distancetransporter = require('role_distancetransporter');
- var r_cat = require('role_cattacker');
- var r_bha = require('role_bankhauler');
- var vg = require('general_var');
- module.exports = {
- routine: function() {
- // Enter your very cool string for marking controllers here!
- const signstring = 'Dolus Malus.';
- for(var name in Game.creeps) {
- var creep = Game.creeps[name];
- // Creep is still spawning? Give it some rest!
- if(creep.spawning)
- continue;
- // Standing still? DenDens' STUCK DETECTOR
- if(creep.memory.pos && creep.pos.x === creep.memory.pos.x && creep.pos.y === creep.memory.pos.y) {
- if(!creep.memory.stuck)
- creep.memory.stuck = 0;
- creep.memory.stuck++;
- }
- else {
- creep.memory.stuck = 0;
- }
- creep.memory.pos = creep.pos;
- // Now we only need to use it in a smart way... to be continued!
- // Healers can stand as a backline on edge in an attack so they don't need to mind the edge imho
- if(creep.memory.role !== 'HEA')
- generalfunctions.mindedge(creep);
- // Enemy detection, or as i would call it... target detection!
- if(creep.room.find(FIND_HOSTILE_CREEPS, {filter: (s) => (!vg.friends.includes(s.owner.username))}))
- var creeptarget = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS, {
- filter: (s) => (!vg.friends.includes(s.owner.username))});
- 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)))}))
- var tower = creep.pos.findClosestByRange(FIND_HOSTILE_STRUCTURES, {
- filter: (s) => ((s.structureType === STRUCTURE_TOWER || s.structureType === STRUCTURE_SPAWN)&& (!vg.friends.includes(s.owner.username)))});
- // This signs controllers with your signstring. Only if there are no enemies and stuff.
- // 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.
- 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
- && !vg.friends.includes(creep.room.controller.sign.username) && creep.room.controller.sign.text != signstring)) {
- if(creep.signController(creep.room.controller, signstring) === ERR_NOT_IN_RANGE)
- creep.moveTo(creep.room.controller, {maxRooms: 1, range: 1, visualizePathStyle: {stroke: '#5f0c05', opacity: 0.8}});
- }
- // DenDens very clever dodge script. And everyone uses it. Everyone escapes from bad guys. I love it!
- // Imagine how strong kiting range attackers are with this single piece of code.
- 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) {
- let goal = {
- pos: creeptarget.pos,
- range: 5
- }
- var getawaypath = PathFinder.search(creep.pos, goal, {flee: true});
- creep.move(creep.pos.getDirectionTo(getawaypath.path[0]));
- }
- // TSP gets back to DTP
- // distance transporters will change role to local transporters if nothing to do, and vice versa
- 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']) {
- creep.memory.role = 'DTP';
- Memory.creepcounter[creep.memory.target]['DTP'] += 1;
- Memory.creepcounter[creep.memory.target]['TSP'] -= 1;
- creep.say('>distanceTSP');
- creep.memory.recycle = false;
- }
- // This creeper is not wanted anymore? Get some juicy last energy out of it.
- else if(creep.memory.recycle) {
- var spawn = Game.rooms[creep.memory.home].find(FIND_MY_STRUCTURES, {
- filter: (s) => s.structureType === STRUCTURE_SPAWN});
- if(!spawn[0])
- continue;
- creep.moveTo(spawn[0], {range: 1, maxRooms: 1, visualizePathStyle: {stroke: '#ff0c00', opacity: 0.8}});
- // the gf.recycle stuff should probably go here instead of in main.
- }
- // Make sure creep isn't dismantling something important for the lord script operator who just pasted an objectID into an dismantle array
- else if(creep.saying != 'DISMANTLE!') {
- if(creep.memory.role === 'TSP') {
- roleTransporter.run(creep);
- }
- else if(creep.memory.role === 'DTP') {
- r_distancetransporter(creep);
- }
- else if(creep.memory.role === 'MIN') {
- roleMiner.run(creep);
- }
- else if(creep.memory.role === 'UPG') {
- r_upgrader(creep);
- }
- else if(creep.memory.role === 'BAU') {
- roleBauer.run(creep);
- }
- else if(creep.memory.role === 'REP') {
- roleRepairer.run(creep);
- }
- else if(creep.memory.role === 'RAT') {
- rolerattacker.run(creep);
- }
- else if(creep.memory.role === 'MAT') {
- rolemattacker.run(creep);
- }
- else if(creep.memory.role === 'HEA') {
- roleHealer.run(creep);
- }
- else if(creep.memory.role === 'CLA') {
- roleClaimer.run(creep);
- }
- else if(creep.memory.role === 'RSV') {
- r_reserver(creep);
- }
- else if(creep.memory.role === 'CAT') {
- r_cat(creep);
- }
- else if(creep.memory.role === 'BHA') {
- r_bha.run(creep);
- }
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement