Results 1 to 20 of 72

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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
  •