Page 1 of 1

confusion with modding result_units in unit-spawners

Posted: Sun Aug 05, 2018 1:39 am
by noteark
I am attempting to add a few more enemies to the game as well as changing the stats of the current ones. I am confused on how the result_units function works on the spawners. I was trying to make all the mobs spawnable right from the beginning not that it is important to do so in my mod it was strictly just to test all the names changed properly and that they would spawn in the first place. I can get all my new units and previous units to spawn if I put them on res[1] and res[2] so no problem there. I was able to get res[3] through res[7] to spawn in a different save with much more pollution after I synced the mod with it. They spawn kind of goofy with just a bunch different unit tiers. To the main point of this topic is what exactly changes how they spawn and when.

So I found this in the LuaEntityPrototype api under result_units. The main part I am confused on is what exactly is evolution_factor stand for and where is its place in the result_units function

unit :: string: Prototype name of the unit that would be spawned
spawn_points :: array of SpawnPoint: Each SpawnPoint is a table:
evolution_factor :: double: Evolution factor for which this weight applies.
weight :: double: Probability of spawning this unit at this evolution factor.

result_units = (function()
local res = {}
res[1] = {"small-biter", {{0.0, 0.3}, {0.35, 0}}}
res[2] = {"small-spitter", {{0.25, 0.0}, {0.5, 0.3}, {0.7, 0.0}}}
res[3] = {"medium-spitter", {{0.4, 0.0}, {0.7, 0.3}, {0.9, 0.1}}}
res[4] = {"big-spitter", {{0.5, 0.0}, {1.0, 0.4}}}
res[5] = {"behemoth-spitter", {{0.9, 0.0}, {1.0, 0.3}}}
return res
end)(),
So the unit is obviously "small-biter" and I believe the spawn_points are the bracket but what is evolution factor and weight {"small-biter", {{spawnpoint?, spawnpoint?}, {evolution_factor?, weight?}}}
if the above statement is true then what is the third set of brackets for small-spitter and medium-spitter and why do the other ones not have a third set of brackets. This is my first time modding in factorio so any and all information will be appreciated. Please let me know if I need to add any more information.

Re: confusion with modding result_units in unit-spawners

Posted: Sun Aug 05, 2018 1:59 am
by DaveMcW
Each SpawnPoint is a table:
evolution_factor :: double: Evolution factor for which this weight applies.
weight :: double: Probability of spawning this unit at this evolution factor.
Spawn_point is a table containing evolution_factor and weight.

There are 2-3 spawn_point tables in the spawn_points table, each works for a specific evolution factor.

Re: confusion with modding result_units in unit-spawners

Posted: Sun Aug 05, 2018 4:19 pm
by noteark
Thank you very much for the reply it helped me understand where I was going wrong.