Changing Leader Mid-Game

Discussion in 'Mod Creation Help' started by DarkAlzara, Jul 4, 2020.

  1. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    Hey all,

    Just a question. Does anybody know if it is possible to code a leader change mid-game. Like, say a civilization fulfills a certain criteria and their leader changes to somebody different?

    Thanks all! :)

    Al
     
  2. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    So, do we know if this is remotely possible?
     
  3. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,830
    Gender:
    Male
    Location:
    Warsaw
  4. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    Ok... not to be one of those guys... but why?
     
  5. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,830
    Gender:
    Male
    Location:
    Warsaw
  6. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    so there is no way to update the database mid-game? Link to a new leader? I was hoping for a more specific response than “no, go ask firaxis”...
     
  7. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,334
    Location:
    France
    changing the DB mid game has no effect.

    As for the reason there is no method to do that in game, how could we know ? Simple answer is "they do not need it"

    Maybe there is 3D engine issue with swapping leader head, code issue with applying LUA, etc, etc...

    You can try: PlayerConfigurations:SetLeaderTypeName(LeaderType), but I suppose it's working for setup only (it's in UI context, ie not meant for gameplay changes), and won't do anything in game (or crash).
     
    DarkAlzara likes this.
  8. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    167
    Gender:
    Male
    As a one-line rule, my understanding is that the database cannot be updated once a game has been loaded. I have not delved into Lua-based modding, which I understand is the way to make the most 'dynamic' changes mid-game, but I think these functions are still limited to reading from the existing database.

    Now, I'm definitely not an expert when it comes to the boundaries of what is possible, but in this scenario - and it's not something I've considered, until composing this reply - I would expect the limitation is imposed because the leader (actually, the Player) is written to a database that contains the game's configuration at the point a game is started. The moment this happens, the game commits some information to the database - which Player is in slot 1, which Player is in slot 2, etc.

    Because there is a database-written action that homes a Player to a slot - and, presumably, there is logic that means the foundation of what makes up a 'Player' comprises a single Leader (which inherits their unique 'things', the civilization they lead and that civilization's unique 'things') - I think that means we arrive at a point where changing the leader, based on some condition being triggered, is not possible.

    Hypothetically, if it was possible for one Player to consist of multiple leaders, then additional database entries that describe the various conditions that 'select' the active leader at a given time may be achievable - but I daresay this would involve substantial re-work of the
     
    DarkAlzara likes this.
  9. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    Ok excellent replies thank you! I may look into this in more detail eventually. It’s something that would be very useful for what Im Trying to achieve.
     
  10. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    and just an immediate thought I’ve had regarding this: there are already instances of civilizations with multiple leaders: like Elanore. Also I know that Anno domini has a wealth of leaders for some civs. Maybe this is a good place for me to start my investigation...
     
  11. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    167
    Gender:
    Male
    It's correct that there's both civilizations with multiple choices of leader and also leaders that can lead multiple civilizations - but I think the point is that each combination of one-leader-and-one-civilization represents one entry into the Players list at the point the game is configured. I think that's the limiting factor - I don't think the ability to overlap leaders with civilizations changes that, unfortunately. No matter how many leaders are available and no matter which civilizations they can lead, a Player slot still consists of one leader in charge of one civilization.

    I'd recommend starting with exploring the Lua command Gedemon mentioned earlier - my replies are just observations and logic based on a level of assumption; no cold, hard facts, as it were. But well-intentioned to try and save you a wild goose chase.
     
    Last edited: Jul 6, 2020
    DarkAlzara likes this.
  12. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    Still, it points me in the right direction and gives me food for thought! Thanks for all the help! I’ll start looking into it!
     
  13. cvb

    cvb Prince

    Joined:
    Jun 12, 2017
    Messages:
    446
    As written 'changing the DB mid game' does not work. At least not directly. This issue has been mentioned already:
    All LeeS has written is correct & true. I don't want to take issue at all with that - I just want to add my thought on a "remotely possible" solution to the given task "say a civilization fulfills a certain criteria and their leader changes to somebody different?" ...
    - No, the leader changes not at all, because he may not from the standpoint of the game - formally you have only one
    - Yes, if you have different sets of files with different attributes as abilities or pictures, you can swap them while the game is not running - same vessel, but different content. It has the effect of a changing leader.

    You can use a Lua script notifying the player to save and stop civ6 when "a civilization fulfills a certain criteria" & writing a short unique keyword to Lua.log
    A shell-script/batch-file (OS level) can then analyze the correlating Lua.log file and rename the right files of leader definitions (ie. "changing leader") WITHOUT the player even knowing what was done when he reloads the game and continues play. He just runs a tiny tool between two civ6 sessions ...

    .
     
  14. DarkAlzara

    DarkAlzara Chieftain

    Joined:
    Jul 1, 2020
    Messages:
    39
    Gender:
    Male
    Clever! Now all I need is a force-save and force-quit prompt! :)
     
  15. Gedemon

    Gedemon Modder Super Moderator

    Joined:
    Oct 4, 2004
    Messages:
    10,334
    Location:
    France
    I'm curious to know if the modifiers are correctly removed and re-applied for Leaders Unique Attributes.

    If that the case, then simply using PlayerConfigurations:SetLeaderTypeName(LeaderType) then saving/reloading *may* work without the need to quit the game and could be fully automated.
     
  16. cvb

    cvb Prince

    Joined:
    Jun 12, 2017
    Messages:
    446
    Well, That IS the question. What happens, when you create entirely new modifiers, which in worst case contradict modifier setups already applied to existing game objects?
    Has to be tested individually, in general I'd rather avoid such potential conflicts. I mean, Leader Attributes (if not just used as index into array) are not only simple content, they may be part of the vessel. Graphical stuff like icons, pictures, animations are probably simple content as numerical values.

    I don't expect a game started e.g. with <Row Name="CITY_AMENITIES_FOR_FREE" Value="1" /> to show problems when it is later continued additionally with UPDATE GlobalParameters SET Value = 0 WHERE Name ='CITY_AMENITIES_FOR_FREE';
    Likewise THRESHOLD_SHIFT_PER_PAST_GOLDEN_AGE, BARBARIAN_CAMP_MINIMUM_DISTANCE_CITY ...Unit Maintenance, CombatStrength, Healing, GainingEXP ... I see a lot of interesting parameters which could use some change during a game (for the human player).

    .
     
  17. isau

    isau Deity

    Joined:
    Jan 15, 2007
    Messages:
    3,071
    If the leader choices are custom leaders and not the existing ones, you can use RequirementSets to only activate certain abilities under certain conditions. When a RequirementSet is used, the Modifiers are still loaded by the database,just not actually "turned on" unless the requirement conditions are met.

    This wouldn't solve the issue of graphics.
     

Share This Page