Results 1 to 13 of 13

Thread: scripting question

  1. #1

    Default scripting question

    I'm trying to make a script to spawn an army after a certain amount of turns.
    (for now I tried after 2 turns)

    script

    monitor_event FactionTurnStart FactionType slave
    and I_TurnNumber = 2

    if spawn_armyA=0

    spawn_army
    faction macedon
    character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2

    set_counter spawn_armyA 1
    end_if


    terminate_monitor
    end_monitor
    end_script


    I put it with the rest of the scripts in the scripts/showme folder, but it does nothing.
    And when I add it to descr_strat, it crashes without showing an error.

    What do I have to change to make it work?

  2. #2
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: scripting question

    Quote Originally Posted by Ian Altano
    script

    monitor_event FactionTurnStart FactionType slave
    and I_TurnNumber = 2

    if spawn_armyA=0

    spawn_army
    faction macedon
    character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, exp 5 armour 0 weapon_lvl 2

    set_counter spawn_armyA 1
    end_if


    terminate_monitor
    end_monitor
    end_script
    Some points:

    - The correct synthax of the spawn_army comand is:

    spawn_army
    faction macedon
    character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    end


    - Which type of script is this?
    If it is a background script I think you need to include some loop. If not the script will be read and, as the event doesn't happen, it will be ignored.
    The simplest way is to put this piece of code before the end of the script:

    while I_CompareCounter loop = 0
    end_while

    Another method is to launch the script as a show_me script with the trigger (event) in export_descr_advice. In that case you need only the spawn_army code in the script.

    Good luck!

  3. #3

    Default Re: scripting question

    How exactly do you do the second option? :-/

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

    Default Re: scripting question

    There is a tutorial on scripting in the scriptorium here at the Org which shows how to do this. Perhaps, if you cannot get the tutorials to work, you may wish to post back here...
    "One of the most sophisticated Total War mods ever developed..."

  5. #5
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: scripting question

    Quote Originally Posted by Ian Altano
    How exactly do you do the second option? :-/
    Try this configuration:

    export_descr_advice.txt (Data folder)
    In the first part of the file (advices):
    Code:
    ;------------------------------------------		
    AdviceThread Alexander_army_Thread		
    	GameArea Campaign	
    
    	Item Alexander_army_Text_01	
    		Uninhibitable
    		Verbosity  0 
    		Threshold  1  
            MaxRepeats  0
            RepeatInterval  1
            Attitude Excited
    		Presentation Default
    		Title Alexander_army_Text_01_Title
         	Script scripts\show_me\alexander_army.txt	
    		Text Alexander_army_Text_01_Text1
    In the second part (triggers):
    Code:
    ;------------------------------------------
    Trigger Alexander_army
        WhenToTest FactionTurnStart
    
        Condition FactionIsLocal
              and I_TurnNumber = 2
    
        AdviceThread Alexander_army_Thread  1
    I don't know if you want any other conditions, as the name of the faction played by the human (for example, and not FactionType macedon)

    export_advice.txt (Data/text folder)
    Code:
    {Alexander_army_Text_01_Title}	Alexander army arrives
    
    {Alexander_army_Text_01_Text1}	Insert your explaining text here.
    create a new text file named
    alexander_army.txt (Data/scripts/show_me folder)
    Code:
    script
    declare_show_me
    
    spawn_army
    "insert the correct piece of code here"
    end
    
    end_script
    Good luck.

  6. #6
    Bibliophilic Member Atilius's Avatar
    Join Date
    Oct 2005
    Location
    America Medioccidentalis Superior
    Posts
    3,837

    Default Re: scripting question

    Just a quick note:

    The "soldiers" parameter to spawn_army is optional. This is nice because you don't need to concern yourself with the unit scale. If you DO use the "soldiers" option, you get the specified number of soldiers in the unit regardless of whether you're playing using small, normal, large, or huge.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  7. #7
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: scripting question

    Quote Originally Posted by Atilius
    Just a quick note:

    The "soldiers" parameter to spawn_army is optional. This is nice because you don't need to concern yourself with the unit scale. If you DO use the "soldiers" option, you get the specified number of soldiers in the unit regardless of whether you're playing using small, normal, large, or huge.
    Is that right?
    I didn't know.
    I was annoyed because of that problem (fixed number of soldiers irrespective of the scale small-huge).
    Thanks.

  8. #8
    Bibliophilic Member Atilius's Avatar
    Join Date
    Oct 2005
    Location
    America Medioccidentalis Superior
    Posts
    3,837

    Default Re: scripting question

    Quote Originally Posted by Monkwarrior
    Is that right?
    I didn't know.
    I was annoyed because of that problem (fixed number of soldiers irrespective of the scale small-huge).
    Yeah, I was annoyed with it too. Tried to use create_unit instead, but that has its own set of problems. Then I stumbled across some code which used spawn_army and omitted "soldiers". I figured that was wrong, but luckily I decided to test it.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  9. #9

    Default Re: scripting question

    Thx for the help so far: when I play 2 turns now, the advisor tells me of Alexander, but when I click the ShowMeHow button, it CTDs...

  10. #10
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: scripting question

    Quote Originally Posted by Ian Altano
    Thx for the help so far: when I play 2 turns now, the advisor tells me of Alexander, but when I click the ShowMeHow button, it CTDs...
    Post here exactly the script you use. Let's see if there is any mistake.

  11. #11

    Default Re: scripting question

    script
    declare_show_me

    spawn_army
    faction macedon
    character Gyras, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 86, y 97
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
    end

    end_script
    that's it. filename alexander_army.txt

    other bits of code have been implemented in the correct files, no errors there.

  12. #12
    Bibliophilic Member Atilius's Avatar
    Join Date
    Oct 2005
    Location
    America Medioccidentalis Superior
    Posts
    3,837

    Default Re: scripting question

    If you're modding vanilla RTW, there's no unit with the name "levy pikemen", you need "greek levy pikemen" or something else. Everything else looks non-toxic. As an aside, the command, management, influence, and subterfuge settings are ignored by this command for some reason.
    The truth is the most valuable thing we have. Let us economize it. - Mark Twain



  13. #13

    Default Re: scripting question

    ok, that got it to work (silly mistake)

    thanks for helping out guys ;)

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