Enemy spawn script?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
.ex.inferis.
Posts: 223
Joined: Wed Dec 17, 2008 7:30 am
Location: At the End Mills, within the Black Star

Enemy spawn script?

Post by .ex.inferis. »

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.
fcas3t
Posts: 43
Joined: Sun Nov 29, 2020 6:46 pm

Re: Enemy spawn script?

Post by fcas3t »

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: Select all

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: Select all

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.
fcas3t
Posts: 43
Joined: Sun Nov 29, 2020 6:46 pm

Re: Enemy spawn script?

Post by fcas3t »

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

Don't delete the entire

Code: Select all

if ( level.time == 2)
block. You still need to populate AllStaticSPs, otherwise DER can't spawn anything.

And

Code: Select all

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: Select all

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

Return to “Scripting”