More Enemies


Simple idea of just having more enemies, with larger and/or more enemy attack groups. Comes with five preset difficulties: Easy(0.1), Vanilla(1), Vanilla+(1.75), Hard(4), and Insanity(11). Each added setting can be configured independently of the selected difficulty to personal taste. Engineer beware - they come for you.

Tweaks
8 hours ago
2.0
2.64K
Enemies

b [0.7.6 - Fixed] Error on new game (0.7.5)

6 days ago
(updated 6 days ago)

Hi there - following error occurs on starting a new game.

Error while running event level::on_player_created (ID 32)
The mod More Enemies (0.7.5) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event more-enemies::on_entity_died (ID 4)
more-enemies/scripts/service/spawn-service.lua:453: attempt to index upvalue 'surfaces' (a nil value)
stack traceback:
more-enemies/scripts/service/spawn-service.lua:453: in function 'on_entity_died'
more-enemies/scripts/controller/spawn-controller.lua:130: in function 'func'
TheEckelmonster-core-library/scripts/event-handler.lua:73: in function 'process_event'
TheEckelmonster-core-library/scripts/event-handler.lua:90: in function <TheEckelmonster-core-library/scripts/event-handler.lua:84>
stack traceback:
[C]: in function 'die'
core/lualib/crash-site.lua:245: in function 'create_crash_site'
base/script/freeplay/freeplay.lua:84: in function 'handler'
core/lualib/event_handler.lua:72: in function <core/lualib/event_handler.lua:70>

Seems like a simple race condition problem on frame 1 relating to how the crash site works. The game is killing whatever's under the crash site before your variables get initialised, so the function on_entity_died is called with a nil value for surfaces because that value isn't defined in the function.

This architecture also appears to involve running scripts on every entity death, which is probably gonna cause UPS issues. I think it's to do with how the custom whitelist stuff is implemented? You probably wanna do that stuff in on_init() as you only need to pass over the prototypes once during game load :)

6 days ago
(updated 6 days ago)

Oh, didn't notice the other guy's post, but it's relevant here because it confirms UPS issues with on_entity_died and that this bug is a product of how the solution is designed.

Because this script is called on EVERY entity death it's going to generate a lot of script load (see the other user's comment about asteroids) and it'll break when a mod does something in a way your script isn't designed to handle.

In my case, it's basically because of a simple code oversight (the variable isn't initialised in on_entity_died because the script is called by the game before it bootstraps mod vars and the function doesn't itself initialise surfaces), in the other case it's probably because the biter-factions-ng mod has custom scripts for its deaths and don't include data your scripts expect in its death events.

In all cases, calling on every entity death is gonna result in a LOT of script load, especially as the game progresses and you will probably keep running into bugs relating to on_entity_died.

I'd definitely recommend looking into:

https://lua-api.factorio.com/latest/classes/LuaBootstrap.html#on_init

https://lua-api.factorio.com/latest/concepts/EntityPrototypeFilter.html

https://lua-api.factorio.com/latest/classes/LuaPrototypes.html#entity

Using the game's own filtering to establish your whitelist during the initialisation phase is gonna be MUCH better for UPS. Of course mod compatibility is still kind of a problem, but it's better to use the game's internal tools and then if a mod breaks your mod, it's not your fault and not your problem to patch. ;)

Hello! Apologies for the issue, but thanks for the report!

That said, the on_entity_death event filtering is a known issue that I have fixed locally already for version 0.7.6, it's just not publicly ready yet. Appreciate the detail though!

Additionally, the bug reported only occurs with Vanilla; confirmed with version 0.7.5, it does start a new game fine when SA is present. As well, have confirmed this bug is already fixed with my local version of 0.7.6 for both Vanilla and Space-Age.

Hope to have 0.7.6 out as soon as I reasonably can. Apologies again for the oversights on my part, but I greatly appreciate you bringing them to my attention!

6 days ago

Thanks for the quick reply! This did happen on a Space Age playthrough with v0.7.5 interestingly, I figured the actual bug I experienced (the race condition) is effectively random, because it requires the crash site sequence to kill an entity underneath it on frame 1, which isn't guaranteed to happen because it isn't guaranteed that the crash site will spawn over an entity it needs to kill. I'm not sure if there's some additional condition which might cause it to happen differently in vanilla and SA, but it's moot anyway as you've fixed the issue. :)

8 hours ago

With the release of version 0.7.6, this issue should be fixed.

Please do let me know if you encounter any further issues. Thanks again for bringing this to my attention!

New response