Page 1 of 1

Dungeon Enemy Spawns

Posted: Mon Feb 22, 2021 8:19 am
by reaven
Hey all!

So I'm just starting fiddling with daggerfall unity modding. My idea here is to alter the number of enemies that spawn in dungeons. I've been looking at the code and I see several methods for handling the enemy spawn, but I cant really say which are used inside dungeons. Any direction would be welcome!

More specifically, my idea would be to add an additional chance of another enemy spawn when an enemy is placed inside a dungeon. I'd like to make this customizable but I'll play with that later.

Thanks!

Re: Dungeon Enemy Spawns

Posted: Mon Feb 22, 2021 5:05 pm
by reaven
So, after some research, I've found what I think I want to change: The 'AddRandomEnemies' method from 'RDBLayout' class.
I've made some changes on the unity code to make a prototype of what I intend to do with the mod. Now my question is, can I mod this at all? I've seen examples of overriding with FormulaHelper and subscribing to events but Im not sure if overridding something like this is supported.

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 8:20 am
by reaven
I've been thinking that maybe subscribing to the event OnTransitionDungeonInterior I could call AddRandomRDBEnemyClassic() to spawn additional enemies for the random enemy spots in the dungeon, given a random chance to trigger. But this method has a lot of parameters, some of which I'm not sure how to obtain from my mod class.
Any experienced modder or dev could chip in? Is this a valid approach?
Thanks!

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 10:00 am
by Ralzar
Off the top of my head, one way to do this that I actually considered but never got around to:

On transitioning into dungeon, find all enemies. Then do a foreach where you do a roll (against Luck?) if you want to add a second enemy. Placing the second enemy slightly positioned off from the first.

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 10:04 am
by reaven
Nice idea, maybe this is easier to from a mod POV. I'll give it a shot. Thanks!

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 10:46 am
by BadLuckBurt
I think Ralzar's suggestion is the best way to approach this for now.

I had a quick glance at the code that generates the enemies when creating a dungeon block and it's very much tied to that creation process atm. It would be nice to split that up at some point to allow for easier modding.

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 2:10 pm
by reaven
BadLuckBurt wrote: Thu Feb 25, 2021 10:46 am I think Ralzar's suggestion is the best way to approach this for now.

I had a quick glance at the code that generates the enemies when creating a dungeon block and it's very much tied to that creation process atm. It would be nice to split that up at some point to allow for easier modding.
Yeah, that was my impression... thanks for the input

Re: Dungeon Enemy Spawns

Posted: Thu Feb 25, 2021 5:55 pm
by l3lessed
If you do Ralzars approach, don't forget to check the environment around some how, or you'll begin spawning enemies outside the walls and floors.

You could use a sphere cast, sized to the enemy capsule size, going from the center of the enemy and the first open space it finds from a certain distance spawns another enemy.

If they aren't a flying enemy, you also would need to shoot a raycast down from that found spawn location and ensure there is a floor under them too, so they don't get spawned over ledges and fall to death instantly.