Research Causes Evolution

by H8UL

Replaces the vanilla enemy evolution mechanic: unlocking technologies now increases biter evolution!

Content
5 years ago
0.15 - 0.17
20
Enemies

b Not using research count in calculation [solved]

6 years ago
(updated 6 years ago)

Hello, looks like you've been using the ingredient count as the research count, but that's the ratio of science packs per research count and is almost always 1. So this means that the mod doesn't increase evolution proportional to the total number of red science packs in the research. The mod setting to make them all equal has little effect -- they're pretty much already treated as equal.

I think you intended to use the research count; the total red science pack count is best calculated by multiplying the ingredient count by the research count. That way, early game tech only increases evolution by about 0.1%, while nuclear power increases evolution by 3.7%. Without the change, everything pretty much increases evolution by 1%.

Also, while investigating this I saw that you're accessing settings in a loop. Setting values are relatively expensive so should be accessed only once.

I made the appropriate changes and tested them; this is what I'm playing with now:

    local equalTechValue = settings.global["research-causes-evolution-all-techs-equal"].value
    for techname, tech in pairs(eventForce.technologies) do
        if tech.research_unit_count_formula == nil and not tech.upgrade then -- not an infinite research and not an upgrade
            for _,ingredient in pairs(tech.research_unit_ingredients) do
                if ingredient.name == "science-pack-1" then -- find the red research pack

                    local thisTechReds
                    if equalTechValue then
                        thisTechReds = 1
                    else
                        thisTechReds = ingredient.amount * tech.research_unit_count
                    end

                    if tech.researched then
                        currentReds = currentReds + thisTechReds
                    end
                    totalReds = totalReds + thisTechReds
                end
            end
        end
    end
admo
6 years ago

Change deployed as 16.2.1.

New response