Changelog 2016-07-11

  • Introduced Creep.withdraw method. It replaces all structures’ transfer methods which are now considered deprecated.
  • Executing StructureSpawn.createCreep now inserts a new dummy Creep object into Game.creeps hash immediately. The id property of such object is undefined until the next tick.
  • Executing Room.createFlag now inserts a new Flag object into Game.flags hash immediately.
Have more questions? Submit a request

Comments

  • Sparshong

    With the 'transfer' methods, it was possible in the same tick for, say, refill the creep's carry AND do something else like move or upgradeController.

    I guess with the withdraw method this will not be possible anymore?

  • CAFontana

    Given that they'd have to make a special exception in the loop to allow two actions to be performed by the creep now, no, you wouldn't be able to do it in the same tick anymore.

    Were structures limited to one action per tick?  Because this would now open up the ability to have two creep withdraw from the same structure at once if they couldn't before.

  • Spite

    Yes, containers could previously only make one action per tick, which got annoying if you had units doing upgrades or builds within reach of the stockpile.  I'm also looking forward to this change as a nice CPU saver too (no longer having to scan my whole array of n creeps for y containers).

  • bonzaiferroni

    It looks like you can use withdraw and upgradeController at the same time, here it is in action: https://gfycat.com/CourageousNervousGuillemot

    As you can see, the quantity of the link is going down but all three creeps never miss a tick with upgradeController. 

    @CAFontana there are actually a lot of other examples of simultaneous actions, certain ones are allowed and certain aren't. Take a look at this article for more info: http://support.screeps.com/hc/en-us/articles/203137792-Simultaneous-execution-of-creep-actions

    Would you like your archers to move and rangedAttack and heal themselves in the same tick? they can do that!

    Edited by bonzaiferroni
  • Avatar
    Artem from Screeps

    Creep.withdraw can be used with any other method simultaneously, including Creep.transfer.

  • Avatar
    Dissi

    Hey Artem,

    We were just looking through the code of withdraw, it seems we can withdraw energy and ghodium from the nuker. I thought the nuker was input only: 

    http://support.screeps.com/hc/en-us/community/posts/206757749-Missing-method-transfer-on-StructureNuker 

  • Avatar
    Dissi

    Will using .withdraw make the resource available immediately?

     

    As in Creep has 0 energy

    witdraw(storage, RESOURCE_ENERGY)

    Creep now has X energy

    transfer(terminal, RESOURCE_ENERGY);

     Creep now has 0 energy again.

     

     

    Will this result in a creep picking up and dropping energy in 1 tick?

    Edited by Dissi
  • NhanHo

    In the tick when you call `Spawn.createCreep` , the resulting creep object being added has `Creep.carryCapacity` equals to 0, even if the creep has CARRY part . 

     

    Edited by NhanHo
  • Avatar
    Artem from Screeps

    We were just looking through the code of withdraw, it seems we can withdraw energy and ghodium from the nuker. I thought the nuker was input only:

    No, you shouldn’t be able to. If you can, please report.

    Will using .withdraw make the resource available immediately?

    The command flow is the same as with transfer and all other operations. You schedule the command first, and it is processed after the tick ends.

    In the tick when you call Spawn.createCreep , the resulting creep object being added has Creep.carryCapacity equals to 0, even if the creep has CARRY part .

    Right, thanks for reporting, fixed.

  • Avatar
    Dissi

    @artem

    Code responsible is inside Creep.prototype.withdraw

    if (target.structureType == 'nuker') {
    if (resourceType != C.RESOURCE_ENERGY && resourceType != C.RESOURCE_GHODIUM) {
    return C.ERR_INVALID_ARGS;
    }
    if (!amount) {
    amount = Math.min(data(target.id)[resourceType], emptySpace);
    }
    if (data(target.id)[resourceType] < amount) {
    return C.ERR_NOT_ENOUGH_RESOURCES;
    }
    if (amount > emptySpace) {
    return C.ERR_FULL;
    }
  • Avatar
    Artem from Screeps

    It's just leftover code. There is a check in the top which doesn't allow passing a nuker as a target. But of course we should remove this for consistency.

    Edited by Artem from Screeps
  • ZeekDaGeek

    If StrutureSpawn.createCreep creates a creep within in that exact tick shouldn't StructureSpawn.spawning also be set to the spawning object as well? Otherwise you end up creating 5 dumby creeps because they have no way of checking if the Spawner already has a creep being spawned...

    * Sidenote: Editing a comment is missing CSS to make it so text in the edit field is white instead of black.

    Edited by ZeekDaGeek
Powered by Zendesk