Power Creep: Can't use an intershard portal to switch shard.



  • Oddly, I can't drive my PC onto a portal and go to shard 1 from shard 2. It has a valid pos it's trying to use moveTo(pos); to get to, and the call returns 0. If I step in and manually force move(RIGHT); it still won't go. Is this intended, or is the portal somehow broken?

    The portal is on shard 2, at W50S20 24,39

    Ok... engineeryo on the power_screep slack pointed this out:

    In move(), which is ultimately called...

    if(!_.any(targetObjects, (target) => _.contains(C.OBSTACLE_OBJECT_TYPES, target.type) && target.type != 'creep' && target.type != 'powerCreep' || target.type == 'rampart' && !target.isPublic && object.user != target.user || object.type == 'powerCreep' && target.type == 'portal' && target.destination.shard)) {

    movement.add(object, dx, dy);

    Ok. first I have to consult the operator precedence chart... Yup, && superceeds ||, so the &&s are done first. So it appears the intershard portals are specifically set as an obstacle. And then if it IS an obstacle I guess it just runs off the end of the function and returns OK.

    👍

  • Dev Team

    Thank you for the report, we'll take a look.

    Meanwhile, you can activate experimentation period and re-create the power creep to make it spawned on another shard.



  • Thanks, Goggles!

    It's pretty clear what the issue is, after doing a bit of research (I added the code bit after submitting the report.) it's intended to be that way, either as a stopgap to prevent something else, or whatever... I just wanted to bring it to your attention. As a fix... I'm not going to waste an experimental period... I'll just eat the 8 hours and "Necro-port" to the other shard.

    I would like to point something out, though... The post-cooldown respawn of the Power Creep has no way to know what SHARD the room you've specified is on. If you have a condition where 2 rooms are on top of each other, but on different shards... and since you cannot use the portal, it may actually be impossible to spawn a PC in a desired room in those cases.

    I'll consider this solved and trust it'll stay on a burner.

    Edited to add: As soon as I posted this, I had a moment of clarity... I was looking for the Power Spawn by room name. Which, isn't guaranteed unique. But if I used the ID of the spawn, and then used Game.getObjectById(), it would only return an object on the shard that particular spawn is on. So I'll fix my code to reflect that.


  • Dev Team

    @smokeman I have a couple of rooms on top of each other (see E2S7s) but I'm not sure if I understand how exactly it can prevent me to spawn a power creep in either of them...



  • Only if you were doing it wrong like I was. (See the edit at the bottom of that post.) If you referenced the Power Spawn as the room / room.find(FIND_MY_STRUCTURES,{filter: {structureType: STRUCTURE_POWER_SPAWN}}) then it could get confused. Simply using the Power Spawn's ID would clear that right up.



  • @smokeman if you were doing that via console command, then you should be aware that console code runs only on the shard you're currently viewing. Which means referencing room by its name from Game.rooms would work as long as you had your view set on the intended shard in the client.



  • @orlet Code has the same limitation, it's only aware of the current shard. And no, I was doing this in code. All three shards I'm on run the same code, with the difference being the Game.... data and Memory... data being different. The mistake I was making was using the room name to find the room, then room.find the find the Power Spawn in the room. The correct way (And I might add, the way the docs have an example for.) is to use the Id of the Power Spawn with Game.GetObjectById('XXX');

    An interesting ramification of this is you cannot use the Creep's memory to store where it wants to go, as you can neither use a portal nor read that memory from another shard (I originally thought the PCs were somehow synced across shards. They are not. They are merely unique across shards.)

    I certainly dislike hard coding the Power Spawn ID into the code, or the room name, for that matter. A solution would be to dedicate a section of the intershard memory to the startup parameters for each named Power Creep you have, then look at that occasionally to see if one that should be on the current shard isn't there and try to spawn it.



  • @smokeman right. But difference being the same code is executed on all shards, while being aware of the single shard. Console is only executed on the shard you're viewing. My point being, if you were trying to spawn the creep via console, it would've gone through no problem.

    And yes, seems like keeping some powercreep data in intershard segment for the sync purposes.