Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: Help with mission script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Icon5 Help with mission script

    I'm trying to write a background script that would add a "search and rescue" mission to the game (=e.g. ImportantDude being taken captive). Using BI engine. I'm very new in scripting so I hope someone would be kind enough to help me out. I've tried to read all tutorials on the topic, but many questions remain. I've followed the basic advice by HouseOfHam on how to add a background script. I'm trying to proceed step-by-step and the first task would be to create a status of ImportantDude being captive. I've succeeded in that with a counter, but for some reason my script does not prevent the same thing happening multiple times. Why on earth does the message "PromptThreadCaptive" appear every time the unit is attacked and loses more than 10 % of its men?

    Code:
    declare_counter captive
    set_counter captive 0
    
    monitor_event PostBattle FactionIsLocal
        if I_LocalFaction sarmatians
        and if I_PercentageUnitKilled importantdude_bodyguard > 10  ; here 10 % just an example of loss
        and if I_CompareCounter captive = 0
            advance_advice_thread PromptThreadCaptive 1   ; this works, i.e. the message appears after battle
            set_counter captive 1   ; I don't know if this goes through...
            console_command add_money 20000  ; this works too
        end_if   ; should here be one or two rows of "end_if"?
    end_monitor
    I have created a unit type importantdude_bodyguard and assuming that the captain of that unit would be the ImportantDude. I'm not making him a general on purpose as I do not want to lose him due to high age and I do not want to use Alex engine (if I have understood correctly, Alex is the only engine with which you can make very long-living generals).

  2. #2
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    - I don't think "and if" is valid syntax. At least, I've never seen it used that way. It should be just "and", since it's part of the same "if" statement.
    - The unit_label parameter expected by I_PercentageUnitKilled is a id created via the label_unit command, where the unit_label refers to a specific unit index within a specific army. This pretty much limits its use to historical battles where you know each unit's index ahead of time.
    - Moreover, I_PercentageUnitKilled only works in battle mode, whereas PostBattle only work in strategy map mode. I wouldn't expect a monitor that combines the two to work at all.

    Anyhow, I don't think there's a way to do this without tying it to general's unit, so you can use the PercentageBodyguardKilled condition.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  3. #3

    Default Re: Help with mission script

    Thanks mate! Bare with me, but I'd like to ask some clarifications so that I understand better.

    Quote Originally Posted by HouseOfHam View Post
    - I don't think "and if" is valid syntax. At least, I've never seen it used that way. It should be just "and", since it's part of the same "if" statement.
    Before ending up with this syntax for monitoring I tried two others that seemed more "according to examples". But none of these two worked.

    Code:
    FIRST ONE:
    monitor_event PostBattle FactionIsLocal
        if I_LocalFaction sarmatians
        and I_PercentageUnitKilled importantdude_bodyguard > 10
        and I_CompareCounter captive = 0
            advance_advice_thread PromptThreadCaptive 1
            set_counter captive 1
            console_command add_money 20000
        end_if
    end_monitor
    
    SECOND ONE:
    monitor_event PostBattle FactionIsLocal
        I_LocalFaction sarmatians
        I_PercentageUnitKilled importantdude_bodyguard > 10
        I_CompareCounter captive = 0
            advance_advice_thread PromptThreadCaptive 1
            set_counter captive 1
            console_command add_money 20000
    end_monitor
    Neither of them brings up the advance_advice_thread or add money (I'm using it just as an indicator here!). I tried to fight both in battle mode and on strat map with no difference. With both of the versions the background script seems to start endless times every time I select a city or press some of the UI buttons in strat map. I.e. the campaign adviser comes several times saying "background script started". Should any of these be correct syntax and if so, why does the adviser come several times?

    The one I sent in the first message (with "and ifs") seemed to be the only one that works at least partly. I am able to get the message defined by advance_advice_thread and to get the money. But it comes every time the unit type loses more than 10 %, which should not be the case.

    Quote Originally Posted by HouseOfHam View Post
    - The unit_label parameter expected by I_PercentageUnitKilled is a id created via the label_unit command, where the unit_label refers to a specific unit index within a specific army. This pretty much limits its use to historical battles where you know each unit's index ahead of time.
    But I have not used any label_unit command, just the name that is after the dictionary tag in EDU.txt. I tried to send two different importantdude_bodyguard -units to fight two different armies and it worked for both. So could it be that in the absence of a label it looks at the dictionary name?

    Quote Originally Posted by HouseOfHam View Post
    - Moreover, I_PercentageUnitKilled only works in battle mode, whereas PostBattle only work in strategy map mode. I wouldn't expect a monitor that combines the two to work at all.
    This I did not know at all! But as said, it seemed to work - at least partly and a weird syntax ;-). Any idea why?

    Quote Originally Posted by HouseOfHam View Post
    Anyhow, I don't think there's a way to do this without tying it to general's unit, so you can use the PercentageBodyguardKilled condition.
    Ok, that would work both in battle and strat map mode. But i'm still not sure how I should proceed, since the basic syntax of ifs is not clear really... Could you or someone else help?!

    I enclose the full background script if that would help:

    Code:
    script
    
    ; Anything following a semicolon is a comment.
    
    ; Remove the adviser portrait from screen.
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_up
    
    ; Wait for it to go away.
    while I_AdvisorVisible
    end_while
    
    suspend_unscripted_advice true
    
    ; Open the adviser message bubble automatically whenever advance_advice_thread is called.
    ; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
    ; Do NOT mix both methods, though, or the advisor will show and then immediately close before
    ; you get a chance to read the text.
    declare_show_me
    
    ; Very useful for debugging - uncomment to use
    ;console_command toggle_perfect_spy
    
    ;;;
    ;;; --- Forced shutdown ---
    ;;;
    ;;; Press 'Esc' on the campaign map, then click on the '?' button in the
    ;;; menu scroll to terminate the script.
    ;;;
    ;;; When would this be useful? -- When you are already in a game and
    ;;; exit back to the main menu to restart the campaign, or reload a saved
    ;;; game, RTW does not automatically terminate the script, so you have
    ;;; to do it yourself. If you leave the old script running, you'll have all
    ;;; sorts of weird problems with the script in the new game.
    ;;;
    monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
        terminate_script
    end_monitor
    
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
      terminate_script
    end_monitor
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; This is where to put your own code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    declare_counter captive
    set_counter captive 0
    
    monitor_event PostBattle FactionIsLocal
        if I_LocalFaction sarmatians
        and if I_PercentageUnitKilled importantdude_bodyguard > 10
        and if I_CompareCounter captive = 0
            advance_advice_thread PromptThreadCaptive 1
            set_counter captive 1
            console_command add_money 20000
        end_if
    end_monitor
    
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; End of your code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
    ; In M2TW scripts, this loop is replaced by the wait_monitors command. Unfortunately, this command is not available in RTW.
    
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    
    end_script

  4. #4
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    What I've noticed is that sometimes, when you have a syntax error in a condition, the game just ignores that line (as if the condition evaluated to true). This could explain why it seems to work.

    You could say this "very important person" is part of a particular general's bodyguard. The PostBattle event is generated for every general that took part in the battle (though, I'm not sure what happens if a general dies), so you need to have a unique trait to identify that specific general. You could then combine PercentageBodyguardKilled with a trait check. Something along the lines of:
    Code:
    declare_counter captive
    set_counter captive 0 
    
    monitor_event PostBattle FactionType sarmatians
              and FactionIsLocal
              and PercentageBodyguardKilled > 10
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
    end_monitor
    Last edited by HouseOfHam; April 25, 2011 at 11:53 AM.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  5. #5

    Default Re: Help with mission script

    Quote Originally Posted by HouseOfHam View Post
    What I've noticed is that sometimes, when you have a syntax error in a condition, the game just ignores that line (as if the condition evaluated to true). This could explain why it seems to work.
    Indeed, this was probably the case here. I tried to attack with another army that did not contain the importantdude_bodyguard, and the advisor appeared to give the message also then (although shouldn't)!

    Quote Originally Posted by HouseOfHam View Post
    You could say this "very important person" is part of a particular general's bodyguard. The PostBattle event is generated for every general that took part in the battle (though, I'm not sure what happens if a general dies), so you need to have a unique trait to identify that specific general. You could then combine PercentageBodyguardKilled with a trait check. Something along the lines of:
    OK, sounds like a possible solution. But how can I make him live throughout the campaign? I mean doesn't he disappear when the general dies, in battle or because of old age? Is it possible to create a new general unit automatically, with the same ancillary, when the first one doesn't exist any more?

    While still trying to find a solution for not needing to use a general unit, I also tried this (see below), but for some reason it doesn't work. Any idea why?

    Code:
    label_unit 0 0 4 importantdude
    declare_counter captive
    set_counter captive 0 
    
    monitor_event BattleConflictPhaseCommenced FactionType sarmatians
              and FactionIsLocal
              and I_PercentageUnitKilled importantdude > 50
              and I_CompareCounter captive = 0
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
    end_monitor
    I hope I labelled the correct unit. I took the first sarmatian army defined in descr_strat.txt and the fifth unit in it (I presume the first one - the general - is number zero). Am I correct?
    Last edited by chrisb; April 25, 2011 at 04:05 PM.

  6. #6

    Default Re: Help with mission script

    I'm getting really frustrated with scripting. Will soon give up as the logic of it seems too difficult for me to grasp...

    OK, making the "importandude" part of a general's party seems to work. I get the message defined by PromptThreadCaptive as well as the money. Plus an extra building to mark the capture (instead of losing it every time the game is switched off) also works. And all this happens only once, as it should. So far so good!

    But then tried to proceed with adding into the background script a section that would remind me every time a new round starts about the importantdude being captured and perhaps causing some other effect (e.g. reducing money that needs to be used for the SAR mission or causing unrest). Why on earth does the second part of the following code not work?

    Code:
    declare_counter captive     ; I may remove this completely, as the building should be enough
    set_counter captive 0 
    
    monitor_event PostBattle FactionType sarmatians
              and FactionIsLocal
              and PercentageBodyguardKilled > 10
              and I_CompareCounter captive = 0    ; this could be removed and condition on the building added
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1      ; What does the number one mean here, copied it?
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicus_Sarmatae caravan   ; caravan is from another faction but seems to work, as it is added to the settlement after the bodyguard has reduced more than 10 %
    end_monitor
    
    ; SECOND PART STARTS HERE
    
    monitor_event SettlementTurnStart FactionType sarmatians
        and SettlementIsLocal
        and SettlementName Vicus_Sarmatae
        and I_LocalFaction sarmatians
        and SettlementBuildingExists = caravan
            advance_advice_thread PromptThreadCaptiveStill 1   ; This is the reminded message that shoudl appear if importantdude is still captured. But it does not work.
            console_command add_money 15000   ; No more money comes either (here just an indicator)
    end_monitor

  7. #7
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    The number on advance_advice_thread means how many "points" you're advancing the advice thread by. Each item (text message) in an advice thread has its own threshold (i.e. how many points must an advice thread be advanced by for the message to be displayed) and it works just like with traits. Tough, this mechanism is hardly ever used and the threshold is 1 for most messages. See AdviceThread Characters_Agent_Army_Early_Advice_Thread for an example of a thread with multiple messages.

    About the second part:

    - Is that the correct external settlement name or are you trying to use the internal name? Spaces in external settlement names are a known problem area for scripts.
    - The "and I_LocalFaction sarmations" is redundant. It's already implied by the other conditions you have
    - for the SettlementBuildingExists, you might want to try >= instead of =, so it works even if it's been upgraded
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  8. #8

    Default Re: Help with mission script

    Thanks HoH, your help is much appreciated!

    I was using the internal name, is that correct or wrong? I tried also with
    Code:
    and SettlementName Vicus Sarmatae
    where the external name should be correct, but it didn't work either. Which name should I use and is the code otherwise ok, assuming I remove the redundant entry you mentioned?

    I'm still trying to find also a solution for using a non-general unit (so that it would be more long-living and I could use non-cavalry). Any idea why the version with "BattleConflictPhaseCommenced" didn't work (see above)?

    And finally, if I end up using general unit after all, is there are way to recreate a general automatically whenever he dies?

    I hope you HoH or someone else still has patience with this!

  9. #9
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    Scripting commands use external settlement names, so you'd either have to remove the space from it or use another settlement that doesn't have a space in its name.

    The BattleConflictPhaseCommenced didn't work because you can't label a unit unless you're in battle_mode, so you need to put the label_unit command inside another monitor, something along the lines of:

    Code:
    monitor_event PreBattle FactionType sarmatians
               and FactionIsLocal
               and I_CompareCounter captive = 0    ; this could be removed and condition on the building added
               and Trait HasCapturableAncillary = 1
         label_unit 0 0 4 importantdude 
    end_monitor
    though, there is no guarantee it's actually at that index - that's why I said all the unit label-related commands are really only useful in historical battles.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  10. #10

    Default Re: Help with mission script

    Extrernal name? Oh, didn't know that... Well, I'll try again and let you know how it worked. The label doesn't seem to work here either, as it seems impossible to track constantly the same unit. And a big THANK you again !

    Ps. Still the question remains: is it possible to "rebirth" a general automatically?

  11. #11
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    Quote Originally Posted by chrisb View Post
    Extrernal name? Oh, didn't know that... Well, I'll try again and let you know how it worked. The label doesn't seem to work here either, as it seems impossible to track constantly the same unit. And a big THANK you again !

    Ps. Still the question remains: is it possible to "rebirth" a general automatically?
    You can create a unique ancillary (ImportantPerson) for him, then use the FactionwideAncillaryExists condition to check if it still exists and respawn the general if its gone:

    Code:
    monitor_event FactionTurnStart FactionType sarmatians
             and FactionIsLocal
             and not FactionwideAncillaryExists ImportantPerson
      spawn_army 
        faction sarmatians
        character John Smith, named character, age 16, ...
      end
    end_monitor
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  12. #12

    Default Re: Help with mission script

    Now that is actually a great idea, thanks again! I will try to proceed so that the ancillary (=ImportantDude) is actually transferred to the general whoever captured him (in a battle or through capturing a city where the Dude was). Then I might use WorldWideAncillaryExists to prevent creating a new general if the ImportantDude is already captured. Will return with news on experimenting.

  13. #13

    Default Re: Help with mission script

    OK, now I'm in trouble again. More help?

    I've changed the external name of the Sarmatian capital to contain only one word and created a new trait to identify the general that has the Important Dude in his crew. The following works:

    1) I get a message (PromptThreadCaptive) saying that importantdude has been captured after a battle, whenever the general that has the trait "HasCapturableAncillary" is still alive but has lost more than 10 % of bodyguard.

    2) This won't happen whenever the dude has already been captured (as it cannot happen more than once)

    3) I get a reminder message (PromptThreadCaptiveStill) at the beginning of each turn saying that the dude is still held captive and I should rescue him.

    The problem is that whenever the general dies in battle, the first capture message (PromptThreadCaptive) does not appear. I tried to add another monitor to mend this, but it doesn't seem to work. Any ideas? Code below.

    Another question: when you create ancillaries or traits for these kinds of purposes, do you also have to add triggers to them (if you don't want them to appear without scripted conditions or events)?

    Code:
    declare_counter captive
    set_counter captive 0 
    
    ; Detect excessive loss of bodyguard troops without general being killed in battle WORKS:
    
    monitor_event PostBattle FactionType sarmatians
              and FactionIsLocal
              and PercentageBodyguardKilled > 10    ; low percentage simply to make it easier to test
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicussarmatae caravan   ; this is just a test to also record the capture somewhere, it works.
    end_monitor
    
    ; Detect general with a specific trait being killed in battle DOES NOT WORK:
    
    monitor_event BattleGeneralKilled FactionType sarmatians
              and FactionIsLocal
              and PercentageBodyguardKilled > 10   
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicussarmatae caravan
    end_monitor
    
    ; Detect whether Important dude is still captured WORKS:
    
    monitor_event SettlementTurnStart FactionType sarmatians
        and SettlementIsLocal
        and SettlementName Vicussarmatae
    ;    and I_LocalFaction sarmatians
        and SettlementBuildingExists = caravan
            advance_advice_thread PromptThreadCaptiveStill 1
            console_command add_money 15000
    end_monitor
    Last edited by chrisb; May 01, 2011 at 04:31 PM.

  14. #14
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    The BattleGeneralKilled only exports a character object. Faction-based conditions don't work with it. Try this:
    Code:
    monitor_event BattleGeneralKilled CharacterIsLocal
              and PercentageBodyguardKilled > 10   
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicussarmatae caravan
    end_monitor
    Alternatively, you could mark ImportantDude as being held captive when you respawn the general.

    You don't need to create triggers unless you want those traits/ancillaries to be assigned automatically.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  15. #15

    Default Re: Help with mission script

    Thanks again! (I'm starting to feel a bit embarrassed for needing so much help .

    I copied and pasted the code you gave. It makes sense, but doesn't work either for some reason. The trait should be ok, as the rest of the code works when the general is not killed. Here the trait if there would be something wrong. Any idea why it doesn't work?

    Code:
    Trait HasCapturableAncillary
        Characters family
        NoGoingBackLevel  1 
    
        Level CapturableDudeTrait
            Description CapturableDudeTrait_desc
            EffectsDescription CapturableDudeTrait_effects_desc
            Threshold  1 
    
            Effect TroopMorale  1

  16. #16
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Help with mission script

    The trait looks just fine.

    Do you have suspend_during_battle in your script by any chance?

    Not sure if console_command create_building would work in battle mode.

    Otherwise, it should work. Idk, maybe the BattleGeneralKilled event got broken in patch 1.5/1.6...
    Last edited by HouseOfHam; May 03, 2011 at 10:16 AM.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  17. #17

    Default Re: Help with mission script

    Quote Originally Posted by HouseOfHam View Post
    The trait looks just fine.
    OK, that is good to hear.
    Quote Originally Posted by HouseOfHam View Post
    Do you have suspend_during_battle in your script by any chance?
    No, full script available below.
    Quote Originally Posted by HouseOfHam View Post
    Not sure if console_command create_building would work in battle mode.
    It seems to work, as I do get the caravan building after the general (who has the trait) has escaped from a battle but lost more than 10 % of bodyguard. Using caravan just as an example while testing.
    Quote Originally Posted by HouseOfHam View Post
    Otherwise, it should work. Idk, maybe the BattleGeneralKilled event got broken in patch 1.5/1.6...
    That would be pity! Any more info on this, or some other command that might work in this context?

    Code:
    script
    
    ; Anything following a semicolon is a comment.
    
    ; Remove the adviser portrait from screen.
    select_ui_element advisor_dismiss_button
    simulate_mouse_click lclick_up
    
    ; Wait for it to go away.
    while I_AdvisorVisible
    end_while
    
    suspend_unscripted_advice true
    
    ; Open the adviser message bubble automatically whenever advance_advice_thread is called.
    ; I recommend using this method instead of the select_ui_element + simulate_mouse_click approach.
    ; Do NOT mix both methods, though, or the advisor will show and then immediately close before
    ; you get a chance to read the text.
    declare_show_me
    
    ; Very useful for debugging - uncomment to use
    ;console_command toggle_perfect_spy
    
    ;;;
    ;;; --- Forced shutdown ---
    ;;;
    ;;; Press 'Esc' on the campaign map, then click on the '?' button in the
    ;;; menu scroll to terminate the script.
    ;;;
    ;;; When would this be useful? -- When you are already in a game and
    ;;; exit back to the main menu to restart the campaign, or reload a saved
    ;;; game, RTW does not automatically terminate the script, so you have
    ;;; to do it yourself. If you leave the old script running, you'll have all
    ;;; sorts of weird problems with the script in the new game.
    ;;;
    monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
        terminate_script
    end_monitor
    
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
      terminate_script
    end_monitor
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; This is where to put your own code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    declare_counter captive
    set_counter captive 0 
    
    ; Detect excessive loss of bodyguard troops without general being killed in battle (this part of code seems to work fully):
    
    monitor_event PostBattle FactionType sarmatians
              and FactionIsLocal
              and PercentageBodyguardKilled > 10    ; low percentage simply to make it easier to test
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicussarmatae caravan
    end_monitor
    
    ; Detect general with a specific trait being killed in battle (this part of code DOES NOT WORK):
    
    monitor_event BattleGeneralKilled CharacterIsLocal
              and PercentageBodyguardKilled > 10   
              and I_CompareCounter captive = 0
              and Trait HasCapturableAncillary = 1
        advance_advice_thread PromptThreadCaptive 1
        set_counter captive 1
        console_command add_money 20000
        console_command create_building Vicussarmatae caravan
    end_monitor
    
    ; Detect whether Important dude is still captured (this part of code works):
    
    monitor_event SettlementTurnStart FactionType sarmatians
        and SettlementIsLocal
        and SettlementName Vicussarmatae
        and SettlementBuildingExists = caravan
            advance_advice_thread PromptThreadCaptiveStill 1
            console_command add_money 15000
    end_monitor
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; End of your code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    ; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
    ; In M2TW scripts, this loop is replaced by the wait_monitors command. Unfortunately, this command is not available in RTW.
    
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    
    end_script

  18. #18
    Kylan271's Avatar Domesticus
    Join Date
    Jul 2007
    Location
    Vietnam
    Posts
    2,232

    Default Re: Help with mission script

    There are some missions not used from RTW,such as poison wells,kidnap and rescue,if you look at the TGAs you will see them(if I recall in UI).

    I asked about this mission type ages ago,but not sure how it would be used? If you succeed with the script,use the tgas as picture!


  19. #19

    Default Re: Help with mission script

    Quote Originally Posted by Kylan271 View Post
    There are some missions not used from RTW,such as poison wells,kidnap and rescue,if you look at the TGAs you will see them(if I recall in UI).
    I asked about this mission type ages ago,but not sure how it would be used? If you succeed with the script,use the tgas as picture!
    That is interesting to hear! But I did not find pics you refer to in the UI. Do you remember anything more specific?
    Also good to hear that someone else has thought of the same mission type (although it is not that original :-). I just thought that it would make the game more challenging if you would need to balance between maintaining your overall empire and at the same time having to go for a dangerous rescue mission and often splitting your troops.

    The basic idea I have is the following: someone is captured and needs to be rescued. While he is still captured, there is some penalty to your faction (e.g. money lost each turn, as extra resources are needed for the SAR mission, or more unhappy people). After the capture the kidnapped person could be kept either as a retinue member of the general who captured him (providing some positive effect on the capturer) or as a prisoner in one the enemy cities (e.g. capital of that faction that captured the person). Then one would need to rescue him either by defeating the general who has him as a retinue member or by occupying the city where he is kept as prisoner. May sound a bit complicated, but perhaps it is not that complicated. If we just could find a set of scripts to make it happen! :-) Comments to the overall concept are welcome!
    Someone may think that you don't need this kind of activity to a strategy game, but I still claim that it might make also the strategy part more interesting, as you would need to be more careful with allocating your troops in different tasks.

  20. #20
    Kylan271's Avatar Domesticus
    Join Date
    Jul 2007
    Location
    Vietnam
    Posts
    2,232

    Default Re: Help with mission script

    You have to unpack the files first in RTW vanilla to see them.

    You need I think to use not script,but ANCILLIARY. The mission script is difficult without using Rome-Senate,but you can get Senate missions,did you know? Put your faction in sm_factions,at the top,above the Senate and you will trigger missions,if senate in game. I did not get around to using the unused missions,so hopefully my data can help you. I just don't know how to rework the Senate Missions???

    I got the ideas of activate Senate Missions via sm_factions,use the Eagle in place of a person-add Eagle to General units so if lost(recapture eagle missions),but alter to the capture person UIs. It functions for Roman factions only though? Just a thought.

    Another idea is the ancilliary,use capture settlement condition or capture wonder...have to find more specific conditions ie,leader's capital. I included the CA files to look at. I tried to use the Queen/Princess in with game units to help with this,as below.

    The other idea is to use somehow your agents,ie spy/assassin,but I am unsure how?


Page 1 of 2 12 LastLast

Posting Permissions

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