Got Dzibix?

A place for discussion of making game modifications.
gaerzi
Posts: 202
Joined: Wed Jul 10, 2019 1:30 pm

Got Dzibix?

Postby gaerzi » Tue Jul 19, 2022 8:30 am

If you manage to peacefully annex the Tinkers (ally them, and be bigger than them for long enough that they give up), there's a problem in that the Tinkers you get become disconnected. Logically, they should remain connected: Dzibix is now on your side. You also get to inherit their harmonized alien populations, but they're all also disconnected and riot. Unoptimal.

Here's what I did to solve this:

First, I went to Orders/orbits.lua where I modified the absorb_major_empire function:

Code: Select all

function absorb_major_empire(new_empire,empire)
  order.absorb_fleets(new_empire,empire)
  order.absorb_empire(new_empire,empire)
  if not new_empire.absorbed
    new_empire.absorbed={empire}
  else
    new_empire.absorbed[1+#new_empire.absorbed]=empire
  end
 
  --special hardcoded weirdness
  if empire.species=='tinker'
   new_empire.got_dzibix = true
   print('got dzibix!')
  end
 
  --coin and ore
  new_empire.metal += empire.metal
  empire.metal = 0
  new_empire.credits += empire.credits
  empire.credits = 0


As you can see, I set a new empire variable that I called "got_dzibix". This will be referenced by the other changes inserted in the code.

@Technologies/tech_queries.lua:

Code: Select all

Empire.possible_improvements = weak_memoizeNN | function(empire,planet)

  -- always show these basic improvement types.
  local rval = set('Factory','Lab','Planetary Defenses','Farm','Mine')

  local mt = getmetatable(empire.tech_info)

  -- add additional improvements if we appear to have tech for
  -- them.
  for t,info in pairs | empire.tech_info
    local unlocks_improvement in info
    if unlocks_improvement
      rval[unlocks_improvement]=true
    end
  end

   if empire.species=='tinker' or (empire.got_dzibix and (planet.pop_and_habs['tinker'] or planet.pop_and_habs['tinker_harmonized']))
      rval.Factory=nil
      rval['Machine Altar']=true
   end

  return rval
end

This change makes it that an empire that has annexed the Tinkers will build Machine Altars instead of Factories on planets which have a Tinker population; while on planets without Tinkers it is Factories that will be available as normal. Technically it could be changed to be Machine Altars everywhere as there are no real downside (it makes Tinkers productive, and other populations don't see a difference between that and regular factories) but it sort of made more sense to me this way.

Galaxy\apply_morale_effects.lua:

Code: Select all

function wont_become_unhappy(planet,race)
  local suffix = get_race_suffix(race)
  if suffix=='slave'
    return true
  end
  if suffix=='harmonized'
    if (planet.empire.species=='tinker' or planet.empire.got_dzibix) and planet.machine_altars>0
      return true
    end
  end
end

Rather straightforward change, this allows annexed tinkers (and other harmonized populations) to remain harmonized if Machine Altars are present.

GUI\~GalaxyMap\@PlanetPopInfoBoxes.lua, in the planet_race_info_text function:

Code: Select all

      -- tinkers always get a harmonize button, though it may be
      -- greyed out.
      if (planet.empire.species=='tinker' or planet.empire.got_dzibix) and (get_race_suffix(race)~='harmonized') and (get_race_suffix(race)~='harmonized_unhappy')
         local cant_harmonize = planet:cant_harmonize(race)

Just one of the places where I replaced a check for empire.species=='tinker' by one that also checks for the annexation flag being set. This gives you the possibility to harmonize populations; though that's not necessarily what you'd want to do as a non-Tinker.

Orders\activities.lua:

Code: Select all

function Empire.cant_use_activity(empire,activity)
   if empire.species=='tinker' and not empire.absorbed
      return activity=='City Planning'
   elseif not empire.got_dzibix
      return activity == 'Manufacture Population'
   end
end

Alright, so with this there are two changes:
1. A Tinker empire that annexed another species get access to City Planning.
2. A Non-Tinker empire that annexed the Tinkers get access to Manufacture Population.
Note that these activities are also constrained by planet-level checks, this one is merely the empire-level check. Basically you'll get ManuPop on planets with cyborgized populations, and CitPlan on planets with regularly-biological populations, and if both pop types are present you do get both activities.

Orders\harmonize_mechanics.lua:

Code: Select all

Planet.cant_harmonize = weak_memoizeNN | function(planet,race)
  local vanilla = remove_race_suffix(race)
   if not planet.empire return 'no_empire' end

   if not RACE_INFO[race].harmonizable
      return 'not_harmonizable'
   end

  if get_race_suffix(race)=='harmonized' or get_race_suffix(race)=='harmonized_unhappy'
    return 'already_harmonized'
  end

   local empire in planet
   if not empire:known 'Cybernetic Organisms'
      return 'tech_not_known'
   end

   if empire.species~='tinker' and not empire.got_dzibix
      return 'not_tinker'
   end

   if planet.machine_altars < 1
      return 'no_altars'
   end

Straightforward change here. There are three more in the same file. The next two are in the order.check_connected_tinkers function.

Code: Select all

   -- implicitly deharmonize if we have harmonized tinkers that
   -- are, indeed, disconnected.
   if planet.pop?.tinker_harmonized
      if (planet.empire?.species~='tinker' and not planet.empire.got_dzibix) or (planet.machine_altars < 1)
         local race ='tinker_harmonized'
         local vanilla = 'tinker'
         local n=planet.pop[race]
         planet.pop[vanilla] =n + (planet.pop[vanilla] or 0)
         planet.pop[race] = nil
      end
   end

   -- implicitly make happy any unhappy harmonized aliens
  if (planet.empire?.species=='tinker' or planet.empire?.got_dzibix) and (planet.machine_altars > 0)
    for r, n in pairs | shallow_copy | planet.pop?
      if get_race_suffix(r)=='harmonized_unhappy'
        order.convert_to_removed_suffix(planet,r,'unhappy',n)
      end
    end
  end

There we make it so that annexed Tinkers are not automatically deharmonized, and instead reconnect any unhappy harmonized population when Machine Altars are present.

The last in this file is this:

Code: Select all

function Planet.isnt_harmonized(planet,race)
  if get_race_suffix(race)~='harmonized' and get_race_suffix(race)~='harmonized_unhappy'
    return 'not_harmonized'
  end
   local empire in planet
   if empire.species~='tinker' and not empire.got_dzibix
      return 'non_tinker_empire'
   end
   if planet.machine_altars<=0
      return 'no_altar'
   end
end

Another simple check change.

And that's it.

emky
Posts: 20
Joined: Fri May 07, 2021 8:12 pm

Re: Got Dzibix?

Postby emky » Wed Jul 20, 2022 1:22 pm

I always felt it was strange that, of all the empires, the Tinkers functioned oddly/differently when annexed. The others give you their big perks, but not the Tinkers. Nice hunting to track it all down!


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 4 guests

cron