Combat Robots Overhaul

by Wannie

Overhaul of Factorio's Combat Robots behaviour to make them more useful by automatically attacking enemies.

Tweaks
9 days ago
1.1 - 2.0
8.75K
Combat

g Thank you!

4 days ago
(updated 3 days ago)

Hey Wannie! Just wanted to say thanks for the amazing mod!

Just as a bit of a crazy side-note... I was trying to deploy the capsules in this mod, automatically via Renai Transportations:
https://mods.factorio.com/mod/RenaiTransportation

Specifically, using their "military thrower", which is basically just an inserter that throws grenades, capsules, etc.

Unfortunately, when the inserter threw a destroyer-unit capsule, the moment it landed, I got an error regarding "last_user" being nil (I tried to swap last_user in control.lua with game.players[1], but that didn't work).

So I was wondering, would it be possible for me to create a mod that could use a custom building to automatically deploy the bots?

Or would it not be feasible due to differences these capsules have from the ones found in the vanilla game.

Regardless, thanks again for the amazing mod!

3 days ago

As you saw yourself, the issue is the missing last_user when the entity is created. Unfortunatly, the function on_trigger_created_entity has no last_user set when there is no player character. Hence why last_user is nil when the capsule is spawn by something other than a player with a character. I adressed this with the developers, but according to them it works as intendet. See here: https://forums.factorio.com/viewtopic.php?f=48&t=104108.

I circumvented the issue by removing the projectile after a capsule is being spawn, and then checking if a character is present. If not, I spawn the combat robot directly without a projectile being fired. You can see this logic in the function player_used_capsule. I assume you could use a similar approach for your building.

Unfortunatly, I don't know if the variable "Source" is filled in the event on_trigger_created_entity when the capsule is thrown by the thrower. If yes, you could maybe use the last_user from the source entity. Otherwise you would have to check for a turret near the spawned entity and spawn the robot directly.

3 days ago

Ahhh okay, thank you Wannie! I definitely appreciate the info! Again, thanks for the awesome mod (:

New response