Configurable spawning direction#61
Conversation
|
Spawn.spawnDirections and Spawn.spawning.spawnDirections should not be visible to other players. I wasn't sure how to test that. |
artch
left a comment
There was a problem hiding this comment.
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.
|
@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. |
Could you please elaborate some of such use cases? |
|
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? |
|
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 |
|
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 |
|
Would it be expected that I build a new class for |
|
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. |
|
@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 |
|
@sparr |
|
Also, it makes me think that |
|
@artch would it be appropriate for the intents to still be on the spawn, not a new intent target for the spawning object? |
|
|
|
@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. |
|
Please rebase this to the |
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
|
Merged in 072b738. |
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).