Page 1 of 2 12 LastLast
Results 1 to 20 of 31

Thread: Building only buildable when character with a specific trait is in settlement

  1. #1
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Building only buildable when character with a specific trait is in settlement

    Hi there. So I'd like to have a building be only buildable in a settlement when a character with a specific trait is present in the same settlement. I was under the impression that you could work out something with an event_counter requirement, but I don't know how to set this up.

    To give you more context: I'm working on a mod set in Japan of the 1500s Sengoku era (similar to Shogun 2) and want to be able to have famous spawned characters (like Honda Tadakatsu, Ii Naomasa etc.) be able to "settle" as retainers/vassals by building a "clan" bluilding indicating that they rule the territory in the faction owner's name. So if character Honda Tadakatsu is in a settlement, I can build a "Honda clan" building.

    Can somebody perhaps help me explain how to set this up (if it is even possible)?

  2. #2

    Default Re: Building only buildable when character with a specific trait is in settlement

    I will preface my answer by saying that things like this are trivial with EOP, but that requires knowledge of Lua scripting and I won't discuss it here as it's not the correct forum for it. I will limit the rest of my answer to conventional (sans EOP) scripting.

    The difficulty in realizing your idea is that we're limited to a very small set of valid conditions for building levels and effects in export_descr_buildings.txt (EDB). All EDB conditions that I'm aware of are listed below:

    Code:
    building_present
    building_present_min_level
    event_counter
    factions
    hidden_resource
    marian_reforms
    port
    region_religion
    resource
    As you can see, none of these make reference to the settlement governor or his traits, ancillaries, attributes, or etc. We could use campaign_script.txt to test if any governor with a particular trait is present in a particular settlement and then set an event counter referencing that settlement to 1, but if we test the value of that event counter in EDB using the event_counter condition, then we've essentially limited the building to only be available in that one particular settlement.

    If you really want the building to be buildable normally, there is a workaround I can envision that involves, thousands of monitors in campaign_script.txt (CS), hurting AI turn times, and dozens of building chains just for one governor character. It would require overhauling your hidden resources to set up an exponential system for uniquely identifying all regions on the map, similar to what is described in this thread. You would quickly run out of building chains (hard coded 128 limit) if you were to expand such a script for multiple governors.

    Alternatively, you could abandon the idea of normally buildable buildings and use guilds instead. The code in export_descr_guilds.txt for such a guild might look like this:

    Code:
    Guild HondaClanGuild
     building honda_clan_building ;this building must still be set up in EDB, no conditions are needed except the faction or culture type
     levels 50 100 300
    
    ;[...]
    
    Trigger HondaClanTrigger
    WhenToTest SettlementTurnStart
    Condition GovernorAttribute Magic == 1 ;perhaps 1 means Honda clan governor, 2 means Ii clan governor, etc.)
     Guild HondaClanGuild o 5 ;add +5 guild standing points to this settlement only per turn that this governor is in the settlement, after 10 turns, the guild will be offered
     Guild NaomasaClanGuild o -1 ;just for fun and to show what's possible, we can also subtract points from the other clan guilds making it harder for this region to ever be settled by them
    The Magic attribute is used by the witch agent in the vanilla game and usually not used for generals/governors in most mods which is why I prefer it for this type of thing. The special trait you set up might look something like this in export_descr_character_traits.txt:

    Code:
    Trait HondaClanTrait
     Characters family
     Level HondaClanTrait_A
      Description HondaClanTrait_A_desc
      EffectsDescription HondaClanTrait_A_effects_desc
      Threshold 1
      Effect Magic 1
    As you can see, the virtue of using guilds instead of normal buildings is that their trigger conditions are much more numerous than the EDB conditions. Additionally, guilds are limited to one per settlement which I think is thematic for the clan buildings you're describing. The second tier of the guild is limited to one per faction and the third tier is limited to one on the entire map which you could also use for thematic effect, for example by making the second tier be the faction leader's residence. The AI might even avail themselves of these guilds (I don't remember if the AI ever builds guilds in the vanilla game).

    The basic concept of this guild system is extremely extensible. For example, you could tier the traits so that governors with greater loyalty to the Honda clan, represented by different Magic attribute values, add guild points to settlements faster and subtract points of the other clans' guilds, allowing them to more quickly 'settle' conquered regions. You could go really crazy and convert religions into clans and add a religious conversion effect to the guild buildings in EDB.
    Last edited by Callistonian; January 13, 2024 at 04:38 PM.

  3. #3
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    Thanks for the reply! Hmmm... I already had a hunch that it would require a ton of work to have a work-around. I'm having some 76 of these "clan buildings" on my list already (some are factions once they no longer exist, others are retainer/vassal clans).

    It's an interesting suggestion that I haven't thought of, but I don't think guilds will work. Guilds are offered during a yes/no event, right? I can see it becoming a nuisance when a window pops up every time special character is residing inside a settlement. Also, doesn't the magic attribute go from 0 to 10 max? That would allow me to use only 11 retainer clans per faction.

    Hmmm...

  4. #4
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    All attributes are 999 limit, so no problem with that.

    Question is - do you want to player only possibility to build or AI too.

    If player only - it's pretty easy. Activate event_counter for building at SettlementSelected event in combination with GovernorAttribute condition. And add this event_counter as a requirement for building in EDB. That's all.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  5. #5
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    Thanks for the suggestions!

    Preferably I'd want the AI to be able to build them as well dynamically, but perhaps that can be simulated with straightforward scripts (create_building) when an AI faction conquers a province.

    Also, does the condition specifically have to be an attribute or can it also be a trait? I'm using traits with epithets in combination with recruitable generals. For example: recruited generals will receive the Honda clan trait and the family name 'Honda' when they're recruited in a settlement that has built the Honda clan building. Characters with the Honda clan trait can then build a Honda clan building when they're inside other settlements that haven't built a retainer clan building yet. It would be nice if I could simply use a trait as a condition.
    Last edited by Razor; January 14, 2024 at 12:10 AM.

  6. #6
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    double post

  7. #7
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    Yes, you can use that trait as a condition. Just set Magic level or whatever attributes you want to your trait.

    I'm using similar system for ancillaries of lordship.

    As for AI it will be easier to faction related event_counter for EDB, because for campaign script way it will be a huge amount of coding.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  8. #8
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    Double posted for unknown reason.

    By the way - give an example of this Clan trait for recruited generals, I'd like to give such for mercenaries.
    Last edited by bitterhowl; January 14, 2024 at 01:51 AM.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  9. #9

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by Razor View Post
    I can see it becoming a nuisance when a window pops up every time special character is residing inside a settlement.
    In my example, it takes 10 turns, starting from when the governor enters a fresh settlement, before the guild is offered. You could also add a RandomPercent condition on top of or instead of this to add randomness. If a guild is rejected, the game has a 10 turn cool down until it's offered again, even if the conditions are still met. All of these would mitigate the spam of yes/no offers to some extent.

    I've never thought of yes/no messages as annoying, but I know there's a train of thought in M2 modding that all messages should be eliminated to leave the player alone with the core game play loop. I think, if anything, a message about the building's availability, whether guild or not, would highlight its importance to the player.

    Quote Originally Posted by Razor View Post
    Also, doesn't the magic attribute go from 0 to 10 max? That would allow me to use only 11 retainer clans per faction.
    I'm not sure where bitterhowl got 999 from, but the actually limit is set by the type of variable used to store this data in the game code, which I forget, probably a 32-bit signed integer so ±2.1 billion. Of course, most attributes only have 'real' effects in-game on the range of 0 to 10. And Magic was just an example, you can use as many attributes as you want for this, although I'd suggest sticking with just one for simplicity's sake.

    Quote Originally Posted by bitterhowl
    If player only - it's pretty easy. Activate event_counter for building at SettlementSelected event in combination with GovernorAttribute condition. And add this event_counter as a requirement for building in EDB. That's all.
    In addition to the fact that SettlementSelected doesn't work the AI, there is also the problem of the arrow buttons for switching between settlements. These buttons, which can't be removed from the UI, don't trip the SettlementSelected event, but they give the player access to building queues. In my mind, this completely kills the concept of using SettlementSelected for settlement-specific scripting.

    Even if you ignore this, there is the more serious problem of when to set the event counter back to 0. Presumably, you would have a 'SettlementSelected and not GovernorAttribute' monitor to set the counter to 0 when the player selects any other settlement so that the building isn't available in those settlements. But this means that when you select any other settlement, construction of the clan building in the original settlement becomes hung in the queue. You could use multiple counters, but you'd still have to somehow account for the case when the player moves the general out of the settlement.

    Quote Originally Posted by Razor
    Also, does the condition specifically have to be an attribute or can it also be a trait? I'm using traits with epithets in combination with recruitable generals. For example: recruited generals will receive the Honda clan trait and the family name 'Honda' when they're recruited in a settlement that has built the Honda clan building. Characters with the Honda clan trait can then build a Honda clan building when they're inside other settlements that haven't built a retainer clan building yet. It would be nice if I could simply use a trait as a condition.
    There is no 'GovernorTrait' script condition. There is only, GovernorAttribute. If you employ an otherwise unused attribute like Magic, then you are essentially identifying a trait. So 'GovernorTrait' or 'GovernorAncillary' conditions would be redundant. You can still use your traits with epithets, just add a Magic effect (or whatever other unused attribute you prefer).
    Last edited by Callistonian; January 14, 2024 at 01:38 AM.

  10. #10
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    I'm not sure where bitterhowl got 999 from
    I got it form script that checks if faction is dead, including hordes. A condition there is I_FactionLeaderAttribute Command < 999

    Anyway, topic starter's question was if amount of attribute is above 11, so both 999 and 2.1 billion is true for that case.

    As for other limitations. I've made a script that only few generals (with high command and low chivalry) can recruit mercenaries. Same thing - first monitor with CharacterSelected set event_counter to 0, and next one change it to 1 if required conditions match.

    As for selecting - just give a message for player that it's needed to select settlement for getting full capabilities of building tree.

    Even if you ignore this, there is the more serious problem of when to set the event counter back to 0. Presumably, you would have a 'SettlementSelected and not GovernorAttribute' monitor to set the counter to 0 when the player selects any other settlement so that the building isn't available in those settlements. But this means that when you select any other settlement, construction of the clan building in the original settlement becomes hung in the queue. You could use multiple counters, but you'd still have to somehow account for the case when the player moves the general out of the settlement
    Hmm, looks like you're right. IDK how it works for my lordship script (building and recruitment works properly even when I selected next settlement and governor_event_counter changed multiple times).

    If I remember correctly building procedure happens at the SettlementTurnEnd event. So we can duplicate previous two monitors with SettlementSelected to SettlementTurnEnd.
    Last edited by bitterhowl; January 14, 2024 at 02:12 AM.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  11. #11

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by bitterhowl View Post
    I got it form script that checks if faction is dead, including hordes. A condition there is I_FactionLeaderAttribute Command < 999
    Ah yes, I remember that from Withwnar's faction aliveness check. Not sure why he used 999, that condition is essentially just checking if the faction leader has a command attribute at all, if he doesn't exist then he doesn't have that attribute so the condition returns false. I would guess that > -999 also works.

    Quote Originally Posted by bitterhowl View Post
    As for other limitations. I've made a script that only few generals (with high command and low chivalry) can recruit mercenaries. Same thing - first monitor with CharacterSelected set event_counter to 0, and next one change it to 1 if required conditions match.
    There is also a button for cycling between characters that doesn't trip CharacterSelected, but ignoring that, this works better for mercenaries because they're recruited instantly. Buildings cannot be constructed instantly (except guilds) - the even counter needs to be 0 at... if I remember correctly, the end of the last (usually slave) faction's turn in order for construction to progress.

    Quote Originally Posted by bitterhowl View Post
    As for selecting - just give a message for player that it's needed to select settlement for getting full capabilities of building tree.
    It's not an issue of getting full capabilities like with your mercenary script where the mercs just aren't available otherwise. In the case of the clan building, it will be available everywhere if you use the arrows to cycle through settlements. And then if you have any means of setting the counter to 0, it will just stop building in those settlements, including the one it's supposed to be building in.

  12. #12
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by bitterhowl View Post
    Double posted for unknown reason.

    By the way - give an example of this Clan trait for recruited generals, I'd like to give such for mercenaries.
    Here's my setup: two traits, one trait assigning the clan name and one trait to filter out existing characters that shouldn't get the trait.

    export_descr_character_traits.txt:
    Spoiler Alert, click show to read: 
    ;------------------------------------------ RECRUITED LOCAL CLAN NAMES - FILTER TRAIT
    Trait EstablishedName
    Characters family

    Level Established_Name
    Description Established_Name_desc
    EffectsDescription Established_Name_effects_desc
    Threshold 1

    ;------------------------------------------ RECRUITED LOCAL CLAN NAMES
    Trait NameHonjo
    Characters family
    Hidden

    Level Name_Honjo
    Description Name_Honjo_desc
    EffectsDescription Name_Honjo_effects_desc
    Epithet Name_Honjo_epithet_desc
    Threshold 1





    ;------------------------------------------ RECRUITED LOCAL CLAN NAMES - FILTER TRAIT
    Trigger Established_Name_1
    WhenToTest CharacterTurnStart

    Affects EstablishedName 1 Chance 100

    ;------------------------------------------ TEST
    Trigger Established_Name_2
    WhenToTest OfferedForAdoption

    Condition FatherTrait EstablishedName = 1

    Affects EstablishedName 1 Chance 100

    ;------------------------------------------ TEST
    Trigger Established_Name_3
    WhenToTest LesserGeneralOfferedForAdoption

    Condition FatherTrait EstablishedName = 1

    Affects EstablishedName 1 Chance 100

    ;------------------------------------------ RECRUITED LOCAL CLAN NAMES
    Trigger Name_Honjo_1
    WhenToTest CharacterTurnEnd

    Condition EndedInSettlement
    ; and SettlementName Murakami
    and SettlementName Kagoshima
    and not Trait EstablishedName = 1

    Affects NameHonjo 1 Chance 100

    ;------------------------------------------
    Trigger Name_Honjo_2
    WhenToTest CharacterComesOfAge

    Condition FatherTrait NameHonjo = 1

    Affects NameHonjo 1 Chance 100

    ;------------------------------------------ TEST
    Trigger Name_Honjo_3
    WhenToTest OfferedForAdoption

    Condition FatherTrait NameHonjo = 1

    Affects NameHonjo 1 Chance 100

    ;------------------------------------------ TEST
    Trigger Name_Honjo_4
    WhenToTest LesserGeneralOfferedForAdoption

    Condition FatherTrait NameHonjo = 1

    Affects NameHonjo 1 Chance 100


    export_vnvs.txt:
    Spoiler Alert, click show to read: 
    {Established_Name}Established Name
    {Established_Name_desc}Prevents recruited general epithets in name.
    {Established_Name_effects_desc}Prevents recruited general epithets in name.
    {Name_Honjo_epithet_desc}Honjo


    Do note that the 'established name' trait in my example isn't set to hidden, because I was testing the trait in my mod.
    Last edited by Razor; January 14, 2024 at 08:58 AM.

  13. #13
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by Callistonian View Post
    Ah yes, I remember that from Withwnar's faction aliveness check. Not sure why he used 999, that condition is essentially just checking if the faction leader has a command attribute at all, if he doesn't exist then he doesn't have that attribute so the condition returns false. I would guess that > -999 also works.



    There is also a button for cycling between characters that doesn't trip CharacterSelected, but ignoring that, this works better for mercenaries because they're recruited instantly. Buildings cannot be constructed instantly (except guilds) - the even counter needs to be 0 at... if I remember correctly, the end of the last (usually slave) faction's turn in order for construction to progress.



    It's not an issue of getting full capabilities like with your mercenary script where the mercs just aren't available otherwise. In the case of the clan building, it will be available everywhere if you use the arrows to cycle through settlements. And then if you have any means of setting the counter to 0, it will just stop building in those settlements, including the one it's supposed to be building in.
    Crap. This is quite disheartening.

  14. #14
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    I suppose we can script it at least by creating a building by create_building and yes/no event for player. I'll post a suggestion code a bit later. It wouldn't be bad for CPU performance.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  15. #15
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by Callistonian View Post
    In my example, it takes 10 turns, starting from when the governor enters a fresh settlement, before the guild is offered. You could also add a RandomPercent condition on top of or instead of this to add randomness. If a guild is rejected, the game has a 10 turn cool down until it's offered again, even if the conditions are still met. All of these would mitigate the spam of yes/no offers to some extent.

    I've never thought of yes/no messages as annoying, but I know there's a train of thought in M2 modding that all messages should be eliminated to leave the player alone with the core game play loop. I think, if anything, a message about the building's availability, whether guild or not, would highlight its importance to the player.

    I don't think yes/no events should be eliminated, because I think they can be very useful. I just don't like messages asking you for something you didn't ask for and already answered once even if it's every now and then. And then when you actually do want it you can't get it, because it's dependent on a yes/no event popping up.


    I think I'll have to take a diffferent approach:

    1) A yes/no event gets triggered: "A renowned member of a local samurai family wants to offer his allegiance and join your clan. Would you like to accept him among your ranks? Yes/no."

    2) A special character, say Honda Tadakatsu, gets spawned by script for your faction (say Tokugawa) and during that event a counter is set to 1.

    3) This counter is then used as building requirement in export_descr_buildings.txt for only your Tokugawa faction that has this character spawned for and allows your faction to build the Honda clan building.


    The downside of this is that the clan building can be built anywhere and isn't restricted to the presence of a governor with a certain trait/attribute. That is unless I add other build conditions in export_descr_buildings.txt.



    Quote Originally Posted by bitterhowl View Post
    I suppose we can script it at least by creating a building by create_building and yes/no event for player. I'll post a suggestion code a bit later. It wouldn't be bad for CPU performance.

    Yes, but that would still be 'forcing' a yes/no event on the player, which I don't like for this kind of buildings. At least the guild system could still be used for other building types (martial arts). But I'm definitely open to suggestions. And yes, I definitely like to keep my scripts as light as possible.
    Last edited by Razor; January 14, 2024 at 07:47 PM.

  16. #16

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by bitterhowl
    I suppose we can script it at least by creating a building by create_building and yes/no event for player. I'll post a suggestion code a bit later. It wouldn't be bad for CPU performance.
    This sounds like a guild with more steps and longer AI turn times. The GovernorAttribute condition requires a new monitor every time it's used, which means the total number of required mintors for such a script is the number of clans multiplied by the number of regions on the map. And you still have to decide on an arbitrary time to stop offering the yes/no event when all conditions are met (presumably, governor with the trait is in the settlement and no clan buildings exist there), just like with a guild setup. Here's an example:

    Code:
    monitor_event SettlementTurnStart SettlementName settA   ;this monitor is just for the Honda clan offer for settlement A, it has to be replicated for every other clan for settA and then those monitors have to be replicated for every other region on the map
    and GovernorAttribute Magic == 1
    and not SettlementBuildingExists hondaclan_building_level_a
    and not SettlementBuildingExists naomasaclan_building_level_a
    ;and not SettlementBuildingExists ... all other clan buildings
     historic_event offer_HondaClan_settA true factions { ourFAc, }
     set_event_counter offer_HondaClan_settA_pending 1
    end_monitor
    
    monitor_event EventCounter TrueCondition   ;you only need one generic EventCounter monitor for yes/no event effects
     if I_EventCounter offer_HondaClan_settA_accepted > 0
      set_event_counter offer_HondaClan_settA_accepted 0
      console_command create_building settA hondaclan_building_level_a
      set_event_counter offer_HondaClan_settA_pending 0
     end_if
     if I_EventCounter offer_HondaClan_settA_declined > 0
      set_event_counter offer_HondaClan_settA_declined 0
      set_event_counter offer_HondaClan_settA_pending 0
     end_if
    end_monitor
    Note that this script doesn't have any mechanism to stop offering the yes/no events when all conditions are met. You could easily terminate these monitors the first time the player declines the yes/no offer but then the clan building would never be available in that settlement again for the rest of the campaign, and I can't bring myself to write such a script even as an example...

    Quote Originally Posted by Razor View Post
    The downside of this is that the clan building can be built anywhere and isn't restricted to the presence of a governor with a certain trait/attribute. That is unless I add other build conditions in export_descr_buildings.txt.
    What other building condition would you use? Please see my original post for the list of valid EDB conditions.

  17. #17
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,075

    Default Re: Building only buildable when character with a specific trait is in settlement

    I was thinking of a simple hidden resource. And add the temple_ prefix to these buildings to allow only one one of them in settlements.

  18. #18
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    This is how I dealt with cycling between characters.
    Code:
    monitor_event ButtonPressed ButtonPressed character_info_prev_item_cycle
            campaign_wait 0.1
            set_event_counter MercenHire 0
    end_monitor
    
    monitor_event ButtonPressed ButtonPressed character_info_next_item_cycle
            campaign_wait 0.1
            set_event_counter MercenHire 0
    end_monitor
    settlement_info_next_item_cycle button could be healed in the same way.

    these buildings to allow only one one of them in settlements.
    If event_counter will fire only when no clan building presents in settlement then you don't need them to be temples.

    This is what I suggest.
    Code:
    monitor_event SettlementSelected TrueCondition
    set_event_counter building_clan 0
    end_monitor
                
    monitor_event SettlementSelected GovernorAttribute Magic = 1
    and not SettlementBuildingExists hondaclan_building_level_a
    and not SettlementBuildingExists naomasaclan_building_level_a
    set_event_counter building_clan 1
    end_monitor
    
    monitor_event ButtonPressed ButtonPressed settlement_info_prev_item_cycle
            campaign_wait 0.1
            set_event_counter building_clan 0
    end_monitor
    
    monitor_event ButtonPressed ButtonPressed settlement_info_next_item_cycle
            campaign_wait 0.1
            set_event_counter building_clan 0
    end_monitor
    You can give different Magic for different clans, so you have to replicate second monitor for different Magic numbers.

    And finally we need this two monitors for turn end for event_counter being active during building sequence.

    Code:
    monitor_event SettlementTurnEnd TrueCondition
    set_event_counter building_clan 0
    end_monitor
                
    monitor_event SettlementTurnEnd GovernorAttribute Magic = 1
    set_event_counter building_clan 1
    end_monitor
    Last edited by bitterhowl; January 14, 2024 at 10:01 PM.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  19. #19

    Default Re: Building only buildable when character with a specific trait is in settlement

    Quote Originally Posted by Razor View Post
    I was thinking of a simple hidden resource. And add the temple_ prefix to these buildings to allow only one one of them in settlements.
    Hidden resources can't be changed during the course of the campaign, so you will just be restricting the clan to specific regions by adding a hidden resource condition in EDB.

    Quote Originally Posted by bitterhowl
    This is what I suggest.
    There are still quite a few problems with this:

    1) The arrows aren't the only way to access the construction scroll without tripping the SettlementSelected event. This can also be done by moving characters (any sort of character) into a settlement, and I'm sure there are other ways besides this that haven't occurred to me yet. I.e. simply moving characters allows you to construct the clan building in any settlement on the map.

    2) This script doesn't account for the case where the Magic-attribute-holding general moves into a different settlement after beginning construction of the clan building (construction will continue).

    3) This is just a nitpick: the 'not SettlementBuildingExists hondaclan_building_level_a' condition is redundant because buildings won't be offered if they're already in the queue or present in the settlement.

    4) The 'not SettlementBuildingExists naomasaclan_building_level_a' condition doesn't account for the case when the naomasaclan_building_level_a is already in the construction queue.

    5) The 'SettlementTurnEnd' monitors aren't doing anything because construction happens before that event fires. The value of the building_clan counter is still being determined by the last settlement that was selected before the end of the turn. In other words, if you select any other settlement on the map before the end of the turn, construction doesn't progress. There might be a way to address this using 'ButtonPressed end_turn' with a second counter, but the decision when to set and reset the second counter seems arbitrary to me and unlikely to be bug-free. For reference, this is the sequence of events at the end of a faction's turn:

    Code:
    ButtonPressed end_turn > AI moves papal_faction inquisitors > units recruited, buildings constructed, etc. > CharacterTurnEnd > SettlementTurnEnd > FactionTurnEnd
    6) Even if construction happened after the SettlementTurnEnd event, this still wouldn't work because that event fires for every settlement on the map. The order-of-operations dependence of this script (defaulting to 0, then setting to 1 if GovernorAttribute Magic == 1) assumes that the settlement with the special governor is the last settlement in that faction's list of settlements. If it's any other settlement, the very next one after it will set the counter to 0 and prevent construction. This isn't a problem for Withwnar's original version of this script because he tests by SettlementName immediately after each SettlementTurnStart monitor, or in other words, he's using SettlementName for all the settlement-specific stuff. This order-of-operations trick doesn't work for settlements which haven't already been uniquely identified by name or other means.
    Last edited by Callistonian; January 25, 2024 at 01:57 AM.

  20. #20
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Building only buildable when character with a specific trait is in settlement

    Ok, so I've dealt with it in my Westeros submod, my task was even more complicated - I made a building "King's Court" which could be built only in capital by faction leader. I'll post the code here tomorrow.

    Only limitation is that first tier of building doesn't work with event_counter building requirements. So I had to make first tier as governor court and make second tier for king's building. And it works just fine, building available to be built only in capital when FL is inside and ended turn there.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •