View Full Version : Eureka! Running scripts automatically!
HouseOfHam
05-28-2008, 06:18
Summary: Traditionally, the advice thread in EDA used to run the script had a Script line in it. Replace the Script keyword with the OnDisplay keyword to have the script run automatically, without having to click on the 'Show me how' button.
The full tutorial is posted here: http://www.twcenter.net/forums/showthread.php?t=169689
This thread is for discussion only.
Monkwarrior
05-28-2008, 12:06
And for reloading a saved game? :inquisitive:
Flying Pig
05-28-2008, 12:18
Congratulations! This is probably the most exciting recent find I can think of! Should a mod move it to Scriptorium?
And for reloading a saved game? :inquisitive:
. . . and for loading a saved game, you only need to click on the advisor portrait and you're done.
<snip>
See the bolded mark of the OP.
Monkwarrior
05-28-2008, 19:07
But I don't understand how it is triggered when reloading.
An additional trigger is needed, isn't it?
What does on_display make? What's the difference with a "normal" advice thread?
Sorry, maybe I've missed something. :embarassed:
I used the system "campaign script -> background script" to launch it at the start of a campaign (this is not new for me), but I had to use a normal trigger (click on settlement for example) when reloading. I'd like to understand the difference.
HouseOfHam
05-28-2008, 20:55
You will still need to keep those triggers. But when loading a saved game, they'll only need need click on the advisor portrait and that's it.
The best way to see what it does is to try it. :)
Patrizius
05-29-2008, 11:57
EUREKAAA!
i find a way to get ride of those annoying script activation,using this incredible thing.
you make a trigger for the ADVICE like this:
Trigger my_script
WhenToTest FactionTurnStart
Condition FactionIsLocal
AdviceThread My_script_Thread
this way as you see there is a problem cause the script will be activated each time you start a turn...but :idea2:
in the script write:
suspend_unscripted_advice true
this way no more advice will be displayed.ANd
:yes: :yes: :yes: :yes: We you load a game you will have your script activated.
and if you reload,it will reativate again:smash:
Great work HouseOfHam:2thumbsup: :bounce:
HouseOfHam
05-29-2008, 16:34
Thanks. :)
Does that event trigger immediately as you load a saved game or do you have to hit 'End turn' first?
I'll give it a try tonight.
Patrizius
05-29-2008, 17:07
it can be that toghetr we have solved one of the greatest problems in the modding.Having the player to remember to activate the script.
the characterTurnStart event should trigger immediantly when you firstly start a campaign,but i think not when you load....GameReloaded seems the event we need to make the last step,but i think FactionTurnEnd would work anyway(but in this way the player must pass a turn to have thee script activated).Let me know.I'll try with GameReloaded and let you know ;)
Patrizius
05-29-2008, 17:47
ok maded some extra tests.
FactionTurnStart is useless there.and even gameReloaded seems a fake.
indeed we can get ride of this problem in this way,unless it won't work for all kind of scripts(in the fact it will work almost for all kind of script:2thumbsup: ),using the combination SettlementSelected,CharacterSelected,factionTurnEnd.
This way if the player touches anything in the strat map,it will activate the script.
the only drawback is that this method requires the advice_frequence to be set to high,unless someone discover how to make advices to appear anyway(there is a big set of attributes added to an advice.Maybe someone will do the trick.)
I'm gonna check right about now.Keep it up HouseOfHam.WE MUST DISCOVER THE SECRET
HouseOfHam
05-29-2008, 19:29
Yeah, I've never been able to detect the GameReloaded event, either. I don't think they ever implemented it.
Anyhow, the remaining problem is not so much what trigger(s) to use but how to get the script to run without having to click on the advisor portrait. If that's not a concern, whatever triggers people used in their mod will still work just fine.
Patrizius
05-29-2008, 19:29
After an afternoon spent doing tests,here it's my conclusions:
i used those advice and triggers
;------------------------------------------
AdviceThread Help_Game_Options_Scroll_Thread
GameArea Campaign
Item Help_Game_Options_Scroll_Text_01
Verbosity 0
Priority 2
MaxRepeats 0
RepeatInterval 1
Threshold 1
Attitude Excited
Presentation Default
Title Help_Game_Options_Scroll_Text_01_Title
On_display scripts\show_me\script.txt
Text Help_Game_Options_Scroll_Text_01_Text1
Trigger 3699_City_Construction_Build_temple_of_trade_pantheon_britons_Next_Trigger
WhenToTest SettlementSelected
AdviceThread Help_Game_Options_Scroll_Thread 1
Trigger 3699_City_Construction_Build_temple_of_trade_pantheon_britons_Next_Trigger
WhenToTest CharacterSelected
AdviceThread Help_Game_Options_Scroll_Thread 1
note that the line "Attitude Excited" force RTW to automaticcally open the advice(so you don't have to click on it).then you must write "suspend_unscripted_advice true" on your script
the two drawback are:
1)it doesn't start unless you select something on the map(factionturnend is completely useless).
2)you have to select the advice frequency to low to get it to work.
a big leap for our scripters.but still not perfection.This damn RTW has only one thing done well:THE BUGS:furious3:
Patrizius
05-29-2008, 19:32
i have reaad just now.i solved that problem :2thumbsup:.please tell me if you find something new.;)
HouseOfHam
05-29-2008, 19:41
Good to know about Attitude Excited. Does that only work if advisor is set to something other than "No advice"?
Why did you use Priority 2?
Patrizius
05-29-2008, 19:49
it's a matter of setting.those ones with higher priority seems to be considered first(so if you have to advices that should pop out in the same moment,the engine will show first the one with higher priority ) and also that one is used in deciding which advices are to be shown or not when you change the "advice frequency" setting.Some of them will never pop out if you select an addvice priority of "high".writing priority 2 will ensure that advice is displayed also when you select "low".but seems to do nothing against the "noone" advice frequency option :( ...
HouseOfHam
05-29-2008, 19:55
No reason you couldn't use more than 1 thread. 1st for people who have advisor set to "no advice" - to start it by clicking on the advisor portrait, and 2nd to start it automatically for people who have advisor set to "low" or higher.
Patrizius
05-29-2008, 19:58
yes i already use this way.I didn't post it cause it was a known solution ;)
Patrizius
05-30-2008, 09:01
ok maded some extra tests and i have you have to forgive me...
atitude excited seems not to work.In the fact,it worked because i set the advisor in the "only speech" mode...It seems the only real solution right about now.Hope you find something bettter ;)
Great discovery HouseOfHam, :2thumbsup:
I have tested it, writting "On_display" in stead of "Script" in the advice line, and it is working fine in our mod.
The scripts are still not automatically lauched, since they need the player to click the advisor's portrait, but it is a BIG step to make the scripts easier to be activated for the players.
I wonder how did you found this "On_display" command, because maybe it exists another commnad that directly executes the script (without clicking on the advisor portrait), like it happens with the descr_strat final line.
I have always missed some kind of guide about the export_descr_advice.txt file, and I think it is a good moment to start researching every possible command/atribute used in the declaration of advices.
I'll join to your efforts to try to find some way to open the advisor portrait automatically. But I use "Attitude Excited" in all my scripts and this is not the solution.
I have also tested with:
-Suppressible
-Uninhibitable
-Verbosity
-Priority
-Attitude
I wonder if somebody knows any other possible value for "Presentation Default"?
Yeah, I've never been able to detect the GameReloaded event, either. I don't think they ever implemented it.
We use this even to relaunch the scripts in lotr-tw and it does work. It is triggered so quickly that it does not allow you to launch the advisor with this event, but you can use it as condition to know when the game has been reloaded, and then use the usual events (like characterselected...) to trigger the advisor.
atitude excited seems not to work.In the fact,it worked because i set the advisor in the "only speech" mode...It seems the only real solution right about now.Hope you find something bettter ;)
Patrizius, then the scripts are launched completely automatically (without human intervention) when you select "only speech mode"?
HouseOfHam
05-30-2008, 18:34
I was looking through the .exe to see what text strings I could find and came across a section that had a bunch of advice thread keywords and mixed in with them was On_display. It looked a lot like a javascript event handler, so I thought it was promising. Then, I searched export_descr_advice.txt and found it in 2 places in BI where it was used. I put it into TIC and with a little testing and tweaking got it to work.
There is another keyword there which I haven't looked at yet, UseInTutorial
In general, just looking at what error messages are coded in the exe can give a pretty good indication of what the limitations are or what it expects.
Patrizius
05-30-2008, 18:59
Patrizius, then the scripts are launched completely automatically (without human intervention) when you select "only speech mode"?
yes:2thumbsup:
but we need to find something better for me.I'm also going to test.in three we may reach some results ;)
Wow, very smart, I don't know which discovery I like more: on_display is one of the best improvements in scripting that I have seen in long time,
but the possiblity to view all the attributes allowed by the .exe... this is incredibly useful too.
Regretably, it seems the only possible value for presentation is "default".
I'll test now the "only speech mode", good one Patrizius.
Patrizius
05-30-2008, 19:37
great topic!
Patrizius
05-30-2008, 19:44
great discover of course and thanks ;)
Dol Guldur
05-30-2008, 20:02
Good work. Keep going and you may even convince me that scripts might be worth considering.... :yes:
Patrizius
05-30-2008, 20:18
good to hear this ;) dol_guldur
HouseOfHam
05-30-2008, 20:21
Good work. Keep going and you may even convince me that scripts might be worth considering.... :yes:
Hah, RTW without scripts = stone age. :logic:
Patrizius
05-30-2008, 20:23
Hah, RTW without scripts = stone age. :logic:
i agree with you.but scripts make us :dizzy2:
HouseOfHam
05-30-2008, 20:30
The scripts are still not automatically lauched, since they need the player to click the advisor's portrait, but it is a BIG step to make the scripts easier to be activated for the players.
When starting a new campaign, it should be launched automatically, if you followed my directions exactly.
I have also tested with:
-Suppressible
-Uninhibitable
-Verbosity
-Priority
-Attitude
I've also looked into what the Parameter values are used for, but AFAICT the functionality they offer is redundant if you already use a background script.
We use this even to relaunch the scripts in lotr-tw and it does work. It is triggered so quickly that it does not allow you to launch the advisor with this event, but you can use it as condition to know when the game has been reloaded, and then use the usual events (like characterselected...) to trigger the advisor.
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.
Dol Guldur
05-30-2008, 20:45
Although I did not use scripts in GAFM, Aradan did work on the advice thread for me. It triggers when certain ancs are lost or when certain characters (or rather their traits) are killed.
He can probably tell you more about that, but I did notice that sometimes the advisor did not always show. I think - and I noticed this with perfect spy too - that when you quit the game using alt+f4 (as most modders will to save time) it can interfere with it. I also noticed that having the automatic settlement government option checked interfered with perfect spy too.
There's an option in the actual game to "reset" the advisor but I never could work out what that actually changed if you used it ;)
Although I'm probably somewhat known for promoting and recommending modfoldering, I actually resisted it when it was first revealed and succesfully implemented because it had seming loop holes in it. These were quickly overcome by researchers and I then used (and improved) it to where it is today. I still see loop holes in scripting which is why I do not support it - or at least its heavy use (and I think FATW is the better for it imho) - but (as I implied before) your work here is overcoming some of those loop holes for me so kudos to you all :laugh4:
I of course realize that some mods - many mods perhaps - need certain things to happen (historical accuracy and so forth) and so scripting is important. I am actually looking into a script at present to overcome an issue that no one else seems to have addressed (which is really quite strange seeing as it is a huge gap in the gameplay) but I may ask a little help from some of you soon on the matter as it ties in with this thread :)
Patrizius
05-30-2008, 21:05
you have just make us courious to know
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"...
Patrizius
05-30-2008, 22:17
i'll go away til the 3.hope to find good news when i get back XD.Goodbye to all.
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).
HouseOfHam
05-30-2008, 23:49
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?
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
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.
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.
HouseOfHam
05-31-2008, 18:49
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. ~:)
Dol Guldur
06-01-2008, 23:00
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
script
TOL_Campaign_Script.txt
TOL_Campaign_Script.txt (in same folder as DS.txt)
; 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
;------------------------------------------
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
{my_Title_1} Title of Liberty - Total War
{my_Text_1}
Welcome to Title of Liberty - Total War!
tol_siege_script.txt
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. :)
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:
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
HouseOfHam
06-02-2008, 03:06
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.
Dol Guldur
06-02-2008, 15:42
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.
:(
HouseOfHam
06-02-2008, 17:36
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,
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.
HouseOfHam
06-20-2008, 20:11
Can I get this stickied or moved to another forum, before it slides down into oblivion?
Makanyane
06-21-2008, 07:35
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.
HouseOfHam
06-21-2008, 17:36
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.
Makanyane
06-23-2008, 23:14
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. :yes:
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.
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.
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.
Dol Guldur
07-15-2008, 23:39
Good work, Bardo.
HouseOfHam
11-05-2008, 22:51
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.
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
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
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
Trigger Campaign_script_Trigger1
WhenToTest ButtonPressed
Condition ButtonPressed faction_button
AdviceThread Campaign_script_Thread 0
And for reference, this is how the AdviceThread looks:
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.
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.