View Full Version : Can I use a script to end the turn?
mrtwisties
11-28-2007, 08:42
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:
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
mrtwisties
11-28-2007, 09:11
Maybe something like this?
select_ui_element end_turn
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
mrtwisties
11-28-2007, 09:53
Okay, that does work, I just can't figure out how to loop it.
mrtwisties
11-28-2007, 09:58
Here's the code I'm using now:
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.
Monkwarrior
11-28-2007, 10:00
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:
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.
Monkwarrior
11-28-2007, 10:03
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. :dizzy2:
Makanyane
11-28-2007, 10:04
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 :inquisitive:
EDIT: lots of posting at same time! You can not get control back after using -ai on the shortcut unfortunately.
Monkwarrior
11-28-2007, 10:09
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 :inquisitive:
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. :embarassed:
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.
mrtwisties
11-28-2007, 10:23
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:
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.
mrtwisties
11-28-2007, 10:31
This one doesn't work at all:
declare_counter loop
monitor_event FactionTurnStart FactionType romans_julii
and I_TurnNumber < 5
console_command control romans_julii
campaign_wait 5
console_command add_money 1000
campaign_wait 5
console_command control egypt
campaign_wait 5
console_command add_money 1000
campaign_wait 5
campaign_wait 60
console_command control romans_julii
terminate_monitor
end_monitor
while I_CompareCounter loop = 0
end_while
mrtwisties
11-28-2007, 10:47
Maybe if I write out the logical structure of what I'm trying to do, it'll be easier for people to understand me.
Assume you start off in control of faction a, the first faction in the turn sequence. You want to be in control of faction x in turn 200, and you want the AI to play for every faction in the meantime.
Here's the logical structure I want:
*** Is the current turn number 200 or greater?
If YES, then:
Switch control to faction x, and stop running this script
If NO, then:
1. Switch control to the last faction in the turn sequence ("faction z")
2. Wait until the AI has played the turns of all the other factions
3. Switch control to the first faction in the turn sequence ("faction a")
4. Wait until the AI has played the turn for faction z
Go to ***
Is that clearer?
Monkwarrior
11-28-2007, 10:49
Some points to your attempts.
- If you want a monitor is repeated, don't use terminate_monitor. With this command the monitor is finished completely once it is true for the first time.
- The command console_command control is not as simple as it seems. It only works with some factions and depends on the relative position of them in descr_strat, at least in my experience.
I have this structure in my scripts:
monitor_event FactionTurnStart FactionType carthage
and I_TurnNumber = 0
console_command control carthage
console_command capture_settlement Saguntum
console_command control romans_julii
terminate_monitor
end_monitor
This piece of script only works when carthage and romans_julii are placed one after the other in descr_strat (romans are playable). In the same campaign, if I try to give control to greek_cities, the command doesn't work.
Moreover, I don't allow the player to do anything during the change of control. It is only to allow the script to use the capture_settlement command with an AI controlled faction.
- After this kind of control change, the human player cannot manage the recruitment and building for one turn. It is a side effect of this command.
Because of that problems, I don't think that a single script will work for all the playable factions at the same time. From your idea of making the script for EB, perhaps the only way to do it is to sacrifice one faction, making it spawned by script, and use it in the same way as ER did in year_jump mod.
Regarding the question of human decisions in diplomacy etc, I think it is not possible, as the rollers don't appear in the AI turns (I cannot see the interest in AI sending messages to itself :laugh4: ). This means you have no event to monitor (afaik).
mrtwisties
11-28-2007, 10:51
Roughly speaking, this is the code for 1 - 4:
console_command control greek_cities
campaign_wait 60
console_command control romans_julii
campaign_wait 60
It works, more or less. The AI does play turns for all the factions, and it does advance to the next turn. There are problems with the code (eg dialog boxes; using campaign_wait rather than a more sophisticated trigger) but I'd like to focus on getting the overall logical structure working first.
Monkwarrior
11-28-2007, 10:56
@ Makanyane
Did you use intensivelly the -ai option?
Do you know if it saves automatically the turns?
Do you know if it is compatible with background scripts?
One option could be use this option until a given turn, using the background script to stop it at some date, and use the autosaved file to start a new normal campaign.:juggle2:
mrtwisties
11-28-2007, 11:02
Sorry Monkwarrior, we posted at the same time. I like your idea about the -ai switch, it'd be an elegant solution if it worked.
I'm still bashing away at my concept at the moment. But I can't even get this to work:
declare_counter loop
monitor_event FactionTurnStart FactionType romans_julii
and I_TurnNumber < 5
add_money 40000
end_monitor
while I_CompareCounter loop = 0
end_while
Thanks for all your help.
Makanyane
11-28-2007, 11:29
on that last example think you're missing
set_counter loop 0
under the declare_counter
not sure if it defaults to that otherwise.
@Monkwarrior, I haven't tried -ai from background script, I might have a look at that. I did get it to save with that on shortcut at one stage but, reloading the save without the shortcut command still set it off on its own again, so I rather gave up on looking at it.
If you are doing anything that switches command to AI I think you may need to look at how rest of script works, I assume that it messes up anything reliant on LocalFaction triggers. I've got Year Jump script triggerable while background script is in use, so I've put a counters in to determine what local faction is on first turn, and use those counters throughout instead of LocalFaction
EDIT: old discussion on -ai for info
https://forums.totalwar.org/vb/showthread.php?t=51550&highlight=run_ai
mrtwisties
11-28-2007, 12:32
Makanyane - in my own chaste way, I love you. Here's the partially working script:
script
declare_counter loop
set_counter loop 0
monitor_event FactionTurnStart FactionType romans_julii
and I_TurnNumber < 5
console_command control greek_cities
campaign_wait 10
console_command add_money 40000
console_command control romans_julii
end_monitor
while I_CompareCounter loop = 0
end_while
end_script
This fast-forwarded me to 268 BCE. All I had to do was click a few boxes along the way. When I got to 268 BCE, the AI had taken Segesta and built a whole bunch of units for the Julii. Meanwhile, the Greeks had built up a fortune of some hundreds of thousands of denarii.
So all I have to do is figure out how to avoid having to click through the scrolls, and I'll be able to use this to fast forward to any turn.
mrtwisties
11-28-2007, 13:23
I tested the script again, using it to fast forward 50 turns to 245 BCE. If you decide to do the same, make sure you turn off "follow AI characters", which I didn't do the first time. Turns out the AI likes to put spies and diplomats everywhere, which means you end up following one helluva lot of AI characters. Running RTW.exe in windowed mode was definitely a good idea, though.
The Romans and the Greeks got into an extended naval war, which I witnessed first-hand from both sides. It was actually kind of fun to see, and verified that both factions are highly active when they're under AI control. I guess forgetting to take away +40,000 denarii for the Greeks every turn probably contributed to them getting ornery, huh?
I had also forgotten that those dog units existed in vanilla RTW. Turns out the AI likes to move around whole armies of them. Not sure how I feel about that. Pretty sure the answer is "mirthful", though - the dogs of the Julii more or less chased the Gauls out of northern Italy. Dogmatix would have been ashamed. But then the Gauls came back with a whole mass of soldiers, and they all had a bunch o' fight near the Po.
By the end of the 50 turns:
* The Julii owned northern Italy
* The Brutii owned Epirus and Dalmatia
* The Scipii owned Sicily, Sardinia, Corsica and bits of Tunisia
* The Gauls owned bits of Spain, for which I don't blame them, I understand it's got lovely countryside
* The Seleucids were swallowed by Parthia and the Ptolemies (I mean, *cough*, Egypt)
* Pontus were on their way to becoming a superpower
* The Sweboz and the Getai were both massive
But despite all the fun, it was 50 turns that I had to sit there for, clicking on the occasional scroll. Here are the ones that paused or delayed the turn sequence. I need to find a way to automagically resolve these, so I can do something else with my life while the script is fast-forwarding:
* Diplomacy scrolls
* Naval battle predeployment
* Land battle predeployment
* Assistance requested from SPQR
* Senate missions (create massive lag during the turn sequence)
I can't find events for any of these in the docudemon. Do they exist? And can anyone suggest code for automagically resolving these happenings (preferably with the AI deciding what to do)?
mrtwisties
11-28-2007, 13:51
Thanks for the -ai link, M. I'm testing that as well.
mrtwisties
11-28-2007, 13:56
Hmmm... my capacity to edit my posts seems to appear and disappear at random.
Anyhoo, first attempts with the -ai command are a bit buggy. I can put myself in control of a faction, I can end turn, I can keep playing with that faction for a bit... I can even save the game I'm playing with the faction. But I can't load the game again. Any attempt to do so CTDs.
I'm trying again with a different faction - the Julii, instead of the Gauls. I figure the Gauls aren't unlocked in my RTW game, so that might be why loading a Gallic game CTDs.
mrtwisties
11-28-2007, 15:01
The -ai thing totally works. I just took over a Julii campaign in 168 BCE. Then I saved it. Then I closed RTW. Then I loaded it and played for a bit.
Totally. Works.
Red Spot
11-28-2007, 15:28
afaik the -ai switch will not work properly ...
at least I've ran a zillion games with the -ai switch and there is always "something" that makes me believe there is some diff. (dont ask me what, I just wouldnt risk it, the -ai switch clearly hasnt been intended to jump a campaign ... my advise, dont use it as such)
also about the "simulate_mouse_click lclick_down/up" ... afaik you do not need both, dont know where people got the 2nd command from but I'm not using it and have the same results ...
G
mrtwisties
11-28-2007, 16:10
You're right. When I implemented the -ai switch in EB, I couldn't get the EB background script to work, even when I turned the ai switch off and reloaded the game.
Red Spot
11-28-2007, 17:46
just wondering, what are you trying to do?
make some sort of randomised start?
if so, there are easier ways imo, wich again leave slightly more of the control in your hands ...
like I've partially set up my game, take traits and ancillaries, I've made a few hidden traits, where one is used only in descr_strat, it is given to starting families wich than at characterturnstart get a random collection of traits
like so;
;------------------------------------------
Trigger game_startup2
WhenToTest CharacterTurnStart
Condition IsGeneral
and Trait RS_StartGame >= 1
Affects RS_StopGame 1 Chance 100
Affects RS_Management 1 Chance 30
Affects RS_Influence 1 Chance 30
Affects RS_Law 1 Chance 30
Affects RS_Trading 1 Chance 30
Affects RS_TaxCollection 1 Chance 30
Affects RS_TrainingAgents 1 Chance 30
Affects RS_TrainingUnits 1 Chance 30
the stopgame trait prevents it giving traits again as its the startgame trait's antitrait, together with some random augmentation of the traits the generals get in descr_strat
wich together wich some other settings creates a mild feel of a diff game each "turn 0" (gamestart), scripts can even do the same with entire factions
G
mrtwisties
11-29-2007, 00:42
Hi RedSpot, I explained what I'm trying to do a bit more clearly in posts 9 and 11. It's not just about a randomised start - it's about starting the game at a whole new point in history, when the factions are a little more developed.
Since the -ai switch seems a bit buggy, I'm having another crack at my original script. What I'd really like to do now is to set up code to have the AI deal with battles and diplomacy.
Here's my script at the moment:
script
declare_counter loop
set_counter loop 0
monitor_event FactionTurnStart FactionType romans_julii
and I_TurnNumber < 5
console_command control greek_cities
campaign_wait 10
console_command add_money 40000
console_command control romans_julii
end_monitor
;monitor_event PreBattlePanelOpen
;console_command puppify_my_love
;end_monitor
;monitor_event NavalAutoResolvePanelOpen
;console_command puppify_my_love
;end_monitor
;monitor_event DiplomacyMission
;console_command puppify_my_love
;end_monitor
;monitor_event ScrollOpened
;console_command puppify_my_love
;end_monitor
while I_CompareCounter loop = 0
end_while
end_script
If I take out the comments on my new monitor_events, RTW 1.5 CTDs as it loads (presumably when it tries to load this script). But these events are in the docudemon - can anyone tell me what I'm doing wrong?
mrtwisties
11-29-2007, 04:30
The script is pretty much working. I ripped off some of the code from the EB team - it automatically resolves land and sea battles and exits from diplomacy screens. I still need to:
1. Figure out a way to automatically dismiss the battle results scroll after a land or sea battle.
2. Figure out a way to automatically dismiss all the other scrolls that pop up (blah blah senate mission, etc). They don't pause the turn sequence, but they do create lag.
Here's the code, I'd be very grateful if anyone could help:
script
;
declare_counter loop
set_counter loop 0
;
declare_counter clickAutoResolve
set_counter clickAutoResolve 0
;
declare_counter clickAutoResolveNaval
set_counter clickAutoResolveNaval 0
;
declare_counter declineDiplomaticOffer
set_counter declineDiplomaticOffer 0
;
monitor_event FactionTurnStart FactionType romans_julii
console_command control greek_cities
console_command add_money 40000
end_monitor
;
monitor_event FactionTurnStart FactionType greek_cities
console_command control romans_julii
console_command add_money 40000
inc_counter loop 1
end_monitor
;
monitor_event PreBattlePanelOpen TrueCondition
set_counter clickAutoResolve 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolve = 1
set_counter clickAutoResolve 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event NavalAutoResolvePanelOpen TrueCondition
set_counter clickAutoResolveNaval 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolveNaval = 1
set_counter clickAutoResolveNaval 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event DiplomacyPanelOpen TrueCondition
set_counter declineDiplomaticOffer 1
end_monitor
;
monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
select_ui_element confirm_quit_scroll
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
while I_CompareCounter loop < 5
end_while
;
console_command control egypt
;
end_script
mrtwisties
11-29-2007, 04:30
The script is pretty much working. I ripped off some of the code from the EB team - it automatically resolves land and sea battles and exits from diplomacy screens. I still need to:
1. Figure out a way to automatically dismiss the battle results scroll after a land or sea battle.
2. Figure out a way to automatically dismiss all the other scrolls that pop up (blah blah senate mission, etc). They don't pause the turn sequence, but they do create lag.
Here's the code, I'd be very grateful if anyone could help:
script
;
declare_counter loop
set_counter loop 0
;
declare_counter clickAutoResolve
set_counter clickAutoResolve 0
;
declare_counter clickAutoResolveNaval
set_counter clickAutoResolveNaval 0
;
declare_counter declineDiplomaticOffer
set_counter declineDiplomaticOffer 0
;
monitor_event FactionTurnStart FactionType romans_julii
console_command control greek_cities
console_command add_money 40000
end_monitor
;
monitor_event FactionTurnStart FactionType greek_cities
console_command control romans_julii
console_command add_money 40000
inc_counter loop 1
end_monitor
;
monitor_event PreBattlePanelOpen TrueCondition
set_counter clickAutoResolve 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolve = 1
set_counter clickAutoResolve 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event NavalAutoResolvePanelOpen TrueCondition
set_counter clickAutoResolveNaval 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolveNaval = 1
set_counter clickAutoResolveNaval 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event DiplomacyPanelOpen TrueCondition
set_counter declineDiplomaticOffer 1
end_monitor
;
monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
select_ui_element confirm_quit_scroll
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
while I_CompareCounter loop < 5
end_while
;
console_command control egypt
;
end_script
mrtwisties
11-29-2007, 04:33
It occurs to me that I could use the same counter for both land and sea battles, and just create two separate triggers for activating that counter. I might do that, if only for the sake of efficiency.
But getting rid of the battle results screen is the key concern. Do you think I could just nerf the entire UI while the script is running?
mrtwisties
11-29-2007, 08:02
Here's the more efficient version. It also has an automatic scroll-closer implemented, but I still haven't figured out a way of automatically closing the battle results. Gah!
script
;
declare_counter loop
declare_counter clickAutoResolve
declare_counter DismissScroll
declare_counter declineDiplomaticOffer
set_counter loop 0
set_counter clickAutoResolve 0
set_counter DismissScroll 0
set_counter declineDiplomaticOffer 0
;
monitor_event FactionTurnStart FactionType romans_julii
console_command clear_messages
console_command control greek_cities
console_command add_money 40000
end_monitor
;
monitor_event FactionTurnStart FactionType greek_cities
console_command clear_messages
console_command control romans_julii
console_command add_money 40000
inc_counter loop 1
end_monitor
;
monitor_event PreBattlePanelOpen TrueCondition
set_counter clickAutoResolve 1
end_monitor
;
monitor_event NavalAutoResolvePanelOpen TrueCondition
set_counter clickAutoResolve 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolve = 1
set_counter clickAutoResolve 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event ScrollOpened ConditionTrue
set_counter DismissScroll 1
end_monitor
;
monitor_conditions I_CompareCounter DismissScroll = 1
set_counter DismissScroll 0
select_ui_element confirm_quit_scroll
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event DiplomacyPanelOpen TrueCondition
set_counter declineDiplomaticOffer 1
end_monitor
;
monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
select_ui_element confirm_quit_scroll
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
while I_CompareCounter loop < 5
end_while
;
console_command control egypt
console_command clear messages
;
end_script
Monkwarrior
11-29-2007, 12:18
Sorry, I can't help you.:embarassed:
Even I don't understand why the game changes the turn simply by changing the faction controlled. :dizzy2:
I wonder if the factions involved in this system of changes make any movement and when.
mrtwisties
11-29-2007, 14:35
I wonder if the factions involved in this system of changes make any movement and when.
They do. The script wouldn't have much point otherwise.
I wrote a couple of drafts to try and explain why it works, but they all got a bit cumbersome. Briefly, there's an order in which factions take their turns, and it loops. What happens in this mod is:
1. The AI plays for any faction that isn't you until it's your turn.
2. The script waits until it's your turn, and then makes "you" into someone else who is later in the turn sequence.
3. The AI plays for any faction that isn't you until it's your turn.
Rinse, lather, repeat. Every faction has "its turn" played by the AI. The only weakness is that if someone does something to your faction when it's not your faction's turn and you have to respond... well, you're still in charge of the faction and you have to respond.
I've more or less finished dealing with this weakness, though. The script now autoresolves battles and dismisses diplomacy windows.
mrtwisties
11-30-2007, 16:31
Incidentally, I did a whole bunch of experiments with the -ai command line. I think what makes it weird is that a game started under -ai can't load any scripts.
Red Spot
11-30-2007, 21:57
nor can you continue a game after starting it with the -ai command, you can after taking some actions, but you cant just press the turnbutton after disabling the AI again, or at least I couldnt after freezing the AI using the "halt_ai (optional; faction)" as the players turn would end but the AI never actually started its turn ....
G
mrtwisties
12-01-2007, 09:44
If you use "console_command control faction" rather than halt_ai, the ai seems to keep playing turns for all of the other factions.
I've been trying to figure out whether the -ai switch turns off something that can be turned on again, so far as getting scripts running again goes. No progress yet.
Incidentally, I did a whole bunch of experiments with the -ai command line. I think what makes it weird is that a game started under -ai can't load any scripts.
I can confirm that you can use a background_script with the -ai command if you launch it automatically using the Campaign script. You know:
advance_advice_thread Background_Script_Thread no_dismiss
wait 1
select_ui_element advisor_portrait_button
simulate_mouse_click lclick_up
So then, you can use the script to halt the game the turn you want to control any faction using the command:
"console_command control faction"
I posted it in a similar thread of this forum when I discovered it, I'm sorry I have not read this topic before to explain it here.
I have been using this way to debug my scripts and the campaign balance for long time now, with great results.
BTW, as Red Spot always says, I can also confirm that you don't need to use the combo with "simulate_mouse_click lclick_down", just needed the click_up.
Makanyane
12-04-2007, 10:03
mrtwisties, apologies if I've slightly lost track of where you've got to with this.
Does your version give you an autosave you can re-load do you know?
I'm running testing at the moment with script automatically launched from campaign script and then also triggering ER's year jump script to go on 200 turns (BI mod), that works fine for balance issues, but I'm getting occassional CTD about 140 turns in which is probably script generated unfortunately. It autosaves whilst on year jump but save doesn't seem to know who you are so crashes if trying to re-load. I could really do with being able to re-load before CTD as never manage to be watching campaign at right point to see what problem area is otherwise. (watching campaign prevents CTD occuring, it just happens as soon as you get distracted! :wall: )
mrtwisties
12-04-2007, 12:19
Hey Makanyane. It's neither implemented nor tested yet, but for that very reason I've mocked up some code that auto-saves once every four turns.
I'm still working on getting the core module working. I've reworked it so that hopefully it can be spliced into another script (like the EB background script) and still function, but I still need to find a way to auto-resolve diplomacy and auto-dismiss the battle results screen. Here's what the script looks like:
script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Jumpity Jumpity Jump Jump Jump
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
declare_counter loop
declare_counter clickAutoResolve
declare_counter DismissScroll
declare_counter declineDiplomaticOffer
set_counter loop 0
set_counter clickAutoResolve 0
set_counter DismissScroll 0
set_counter declineDiplomaticOffer 0
;
monitor_event FactionTurnStart FactionType romans_julii
and I_CompareCounter loop < 4
console_command clear_messages
console_command control greek_cities
end_monitor
;
monitor_event FactionTurnStart FactionType greek_cities
and I_CompareCounter loop < 4
console_command clear_messages
console_command control romans_julii
inc_counter loop 1
end_monitor
;
monitor_event PreBattlePanelOpen TrueCondition
and I_CompareCounter loop < 4
set_counter clickAutoResolve 1
end_monitor
;
monitor_event NavalAutoResolvePanelOpen TrueCondition
and I_CompareCounter loop < 4
set_counter clickAutoResolve 1
end_monitor
;
monitor_conditions I_CompareCounter clickAutoResolve = 1
set_counter clickAutoResolve 0
select_ui_element prebattle_auto_resolve_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
monitor_event ScrollOpened ConditionTrue
and I_CompareCounter loop < 4
set_counter DismissScroll 1
end_monitor
;
monitor_conditions I_CompareCounter DismissScroll = 1
set_counter DismissScroll 0
select_ui_element confirm_quit_scroll
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
;
;None of this diplomacy stuff works
;
;monitor_event ScrollOpened diplomacy_scroll
;set_counter declineDiplomaticOffer 1
;end_monitor
;
;monitor_event DiplomacyPanelOpen TrueCondition
;set_counter declineDiplomaticOffer 1
;end_monitor
;
;monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
;set_counter declineDiplomaticOffer 0
;select_ui_element confirm_quit_scroll
;simulate_mouse_click lclick_down
;simulate_mouse_click lclick_up
;end_monitor
;
monitor_conditions I_CompareCounter loop = 4
console_command control egypt
console_command clear messages
terminate_monitor
end_monitor
while loop < 5
end_while
end_script
I can't even get the diplomacy or battle-result monitors working, at the moment. Haven't really had a chance to make any progress in the last few days, though.
Makanyane
12-05-2007, 00:43
In addition to what you had with slight adjustment:
monitor_event DiplomacyPanelOpen TrueCondition
set_counter declineDiplomaticOffer 1
end_monitor
monitor_conditions I_CompareCounter declineDiplomaticOffer = 1
set_counter declineDiplomaticOffer 0
select_ui_element diplomacy_decline_offer_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up
end_monitor
declines the diplomacy offer, I just can't figure out how to quit the scroll
I think the one you're trying to use
select_ui_element confirm_quit_scroll
is actually the "do you really want to leave the game, yes or no" scroll
but can't figure out what button for just escaping scroll actually is :wall:
mrtwisties
12-05-2007, 07:15
I know what you mean. Have mostly got the monitors working. But I think I've tried every single ui_element that looks even vaguely like it might work to close those scrolls. I've even been making up names!
Am no longer convinced that this approach can work. Might try:
1. Using another utility to automate pressing "enter" and "esc" every few seconds. These keypresses would be sufficient to kick things along, but I don't think you'd be able to do anything else with the computer while the year jump was taking place. Not sure, I've never used a utility like that before. Hmmm, I haven't actually tried telling the RTW script to press keys, so maybe that's also worth a go. There do seem to be some key names in descr_shortcut.txt.
2. Using campaign scripts to try and unlock the features that are suppressed by the -ai switch. Using "console_command control factionname" in a campaign script does give you control - but it means that show_me scripts don't work thereafter. Maybe there's a way of fixing that? It'd be good if there was.
3. Killing a faction, switching control to it and then having that faction "re-emerge" (ie "capture_settlement") later in the game. Clearly a sub-optimal solution.
4. Using emergent factions and ER's BI-based year jump mod. My least favourite approach.
Red Spot
12-05-2007, 08:27
3. Killing a faction, switching control to it and then having that faction "re-emerge" (ie "capture_settlement") later in the game. Clearly a sub-optimal solution.
Not really sure if that will work, afaik once a faction is dead it can be respawned, but so far I've been unable to "re-activate" it (they're arent doing a thing ...)
G
Makanyane
12-07-2007, 20:57
1. Using another utility to automate pressing "enter" and "esc" every few seconds. These keypresses would be sufficient to kick things along, but I don't think you'd be able to do anything else with the computer while the year jump was taking place. Not sure, I've never used a utility like that before. Hmmm, I haven't actually tried telling the RTW script to press keys, so maybe that's also worth a go. There do seem to be some key names in descr_shortcut.txt.
not sure on external utility - if you hit esc when there isn't screen to close you'll be going in and out of the menu screen. If you can do it inside script it would work though with a wait after the resolve event but within the same monitor.
4. Using emergent factions and ER's BI-based year jump mod. My least favourite approach. Well, that was where I was, works to test balance to end of fixed period (assuming you have spare factions), is compatible with background script if you launch year jump from trigger in bg script. Just doesn't get you usable autosave :wall:
That seems to be main snag - to get a usable save it has to be legitimately your turn, if its your (human controlled) turn you get the closing scroll problem.
mrtwisties
12-09-2007, 12:23
not sure on external utility - if you hit esc when there isn't screen to close you'll be going in and out of the menu screen. If you can do it inside script it would work though with a wait after the resolve event but within the same monitor.
Have been busy for the last few days, but was thinking of "stealing" the escape key, except for when one of those pesky scrolls pops up.
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.