Results 1 to 30 of 42

Thread: Can I use a script to end the turn?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Can I use a script to end the turn?

    Can I use simulate_mouse_click to end the turn? Is there a better way of doing it?

    I'm trying to create a script that does this:

    1. Starts as faction 1.
    2. Switches to faction 2, so that the AI plays the turn for faction 1.
    3. Switches to faction 1 and ends the turn.
    4. Loop back to 1, until the counter reaches x.

    Here's the code I've got so far:

    Spoiler Alert, click show to read: 

    script

    ;This totally didn't work
    ;console_command control romans_julii
    ;console_command run_ai
    ;console_command halt_ai
    ;console_command control romans_brutii
    ;console_command run_ai
    ;console_command halt_ai
    ;while I_TurnNumber < 5
    ;end_while

    ;Nor did this
    ;console_command control egypt
    ;console_command halt_ai
    ;campaign_wait 30
    ;console_command control romans_julii
    ;console_command run_ai x

    ;So far, so good
    console_command control romans_julii
    console_command control egypt
    ;I can't switch it back to romans_julii without it seemingly failing to switch to egypt at all, I tried campaign_wait 60 and it didn't seem to work at all

    end_script

  2. #2
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Maybe something like this?

    select_ui_element end_turn
    simulate_mouse_click lclick_down
    simulate_mouse_click lclick_up

  3. #3
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Okay, that does work, I just can't figure out how to loop it.

  4. #4
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Here's the code I'm using now:

    Spoiler Alert, click show to read: 

    script

    ;This ends the turn, but doesn't keep working thereafter
    ;monitor_event FactionTurnStart FactionType romans_julii
    ;and I_TurnNumber < 5
    ;simulate_mouse_click lclick_down
    ;simulate_mouse_click lclick_up
    ;console_command add_money 10000
    ;terminate_monitor
    ;end_monitor

    ;Every time I run this script, it takes me to the very next turn, which is good
    console_command control egypt
    console_command add_money 1000
    campaign_wait 60
    console_command control romans_julii

    end_script


    There are two tasks that I still need to complete:

    1. Figure out how to loop this script, so that it keeps advancing turns under AI control until it reaches a certain turn number.

    2. Create triggers to switch control temporarily to another faction whenever a dialog box pops up (eg a treaty negotiation, or battle, or adoption box).

    Can anyone help with #1? Please? I'm guessing it has something to do with monitors and whiles, but I just don't get it.

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

    Default Re: Can I use a script to end the turn?

    I'm not sure that your objective is possible at all.
    Do you want the AI to play all factions for some turns?

    I know there is a method to make the AI play the game (I think the option -ai in the desktop shortcut), but I wonder if you can retrieve the control of the game after some turns.

    For example, I would try a background script (started directly at the beginning of the campaign) with the console_command control romans_julii option after some turns.

    As one possibility:
    Code:
    script
    
    declare_counter loop
    
    monitor_event FactionTurnStart FactionType romans_julii
    and I_TurnNumber = 2
    console_command control romans_julii
    terminate_monitor
    end_monitor
    
    while I_CompareCounter loop = 0
    end_while
    
    end_script
    It is only a draft, but perhaps you can calibrate if the solution is possible.

    After that, if really you can play julii, you must save the game and load the saved campaign with a normal shortcut to RTW (without -ai option). In such case the background script won't work.

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

    Default Re: Can I use a script to end the turn?

    Ops, posting at the same time.

    Could you explain the main objective of the script?
    I don't understand if you are trying to play different factions along the game, or only taking decisions for the AI in some moments.

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

    Default Re: Can I use a script to end the turn?

    I think what you want might be something similar to ER's year jump script - its only little download you might as well have a look at it: https://forums.totalwar.org/vb/showthread.php?t=65109

    That was using an emerging faction from BI though, I'm not sure if it will work if you haven't got a redundant faction to switch control to


    EDIT: lots of posting at same time! You can not get control back after using -ai on the shortcut unfortunately.
    Last edited by Makanyane; 11-28-2007 at 10:05.
    Not used mods before? Looking for something small and fun?!
    Download the:

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

    Default Re: Can I use a script to end the turn?

    Quote Originally Posted by Makanyane
    I think what you want might be something similar to ER's year jump script - its only little download you might as well have a look at it: https://forums.totalwar.org/vb/showthread.php?t=65109

    That was using an emerging faction from BI though, I'm not sure if it will work if you haven't got a redundant faction to switch control to


    EDIT: lots of posting at same time! You can not get control back after using -ai on the shortcut unfortunately.
    I was looking for this, but I didn't remember the name of the mod.
    And you solved my doubts.

    The only problem of year_jump is that it works giving the human player the control of a faction that is not present in the initial game. It is possible to make one faction in RTW "spawned_by_event" without that event, and use it as the "ghost faction". The other limitation is that the number of turns is fixed. I don't know if this fits with the objective of mrtwisties.

  9. #9
    Member Member mrtwisties's Avatar
    Join Date
    Nov 2007
    Location
    Sydney, Australia
    Posts
    235

    Default Re: Can I use a script to end the turn?

    Wow, thanks heaps for the responses, guys. It's very encouraging.

    What I'd like to be able to do is make a script that'll hand control to the AI for x turns, after which I start playing again. I want to make it work for EB, but I'm testing on RTW 1.5 at the moment because it's faster (and because my EB installation is a bit corrupted).

    You can see more about what I'm trying to do here: https://forums.totalwar.org/vb/showthread.php?t=95753

    Epistolary Richard's mod, as has been said, works by switching control to an unemerged emergent faction until turn x. Since EB already has 21 factions (none of which are emergent), my understanding is that this just wouldn't work.

    If you run this code, you'll advance to the next turn:
    console_command control egypt
    console_command add_money 1000
    campaign_wait 60
    console_command control romans_julii
    There are two problems with it so far:

    1. It doesn't run again the next turn, so you have to run it again manually. I'd like it to run automatically at the start of every Julii turn until, say, 200 BCE. I've had a couple of goes at using looped monitors linked to FactionTurnStart FactionIsLocal or FactionType romans_julii, but I just can't get them to work. Here's one example of my crappy code:

    Spoiler Alert, click show to read: 

    declare_counter loop

    monitor_event FactionTurnStart FactionType romans_julii
    and I_TurnNumber < 5
    console_command control egypt
    console_command add_money 1000
    campaign_wait 60
    console_command control romans_julii
    terminate_monitor
    end_monitor

    while I_CompareCounter loop = 0
    end_while


    2. Whenever the Julii or Egyptians have to make a decision while you're in command of them, you need to be the one making the decision. I was thinking of setting up a bunch of monitors so that, whenever there's a decision to be made, the script will switch control to someone else and then straight back, so that the decision is made for you.

    I hope that makes it a bit clearer what I'm trying to do and what I've done. I'm totally hoping that there's just a simple mistake I've made. I'm very new to this.

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