Page 1 of 1

Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 2:57 pm
by Factorimon
Hi,

I'd like to write a mod that introduces a new type of enemy. It should be like a boss with lots of HP, spawn at random position, constantly moving in random directions, slowing down when attacked and destroying anything in its path. It's supposed to be the only enemy unit (biters turned off completely) and force the player/s to flee, leaving his main base and rebuild somewhere else.


I have a lot of coding and some factorio modding experience.

I don't know how to create a new type of enemy, if it's even possible or if there any mods out there i can take a look at.

Any help is appreciated, perhaps somebody has seen a mod that creates new types of enemies or knows of a work-around

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 3:07 pm
by eradicator
Just search for "warfare" or "enemies" on the mod portal. There should be a number of mods that introduce new enemies (mostly recolored/rescaled biters). Hopefully you have a good 3D model for your new boss :P

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 3:54 pm
by Factorimon
I did that and it turns out ppl are just modifying the biter parameters. I need to make changes to their behaviour and damage handler, that's where i'm stuck.

Maybe it just isn't possible..

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 4:48 pm
by eradicator
Going purely by the description i remember that https://mods.factorio.com/mods/Veden/Rampant supposedly introduces some new behavior. But you'll probably require heavy scripting for that (if it's really only just one enemy that shouldn't be a performance problem though).

Not sure what you mean with "damage handler".

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 9:17 pm
by Factorimon
Lol, Rampant was one mod i was looking for but forgot the name. Thanks!

I had success modifying a biter in lua and then use the set_command() function on the entity to make it go to a position i specify even ignoring any damage sources. Hope to release the mod in the near future.

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 10:38 pm
by Factorimon
Is there any way to slow down an enemy via lua on run-time? I want my boss to slow down while he takes damage..

Re: Adding a Boss/custom Enemy

Posted: Mon Jan 08, 2018 10:55 pm
by darkfrei
Factorimon wrote:Is there any way to slow down an enemy via lua on run-time? I want my boss to slow down while he takes damage..
Fast replace with another prototype. Factorio-style!

But here is no events.on_damage and you must check in by yourself.

Re: Adding a Boss/custom Enemy

Posted: Tue Jan 09, 2018 1:15 am
by eradicator
Some "damage" types, like i.e the Slowdown capsule have the effect of...slowing down(!) the enemy :P. So as you'll already have to be hooked into on_tick anyway, just spawn some invisible slowdown capsules onto the boss.

Re: Adding a Boss/custom Enemy

Posted: Tue Jan 09, 2018 2:43 pm
by Factorimon
Both excellent ideas. Unfortunately, i need the movement speed to decrease linear with the boss' HP.

Slowdown capsule effects don't stack, and i would need at LEAST 10 prototypes with different movement_speed to get the desired behaviour. Still, if there's no other way the latter seems to be the best option so far.

Is it possible to change the prototype on a unit or do i have to respawn the unit with a new prototype at the former position?

EDIT: is it possible to equip my boss-unit wih a power armor and exoskeletons? ^^

Re: Adding a Boss/custom Enemy

Posted: Tue Jan 09, 2018 5:31 pm
by eradicator
Adding some prototypes isn't really a problem. You'd have to respawn the boss with current position/rotation/orientation/health etc, yes. And the respawning would interrupt the current animation obviously. I'm not sure if the slowdown effect strength can be defined on capsules (it probably can) in which case you could still use 10 different types of invisible slowdown capsules if the animation interruption looks too ugly.

I'm not sure if there's any prototype that has both an armor inventory/grid and a behavior. https://mods.factorio.com/mods/kyranzor/robotarmy has some things that look like vehicles, you might want to check what prototype they are internally.