-
Notifications
You must be signed in to change notification settings - Fork 534
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
Track RandomSpawner origin of replaced things #2683
base: master
Are you sure you want to change the base?
Conversation
Updating to latest GZDoom for new bot development
This is useful when interacting with randomizer mods.
This PR would produce this |
and is there a need to add a new field to actor just for this? IIRC you can iterate over map-placed random spawners on |
That sounds like boilerplate that would have to be repeated for every mod interested in tracking RandomSpawner cause-effect chains. I agree there probably is a cleaner way, though... |
I'll go think about that and come back with a better idea. Thank you! :) |
might be a good idea to use an event instead, ex. |
Maybe, but mods still have to track what class each actor replaced, which also gets complicated when an actor has a multi-step replacement chain (e.g. due to That is, unless In the end, this really involves adding related state to track what type each actor comes from, which must transcend intermediary steps like Ew singletons, I know, but keep in the barf, it doesn't sound like that bad of an idea here. Singletons are surprisingly useful in ZScript. Besides, it would keep a clear separation between the well-established Actor code and this somewhat niche state tracking, which also helps with partial implementations and other compatibility-related ideas. Heck, it could be monkeypatched to older versions using an |
yes, but that tracking can be done in randomspawner itself instead of in actor, making it much lighter and simpler |
I assume |
The order goes: |
That's fair, I'm also thinking about changing the |
(Tests pending) |
i still don't think this is a good solution -- any tracking can and should be done only by mods that need the relevant data, all that's needed by the engine is an event to signal when replacements happen |
The engine is losing information about map start if it doesn't. I don't know if such behaviour should be left up to mods. This could be made an optional feature. |
the engine doesn't need that information, so if a mod needs it, it can just save the information itself |
Fair enough. I'll probably just make an event for when a mobj is replaced, and I'll move the tracking code elsewhere. I still want it to be in some sort of optional utils library, to reduce the amount of duplicate code across mods. An engine-side ZScript module dependency resolver would be cool. |
I'm not sure I understand the use case for this. Is it solely to detect if something was spawned by a RandomSpawner? The example makes it seem like getting the RandomSpawner's list of monsters is desired, but there are much more trivial ways to do this such as iterating through all classes and storing classes marked as a monster that aren't replaced. This is something the mod itself should be handling in my opinion and not something baked into the engine. |
It's the opposite -- it's for getting the original randomspawner class that created a particular actor |
That was my take away, but it seemed they wanted this so they could get the rest of the monsters the spawner has. My thoughts are that these kinds of mods should simply be looking through the Actor classes for valid monsters, which can be done by getting its default, checking |
This seems to ignore the fact that a mod might want to see what kind of monsters (or even non-monster classes, like Items) could possibly be spawned within a level in its initial configuration, not every class there is as a whole. |
Then the |
This only applies to
RandomSpawner
s at the moment.This allows mods to see the class of the original map thing that eventually led to a thing being spawned, to better interface with randomizer mods and the like.
A good usage example can be seen here: if a Zombieman is replaced by a
RandomSpawner
capable of producing 5 other variants by a replacer mod usingRandomSpawner
, this change in AI Director would allow it to see the originalRandomSpawner
and guarantee access to all 5 variants, even in a level with only 1 initial Zombieman (so other types could spawn on, e.g., >100% start spawn factor, or in continuous spawns).