New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable spawning direction #61

Closed
wants to merge 4 commits into
base: ptr
from

Conversation

Projects
None yet
3 participants
@sparr
Contributor

sparr commented Oct 18, 2017

Allow the script to specify on a per-Spawn and per-spawnCreep() basis which direction(s) the creep should pop out at, instead of always trying north, northeast, etc.

If every selected direction is full then the same thing happens as when the spawn is surrounded, except that enemy creeps only die if there aren't any open unselected directions (so you can still only spawnstomp if you're actually surrounded).

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 18, 2017

Spawn.spawnDirections and Spawn.spawning.spawnDirections should not be visible to other players. I wasn't sure how to test that.

@artch

Adding a property to the StructureSpawn prototype is not a correct way to solve this, since it doesn't represent any real game state, but rather just a config value which is fully controlled by the player. Adding an option to StructureSpawn.spawnCreep should be enough.

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 18, 2017

@artch One goal of this PR is to replace the ridiculously hacky tactic currently employed by some players whereby they wait for the last tick of the spawning and surround their spawn with wall constructionsites for just one tick, immediately and precisely redirecting the spawning creep.

As written, the StructureSpawn property accomplishes that. The spawnCreep option is a convenience that does not fully replace the use cases of the property or constructionsite trick.

@artch

This comment has been minimized.

Contributor

artch commented Oct 18, 2017

The spawnCreep option is a convenience that does not fully replace the use cases of the property or constructionsite trick.

Could you please elaborate some of such use cases?

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 18, 2017

With the spawnCreep() option, the directions are set when you start spawning. With the constructionsite trick, you can set the direction at the last second, on the last tick before the creep spawns.

This is relevant in combat situations; spawn is under a rampart, enemy is attacking, you want your creep to pop out adjacent (if it's a melee defender) or opposite (if it's a ranged attacker) the enemy creep, and you don't know where it will be in advance.

Also relevant if you just change your mind.

What if I get rid of the StructureSpawn.spawnDirections property and change .setSpawnDirections() to alter StructureSpawn.spawning.spawnDirections instead?

@artch

This comment has been minimized.

Contributor

artch commented Oct 18, 2017

As to me, bloating the spawn prototype with the whole new property/method pair is not justified by a rare case of in-battle spawning. It looks more natural to me to add a StructureSpawn.spawning.directions and StructureSpawn.spawning.setDirections methods instead, which remain undefined while the spawn is idle.

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 18, 2017

It had not occurred to me that adding a method to StructureSpawn.spawning was an option. That seems very viable and would completely replace the StructureSpawn property and method. I'll try to implement that and update the PR when I can (later this week?). I don't immediately know what adding a method there will look like, given that the spawning object is declared pretty directly, but I'll puzzle it out.

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 18, 2017

Would it be expected that I build a new class for spawning, or can I shove a method into the object when it's defined?

@bastianh

This comment has been minimized.

Contributor

bastianh commented Oct 19, 2017

Would it be possible to set a default direction for a spawn without setting the direction for every spawning creep? I would like to set a default direction for a spawn depending on the room layout.

@artch

This comment has been minimized.

Contributor

artch commented Oct 19, 2017

@bastianh This is totally possible, but it is a task for your code, not for engine code. You can easily come up with some default config system which always sets directions option on your StructureSpawm.spawnCreep calls depending on some memory, or even override this method globally in the prototype.

@artch

This comment has been minimized.

Contributor

artch commented Oct 23, 2017

@sparr StructureSpawn.Spawning class would be convenient.

@artch

This comment has been minimized.

Contributor

artch commented Oct 23, 2017

Also, it makes me think that StructureSpawn.Spawning.cancel() method might also be a thing here.

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 23, 2017

@artch would it be appropriate for the intents to still be on the spawn, not a new intent target for the spawning object?

@artch

This comment has been minimized.

Contributor

artch commented Oct 23, 2017

StructureSpawn.Spawning instance is not a real object, it doesn't have an id, and no intents can be linked to it. So yes, intents should be placed on the spawn instead.

@sparr

This comment has been minimized.

Contributor

sparr commented Oct 24, 2017

@artch I think I've got it working as requested. I've done some testing but am not adept at manipulating the private server db to try tricky things like setting directions on another player's mid-spawning spawn.

@artch

This comment has been minimized.

Contributor

artch commented Jan 1, 2018

Please rebase this to the ptr branch. It will be included in the next PTR patch.

@sparr sparr force-pushed the sparr:spawn-direction branch from 8ef54e6 to 73f906f Jan 3, 2018

@sparr sparr changed the base branch from master to ptr Jan 3, 2018

artch added a commit that referenced this pull request Feb 9, 2018

feat: Configurable spawning direction (#61)
Squashed commit of the following:

commit 8ee7a2e3c79066c5a931a6065a6e1e5a6d4030de
Merge: 4f82b50 73f906f
Author: Artem Chivchalov <chivchalov@gmail.com>
Date:   Fri Feb 9 12:02:50 2018 +0300

    Merge branch 'spawn-direction' of https://github.com/sparr/screeps-engine into sparr-spawn-direction

    # Conflicts:
    #	src/processor/intents/spawns/_born-creep.js

commit 73f906f
Author: Clarence "Sparr" Risher <sparr0@gmail.com>
Date:   Mon Oct 23 22:13:24 2017 -0700

    move StructureSpawn.setSpawnDirections to StructureSpawn.Spawning.setDirections

commit d4e02ac
Author: Clarence "Sparr" Risher <sparr0@gmail.com>
Date:   Tue Oct 17 19:18:34 2017 -0700

    honor spawnDirections when spawning creep

commit 38b551d
Author: Clarence "Sparr" Risher <sparr0@gmail.com>
Date:   Tue Oct 17 19:17:47 2017 -0700

    implement Spawn.spawnCreep(...,{spawnDirections:[]})

commit 82385fa
Author: Clarence "Sparr" Risher <sparr0@gmail.com>
Date:   Tue Oct 17 15:49:00 2017 -0700

    implement StructureSpawn.setSpawnDirections
@artch

This comment has been minimized.

Contributor

artch commented Feb 9, 2018

Merged in 072b738.

@artch artch closed this Feb 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment