Navigation

    forum

    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    1. Home
    2. Hawthorn
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Groups
    • Blog

    Hawthorn

    @Hawthorn

    12
    Posts
    1056
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Hawthorn Follow

    Posts made by Hawthorn

    • Game.getObjectById() returns null when passed the source.id of a source in an unclaimed room.

      Game.getObjectById() returns null when passed the source.id of a source in an unclaimed room.

       

      I have a creep in the room, but I can't change a sourceID (I verified its correct in the UI) into a GameObject? It works in my own room.

       

      How do I harvest an unclaimed source?

      posted in Help
      Hawthorn
    • RE: [NOT A BUG] Game.rooms['sim'].storage.storeCapacity = 0 (when its not)

      That was it .. Thanks.  Missed that!

      posted in Help
      Hawthorn
    • [NOT A BUG] Game.rooms['sim'].storage.storeCapacity = 0 (when its not)

      NOTE: The issue was the controller was set to level 1.  Setting the controller to level 4 fixed this.

      -----

      In the simulator create a storage tank (defaults to 500k energy and 300k minerals) .. should be 200k left in capacity.

      I have tried with console and the following code (both return 0)

       

      function findStorageNeedsEnergy(thisRoom) {
      if (thisRoom.storage &&
      (_.sum(thisRoom.storage.store) < thisRoom.storage.storeCapacity)) {
      return thisRoom.storage;
      }
      }

       

       

      posted in Help
      Hawthorn
    • RE: How i can control second room?

      I know this is old, but here is a suggestion:

      In your main loop .. loop through all rooms and then all the creeps in the room. 

      From there I would loop through the creeps and make decisions based on their role and logic. 

      I think basing your main loop on spawns is a mistake, many of your important interactions will not be spawn based. Creeps harvesting in other rooms, attacking, chasing down the enemy to punish them for their hubris...

       

      for(var thisRoom in Game.rooms) {

      for (var thisCreep in thisRoom.find(FIND_MY_CREEPS)) {
      // Handle creeps in this room
      }
      }
      posted in Help
      Hawthorn
    • RE: I need help with a few things

      For sources Question:

      In an early edition of my scripts I used:

      var source = creep.pos.findClosestByPath(FIND_SOURCES_ACTIVE)

      Then I added some logic when I noticed they were clustering around one and waiting

      function rememberClosestActiveSource(creep) {
      if(!creep.memory.sourceId ||
      Game.getObjectById(creep.memory.sourceId).energy == 0) {
      var source = creep.pos.findClosestByPath(FIND_SOURCES_ACTIVE, {
      filter: (source) => {
      creep.moveTo(source) != ERR_NO_PATH
      }
      })

      if (source) {
      creep.memory.sourceId = source.id
      }
      }
      }


      What I have now is classified, but the gist is this:

      When the creep is assigned a new job (like repairing a wall, or filling up energy storage) he find the source nearest to that target, stores the id and the path in his own memory. and does the job until its complete .. then grabs another job and repeats.  Lots of little tweaks to save CPU and mem .. but thats the basics


      posted in Help
      Hawthorn
    • RE: Creeps disappear

      You need to learn the following

      1) How to perform a find for all your creeps and get a count. 

      Game.Spawns['Spawn1'].room.find(FIND_MY_CREEPS).length

      2) How to set some limit for how many creeps you want at one time.  Hint: If you just spawn low level creeps as fast as possible, you will never have energy for anything else.

      3) How to spawn a creep.

      Game.Spawns['Spawn1'].createCreep([WORK,CARRY,MOVE],
      utils.generateName('Worker'),
      {role: 'worker'})

      4) How to clean up old creep memory so you don't run out

      for(var name in Memory.creeps) {
      if(!Game.creeps[name]) {
      delete Memory.creeps[name];
      console.log('Clearing non-existing creep memory:', name)
      }
      }

       

      5) How to break all this up into modules and manage your energy.  Then build roads, containers, warriors, mines, nuclear silos .. MUHAHAHHAHAHaahaha

      Its a LOT of work and it will take you MONTHS to get a great strategy. But chip away at it a little at a time.  USE THE SIMULATOR to try things out. You can spawn in items and speed up time for testing.  After 1 week you will want to quit cause its too hard. Tell that little @#$@$ part of your brain to shut up and press on.  Once you get it .. you will be hooked!


      Here is an old, declassified and military redacted script of mine .. MUHAHAHA  Learn how to make modules!

      var utils = require('utils');

      // region Variables

      var debug = false

      // endregion

      // region Module Implementation

      module.exports =
      {
      /**
      * This logic loop handles generating new units (room by room)
      *
      * Thi is a flexible function that can be called from any CZar to control creep dynamics
      * @param minWorkers The minimum number of workers (in this room) that must be active before any other type is created
      * @param maxWorkers The max number of workers (in this room) that should ever be active
      */
      ensureStaffingLevels: function(minWorkers, maxWorkers)
      {
      for(var i in Game.spawns) {
      var thisSpawn = Game.spawns[i]

      var totalCreeps = getTotalCreepCount(thisSpawn)
      var totalWorkers = getTotalWorkerCreepCount(thisSpawn)

      // First make sure we have the min number of workers.
      if (totalWorkers < minWorkers){
      generateWorkerCreep(thisSpawn, true)
      return
      }

      // After we have the minWorkers we can focus on other creeps
      var totalCurators = getTotalCuratorCreepCount(thisSpawn)
      if(totalCurators == 0) {
      thisSpawn.createCreep(generateCuratorBodyParts(thisSpawn),
      `${thisSpawn.name}-Curator`, {role: 'curator'});
      return
      }

      if( totalWorkers < maxWorkers)
      {
      generateWorkerCreep(thisSpawn, false)
      return
      }
      }
      },

      decommissionUnusedResources: function()
      {
      for(var name in Memory.creeps) {
      if(!Game.creeps[name]) {
      delete Memory.creeps[name];
      console.log('Clearing non-existing creep memory:', name)
      }
      }
      },
      generateWorkerCreep: generateWorkerCreep,
      generateMeleeGuardCreep: generateMeleeGuardCreep,
      generateRangedGuardCreep: generateRangedGuardCreep,
      generateWorkerBodyParts: generateWorkerBodyParts
      }






      posted in Help
      Hawthorn
    • RE: FIND_SOURCES vs FIND_SOURCES_ACTIVE

      Thanks!  I am thinking there is a bug when you use FIND_ALL_SOURCES and then filter for energy > 0.  I want not getting any hits until I set it to FIND_SOURCES with that filter.   I will try the FIND_SOURCES_ACTIVE and use it correctly!

      posted in Help
      Hawthorn
    • RE: Branch support in automatic GitHub sync?

      ping

      posted in Feature Requests
      Hawthorn
    • FIND_SOURCES vs FIND_SOURCES_ACTIVE

      Looked around and could not find a good explanation on these?

      posted in Help
      Hawthorn
    • RE: CLOSED - NOT A BUG - Found bug if you place a tower construction slot, delete it, then place it again in same location. Tower construction disappears and you can't replace until next GCL

      NM!  - I figured it out. Somehow to tower was NOT placed where I put it .. it got placed next to a wall, under a creep.  All the creeps were stuck and piled up.

      posted in Technical Issues and Bugs
      Hawthorn