Page 1 of 5 12345 LastLast
Results 1 to 20 of 84

Thread: Script for selecting the heir - (Update 24.07.2015)

  1. #1

    Default Script for selecting the heir - (Update 24.07.2015)

    2nd place in the TW2 Engine in 2016 Modding Awards


    This script is used to choose the next heir of faction whenever the leader or heir dies. Will be shown a question event that to accept it you will open the screen of family tree to choose the future heir. If you decline the option of select the candidate, don't reappears until the faction's leader dies. If you accept, appears the family tree screen. At that moment, you can choose a family member (except leader and heir) and press the zoom button to select the next heir. But if you aren't interested in any existing family member at that moment, you can close the window and choosing the general in other "turn", opening the panel again manually.

    To make it work (apart from the script) also must be created a “trait”. These are the files that have to be modified:

    Add this in campaign_script.txt
    Code:
        declare_counter candidate
        declare_counter first_candidate
        declare_counter checking
        declare_counter active_heir_bucle
        declare_counter decline_sh
    
    
        monitor_event CeasedFactionHeir CharacterIsLocal
            and I_CompareCounter candidate = 0
    
            historic_event select_candidate true
            set_counter first_candidate 1
            
        end_monitor
    
        monitor_event BrotherAdopted CharacterIsLocal
            and I_TurnNumber >= 0
            and I_CompareCounter candidate = 0
            and I_CompareCounter first_candidate = 0
                and I_CompareCounter active_heir_bucle = 0
    
            historic_event select_candidate true
            set_counter first_candidate 1
            set_counter active_heir_bucle 1
    
            terminate_monitor        
        end_monitor
    
        monitor_event CharacterComesOfAge FactionIsLocal
            and IsGeneral
            and I_CompareCounter candidate = 0
            and I_CompareCounter first_candidate = 0
                and I_CompareCounter active_heir_bucle = 0
            
            historic_event select_candidate true
            set_counter first_candidate 1
            set_counter active_heir_bucle 1
    
            terminate_monitor        
        end_monitor
    
            monitor_event FactionTurnEnd FactionType slave
                set_counter checking 1
           end_monitor
    
            monitor_event CharacterTurnEnd CharacterIsLocal
                and I_TurnNumber > 0
                and Trait HeirCandidate > 0
    
                set_counter checking 2
            end_monitor
    
           monitor_event FactionTurnEnd FactionIsLocal
                and I_CompareCounter checking = 1
                and I_CompareCounter active_heir_bucle = 1
                and I_CompareCounter decline_sh = 0
                and I_CompareCounter candidate = 0
    
                historic_event select_candidate true
                set_counter first_candidate 1
            end_monitor
    
        monitor_event EventCounter EventCounterType select_candidate_accepted
            and I_EventCounter select_candidate_accepted = 1
    
            select_ui_element faction_button
            simulate_mouse_click lclick_down
            simulate_mouse_click lclick_up
    
            select_ui_element family_tree_button
            simulate_mouse_click lclick_down
            simulate_mouse_click lclick_up
    
            select_ui_element faction_button
            simulate_mouse_click lclick_down
            simulate_mouse_click lclick_up
    
            ui_flash_start family_tree_zoom_to_button
            set_event_counter select_candidate_accepted 0
            set_counter candidate 1
            
        end_monitor
    
        monitor_event CharacterSelected CharacterIsLocal
            and I_CompareCounter candidate = 1
            and I_ScrollOpen family_tree_scroll
            and IsGeneral
                  and not IsFactionLeader
                  and not IsFactionHeir
    
            ui_flash_stop
            console_command give_trait this HeirCandidate 1
            set_counter candidate 0
            historic_event selected
    
        end_monitor
    
        monitor_event EventCounter EventCounterType select_candidate_declined
            and I_EventCounter select_candidate_declined = 1
    
            set_counter decline_sh 1
        end_monitor
    Add event descriptions in historic_events.txt
    Code:
    {SELECT_CANDIDATE_BODY}You want choose the family member who will be the next heir of the faction?\n\n\n\n(INSTRUCTIONS: If you decline the option of select the candidate, don't reappears until the faction's leader dies. If you accept, appears the family tree screen. At that moment, you can choose a family member (except leader and heir) and press the zoom button to select the next heir. But if you aren't interested in any existing family member at this moment, you can close the window and choosing the general in other "turn", opening the panel again manually.)
    {SELECT_CANDIDATE_TITLE}Select the next heir
    {SELECTED_BODY}The selected general will have rights of inheritance to the throne, followed by the current heir.
    {SELECTED_TITLE}Inheritance privileges granted
    Add this trait and triggers in export_descr_character_traits.txt
    Code:
    ;------------------------------------------
    Trait HeirCandidate
        Characters family
    
        Level Heir_Candidate
            Description Heir_Candidate_desc
            EffectsDescription Heir_Candidate_effects_desc
            Threshold  1 
     
            Effect Authority  8 
            Effect PersonalSecurity  2 
    
    ;------------------------------------------
    ;== TRIGGER DATA STARTS HERE ==
    ;------------------------------------------
    Trigger Heir_excandidate
        WhenToTest BecomesFactionHeir
    
        Condition Trait HeirCandidate > 0
    
        Affects HeirCandidate  -1  Chance  100 
    
    ;------------------------------------------
    Trigger Leader_excandidate
        WhenToTest BecomesFactionLeader
    
        Condition Trait HeirCandidate > 0
    
        Affects HeirCandidate  -1  Chance  100 
    
    ;------------------------------------------
    And add description in export_vnvs.txt
    Code:
    {Heir_Candidate}Candidate for heir
    {Heir_Candidate_desc}It’s one of the main candidates in the line of succession to the throne.
    {Heir_Candidate_effects_desc}It has a good degree of authority and leader skills.

    Script for selecting the heir (By Miguel_80. Thanks to Gigantus by creating a script to cover all possible deaths of the heir candidate.)

    Download link: http://www.twcenter.net/forums/downl...o=file&id=4212


    Sample photos of the script:










    If you use the "script" in a mod with numerous family members in the factions, add this "monitor" (after declare counters) in the "campaign_script.txt" file.

    Code:
        monitor_event FactionTurnStart FactionIsLocal 
            and I_TurnNumber > 1
            and I_CompareCounter candidate = 0
            and I_CompareCounter first_candidate = 0
    
            historic_event select_candidate true
            set_counter first_candidate 1
    
            terminate_monitor        
        end_monitor
    Last edited by Miguel_80; March 02, 2018 at 10:02 AM. Reason: Updated

  2. #2

    Default Re: Script for select the next heir

    Without analyzing the script, the problem I see is you gave that general a lot of authority. Will you also subtract it upon becoming the next King? If not, the King has artificially high authority. Don't you want to take away the trait when a King and rely upon the King's natural authority from other traits and ancillaries?

    A lot of young kings are liable to have low authority. A lot of kings in history were bad leaders. Having all high authority kings results in less challenges to the player. A good rebellion is actually fun once in a while because someone ascends to the throne and has political weakness. Because the human player can easily beat other kingdoms in the early 50 turns, they can steamroll over their bordering neighbors. Giving the king less authority, but still being able to pick an heir, would be better.
    Last edited by RubiconDecision; June 13, 2013 at 04:17 AM.

  3. #3
    Vipman's Avatar Protector Domesticus
    Join Date
    Jul 2010
    Location
    Romania
    Posts
    4,405

    Default Re: Script for select the next heir

    The trait is called Candidate for heir, so once he becomes heir the trait should be removed. Isn't it possible to put in EDCT a trigger to remove this trait if that character has faction heir trait, or maybe there exists a IsFactionHeir condition to use instead?? If not maybe through campaign_script
    Last edited by Vipman; June 13, 2013 at 04:47 AM.

  4. #4

    Default Re: Script for select the next heir

    Thanks guys for the detail missing to add in the triggers. Updated.

    Greetings

  5. #5

    Default Re: Script for select the heir

    If you use the "script" in a mod with numerous family members in the factions, add this "monitor" (after declare counters) in the "campaign_script.txt" file.

    Code:
        monitor_event FactionTurnStart FactionIsLocal 
            and I_TurnNumber > 1
            and I_CompareCounter candidate = 0
            and I_CompareCounter first_candidate = 0
    
            historic_event select_candidate true
            set_counter first_candidate 1
    
            terminate_monitor        
        end_monitor
    Last edited by Miguel_80; October 31, 2013 at 04:04 PM.

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default

    I have build it into the Rise of three Kingdoms mod for the next release and will be testing it.
    Last edited by Gigantus; November 23, 2013 at 11:37 PM.










  7. #7

    Default Re: Script for select the heir

    Ok, the “Rise of three Kingdoms” mod is a great job

  8. #8
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: Script for select the heir

    Good work Miguel. In case you weren't aware, there is a limitation in the next-heir trick...

    Quote Originally Posted by Amaranth View Post
    This will only work if the FL dies before the current FH. If the current FH dies before becoming FL, this system somehow fails, and game engine selects an heir in it's own way, no matter who gets the [trait].

  9. #9

    Default Re: Script for select the heir

    Many thanks Withwnar! I have added the event of the death of the heir so that can choose a new "heir candidate".
    Last edited by Miguel_80; November 25, 2013 at 06:36 AM.

  10. #10

    Default Re: Script for select the heir

    Eres un grande Miguel jejeje

    Good script, very useful for modding

  11. #11

    Default Re: Script for select the heir

    Many thanks Werety! Greetings

  12. #12

    Default Re: Script for select the heir

    I've downloaded the file and added the campaign scripts and added the new files but when I start a new campaign and get to turn 3 and beyond, there's no sign at all of this working. Can anybody help me with this please?

  13. #13

    Default Re: Script for select the heir

    Hello. The script works when it adopts a General (monitor_event BrotherAdopted )

    If you have too many family members at the start of the campaign, add this "monitor_event"

    Code:
        monitor_event FactionTurnStart FactionIsLocal 
            and I_TurnNumber > 1
            and I_CompareCounter candidate = 0
            and I_CompareCounter first_candidate = 0
    
            historic_event select_candidate true
            set_counter first_candidate 1
    
            terminate_monitor        
        end_monitor

  14. #14

    Default Re: Script for select the heir

    I did add that but there's no change.

  15. #15

    Default Re: Script for select the heir

    Is there a certain place within "campaign_scripts.txt" that the script should be? I have it at the very top and the monitor event is right after it.

  16. #16

    Default Re: Script for select the heir

    No matter if it's at the beginning or at the end, but it has to be within the "script command"

    Code:
    script
    
        ;;;SCRIPTS;;;
    
    
        wait_monitors
    
    end_script

    EDIT: The mod contains provincial campaigns?
    Last edited by Miguel_80; April 27, 2015 at 03:39 PM.

  17. #17

    Default Re: Script for select the heir

    It's still not working at all. Here is what I have in the file. I didn't paste the whole file because it's very long but here is the beginning including the heir change script.

    ;
    ; Campaign script
    ;
    script


    declare_counter candidate
    declare_counter first_candidate




    monitor_event CeasedFactionLeader CharacterIsLocal
    and I_CompareCounter candidate = 0


    historic_event select_candidate true
    set_counter first_candidate 1

    end_monitor


    monitor_event CeasedFactionHeir CharacterIsLocal
    and I_CompareCounter candidate = 0


    historic_event select_candidate true
    set_counter first_candidate 1

    end_monitor


    monitor_event BrotherAdopted CharacterIsLocal
    and I_TurnNumber >= 0
    and I_CompareCounter candidate = 0
    and I_CompareCounter first_candidate = 0


    historic_event select_candidate true
    set_counter first_candidate 1


    terminate_monitor
    end_monitor


    monitor_event BattleGeneralKilled CharacterIsLocal
    and I_CompareCounter candidate = 0
    and Trait HeirCandidate > 0


    historic_event select_candidate true
    set_counter first_candidate 1

    end_monitor


    monitor_event EventCounter EventCounterType select_candidate_accepted
    and I_EventCounter select_candidate_accepted = 1


    select_ui_element faction_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up


    select_ui_element family_tree_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up


    select_ui_element faction_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up


    ui_flash_start family_tree_zoom_to_button
    set_event_counter select_candidate_accepted 0
    set_counter candidate 1

    end_monitor


    monitor_event CharacterSelected CharacterIsLocal
    and I_CompareCounter candidate = 1
    and I_ScrollOpen family_tree_scroll
    and IsGeneral
    and not IsFactionLeader
    and not IsFactionHeir


    ui_flash_stop
    console_command give_trait this HeirCandidate 1
    set_counter candidate 0
    historic_event selected


    end_monitor
    ; ---------------------
    ; counters

    declare_counter Opened_Faction_Overview_Scroll
    declare_counter Opened_Settlement_Scroll
    declare_counter mongols_sarkel
    declare_counter mongols_yerevan
    declare_counter mongols_baghdad
    declare_counter timurids_sarkel
    declare_counter timurids_yerevan
    declare_counter timurids_baghdad


    ; ---------------------
    ; start up


    freeze_faction_ai aztecs


    ;----------------------
    ; monitors


    ;-- Mongols invasions --
    monitor_event EventCounter EventCounterType mongols_invasion_warn
    and EventCounter > 0
    ; ADD SCOUTING INVASION
    add_events
    event counter mongols_invasion
    date 4 8
    end_add_events
    if I_EventCounter mongols_invasion_warn == 2
    terminate_monitor
    end_if
    end_monitor

  18. #18

    Default Re: Script for select the heir

    It's not a mod. I'm trying to add this to the vanilla.

  19. #19

    Default Re: Script for select the heir

    In the vanilla doesn't work. The script includes exclusive commands and events of Kingdoms. If you want to add it into the main campaign, you can download the Bare Geomod
    Last edited by Miguel_80; April 27, 2015 at 05:02 PM.

  20. #20

    Default Re: Script for select the heir

    Beside Geomod, how can I know which mod this will work with?

Page 1 of 5 12345 LastLast

Tags for this Thread

Posting Permissions

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