Page 2 of 2 FirstFirst 12
Results 31 to 53 of 53

Thread: Eureka! Running scripts automatically!

  1. #31
    Indiana Jones of Modding! Member Patrizius's Avatar
    Join Date
    Oct 2007
    Posts
    103

    Default Re: Eureka! Running scripts automatically!

    you have just make us courious to know
    Ideator,Scripter and Team Leader of RES BELLICAE modding project.Come visit us on http://www.twcenter.net/forums/forumdisplay.php?f=603

  2. #32

    Default Re: Eureka! Running scripts automatically!

    The "only speech mode" is working as Patrizius said, it is great to see the scripts launched automatically just selecting a character or settlement.
    I have been trying to remove the text of the advice to get the same in the "text and speech" mode, but no luck until now.

    When starting a new campaign, it should be launched automatically, if you followed my directions exactly.
    Yes, this I know, we have been using it for long time (a year or so), and when I discovered it it was alredy known and used by other mods.

    I tryed to explain it (and my use of the GameReloaded event) in this topic: https://forums.totalwar.org/vb/showthread.php?t=92989


    Some mods have a problem where the script does not work correctly if you reload a saved game or start a new campaign without completely restarting the program. Perhaps, it could be used to fix that problem and terminate the previous version of the script.
    This is one of the biggest problems with our scripts, but I have never thought about the possibility to use the event GameReloaded to terminate the previous script, thank a lot for the idea, I'll test it now.


    @Dol Guldur> we all see these holes about scripting, and for us who decided to use scripts long time ago, it would be even better if some of these holes can be fixed. ;)
    I'm also curious about this "huge gap in the gameplay"...
    Last edited by Bardo; 05-30-2008 at 21:49.

  3. #33
    Indiana Jones of Modding! Member Patrizius's Avatar
    Join Date
    Oct 2007
    Posts
    103

    Default Re: Eureka! Running scripts automatically!

    i'll go away til the 3.hope to find good news when i get back XD.Goodbye to all.
    Ideator,Scripter and Team Leader of RES BELLICAE modding project.Come visit us on http://www.twcenter.net/forums/forumdisplay.php?f=603

  4. #34

    Default Re: Eureka! Running scripts automatically!

    Have nice days, Patrizius.

    The use of GameReloaded to terminate the previous scripts has solved our problems relaunching the scripts after reloading without exiting the game.
    I suggest to add this monitor for all with the same problems (I guess related to the use of x turns a year or similar scripts).
    monitor_event GameReloaded TrueCondition
    terminate_script
    end_monitor
    Now this problem only happens when you start a new campaign without exiting the game, does anybody know the name of the ui_element of the exit campaign button?, because I could use the event buttonpressed to terminate the previous script also when you exit the campaign.

    About the advices, I have seen there is an atribute named "hidden", and I can use it without any error message, but it does nothing :(
    I have also been unable to make an advice without text: if I remove the entries "text" or "title" from export_descr_advice.txt, the game ctd, and the same ctd if I try to delete the text of the export_advice.txt (using only tabs and enters).

  5. #35

    Default Re: Eureka! Running scripts automatically!

    Quote Originally Posted by Bardo
    Have nice days, Patrizius.
    The use of GameReloaded to terminate the previous scripts has solved our problems relaunching the scripts after reloading without exiting the game.
    I suggest to add this monitor for all with the same problems (I guess related to the use of x turns a year or similar scripts).
    Have you tested it with loading a saved game both via Ctrl-L and thru the main menu?

    Quote Originally Posted by Bardo
    Have nice days, Patrizius.
    Now this problem only happens when you start a new campaign without exiting the game, does anybody know the name of the ui_element of the exit campaign button?, because I could use the event buttonpressed to terminate the previous script also when you exit the campaign.
    I've looked into that some months ago. The closest I got to solving it was with
    Code:
    monitor_event ScrollOpened ScrollOpened confirm_quit_scroll
      terminate_script
    end_monitor
    The 'v' and 'x' buttons on it are just generic confirm/cancel buttons and AFAIK don't have their own names that you could check for. So, if the player doesn't actually quit from that scroll, you'd have to restart the script.
    RTR VII Developer

  6. #36

    Default Re: Eureka! Running scripts automatically!

    Have you tested it with loading a saved game both via Ctrl-L and thru the main menu?
    Yes, it works with Ctrl-L and main menu, with quicksaves and autosaves, I know because the advice to launch my background script only appears if the event GameReloaded has been triggered, and the advisor always appears after reloading a game (any kind of savegame).

    I've looked into that some months ago. The closest I got to solving it was with
    It would be enough to me, but for some reason it does not work with my script :(. The script never stop, even when I press exit and then reject (nor pressing accept).

    Anyway, you have solved in one day the 2 main problems with our scripts: the needed to press show_me_how, and the collision with previous script when you reload a game without exiting,
    thank you very much for sharing your knowledge here.

  7. #37

    Default Re: Eureka! Running scripts automatically!

    Quote Originally Posted by Bardo
    Anyway, you have solved in one day the 2 main problems with our scripts: the needed to press show_me_how, and the collision with previous script when you reload a game without exiting,
    thank you very much for sharing your knowledge here.
    Glad to be of help.
    RTR VII Developer

  8. #38
    Axebitten Modder Senior Member Dol Guldur's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,550

    Default Re: Eureka! Running scripts automatically!

    Suspense over ;)

    The game-breaking problem I referred to was the fact that the game autoresolves battles unfairly. This has been addressed for units through the use of the secondary hp which is recognized by the autoresolve but not by the battle in real-time.

    However, the autoresolve seems not to take walls into account, and no factor can be found to sway the balance back.

    I have set up a "siegestarter" trait which basically kicks in to give a -10 command or +10 command during sieges, but this is not enough by any means to redress the balance.

    My recent project has been set in antiquity and the walls would have provided much more advantage to the occupants than later times where siege equipment was extant.

    Other than telling the player not to use autoresolve when defending or attacking walls (the RTW "house rule" of playing as it has been called), the only other way is to force the player not to ise autoresolve by disabling it in siege battles.

    So when I saw this thread I thought I would try it. The elements of the solution seems to work but I have hit a brick wall again (as I do with nearly all scripts) when it comes to the script file in the show_me folder: It simply does not seem to be read! I have tracked it down to this.

    Here is all the code....

    bottom of DS.txt

    Code:
    script
    TOL_Campaign_Script.txt
    TOL_Campaign_Script.txt (in same folder as DS.txt)

    Code:
    ; TOLCampaign Script
    ; kill characters
    
    script
    	;suspend_during_battle on
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;KILL THE DEAD FACTION LEADERS & NEPHIHAH, GIVE PAHORAN HIS EPITHET
    
    ;console_command kill_character Amlici
    ;console_command kill_character Zoram
    ;console_command kill_character Laman
    ;console_command kill_character Nephihah
    ;console_command give_trait Pahoran Pahoran 1
    
    wait 1
    console_command clear_messages
    wait 1
    advance_advice_thread My_Script_Thread
    wait 1
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    	
    	;console_command toggle_perfect_spy
    
    terminate_script
    EDA.txt

    Code:
    ;------------------------------------------
    AdviceThread My_Script_Thread
        GameArea Campaign
    
        Item my_Item_1
            Uninhibitable
            Verbosity  0 
            Threshold  1 
            MaxRepeats  0 
            RepeatInterval  1 
            Attitude Normal
            Presentation Default
            Title my_Title_1
            On_display scripts\show_me\tol_siege_script.txt
            Text my_Text_1
    EA.txt

    Code:
    {my_Title_1}	Title of Liberty - Total War
    {my_Text_1}
    Welcome to Title of Liberty - Total War!
    tol_siege_script.txt

    Code:
    script
    	declare_show_me						; This is a show me script
    
    	dismiss_advice
    		select_ui_element advisor_portrait_button
    		simulate_mouse_click lclick_up
    		suspend_unscripted_advice true
    	console_command kill_character Amlici	
    	console_command kill_character Zoram
    	console_command kill_character Laman
    	console_command kill_character Nephihah
    	console_command give_trait Pahoran Pahoran 1
    	monitor_event ScrollOpened ScrollOpened prebattle_scroll
    	campaign_wait 0.2
    	if I_ScrollOpen prebattle_scroll
    	and I_ConflictType Siege
    	disable_ui prebattle_auto_resolve_button
    	end_if
    	if I_ScrollOpened prebattle_scroll
    	and I_ConflictType SallyBesieger
    	disable_ui prebattle_auto_resolve_button
    	end_if
    
    end_monitor
    end_script
    What great blooper have I made? And how can this be improved from what you have found above? Thx. :)
    "One of the most sophisticated Total War mods ever developed..."

  9. #39

    Default Re: Eureka! Running scripts automatically!

    script
    declare_show_me ; This is a show me script

    dismiss_advice
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    suspend_unscripted_advice true
    console_command kill_character Amlici
    console_command kill_character Zoram
    console_command kill_character Laman
    console_command kill_character Nephihah
    console_command give_trait Pahoran Pahoran 1

    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    campaign_wait 0.2
    if I_ScrollOpen prebattle_scroll
    and I_ConflictType Siege
    disable_ui prebattle_auto_resolve_button
    end_if
    if I_ScrollOpened prebattle_scroll
    and I_ConflictType SallyBesieger
    disable_ui prebattle_auto_resolve_button
    end_if
    end_monitor

    while TrueCondition
    end_while


    end_script
    Theoretically it should work, but I have found in my experience that some of the commands you use here did not work as expected:
    1- I_ConflictType. I'm almost sure this command evaluates the last battle fought. When you open the pre-battle scroll, this still refers to the previous battle.
    2- I suggest not to use campaign_wait inside a monitor. Sometimes it stops the execution of the monitor, and I have verified recently that the "if" evaluations after the "wait" command does not work properly.

    You could test a simplified version to verify that the basic commands really work:
    Code:
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    	disable_ui prebattle_auto_resolve_button
    end_monitor
    I agree that the unbalance of autoresolved siege battles is a problem, but I don't thing to forbid them for the player is the solution. Sometimes the player is just tired of playing minor siege battles and he needs some way to autoresolve them.


    EDIT: Oh, now I read it again, maybe you forgot to place an infinite loop at the bottom of your script, it is needed so the script keeps being executed in the background. Else it executes all the lines once and then it stops.
    I see right the rest.

    while TrueCondition
    end_while
    Last edited by Bardo; 06-02-2008 at 00:21.

  10. #40
    RTR, AtB-EB member Member svramj's Avatar
    Join Date
    Mar 2007
    Posts
    78

    Post Re: Eureka! Running scripts automatically!

    great....

  11. #41

    Default Re: Eureka! Running scripts automatically!

    Also, there are several commands which do not work inside monitor_event blocks, including wait, campaign_wait, battle_wait, while, and nested monitor_event/condition. If you try to use them, the script freezes.
    RTR VII Developer

  12. #42
    Axebitten Modder Senior Member Dol Guldur's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,550

    Default Re: Eureka! Running scripts automatically!

    Thx for the advice. The loop did not change things.

    Just to clarify - the advice thread is being read but either:

    1. the on_display line is not (title and thread text is showing though)

    OR

    2. the text file in that line is not being read when the game enters it (none of the designated characaters are killed near the start of that file).


    I've had this before in BI (modfolder) but I am not using a provincial campaign folder now and so it should work better.

    :(
    "One of the most sophisticated Total War mods ever developed..."

  13. #43

    Default Re: Eureka! Running scripts automatically!

    1. In TOL_Campaign_Script.txt, the last line should be end_script. The terminate_script might potentially be killing the background script, too.

    2. Try putting some debugging commands into tol_siege_script.txt. For example,

    Code:
    script
    declare_show_me
    
    dismiss_advice
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    
    suspend_unscripted_advice true
    
    ; do these characters get killed? if yes, script is running
    console_command kill_character Amlici
    console_command kill_character Zoram
    console_command kill_character Laman
    console_command kill_character Nephihah
    
    console_command give_trait Pahoran Pahoran 1
    
    monitor_event ScrollOpened ScrollOpened prebattle_scroll
    
      console_command puppify_my_love     ; visual clue so you can see if/when the event has been detected
    
      if I_ConflictType Siege
        disable_ui prebattle_auto_resolve_button
      end_if
    
      if I_ConflictType SallyBesieger
        disable_ui prebattle_auto_resolve_button
      end_if
    end_monitor
    
    while TrueCondition
      suspend_unscripted_advice true
    end_while
    
    end_script
    3. This one might be a bit of a show stopper for what you're trying to do. I suspect I_ConflictType looks at the results of a battle rather than the ones that's about to happen.
    RTR VII Developer

  14. #44

    Default Re: Eureka! Running scripts automatically!

    Can I get this stickied or moved to another forum, before it slides down into oblivion?
    RTR VII Developer

  15. #45
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Eureka! Running scripts automatically!

    aaargh - I tried adding it to Modding Answers database - (it is now in there) - I just can't work out how to get it into category properly, I think the recent update to the forum software changed something about how that works.....

    You could if you liked re-post the first post plus any updates as a Tutorial in the Scriptorium and give a link back to this thread for discussion (as is done with the EDU and EDB guides to keep the Scriptorium version cleaner.
    Not used mods before? Looking for something small and fun?!
    Download the:

  16. #46

    Default Re: Eureka! Running scripts automatically!

    Thanks. I posted a full tutorial on TWC a while back... I'll just update the 1st post to point there and leave this thread for discussion.
    Last edited by HouseOfHam; 06-21-2008 at 17:40.
    RTR VII Developer

  17. #47
    Finder of Little Oddities Senior Member Makanyane's Avatar
    Join Date
    Jan 2006
    Posts
    2,220

    Default Re: Eureka! Running scripts automatically!

    OK, that's fine - forum software problem is now fixed so its ref'd from 'Scripting' Answers section, so hopefully anyone looking can find it.
    Not used mods before? Looking for something small and fun?!
    Download the:

  18. #48

    Default Re: Eureka! Running scripts automatically!

    OK, using HouseOfHam discoveries to relaunch scripts automatically just pressing the portrait of the advisor, we have gone one step forward, and we have been able to relaunch scripts automatically without the needed to click on the advisor. Now, when you reload a game, as soon as you select any character or army or settlement or you press any button, the scripts are automatically activated. It works even if the only button you press after reloading is the end of turn (not recomended because the script could miss the turn of some factions until it starts running, but you can get the idea of the big improvement of this method).

    Now, it is almost impossible to play the campaign with the scripts unactive, even for newbie players that do not know what is a script. I think this is the definitive step that we all scripters were waiting for.
    The bad new is that it has only been used successfully over AlexanderTW, it seems other people have been unable to use it over BI, but it is not confirmed that it won't be possible in the future.

    All the method is based on the use of 'on_display' to trigger the script without pressing show_me_how button (thank you HouseOfHam for the awesome discovery). And also in the use of 'declare_show_me' inside the script so the advice is opened automatically without clicking the advisor portrait.

    My method to trigger the advice thread after reloading a game is completely different to those used by other mods, because mine does not use the command 'suspend_unscripted_advice true' at all, and maybe this is the reason why the relaunching of the scripts can be completely automatic. Or maybe the reason is that we use AlexanderTW, it is not confirmed yet.

    Well, I think the best way to explain the new system is to copy here the related files we are using:

    Export_descr_advice.txt
    ;===============================================================
    ;== ADVICE THREAD DATA STARTS HERE ==
    ;===============================================================

    ;------------------------------------------ LOTR-TW
    AdviceThread Lotr_Script_Thread
    GameArea Campaign

    Item Lotr_Script_Text_01
    Uninhibitable
    Verbosity 0
    Threshold 2
    Attitude Excited
    Presentation Default
    Title Lotr_Script_Text_01_Title
    On_display scripts\show_me\background_script.txt
    Text Lotr_Script_Text_01_Text1

    ;===============================================================
    ;== TRIGGER DATA STARTS HERE ==
    ;===============================================================

    ;------------------------------------------ LOTR-TW trigger
    Trigger Reload_Script_Trigger1
    WhenToTest SettlementSelected

    AdviceThread Lotr_Script_Thread 1

    ;------------------------------------------ LOTR-TW trigger
    Trigger Reload_Script_Trigger2
    WhenToTest CharacterSelected

    AdviceThread Lotr_Script_Thread 1

    ;------------------------------------------ LOTR-TW trigger

    Trigger Reload_Script_Trigger3
    WhenToTest ButtonPressed

    AdviceThread Lotr_Script_Thread 1

    ;------------------------------------------ LOTR-TW trigger
    Trigger Reload_Script_Trigger
    WhenToTest GameReloaded

    AdviceThread Lotr_Script_Thread 0

    Campaign Script (placed in the campaign folder)
    script

    declare_show_me

    ;...

    wait 1
    console_command trigger_advice Lotr_Script_Thread
    advance_advice_thread Lotr_Script_Thread no_dismiss


    end_script

    Background Script (placed into \scripts\show_me)
    script

    wait 1
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_up

    ; This is the important one, needed so the text of the advice can be opened automatically;
    declare_show_me

    ;This is needed when you reload games without exiting the game, it disables the script of the previous game, and it allows the new script to be launched inmediately. Without this monitor, the script is not activated until end of turn;
    monitor_event GameReloaded TrueCondition
    terminate_script
    end_monitor



    while I_TurnNumber < 1000
    ;... We use a turn per year script inside this loop, but I think it is not relevant.
    end_while

    end_script

    EDITED: Improved method currently used in LOTR-TW 2.04 version. Tested and working. Scripts not completely automatic, but really close.
    Last edited by Bardo; 07-15-2008 at 16:37.

  19. #49

    Default Re: Eureka! Running scripts automatically!

    Bad news.
    Now that I have tested this method better, I must say that it is an important improvement, but still not completly automatic, only semi-automatic...
    You can start a new campaign with scripts automatic, and then to reload any number of savegames with scripts loaded automatically, but when you exit the game and restart again, the first game you load, does trigger the advisor, but you need to click the portrait. Since then, you can reload again any game and the scripts will be relaunched automatically.

    It seems that, as soon as one script with the command 'declare_show_me' is executed, the advices are opened automatically even when the script is no more running. And as soon as you execute another show_me script, the automation stops.

    Now I understand the reason of the 2 flaws I commented about the system:
    1-if you are playing a campaign with scripts, and you want to start a new campaign, you need to restart the game. Else, the new campaign will not allow you to save games.
    (This can surely be fixed in the future).
    2-if you use the option 'continue campaign' to load an 'autosave' game, then the advisor appears, but the script is not automatically launched, you need to click the portrait in this case... I have no idea why, because it works fine when you use 'continue campaign' to load an standard savegame, and also when you use 'load campaign' to load an 'autosave.
    1- when you start a new campaign, declare_show_me has been already declared by the previous script, and so the advices are opened and executed automatically. The campaign script of the new campaign reaches the line 'advance_advice_thread Initial_Lotr_Script_Thread' and the background script is automatically executed this time. The lastest lines with 'select_ui_element advisor_portrait_button' are not reached, and you can not save/load games, because the prologue (campaign-script) has not been properly finished.
    2- I tested it wrongly, because most of the times I started a new campaign before starting to test the savegames, and I thought they were always automatic.
    Actually, no matter if you use 'continue campaign', or 'load campaign', an autosave or a savegame, the first one never loads the scripts automatically (you need to click the advisor portrait), and since then the scripts are automatic for further reloads.


    It is a good improvement for people like me, that use to reload many games before exiting, because now it is immposible to forget to relaunch the scripts. And the method is good enough to me. But it can still be improved to open automatically the message of the first game loaded, maybe using 'speech only advice' by default and then changing it to 'show text' with the first script... but I think it is not worthwile to try it.
    Last edited by Bardo; 07-07-2008 at 20:25.

  20. #50

    Default Re: Eureka! Running scripts automatically!

    I have just discovered that the commnad:
    console_command trigger_advice Lotr_Script_Thread
    has the same effect than (or at leat very similar):
    AdviceThread Lotr_Script_Thread 0
    It seems that when you use "trigger_advice", the counter of the advice thread is reseted and the next command "advance_advice_thread" will trigger the advisor no matter the values of the attributes Threshold, MaxRepeats or RepeatInterval.
    After this discovery, I have been able to simplify a lot my method to launch the scripts. Now I can use only one advice thread to launch the scripts, with Threshold 2, reseted everytime you Reload a game ("GameReloaded" condition in the advice trigger) and everytime you start a new campaign ("trigger_advice" command inside the campaign script)

    I have not tested "trigger_advice" deeply, but I think it could be very useful for scripters to create complex rules to trigger scripted advices.


    I have updated my previous post with the latest version of the method, used in the latest release of our mod.

  21. #51
    Axebitten Modder Senior Member Dol Guldur's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,550

    Default Re: Eureka! Running scripts automatically!

    Good work, Bardo.
    "One of the most sophisticated Total War mods ever developed..."

  22. #52

    Default Re: Eureka! Running scripts automatically!

    Resetting the advisor re-enables advice threads that are marked as suppressible. When such an advice thread is displayed, there is a little checkbox that the user can click to stop it from ever showing again.
    RTR VII Developer

  23. #53

    Default Re: Eureka! Running scripts automatically!

    Greetings.

    I'm pretty new to this scripting-business. I tried using this as instructed, but I kept hitting a wall when loading a save game or a new campaign (quitting a game and restarting). It worked like a charm for the first campaign start, but no matter what I did, I couldn't get it to work when reloading.

    In the end I reverted back to my old fashioned script (based off Arthurian: Total War's), but I wanted to make it more automated. I figured out a way to use the old fashioned script with automated commands. It works for a campaign reload, but you still have to manually activate it when loading a save game.

    What I did: I simply simulated what I'd usually do when starting a campaign (click on the faction menu and then manually select the advisor and then the "Show me how" button).

    startup_script.txt
    Code:
    script
    
    dismiss_advice
    advance_advice_thread Instruct_Script_Startup
    wait 1
    select_ui_element faction_button
    simulate_mouse_click lclick_up
    wait 1
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    wait 1
    select_ui_element advisor_show_me_button
    simulate_mouse_click lclick_up
    
    ;Kill characters, give traits, etc.
    
    end_script
    Campaign_script.txt
    Code:
    script
    
    while I_TurnNumber < 819
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    
    suspend_unscripted_advice true
    suspend_during_battle on
    
    ;console_command toggle_perfect_spy
    
    			
    ;Four turns per year script							
    
    	
    if I_TurnNumber < 819				
    select_ui_element advisor_dismiss_button				
    simulate_mouse_click lclick_down				
    simulate_mouse_click lclick_up				
    end_if				
    			
    end_while
    
    end_script

    This of course requires a trigger when clicking the faction button:

    export_descr_advice.txt
    Code:
    Trigger Campaign_script_Trigger1
        WhenToTest ButtonPressed
    
        Condition ButtonPressed faction_button
    
        AdviceThread Campaign_script_Thread  0
    And for reference, this is how the AdviceThread looks:
    Code:
    AdviceThread Campaign_script_Thread		
    	GameArea Campaign	
    
    	Item Campaign_script_Text_01	
    		Uninhibitable
    		Verbosity  0 
    		Threshold  1  
    		Attitude Normal
    		Presentation Default
    		Title Campaign_script_Text_01_Title
         	Script scripts\show_me\Campaign_script.txt	
    		Text Campaign_script_Text_01_Text1

    It's not beautiful, but it works for me - preferable to the old manual activation at least.
    Last edited by Erilaz; 01-06-2017 at 22:11.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO