A new creature but uses simple biter ai?

This is the place to request new mods or give ideas about what could be done.
Post Reply
ifthenthenif
Manual Inserter
Manual Inserter
Posts: 1
Joined: Tue May 22, 2018 7:28 am
Contact:

A new creature but uses simple biter ai?

Post by ifthenthenif »

I want to add a new creature that spawns from biter nests. Only needs to have same ai as a biter. that's it. how do i do this? I already have the graphics sheets and tested them.
Need the lua parts. Someone upload a very very simple functioning example?

Proof i'm not joking around.
https://vimeo.com/266207227
https://vimeo.com/265672861

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: A new creature but uses simple biter ai?

Post by bobingabout »

you need to add them to the result_units tag on the spawner.

an example of what the table looks like, from a spawner in my mod:

Code: Select all

    result_units =
    {
      {"small-biter", {{0.0, 0.3}, {0.5, 0.3}, {0.7, 0.0}}},
      {"medium-biter", {{0.2, 0.0}, {0.6, 0.3}, {0.8, 0.0}}},
--      {"big-biter", {{0.6, 0.0}, {0.8, 0.4}, {0.9, 0.0}}},
-- Big enemies apear at 0.6, slowly become elemental between 0.7 and 0.8, and disapear by 0.9
      {"big-biter", {{0.6, 0.0}, {0.7, 0.4}, {0.8, 0.0}}},
      {"bob-big-piercing-biter", {{0.7, 0.0}, {0.8, 0.4}, {0.9, 0.0}}},
      {"bob-huge-acid-biter", {{0.7, 0.0}, {0.8, 0.2}}},
      {"bob-huge-explosive-biter", {{0.7, 0.0}, {0.8, 0.1}}},
      {"bob-giant-poison-biter", {{0.8, 0.0}, {0.9, 0.2}}},
      {"bob-giant-fire-biter", {{0.8, 0.0}, {0.9, 0.1}}},
      {"bob-titan-biter", {{0.9, 0.0}, {1.0, 0.3}}},
      {"bob-behemoth-biter", {{0.99, 0.0}, {1.0, 0.3}}},
      {"bob-leviathan-biter", {{0.99, 0.0}, {1.0, 0.05}}},
    },
So... you would need to add in a line as follows:

Code: Select all

table.insert( data.raw["unit-spawner"]["biter-spawner"].result_units, {"bob-leviathan-biter", {{0.99, 0.0}, {1.0, 0.05}}} )
Okay, lets break things down a bit.
table.insert means you're adding a new entry into the table, this is used when each entry in the table is NOT a tag, but just a numbered entry list.
we are adding an entry to the table data.raw["unit-spawner"]["biter-spawner"].result_units, or more specificallly, the result_units table of the biter spawner.
the entry we're adding, in my example, is {"bob-leviathan-biter", {{0.99, 0.0}, {1.0, 0.05}}}, so lets break that down.
"bob-leviathan-biter" is the name of the unit I'm adding, so, you should use the name of your unit.
we then have 2 sets of values {0.99, 0.0}, {1.0, 0.05}, you can actually add as many of these as you want, but 2 or 3 is often enough.
The first value in the bracket is the evolution factor at which this takes effect, the second value is the probability (weight) that this unit will spawn at that evolution factor.

So, going by my numbers, this biter will have a 0% chance all the way up to EF 0.99 and a 5% chance at EF 1.0. (okay, it's not 5%, when you add all my weights you get 1.25, so it's a 0.05/1.25 chance, which is a 4% chance)
So, to further explain, that's a 0% chance all the way up to the first entry, this then becomes a point, it then scales linearly to the value of the next point. to pick something a little easier to see...
{"small-biter", {{0.0, 0.3}, {0.5, 0.3}, {0.7, 0.0}}},
we define a 0.3 chance at EF 0.0, so from the start you have a 0.3 chance (which is 100%, because everything else is 0), this stays constant to EF 0.5 (because that's out second point with the same value), but then drops linearly down to 0 at EF 0.7. So if you were to look at it at EF 0.6(half way between the points at EF 0.5 and EF 0.7), you'd have a chance value of 0.15. The actual chance this unit spawns depends on the values of all the other unit entries in the table.

I hope all this made sense to you.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Post Reply

Return to “Ideas and Requests For Mods”