Results 1 to 22 of 22

Thread: Scripts triggered via advice, "like" show_me

  1. #1
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Scripts triggered via advice, "like" show_me

    Currently my version of RTW is unplayable so I cant test this atm and incase I'd forget I just (already) post it over here ...

    What I'm after are "player made feature's", what I mean with that is that by using the advice ability of RTW we can implement all sorts of (scripted) features (not unknown but unknown to me and imo not much explored according to available info about it)

    ===============

    What I'm currently after are several features wich trigger an advice wich in turn triggers a show_me type script, for instance
    -change the well-known garrison-script so it doesnt need a "warning tag" (once used keep it using or dont use it at all!!)
    -create re-emerging factions according to my specs and not hardcoded routines (with or without BI, though hording helps a lot!)

    the basic logic is simply in that is actually is a simplified version of similiar type script run as show_me script, the hard part is that "afaik" there is no way you can have the script remember things, what I mean is how can I make sure a garrison is spawned now but not the next turn if the script will run only that turn and than quit??
    There are ways of preventing stuff, like creating a new unit (just in label) and use it as spawn-unit for the script and than check up on how many of unit type X are in the garrison, instead of using counters to prevent over-spawn, but those are lacking.

    So basicly this is with the hope someone else already has the info, else as a placeholder for when my game is up and running. (its running but not as a decent test-base)


    G

  2. #2
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    as example, this garrison script I would like to be run as a show_me script but by a "silent" bit of advice, seeing that the problem is that you cant have a script load on gameload or detect if a script is running I was thinking about having it run each turn, basicly transfer the monitors to descr_advice and have that trigger proper scripts
    (say have a monitor check up on AI's treasury than call a script to give some cash if needed, or even the favored 4-turns a year script can be adapted to this so it doesnt need the player "to remember ....")

    example-script;
    Code:
    monitor_event FactionTurnEnd FactionIsLocal
    
    	if I_CompareCounter XCityX_Besieged > 0
    	and I_SettlementOwner XCityX = romans_julii
    		set_counter XCityX_Besieged 0
    	end_if
    
    	if I_CompareCounter XCityX_Besieged = 0
    	and not I_SettlementOwner XCityX = romans_julii
    		if I_CharacterTypeNearTile romans_julii family, 8 XxX,YyY
    			set_counter XCityX_Besieged 1
    		end_if
    		if I_CharacterTypeNearTile romans_julii general, 6 XxX,YyY
    			set_counter XCityX_Besieged 1
    		end_if
    		if I_CompareCounter XCityX_Besieged = 1
    		and not I_FactionNearTile romans_julii 2 XxX,YyY
    			console_command create_unit XCityX "spawn legion" 2
    			console_command create_unit XCityX "spawn archer" 1
    			set_counter XCityX_Besieged 0
    		end_if
    
    		if I_CompareCounter XCityX_Besieged = 1
    			console_command create_unit XCityX "spawn legion" 5
    			console_command create_unit XCityX "spawn archer" 3
    		end_if
    	end_if
    
    	if I_CompareCounter XCityX_Besieged = 2
    		set_counter XCityX_Besieged 0
    	end_if
    
    	if I_CompareCounter XCityX_Besieged = 1
    	and not I_CharacterTypeNearTile romans_julii family, 2 XxX,YyY
    	and not I_CharacterTypeNearTile romans_julii general, 2 XxX,YyY
    		set_counter XCityX_Besieged 2
    	end_if
    
    end_monitor
    basing the trigger on a faction means each script can be written for a specific faction, like the example is written for the Julii
    It will check up on generals and family members nearby, but also when possibly under siege, spawning some extra men if you get close and a full reinforcement once if its possibly you're sieging the settlement
    Than once you leave it takes at least 2 turns before a full reinforcement can take place ..

    The issue I have (in concept) with making this trigger by advice is the lack of being able to set some sort of "City_ Besieged" flag to prevent over-spawn "for sure" ..


    G

  3. #3
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    I've been tempering with the advice file for a day now (export_descr_advice)
    and have come to be believe that there is no way to get some "silent advice"

    seems I had missunderstood a few things, in that I assumed I could trigger a script without the need to press a button, "seems" I'm wrong there ...

    It was a nice idea ....


    G

  4. #4
    Shaidar Haran Senior Member SAM Site Champion Myrddraal's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    5,752

    Default Re: Scripts triggered via advice, "like" show_me

    Yeah sorry Red Spot, it's not possible to trigger advice without pressing the button. Unless you already have a script running, in which case you'd need to press a button to get that one working etc.

    That doesn't mean you can't use them to implement user made features (like different seasons and turns per year )

    There are workaround methods for 'remembering' stuff though.

  5. #5
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    Thanks for replying Myddraal, I apreciate it ;)

    btw do you know if there are ways to get the player promted with something (advisor?) whenever they load a savegame, I did find the "GameReloaded" command but couldnt get it to work (at least not the way I assumed it worked)



    G
    Last edited by Red Spot; 10-16-2007 at 03:52.

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

    Default Re: Scripts triggered via advice, "like" show_me

    If you link the trigger which activates the advisor for the script to a UI button/buttons the player is likely to press then you can make the advisor pop up which should work as a reminder.
    Only thing I played much that is scripted is Arthurian TW, they did it with multiple triggers so more or less anything you selected in the campaign map made the advisor pop up with the start script prompt.
    eg:
    ;------------------------------------------

    Trigger ATW_Campaign_Trigger1
    WhenToTest ButtonPressed

    Condition ButtonPressed faction_button

    AdviceThread ATW_Campaign_Thread 1
    and also same thing for
    Condition ButtonPressed construction_button
    Condition ButtonPressed recruitment_button
    WhenToTest SettlementSelected
    which covers most things you're likely to select during your turn, and the advisor keeps coming up with those buttons / selections until you actually start the script.
    Not used mods before? Looking for something small and fun?!
    Download the:

  7. #7
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    I've tought about somethng like that but afaik it will only work for the 1st reload, at least thats what stopping me from using such right now ...

    Or does that "1" on the end of trigger not specify that the trigger will only work once??


    G

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

    Default Re: Scripts triggered via advice, "like" show_me

    No, that seemed to work when the game was reloaded from saves anyway, which I think is all you need as a reminder.

    I think from memory it kept triggering until you actually accepted advice and pressed button to turn on the script, then stopped. But if you re-loaded the game it started triggering again...
    The top part of their advice thread that is activated by that trigger was:
    AdviceThread ATW_Campaign_Thread
    GameArea Campaign

    Item ATW_Campaign_Text_01
    Uninhibitable
    Verbosity 0
    Threshold 1
    Attitude Normal
    Presentation Default
    Title ATW_Campaign_Text_01_Title
    Script scripts\show_me\ATW_Campaign.txt
    Text ATW_Campaign_Text_01_Text1
    There might be something in those values (threshold?) that determines if something recurs or not - have to confess I don't understand all of it (I just tend to copy things of other peoples I've seen working )
    Not used mods before? Looking for something small and fun?!
    Download the:

  9. #9
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    and there is nothing advisor-related in their script, like for instance blocking unscripted advice?

    anyway thanks for the info, I'll make sure to try it out after I've finished my new map ..


    G

  10. #10
    Member Member Stuie's Avatar
    Join Date
    Aug 2001
    Location
    Upper Gwynedd, PA
    Posts
    406

    Default Re: Scripts triggered via advice, "like" show_me

    Quote Originally Posted by Red Spot
    I've tought about somethng like that but afaik it will only work for the 1st reload, at least thats what stopping me from using such right now ...

    Or does that "1" on the end of trigger not specify that the trigger will only work once??

    G
    Once within a session. Every time you load the game, the first time (and only the first time) you click one of the requisite UI items, the advisor pops up to launch the script.

  11. #11

    Default Re: Scripts triggered via advice, "like" show_me

    Hello, I'm the scripter of LOTR-TW (we have released an open beta last week), and since I'm using a new way to remind people about launching the script after reload a game, I'd like to share it here just in case that someone else could find it useful.
    The result is similar to those used by Europa Barbarorum (and Arthurian TW, I think), but I do not need to execute the command "suspend_unscripted_advice true" every turn to keep the advisor from reappearing after you have activated the script. And I think mine is simpler to implement.

    I'll try to explain it here, even when I'm not an english speaker...

    This is the code from export_descr_advice.txt:
    ;------------------------------------------ LOTR-TW advice
    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
    Script scripts\show_me\background_script.txt
    Text Lotr_Script_Text_01_Text1


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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 1

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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 1

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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 0
    The idea is to use the trigger event "GameReloaded" to detect that the player has reloaded a game and to use it to launch the advisor.
    In this case, the advisor appears when you select any settlement or any army, but it only appears once, the first time you select the settlement/army after the reload, and it does not appear again until you reload a game.

    The method is based on these ideas about advices:
    -"AdviceThread Lotr_Script_Thread 0": this is the way you call the advice. The last number represents the way the advice-counter is incremented:
    1: it increases the advice-counter by 1, then the engine compares the advice-counter to the threshold of the advice (similar to traits/ancillaries), and if equal the advisor appears.
    0:it increases the advice-counter by 1, then the engine compares the advice-counter to the threshold of the advice. If equal, the advisor appears AND then it decreases the advice-counter by 1 again.

    Result:
    1-the first time you start a campaign, when you select a settlement/army, the advice-counter is increased to 1, nothing happens.
    2-the 2nd time, the counter reaches the treshold 2, and the advisor remembers you to launch the script (pressing show me button).
    3-no matter you press show_me or not, the advisor will not appear again until you reload a game.
    NOTE: Since we have not defined "MaxRepeats", it seems that the max value of the advice-counter is equal to the Threshold.

    4-when you reload a game, the trigger Reload_Script_Trigger is executed, it calls the advice, and it decreases the counter by one (2-1=1 in total)
    5-since now, the first time you select a settlement/army, the counter will reach the threshold 2 again, and the advisor will pop-up.


    I'm not sure if this is the exact algorithm of the advisor counters, but it explains my experiments, and it is sure that my code will work as I describe since we have been using it for long time.
    I hope it is useful for other modders... if someone was able to understand something :).

    This is the base of the method, I'll try to describe the whole method I use in the next post. Note that it is hard to explain it, but really easy to implement.

  12. #12

    Default Re: Scripts triggered via advice, "like" show_me

    I have combined the previous method with a campaign script that automatically launches the background script when you start the campaign the first time (this is already known, since I learnt to do it in the scriptorium).

    campaign script = tutorial script (this script is automatically launched from descr_strat.txt)
    background script = show me script, that we want to relaunch every time we reload a game.

    At the end of descr_strat.txt we call the campaign script:
    script
    Alexander_Campaign_Script.txt
    At the end of the campaign script (named Alexander_Campaign_Script.txt in this case) we call the background script:
    script
    ...
    advance_advice_thread Initial_Lotr_Script_Thread no_dismiss
    wait 1
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    wait 1
    select_ui_element advisor_show_me_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up

    end_script
    We add a new advice to launch the scripts the first time (Initial_Lotr_Script_Thread):

    ;------------------------------------------ LOTR-TW advice
    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
    Script scripts\show_me\background_script.txt
    Text Lotr_Script_Text_01_Text1

    ;------------------------------------------ LOTR-TW advice
    AdviceThread Initial_Lotr_Script_Thread
    GameArea Campaign

    Item Initial_Lotr_Script_Text_01
    Uninhibitable
    Verbosity 0
    Threshold 1
    MaxRepeats 0
    RepeatInterval 1

    Attitude Excited
    Presentation Default
    Title Initial_Lotr_Script_Text_01_Title
    Script scripts\show_me\background_script.txt
    Text Initial_Lotr_Script_Text_01_Text1

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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 1

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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 1

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

    Condition TrueCondition

    AdviceThread Lotr_Script_Thread 0
    Finally, to avoid that the advisor pops up when you start the campaign
    (if you remember, it appeared the 2nd time you select a settlement/army)
    I add this at the start of the background script:

    script
    advance_advice_thread Lotr_Script_Thread
    advance_advice_thread Lotr_Script_Thread
    dismiss_advice
    dismiss_advisor
    ...
    I call 2 times the advice, so it reaches the treshold. The advisor appears but I automatically dismiss it so the player do not notice it.


    Tell me if you do not understand something... or even better, tell me if someone was uble to understand it and use it.
    It is working fine in our lotr-tw 2.0 mod.

  13. #13
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    Thanks for the reply Bardo, already have some similair way of doing things, though my method is a bit more traightforward (just dont feel comfi sharing as I wouldnt know who's work I used as a bit of refrence ....)

    anyway I just watch factionturnstart for the start of the game and button and scroll pressed/opened to catch a reload ... (the gamereloaded command didnt seem to work when I tested it from a script ...)


    G

  14. #14
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    just a pointer ...

    in my search for .. er .. scripting stuff I've found out that most if not all mods seem to use the combi;
    Code:
    wait 1
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up
    this is my "starter script" (triggered from descr_strat) with the same result;
    Code:
    script
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    wait 0.2
    console_command clear_messages
    wait 1.6
    select_ui_element advisor_portrait_button
    simulate_mouse_click lclick_up
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    end_script
    (the last 2 commands are repeated at the start of the background-script to remove the advisor from the screen)

    havent figured out yet what the lclick_down does but its clearly not needed for the purpose of getting the advisor selected and the advise shown or the advisor removed from screen


    G

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

    Default Re: Scripts triggered via advice, "like" show_me

    have just started trying to do this for real myself, have a trigger advice combo that works for me, the trigger doesn't repeat except if you re-load the game, unfortunately except when it comes up with the Battle Deployment screen, any idea why that would be?

    EDIT: the script also seems to stall at that point - I've got perfect_spy attached and if I don't reload from the advisor that conks out.... erm, realising it probably is flaw with script contents and not trigger - sorry if wrong thread!
    Last edited by Makanyane; 11-11-2007 at 20:35.
    Not used mods before? Looking for something small and fun?!
    Download the:

  16. #16
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    when the battle-deploment screen comes up the game "seems" to take that as a "battle situation" so the "suspend during battle" command already comes into play ...

    the way I worked around it without the need to set my advice treads to only be allowed to trigger once is by setting my advice treads to be triggered at events that do NOT happen during these stages, like selecting a settlement or opening the faction/finances/diplomacy scroll (those cant be opened/selected at that stage)

    basicly depending on when you want your script to run you may want to decide not to use the "suspend during battle" command


    G

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

    Default Re: Scripts triggered via advice, "like" show_me

    ugh, could have sworn I borrowed triggers off you in first place

    taking suspend during battle out fixes the recall bit, I now just have funny noise when advisor goes away or doesn't pop up when it wants to.

    Also some problems with script itself trying to work out how monitor counters increment to stop them doing same thing again, actually I suppose that doesn't really work anyway as re-load would mess it up!
    Not used mods before? Looking for something small and fun?!
    Download the:

  18. #18
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    Quote Originally Posted by Makanyane
    ugh, could have sworn I borrowed triggers off you in first place

    I know, was in doubt to add the text "forget about my last PM" to the previous post but figured you already noticed me being incorrect in that PM ...


    advisors making funny noises .. in my case that was cause I had several treads that where interfearing, where the first was still being heard while the 2nd was being called


    I've taken out pretty much all counters out of my script and based things on other stuff, like a garrison script based on the siege(seige) scroll being triggered, doesnt need any counters as when you siege you siege and it spawns men based on the buildings build in Rome but that is checked the very first time Rome takes a turn so the script can only be slightly off if you siege in the first turn after a reload where Rome hasnt had any turn ...



    G

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

    Default Re: Scripts triggered via advice, "like" show_me

    The siege scroll as a trigger sounded such a good idea I thought I'd try it so have been trying :
    monitor_event ScrollOpened ScrollOpened seige_scroll
    and I_FactionBesieged vandals
    console_command create_unit Metatron "semin" 1
    console_command create_unit Metatron "semin" 1
    end_monitor
    that's simplified version to test it as I can't get it working, the create unit bits worked with End Turn event and settlement under siege conditions, but switching to ScrollOpened kills it - any idea what I'm missing?

    EDIT: I can get it to work on buttons eg;
    monitor_event ButtonPressed ButtonPressed siege_assault_button
    though I can't see anyway of stopping it triggering for other cities that meet the same faction ownership requirements and have enemy army standing near them (set on counter) - though I suppose if they have enemy army standing near them....
    Last edited by Makanyane; 11-12-2007 at 21:23.
    Not used mods before? Looking for something small and fun?!
    Download the:

  20. #20
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: Scripts triggered via advice, "like" show_me

    you basicly need to double up on the check, first you need to register the event of a scroll being opened, than check the condition of it being the siege-scroll

    Code:
    monitor_event ScrollOpened seige_scroll
    and ScrollOpened seige_scroll
    or

    Code:
    monitor_event ScrollOpened TrueCondition
    and ScrollOpened seige_scroll

    G

  21. #21

    Default Re: Scripts triggered via advice, "like" show_me

    Hey guys!
    Sorry for the dig - if anyone is still interested in progress on the background script automatic startup issue, this might interest you (well, don't expect much, just very small additions).

    my finds
    Last edited by Ludens; 12-18-2010 at 10:52. Reason: merged posts

  22. #22
    Arrogant Ashigaru Moderator Ludens's Avatar
    Join Date
    Nov 2003
    Posts
    9,062
    Blog Entries
    1

    Default Re: Scripts triggered via advice, "like" show_me

    Posts merged.

    Thanks for the contribution, Greno Zee.
    Last edited by Ludens; 12-18-2010 at 10:53.
    Looking for a good read? Visit the Library!

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