This idea grew out of a feature request on Sourceforge by mwedel, which was commented on by kshinji, and then fleshed out considerably on #crossfire. I'm going to try to implement it soon, so I thought I'd write up a specification here to start from.
A spawner (what we were calling this before we decided to just expand the generator to cover these functions) will create items – usually monsters, but not necessarily – at a set rate within a set radius, possibly with some randomness built in.
The objects to be created may be taken from a treasurelist or from inventory, or maybe both methods should be possible. A treasurelist allows different objects to have different odds of creation, but an inventory list could do that too, while also allowing the spawner to “run out” of objects to create.
Running out of monsters could be done wiht food. However, inventored monsters can be special in some case, fe. they can be holding key or special item. So if we want one of the spawned orcs hold a key to next level, then yes - its useful. kshinji
Spawners are indestructible and invisible, unlike generators.
Spawners will only create so many monsters at once. Monsters should be tracked wherever they go, so a player can't use charm monster
near a spawner to build a huge army.
Is this really a problem, though? Players can already do this withsummon pet monster
andsummon cult monsters
, and it doesn't seem to be a problem.
Also, if a spawner creates objects which are not destroyed, like weapons players want to keep and use, that could get tricky. Maybe the spawner should lose track of objects when they pass outside its radius?
I propose rather that it loses track of objects which are not anymore on their map - fe. in players inventory.
* Monsters should apear frozen
for a second, to prevent them from instantly rushing onto player. This could be done with paralyze effect, there was also some code which used speed_left to freeze objects, according to irc.
* There should be monster animation for spawning, or if monster does not have one, fixed effect should be used.
* Spawners should have randomness flag - if set to 0, they would produce new units exactly at the calculated time, if 1, they would add/substract some amount of time at random.
* Spawner should have initial spawns value, which woul make him spawn that much monsters when map is loaded to ram.
* Spawners should use input from connections, to spawn monsters. There should be then option for them to not spawn regularly at all, only when they are triggered.
* Spawners could announce to connection, whenever all their monsters got killed.
* Spawners could have key (by default = 0), which would be percantage chance for spawner to get into faster mode. This mode should wear off after some time. This mode would make spawner produce twice faster, and have twice higher max capacity for a period of time.
* The other key would allow spawner to get into slower mode - where it works twice slower, but probably with the same max capacity.
Please add new ideas here.
So far, I've added the ability for generators to create monsters within a radius, which is set with the generator_radius
field in the object. This defaults to 1 if not set. Patch for this is at http://baugher.pikenet.net/cf/generator_radius.patch.
The limit has been implemented. Patch is here: http://baugher.pikenet.net/cf/generator_radius.patch. If a generator has generator_max
set, it will only create new objects when there are less than that many objects belonging to it already on the map. This works a little funny at the edges of tiled maps: If the generator creates a monster on the neighboring map, it won't be counted, so it could end up creating more than the limit. I'm not sure whether this is really a problem, but if it is, it could be fixed by preventing the generator from creating monsters on other maps.
Note from mwedel: current implementation of finding out how many monsters a generator has generated is highly inefficient - looking at all objects on the map can be a very time consuming process if there are large piles of treasure. A better approach would be to look on the active object list, on the basis all monsters are active objects, and then narrow the search criteria. Even on maps without treasure lists, this may be a gain - taking a quick look at metalforge, there were 3205 active objects when I logged in. A 50×50 world map is sure to have at least 2500 objects.
Reply from Rednaxela: Perhaps one thought, is maybe we should have per-map active object lists? This would increase efficiency of such searches by quite a bit. It would also benefit spells like Charm Monster and Destruction
Both these changes have been committed to trunk.