Enemy spawn script?

Fri Feb 18, 2022 4:35 pm

Or, more specifically, I'm trying to tinker this mod. I asked the author for help, but they sent me here instead, so here I am.

The way it works, it spawns enemies into a map based from the enemy rosters that composed the last map you were on and the current one. The idea is to have that happen from a custom roster instead. Looking at the code, I'm stumped at 'EnemyRoster' and 'LastRosterIdx'. I know what they represent, but now how to manipulate them to do what I intend to? I can comment out/remove LastRosterIdx since I don't plan to use it. 'EnemyRoster' seems to be a DynamicArray, according to the wiki but I can't figure out how to edit this to fit my needs, however. My main problem is understanding how EnemyRoster works so I can bend it to my will. Any help would be vastly appreciated. I'd like to know what I'm doing, haha.

Re: Enemy spawn script?

Sun Feb 20, 2022 11:55 am

Mod author here. I'll help you a bit, since you're determined to make some sort of change, and I received important help on this forum when I was making my mods.

First, your post here is poorly written. You should explain precisely what you want. Be specific.

One of your assumptions is incorrect: DER only uses the current map's enemies to form its roster.

Anyhow, here's a quick way to change EnemyRoster to randomly select from a fixed group of monsters that would be the same for any map.

Replace the declaration line in DER with this:

Code:
private const string[] EnemyRoster = { "HellKnight", "ShotgunGuy", "Archvile" };


Then the only other change to the DER code is replace the current roster creation block with this:

Code:
if ( level.time == 2 ) { LastRosterIdx = EnemyRoster.size() - 1; }


I just picked a few vanilla monsters off the top of my head. You can expand the array to whatever you want.

Re: Enemy spawn script?

Mon Feb 21, 2022 6:22 pm

What I hastily wrote yesterday is incorrect in at least one respect:

Don't delete the entire
Code:
if ( level.time == 2)
block. You still need to populate AllStaticSPs, otherwise DER can't spawn anything.

And
Code:
EnemyRoster.size()
may only be available for a dynamic array. (I obviously didn't test any of these suggestions and have no interest in doing so. Just trying to be helpful.) Instead, you may need to change LastRosterIdx to a constant, like this:

Code:
const LastRosterIdx = 2;
(which covers the example of 3 fixed array elements)