Navigation

    forum

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

    Oblivionburn

    @Oblivionburn

    4
    Posts
    826
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Oblivionburn Follow

    Posts made by Oblivionburn

    • RE: [Code Snippet] Get Possible Connections for Source

      That's definitely simpler! 

      Had to use 

      10-_.countBy

      instead of 

      9-_.countBy

      since it gave the wrong count for me.

      posted in General Discussion
      Oblivionburn
    • RE: [Code Snippet] Get Possible Connections for Source

      lol forgot about swamp... code updated 🙂

      posted in General Discussion
      Oblivionburn
    • [Code Snippet] Get Possible Connections for Source

      Here's a bit of code I came up with for getting how many creeps I can have 'harvesting' a source simultaneously:

      function Get_Connections(source)
      {
      var result = [];
      var North = source.room.lookAt(source.pos.x, source.pos.y - 1);
          North.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[0] = object[LOOK_TERRAIN];
              }
          });

      var NorthEast = source.room.lookAt(source.pos.x + 1, source.pos.y - 1);
          NorthEast.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[1] = object[LOOK_TERRAIN];
              }
          });

      var NorthWest = source.room.lookAt(source.pos.x - 1, source.pos.y - 1);
          NorthWest.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[2] = object[LOOK_TERRAIN];
              }
          });

          var East = source.room.lookAt(source.pos.x + 1, source.pos.y);
          East.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[3] = object[LOOK_TERRAIN];
              }
          });

          var South = source.room.lookAt(source.pos.x, source.pos.y + 1);
          South.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[4] = object[LOOK_TERRAIN];
              }
          });

          var SouthEast = source.room.lookAt(source.pos.x + 1, source.pos.y + 1);
          SouthEast.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[5] = object[LOOK_TERRAIN];
              }
          });

          var SouthWest = source.room.lookAt(source.pos.x - 1, source.pos.y + 1);
          SouthWest.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[6] = object[LOOK_TERRAIN];
              }
          });

          var West = source.room.lookAt(source.pos.x - 1, source.pos.y);
          West.forEach(function(object)
          {
              if (object.type == LOOK_TERRAIN)
              {
                  result[7] = object[LOOK_TERRAIN];
              }
          });

          return result;
      }

       

      and its usage: 

       

      function Assign(creep)
      {
      var sources = creep.room.find(FIND_SOURCES);

          for (s = 0; s < sources.length; s++)
          {
              var connections = Get_Connections(sources[s]);

              var count = 0;
              for (c = 0; c < connections.length; c++)
              {
                  if (connections[c] == "plain" ||
      connections[c] == "swamp")
                  {
                      count++;
                  }
              }

              if (count > 1)
              {
                  var connected = 0;
      for (var name in Game.creeps)
                  {
                      var existing = Game.creeps[name];

                      if (existing.memory.assigned == sources[s].id)
                      {
                          connected++;
                          if (connected == count)
                          {
                              break;
                          }
                      }
                  }

                  if (connected < count)
                  {
                      creep.memory.assigned = sources[s].id;
                      break;
                  }
              }
              else
              {
                  var assigned = false;
                  for (var name in Game.creeps)
                  {
                      var existing = Game.creeps[name];

                      if (existing.memory.assigned == sources[s].id)
                      {
                          assigned = true;
                          break;
                      }
                  }

                  if (assigned == false)
                  {
                      creep.memory.assigned = sources[s].id;
                      break;
                  }
              }
          }
      }

       

      Obviously this doesn't take into account any structures next to the source, which you hopefully should never need to.

       

      posted in General Discussion
      Oblivionburn
    • Controller Level Changed bug (minor)

      When a controller's level falls below the requirement for operating a particular structure, the structure gets highlighted in red... but after raising the controller's level back up the structure does not come back into control (still has red highlight) until game is restarted.

       

      [edit]

      Going to World and back to the Room also resets the red highlight.

      posted in Technical Issues and Bugs
      Oblivionburn