1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Add city modifier based on number of suzerains

Discussion in 'Mod Creation Help' started by Starjon, Sep 16, 2018.

  1. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    Hello there,

    I want to create a new leader, and as part of his unique ability, every city shall get +1 food and production for every city state he is the suzerain of. The only modifiers I could find that change a yield based on how many city states you control are MODIFIER_PLAYER_ADJUST_YIELD_MODIFIER_PER_TRIBUTARY and MODIFIER_PLAYER_ADJUST_YIELD_CHANGE_PER_TRIBUTARY. However, I think that they only work on global yields such as science and culture, not on local yields such as food and production.

    I think I have to use lua to get this to work. Can someone help me with that? I couldn't find any lua function to add a modifier to a city or otherwise change a yield, and I couldn't find an event fired when the suzerain of a city state changes either.

    Thank you in advance,
    Starjon
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,523
    Location:
    Illinois, USA
    there are no lua methods to directly add a modifier to anything.

    Lua can add or take away dummy buildings that add yields or yield modifiers to a city, but there are issues with this method, not the least of which is that unless you hide these dummy buildings from the user by using a customized version of the city panel and plot tooltip lua files, these dummy buildings show in the list for the city, in the city production and purchase screens, etc.

    the lua 'hook' Events.InfluenceChanged() might be the one needed, but at the moment either the arguments passed from the gamecore to code subscribed to this event are unknown by the modding community or else there are no argument data passed.
     
  3. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    hmm, that is unfortunate. can you change an existing modifier or building via lua, or can you just add/remove buildings from cities? if the value of a modifier could by changed, i could just give the modifier to every city and then adjust it as necessary. if it can't, but yields of a building could be changed, i could maybe restrict the bonus to cities with a monument (and then replace the monument with another building that appers to be the same but applies the bonus). if neither are possible, i should probably choose another bonus.

    thanks for your reply, anways.

    another idea: can a requirement demand a certain number of city state of which you are suzerain (either directly or via lua)? that would allow me to implement the bonus in a variant restricted to +X (which might be better for balance anyway).

    thinking this idea further: i think it should be possible to basically add this bonus to every suzerain bonus in the game. identical modifiers can stack, right?
     
    Last edited: Sep 16, 2018
  4. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    my last idea worked! i added a modifier to MINOR_CIV_DEFAULT_TRAIT that gives it's suzerain +1 food and production in every city, exactly what i wanted. turned out i didn't need any lua, just clever sql/xml. :)

    edit: it didn't. i just added food and production to every suzerain bonus for every civilization... i'm currently searching for a way to restrict a modifier to just one civilization/leader.
     
    Last edited: Sep 16, 2018
  5. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,523
    Location:
    Illinois, USA
    lua cannot adjust the definition of anything in XML or SQL. As soon as the game finishes loading, the info added by XML or SQL is locked.

    lua can only add or remove a whole building. The building itself is what adds or removes the yield effects or modifiers, as they were assigned to the building in the XML or SQL.

    lua cannot directly add, remove, or alter a modifier in the game's XML or SQL database. It cannot adjust the effect of a modifier, nor can it adjust the effect of a building's yields or modifiers.

    I think you need to look for a Player_Type_Matches sort of thing in requirements, requirementsets, etc.
     
  6. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    thanks again. i didn't find such a requirement, but i built a workaround by giving my leader a unique palace and using that as the requirement. that did work, but civ still puts the original palace next to the replacement. that is probably something that can be fixed via lua though, because it only concerns removing/adding a building. so now i just have to find all events that might cause the palace to move and make them call a function that - if necessary - removes the palace and/or adds the replacement. doesn't sound like fun, but hey... we'll see whether i manage it.
     
  7. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    I decided that using lua to add/remove the palace replacement when necessary was to much of a hassle. I just did what you suggested with a technical building unique to the leader which is the requirement for getting the bonus. I gave it a themed name though, just to not have a completely ugly "BUILDING_APPLY_BONUS" of some sort in the city screen. Thanks again for your support.
     
  8. luei333

    luei333 Warlord

    Joined:
    May 25, 2014
    Messages:
    185
    The requirement type you're looking for is REQUIREMENT_PLAYER_LEADER_TYPE_MATCHES. Search for that. I can guarantee that works.
     
    raen likes this.
  9. Starjon

    Starjon Chieftain

    Joined:
    Sep 16, 2018
    Messages:
    6
    Gender:
    Male
    Thanks a lot, i'll try that out.

    Edit: Worked, tanks again!
     
    Last edited: Sep 28, 2018

Share This Page