Looking for a way to limit map location spawns in custom mod


I’m working on a mod that adds a custom start location (science bunker) that contains a vat of flavored/unflavored mutagen serum.

My mod is here

Everything is working great, except I am having an issue where I want to limit the total number of Science bunkers that generate in the game world to 2. I know in the overmap specials you can specify a range for occurrences; however I ended up creating a separate overmap special of the science bunker and each of the different mutations to allow specifying which mutagen beginning location you’d like to start in. This means my worlds spawn with up to 23 of these Science bunkers, as each variation has an occurrence of 0-1.
I haven’t really figured out a way to solve this so far that wouldn’t involve more than JSON modding. I know I can set up weighted values, but then I lose the ability to allow the player to select their starting mutagen type (by choosing their starting location) if I change the om_terrain value of the bunkers to be identical.

I’m trying to avoid using LUA, but if it would allow this, I’m up to the challenge – I’m just still not sure what condition/value I would tie the IF statement to.

Any ideas?


Just an update, I’ve decided to go the LUA route for now as I feel JSON will be too limiting for what I am trying to achieve. I found that there is a start_location attribute in class_definitions.lua on line 530 that I think I can reference with an IF statement. If that attribute isn’t sufficient, I think there is enough here for me to be creative and find a method that will work.
If and when I do get this working, I will post my solution for future reference.

Edit: Link to the code used for this