Page 2 of 6 FirstFirst 123456 LastLast
Results 21 to 40 of 119

Thread: How-to: Add a background script to your mod

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

    Default Re: How-to: Add a background script to your mod

    Uncomment the end_monitor line before your code, then it should work. But anyhow, it looks like everything you're doing should only happen when you first start a campaign and thus belongs in the campaign script (before the advance_advice_thread line there) rather than in the background script.
    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

  2. #22
    Fireward77's Avatar Civis
    Join Date
    Dec 2007
    Location
    United States
    Posts
    149

    Default Re: How-to: Add a background script to your mod

    You see, I would like to make it a background script which starts after the 10th turn, so can you show me how to do that HouseOfHam? And I also would like to when all this happens to have greek_cities (Me) have to destroy or outlast parthia, armenia and pontus to win a short campaign, is that possible?

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

    Default Re: How-to: Add a background script to your mod

    - The background script always starts at turn 0. If you want to have something happen on a particular turn, use a monitor like this:
    Code:
    monitor_event FactionTurnStart I_TurnNumber = 10 ; or 9, since turn numbers start with 0
          and FactionIsLocal
          and FactionType greek_cities
          ;and FactionLeaderTrai
      ; all that other code
    
      terminate_monitor
    end_monitor
    - Win conditions are configured via desc_win_conditions.txt (same folder as descr_strat.txt)

    ps: You should also add some checks to prevent the monitor from getting triggered again in case the player saves the game on turn 10 and continues later.
    Last edited by HouseOfHam; August 08, 2008 at 10:05 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

  4. #24
    Fireward77's Avatar Civis
    Join Date
    Dec 2007
    Location
    United States
    Posts
    149

    Default Re: How-to: Add a background script to your mod

    Well I ment a Show_me Script , sorry for the confusion. well here is my updated script, I wish it would be simpler though.
    Oh yea, what do I have to put to put text in the spoiler box on the forums if you know how and would be willing to tell me.
    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
    monitor_event FactionTurnStart I_TurnNumber = 10 ; or 9, since turn numbers start with 0
    and FactionIsLocal
    and FactionType greek_cities
    ;and FactionLeaderTrai
    ; all that other code
    terminate_monitor
    end_monitor
    ; 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
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
     
    end_monitor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; This is where to put your own code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    console_command control greek_cities
    console_command capture_settlement "Phraaspa"
    console_command capture_settlement "Sparta"
    console_command kill_character "Flavius Julius"
    console_command kill_character "Hekhemmut"
    console_command kill_character "Khnumhoptep"
    console_command kill_character "Antiochus"
    console_command kill_character "Aristarchus"
    console_command kill_character "Demetrius"
    console_command kill_character "Hanno"
    console_command kill_character "Kiya"
    console_command kill_character "Burrhus"
    console_command kill_character "Theages"
    console_command kill_character "Theodekles"
    console_command kill_character "Theophanes"
    console_command kill_character "Annibas"
    console_command kill_character "Brennus"
    console_command kill_character "Gisgo"
    console_command kill_character "Eporedorix"
    console_command kill_character "Vindex"
    console_command kill_character "Arminius"
    console_command kill_character "Ariogaisus"
    console_command kill_character "Hariulfus"
    console_command kill_character "Barrivendos"
    console_command kill_character "Belenus"
    console_command kill_character "Cynfawr"
    console_command kill_character "Artaxias"
    console_command kill_character "Rusa"
    console_command kill_character "Zyraxes"
    console_command kill_character "Vezina"
    console_command kill_character "Kleomenes of Sparta"
    console_command kill_character "Dionysios of Sparta"
    console_command kill_character "Antigonos of Sparta"
    console_command kill_character "Eumenes of Sparta"
    console_command kill_character "Memnon of Sparta"
    console_command kill_character "Muttines"
    console_command kill_character "Syphax"
    console_command kill_character "Zipoetes"
    console_command kill_character "Partatua"
    console_command kill_character "Viriathus"
    console_command kill_character "Caraunios"
    console_command kill_character "Matugenus"
    console_command kill_character "Lucius Julius"
    console_command kill_character "Quintus Julius"
    console_command kill_character "Vibius Julius"
    console_command kill_character "Sextus Antio"
    console_command kill_character "Decius Curtius"
    console_command kill_character "Oppius Clausus"
    console_command kill_character "Aulus Brutus"
    console_command kill_character "Marcus Attius"
    console_command kill_character "Luca Antonius"
    console_command kill_character "Caius Flaminius"
    console_command kill_character "Cornelius Scipio"
    console_command kill_character "Julianus Scipio"
    console_command kill_character "Quintus Scipio"
    console_command kill_character "Quintus Caecus"
    console_command kill_character "Aulus Ovidius"
    console_command kill_character "Aulus Volesus"
    console_command kill_character "Flavius Nepos"
    console_command kill_character "Servius Maxentius"
    console_command kill_character "Antigonos"
    console_command kill_character "Gyras"
    console_command kill_character "Arsaces"
    console_command kill_character "Ardumanish"
    console_command kill_character "Mithradates"
    console_command kill_character "Pharnaces"
    console_command kill_character "Tiberius Brutus"
    console_command kill_character "Amulus Brutus"
    console_command kill_character "Decius Maxentius"
    console_command kill_character "Marcus Maxentius"
    spawn_army
    faction parthia
    character Xerxes, named character, age 30, , x 209, y 61 
    unit east infantry soldiers 100 exp 5 armour 0 weapon_lvl 0
    unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    unit east infantry soldiers 100 exp 5 armour 0 weapon_lvl 0
    unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    unit merc arab cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east heavy cataphract soldiers 50 exp 7 armour 0 weapon_lvl 0
    unit east persian cavalry soldiers 50 exp 7 armour 0 weapon_lvl 0
    unit east camel cataphract soldiers 50 exp 7 armour 0 weapon_lvl 0
    unit east heavy cataphract soldiers 20 exp 7 armour 0 weapon_lvl 0
    unit east persian cavalry soldiers 20 exp 7 armour 0 weapon_lvl 0
    unit east camel cataphract soldiers 20 exp 7 armour 0 weapon_lvl 0
    unit parthia huvaka soldiers 20 exp 7 armour 0 weapon_lvl 0
    unit east hillmen soldiers 100 exp 0 armour 0 weapon_lvl 0
    unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    unit east elephant soldiers 38 exp 7 armour 0 weapon_lvl 0
    end
    spawn_army
    faction pontus
    character Rhadamsades, named character, age 30, , x 112, y 65 
    unit east hillmen soldiers 150 exp 5 armour 0 weapon_lvl 0
    unit east generals cavalry early soldiers 20 exp 5 armour 1 weapon_lvl 0
    unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    unit east archer soldiers 100 exp 4 armour 0 weapon_lvl 0
    unit merc eastern infantry soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east cappodocian cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east cappodocian cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east scythed chariot soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east scythed chariot soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east chariot archer soldiers 100 exp 3 armour 0 weapon_lvl 0
    unit east chariot archer soldiers 100 exp 3 armour 0 weapon_lvl 0
    end
    spawn_army
    faction greek_cities
    character Leonidas of_Sparta, named character, age 30, , x 200, y 60
    unit greek general's guard cavalry4 soldiers 100 exp 9 armour 3 weapon_lvl 3
    unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc thracian soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc thracian soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc sarmatian cavalry soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc sarmatian cavalry soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc greek hoplites soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc greek hoplites soldiers 50 exp 9 armour 3 weapon_lvl 3
    unit merc barbarian infantry soldiers 50 exp 9 armour 3 weapon_lvl 3
    end
    console_command move_character "Leonidas of_Sparta" x 209 y 61
    console_command invulnerable_general "Leonidas of_Sparta"
    console_command diplomatic_stance seleucid parthia Atwar
    console_command diplomatic_stance seleucid armenia Atwar
    console_command diplomatic_stance seleucid pontus Atwar
    console_command diplomatic_stance greek_cities parthia Atwar
    console_command diplomatic_stance parthia armenia Allied
    console_command diplomatic_stance parthia pontus Allied
    console_command diplomatic_stance armenia pontus Allied
    console_command diplomatic_stance greek_cities armenia Atwar
    console_command diplomatic_stance greek_cities armenia Atwar
    console_command diplomatic_stance greek_cities seleucid Allied
     
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; End of your code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Spin forever - Do not let the script terminate or any monitors you have set up will immediately get thrown away.
    while I_TurnNumber < 99999
    suspend_unscripted_advice true
    end_monitor
    end_while
    end_script
    Last edited by Aradan; October 14, 2008 at 03:50 PM.

  5. #25

    Default Re: How-to: Add a background script to your mod

    Use [ code][/code ] tags, makes things easier to read.

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

    Default

    HTML Code:
    [spoiler][code]
    your code here
    [/code][/spoiler]
    so that will look like:

    Spoiler Alert, click show to read: 
    Code:
    your code here


    - I wouldn't recommend specifying the exact number of soldiers in a unit, since that number does not automatically adjust when you change the unit size.
    - Any characters names you use in the spawn army commands must be valid names from descr_names.txt, etc. Double-check that.
    - According to the docs, the valid diplomatic stances allied/neutral/war

    Spoiler Alert, click show to read: 

    Code:
    script
    
    ; Anything following a semicolon is a comment.
    
    ; Since you don't have anything happenening during battles, you can add this line to optimize things a bit.
    suspend_during_battle on
    
    ; 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
    
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
    	terminate_script
    end_monitor
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; This is where to put your own code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    monitor_event FactionTurnStart I_TurnNumber = 10			; or 9, since turn numbers start with 0
    			and FactionIsLocal
    			and FactionType greek_cities
    			
    	console_command capture_settlement "Phraaspa"
    	console_command capture_settlement "Sparta"
    	console_command kill_character "Flavius Julius"
    	console_command kill_character "Hekhemmut"
    	console_command kill_character "Khnumhoptep"
    	console_command kill_character "Antiochus"
    	console_command kill_character "Aristarchus"
    	console_command kill_character "Demetrius"
    	console_command kill_character "Hanno"
    	console_command kill_character "Kiya"
    	console_command kill_character "Burrhus"
    	console_command kill_character "Theages"
    	console_command kill_character "Theodekles"
    	console_command kill_character "Theophanes"
    	console_command kill_character "Annibas"
    	console_command kill_character "Brennus"
    	console_command kill_character "Gisgo"
    	console_command kill_character "Eporedorix"
    	console_command kill_character "Vindex"
    	console_command kill_character "Arminius"
    	console_command kill_character "Ariogaisus"
    	console_command kill_character "Hariulfus"
    	console_command kill_character "Barrivendos"
    	console_command kill_character "Belenus"
    	console_command kill_character "Cynfawr"
    	console_command kill_character "Artaxias"
    	console_command kill_character "Rusa"
    	console_command kill_character "Zyraxes"
    	console_command kill_character "Vezina"
    	console_command kill_character "Kleomenes of Sparta"
    	console_command kill_character "Dionysios of Sparta"
    	console_command kill_character "Antigonos of Sparta"
    	console_command kill_character "Eumenes of Sparta"
    	console_command kill_character "Memnon of Sparta"
    	console_command kill_character "Muttines"
    	console_command kill_character "Syphax"
    	console_command kill_character "Zipoetes"
    	console_command kill_character "Partatua"
    	console_command kill_character "Viriathus"
    	console_command kill_character "Caraunios"
    	console_command kill_character "Matugenus"
    	console_command kill_character "Lucius Julius"
    	console_command kill_character "Quintus Julius"
    	console_command kill_character "Vibius Julius"
    	console_command kill_character "Sextus Antio"
    	console_command kill_character "Decius Curtius"
    	console_command kill_character "Oppius Clausus"
    	console_command kill_character "Aulus Brutus"
    	console_command kill_character "Marcus Attius"
    	console_command kill_character "Luca Antonius"
    	console_command kill_character "Caius Flaminius"
    	console_command kill_character "Cornelius Scipio"
    	console_command kill_character "Julianus Scipio"
    	console_command kill_character "Quintus Scipio"
    	console_command kill_character "Quintus Caecus"
    	console_command kill_character "Aulus Ovidius"
    	console_command kill_character "Aulus Volesus"
    	console_command kill_character "Flavius Nepos"
    	console_command kill_character "Servius Maxentius"
    	console_command kill_character "Antigonos"
    	console_command kill_character "Gyras"
    	console_command kill_character "Arsaces"
    	console_command kill_character "Ardumanish"
    	console_command kill_character "Mithradates"
    	console_command kill_character "Pharnaces"
    	console_command kill_character "Tiberius Brutus"
    	console_command kill_character "Amulus Brutus"
    	console_command kill_character "Decius Maxentius"
    	console_command kill_character "Marcus Maxentius"
    	
    	spawn_army
    	faction parthia
    		character Xerxes, named character, age 30, , x 209, y 61
    		unit east infantry soldiers 100 exp 5 armour 0 weapon_lvl 0
    		unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    		unit east infantry soldiers 100 exp 5 armour 0 weapon_lvl 0
    		unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    		unit merc arab cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east heavy cataphract soldiers 50 exp 7 armour 0 weapon_lvl 0
    		unit east persian cavalry soldiers 50 exp 7 armour 0 weapon_lvl 0
    		unit east camel cataphract soldiers 50 exp 7 armour 0 weapon_lvl 0
    		unit east heavy cataphract soldiers 20 exp 7 armour 0 weapon_lvl 0
    		unit east persian cavalry soldiers 20 exp 7 armour 0 weapon_lvl 0
    		unit east camel cataphract soldiers 20 exp 7 armour 0 weapon_lvl 0
    		unit parthia huvaka soldiers 20 exp 7 armour 0 weapon_lvl 0
    		unit east hillmen soldiers 100 exp 0 armour 0 weapon_lvl 0
    		unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    		unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    		unit east archer soldiers 100 exp 7 armour 0 weapon_lvl 0
    		unit east elephant soldiers 38 exp 7 armour 0 weapon_lvl 0
    	end
    	
    	spawn_army
    	faction pontus
    		character Rhadamsades, named character, age 30, , x 112, y 65
    		unit east hillmen soldiers 150 exp 5 armour 0 weapon_lvl 0
    		unit east generals cavalry early soldiers 20 exp 5 armour 1 weapon_lvl 0
    		unit east infantry soldiers 100 exp 4 armour 0 weapon_lvl 0
    		unit east archer soldiers 100 exp 4 armour 0 weapon_lvl 0
    		unit merc eastern infantry soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east cappodocian cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east cappodocian cavalry soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east scythed chariot soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east scythed chariot soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east chariot archer soldiers 100 exp 3 armour 0 weapon_lvl 0
    		unit east chariot archer soldiers 100 exp 3 armour 0 weapon_lvl 0
    	end
    	
    	spawn_army
    	faction greek_cities
    		character Leonidas of_Sparta, named character, age 30, , x 200, y 60
    		unit greek general's guard cavalry4 soldiers 100 exp 9 armour 3 weapon_lvl 3
    		unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit greek hoplite spartan soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc thracian soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc thracian soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc sarmatian cavalry soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc sarmatian cavalry soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc greek hoplites soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc greek hoplites soldiers 50 exp 9 armour 3 weapon_lvl 3
    		unit merc barbarian infantry soldiers 50 exp 9 armour 3 weapon_lvl 3
    	end
    	
    	console_command move_character "Leonidas of_Sparta" x 209 y 61
    	console_command invulnerable_general "Leonidas of_Sparta"
    	
    	console_command diplomatic_stance seleucid parthia war
    	console_command diplomatic_stance seleucid armenia war
    	console_command diplomatic_stance seleucid pontus war
    	console_command diplomatic_stance greek_cities parthia war
    	console_command diplomatic_stance parthia armenia allied
    	console_command diplomatic_stance parthia pontus allied
    	console_command diplomatic_stance armenia pontus allied
    	console_command diplomatic_stance greek_cities armenia war
    	console_command diplomatic_stance greek_cities armenia war
    	console_command diplomatic_stance greek_cities seleucid allied
    	
    	terminate_monitor
    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.
    while I_TurnNumber < 99999
    suspend_unscripted_advice true
    end_monitor
    end_while
    end_script
    Last edited by Amroth; August 09, 2008 at 11:07 AM. Reason: dp
    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

  7. #27
    Fireward77's Avatar Civis
    Join Date
    Dec 2007
    Location
    United States
    Posts
    149

    Default Re: How-to: Add a background script to your mod

    Ill try it, and if it don't work ill post back ASAP.

  8. #28
    Indefinitely Banned
    Join Date
    Jun 2008
    Location
    England
    Posts
    1,058

    Default Re: How-to: Add a background script to your mod

    Hi i have followed you tutorial basically just copied and pasted it all, just to see if i could get the advisor then adding my own code, but every time i try and load rome up it is not responding, i have undone everything i have copied and pasted, then it works fine. so i followed the tutorial again, and now it won't respond.

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

    Default Re: How-to: Add a background script to your mod

    Seeing how you're the first one of more than 1100 people who have viewed this thread to have this problem, I'd say you did something wrong.
    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. #30
    Agisilaos's Avatar GREECE - ΕΛΛΑΔΑ
    Join Date
    Sep 2007
    Location
    Santorini, Hellas
    Posts
    3,109

    Default Re: How-to: Add a background script to your mod

    wonderful work you have done!!! thanks H.O.H.
    Macedones were, are and will always be Greeks
    Under the Noble Patronage of jimkatalanos and proud patron of Agis Tournas and cocobongoclub-DJ
    Terrae Expugnandae, Imperial Might, Mythology, Complete Byzantine Roster, Ruins of glory, Sparta 3, Hegemonia City States, Roma Surrectum 2,300 Warlords of Sparta, Sparta 3.5, Classical Age Total War
    watch this
    , this and this
    Τακτική είναι να ξέρεις τι να κάνεις αν υπάρχει κάτι που μπορείς να κάνεις.
    Στρατηγική είναι να ξέρεις τι να κάνεις όταν δεν υπάρχει τίποτα να κάνεις.

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

    Default Re: How-to: Add a background script to your mod

    Updated 1st post - added a way to terminate the background script. See the script code for details and explanation.
    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. #32

    Default Re: How-to: Add a background script to your mod

    Great tutorial HouseofHam ! I have one question though : Is it possible to have a BuildingIsLocal Building = 'building' condition ? So that there must be a building present to make the script appear ?

    This is my script :

    Spoiler Alert, click show to read: 
    Code:
    script
    
    declare_show_me
    
    ;console_command toggle_perfect_spy
    
    monitor_event ScrollAdviceRequested ScrollAdviceRequested end_game_scroll
        terminate_script
    end_monitor
    
    ; Handle saved game reloads
    monitor_event GameReloaded TrueCondition
      terminate_script
    end_monitor
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; Zeus code
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    monitor_event BuildingIsLocal Building = muster_field
    spawn_army
    faction greek_cities
    character Polydoros of Sparta, general, command 0, influence 0, management 0, subterfuge 0, age 20, x 155, y 61
    unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
    unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
    end
    
    ;;;; End
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    end_monitor
    end_script


    Another thing : Every time i clicked on a settlement or character , the advisor showed up saying 'Script is activated' .. How can i disable this ? And when you click on it , it goes away immediatly .. I know you mentioned this , but i don't see what i'm doing wrong ..
    Last edited by Killerbee; March 22, 2009 at 12:16 PM.

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

    Default Re: How-to: Add a background script to your mod

    Nope, no such condition, unfortunately.

    There are a couple problems with that code:

    1. No event is being monitored.
    Code:
    monitor_event <EventName> <1stCondition>   ; or TrueCondition if none
              [and AdditionalConditions]
      ; commands
    end_monitor
    An event is something like FactionTurnStart. BuildingIsLocal, if such a thing existed, would be a condition.

    Btw, in RTW conditions, if something is Local doesn't mean that it's of the same culture as the settlement. Rather, it belongs to the player faction.

    For example, this will deduct 100 gold from the player's treasury for every settlement they own:
    Code:
    monitor_event SettlementTurnStart SettlementIsLocal
        console_command add_money -100
    end_monitor
    2. The while I_TurnNumber < 99999 loop must be just before the end_script tag, outside the monitor_event...end_monitor block. This is why advisor is popping up every time you click on a settlement.

    I'm not exactly sure what the goal of your monitor is, but since you're spawning that army for a specific faction and settlement, you could try something like this...

    Code:
    declare_counter spartaMusterField  ; initialized to 0 by default
    
    ; Set variable to 1 when player constructs muster_field in Sparta
    monitor_event BuildingCompleted SettlementBuildingFinished = muster_field
              and SettlementIsLocal
              and I_LocaFaction greek_cities
              and SettlementName Sparta
      set_counter spartaMusterField 1
    end_monitor
    
    ; Only spawn when that variable is set
    monitor_event SettlementTurnStart SettlementIsLocal
              and I_LocaFaction greek_cities
              and SettlementName Sparta
              and I_CompareCounter spartaMusterField = 1
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
      terminate_monitor ; so it doesn't spawn on every turn
    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

  14. #34

    Default Re: How-to: Add a background script to your mod

    Alright , many thx ! My goal was to spawn an army when you builded a ceratin building (not the muster field ofcourse , but that's easy to test )

    Great ! All problems solved and it works ! I owe you big time A +rep would do the trick
    Last edited by Killerbee; March 23, 2009 at 10:21 AM.

  15. #35

    Default Re: How-to: Add a background script to your mod

    Hi , sorry for double post and "reviving" this topic , but i thought it would be better to do this than make a whole enw thread .. I have a little "problem" .. fact is ,t hat my script does what i ask , but it generates an error when i exit the game .. This is my script :

    Spoiler Alert, click show to read: 
    Code:
    if I_SettlementOwner Sparta = greek_cities
    
    set_counter SettlementOwner Sparta 1
    end_if
    
    if I_CompareCounter SettlementOwner Sparta = 1
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    end_script


    error said somthing like : undefined number at line 54 ..

    This is line 54 :

    if I_CompareCounter SettlementOwner Sparta = 1

    But still the army gets spawned ..

  16. #36

    Default Re: How-to: Add a background script to your mod

    I_SettlementOwner Sparta = greek_cities
    is a condition and is legitimate code

    set_counter SettlementOwner Sparta 1

    requires a declared counter of "SettlementOwner Sparta" which I don't think would work because of the space in the counter name - think the error message is maybe about it trying to use 'Sparta' as a number

    calling the counter name something similar to the condition might be convenient but if its confusing you try making it something completely different eg:

    Code:
    declare_counter SOS
    
    if I_SettlementOwner Sparta = greek_cities
    set_counter SOS 1
    end_if
    
    if I_CompareCounter SOS = 1
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    obviously needs start and end script bits as well

    fact that its 'working' might be similar to some non-valid code I had recently which HoH pointed out was just defaulting 'true'

    EDIT: if that is all the counter is doing though, you shouldn't need it

    Code:
    if I_SettlementOwner Sparta = greek_cities
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    would do same thing

  17. #37

    Default Re: How-to: Add a background script to your mod

    Yep , i know , i made that script before , but i want to make something else (more complicated) .. I wanted to do a certain thing , that would occur for instance only 3% each turn .. So your chance is 1/33 each turn that the script would generate .. But , i wanted that , if you have multiple settlements (2 to be precise :p) , the chance would increase .. So then i thought about the Counter .. i was thinking something like :

    Spoiler Alert, click show to read: 
    Code:
    script
    
    if I_SettlementOwner Sparta = greek_cities
    
    set_counter SettlementOwner_Sparta 1
    end_if
    
    if I_CompareCounter SettlementOwner_Sparta = 1
       and RandomPercent < 5
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    
    if I_SettlementOwner Athens = greek_cities
    
    inc_counter SettlementOwner_Sparta 1
    end_if
    
    If I_CompareCouner SettlementOwner_Sparta = 2
       and RandomPercent < 10
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    end_script


    Note how the percentage should increase when i capture Athens ..

    EDIT : it worked .. i used following script :

    Spoiler Alert, click show to read: 
    Code:
    script
    
    if I_SettlementOwner Sparta = greek_cities
    
    set_counter SettlementOwner_Sparta 1
    end_if
    
    if I_CompareCounter SettlementOwner_Sparta = 1
       and RandomPercent < 5
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    
    if I_SettlementOwner Thermon = greek_cities
    
    inc_counter SettlementOwner_Sparta 1
    end_if
    
    if I_CompareCounter SettlementOwner_Sparta = 2
       and RandomPercent < 100
    
      console_command kill_character "Polydoros of Sparta"   ; to avoid character cloning CTD
      spawn_army
        faction greek_cities
        character Polydoros of Sparta, general, age 20, x 155, y 61
        unit greek general's guard cavalry early, soldiers 20 exp 9 armour 1 weapon_lvl 0
        unit greek peltast, soldiers 20 exp 9 armour 1 weapon_lvl 0
      end
    end_if
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    end_script
    Last edited by Killerbee; May 02, 2009 at 06:39 AM.

  18. #38

    Default Re: How-to: Add a background script to your mod

    try setting both to <100 to test - I think you'll find you'll fire both spawns with the way it's written so you have a chance of spawning army on top of itself.. eg. it'll do the first one whilst counter is set to 1 then do second one when it increments during same turn.

    might need to contain something in a monitor so you arrive at final result for the counter before applying it? or at least do all the counter setting above both spawns

  19. #39

    Default Re: How-to: Add a background script to your mod

    Yes , but this is just for testing ! For the real script , i won't spawn an army , but do something like the palantir script ~ Show the world without fow .. + i'll use lower numbers for the 'second script' .. So it wouldn't be

    Code:
     and RandomPercent < 100
    But

    Code:
     and RandomPercernt < 10

  20. #40

    Default Re: How-to: Add a background script to your mod

    Err . I ahev (yet another ) problem .. It's really weird though , cause LOTR-TW uses the (almost) exact same script , and ther it works ..

    Spoiler Alert, click show to read: 
    Code:
    script
    
    if I_SettlementOwner Sparta = greek_cities
    
    set_counter SettlementOwner_Sparta 1
    end_if
    
    monitor_event FactionTurnStart FactionIsLocal
       and I_CompareCounter SettlementOwner_Sparta = 1
       and RandomPercent < 5
    
       console_command toggle_fow
       wait 5
       console_command toggle_fow
    
    end_monitor
    
    if I_SettlementOwner Thermon = greek_cities
    
    inc_counter SettlementOwner_Sparta 1
    end_if
    
    monitor_event FactionTurnStart FactionIsLocal
       and I_CompareCounter SettlementOwner_Sparta = 2
       and RandomPercent < 100
    
       console_command toggle_fow
       wait 5 
       console_command toggle_fow
    
    end_monitor
    
    while I_TurnNumber < 99999
      suspend_unscripted_advice true
    end_while
    end_script


    Problem is , that the

    Code:
       wait 5
    Thingies don't work .. I don't know if they're supposed to work , but it looks like they work in LOTR-TW .. Maybe it has something to do that that's Alexander ?

Page 2 of 6 FirstFirst 123456 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
  •