Here is the code. I added Inluence attribute 1 threshold to Factionleader trait. I'm using Artist's Gallery building as a template.
EDB entry, this building has some factionwide effects depend where is FL and amount of his Authority.
Code:building art { levels artist_studio artist_gallery { artist_studio requires factions { all, } { capability { happiness_bonus bonus 1 } material wooden construction 1 cost 1000 settlement_min town upgrades { artist_gallery requires event_counter capital 1 } } artist_gallery requires factions { all, } { capability { law_bonus bonus 2 requires factions { all, } and not event_counter low_authority 1 and not event_counter ai_player 1 and event_counter leader_capital 1 law_bonus bonus -1 requires factions { all, } and not event_counter low_authority 1 and not event_counter ai_player 1 and event_counter no_leader_capital 1 law_bonus bonus -2 requires factions { all, } and not event_counter ai_player 1 and event_counter leader_capital 1 and event_counter low_authority 1 law_bonus bonus -4 requires factions { all, } and not event_counter ai_player 1 and not event_counter leader_capital 1 and event_counter low_authority 1 } faction_capability { law_bonus bonus 1 requires factions { all, } and not event_counter low_authority 1 and not event_counter ai_player 1 and event_counter leader_capital 1 happiness_bonus bonus 1 requires factions { all, } and not event_counter low_authority 1 and not event_counter ai_player 1 and event_counter leader_capital 1 law_bonus bonus -3 requires factions { all, } and not event_counter ai_player 1 and event_counter low_authority 1 happiness_bonus bonus -2 requires factions { all, } and not event_counter ai_player 1 and event_counter low_authority 1 law_bonus bonus -1 requires factions { all, } and not event_counter ai_player 1 and not event_counter low_authority 1 and event_counter no_leader_capital 1 happiness_bonus bonus -1 requires factions { all, } and not event_counter ai_player 1 and not event_counter low_authority 1 and event_counter no_leader_capital 1 } material wooden construction 1 cost 2000 settlement_min town upgrades { } } } plugins { } }
This is additional part for nullifying counters, but since I've added AddedToBuildingQueve monitor I doubt this part is still necessary.Code:monitor_event SettlementSelected SettlementIsLocal set_event_counter capital 0 end_monitor monitor_event CharacterTurnEnd IsFactionLeader and DistanceCapital = 0 set_event_counter no_leader_capital 0 set_event_counter leader_capital 1 end_monitor monitor_event CharacterTurnEnd IsFactionLeader and DistanceCapital != 0 set_event_counter no_leader_capital 1 set_event_counter leader_capital 0 end_monitor monitor_event CharacterSelected IsFactionLeader and DistanceCapital != 0 set_event_counter leader_capital 0 set_event_counter no_leader_capital 1 end_monitor monitor_event CharacterSelected TrueCondition set_event_counter no_leader_capital 1 set_event_counter leader_capital 0 end_monitor monitor_event SettlementSelected GovernorAttribute Influence = 1 and I_EventCounter leader_capital = 1 set_event_counter capital 1 end_monitor monitor_event AddedToBuildingQueue BuildingName = artist_gallery set_event_counter capital 0 set_event_counter leader_capital 0 end_monitor monitor_event SettlementTurnEnd SettlementIsLocal set_event_counter capital 0 end_monitor monitor_event SettlementTurnEnd GovernorAttribute Influence = 1 set_event_counter capital 1 end_monitor
The only limitations for this script is that you have to select capital settlement first after turn start. I will fix it in my case by adding message for the player to force him to build this building because it's absence fires negative factionwide effects.Code:monitor_event ButtonPressed ButtonPressed character_info_prev_item_cycle campaign_wait 0.1 set_event_counter capital 0 end_monitor monitor_event ButtonPressed ButtonPressed character_info_next_item_cycle campaign_wait 0.1 set_event_counter capital 0 end_monitor monitor_event ButtonPressed ButtonPressed settlement_info_prev_item_cycle set_event_counter capital 0 end_monitor monitor_event ButtonPressed ButtonPressed settlement_info_next_item_cycle set_event_counter capital 0 end_monitor monitor_event ShortcutTriggered ShortcutTriggered select_next_selected campaign_wait 0.1 set_event_counter capital 0 end_monitor monitor_event ShortcutTriggered ShortcutTriggered select_prev_selected campaign_wait 0.1 set_event_counter capital 0 end_monitor
Here's the video example of how it works. At turn 2 FL died so I had to move new FL to capital to continue. The whole idea of my script about King's Court is that CeasedFactionLeader event will nullify King's Court in capital and gathering of new one will depend on newcoming FL Authority attribute.