PDA

View Full Version : Scripting



Myrddraal
11-24-2004, 22:10
I posted this as a side point in the WoT mod thread, but maybe someone here can answer it:

If we could change the number of turns in one year that would be awsome. For example, have four seasons to a year instead of two.

I was thinking of a possible way of doing this. I was looking around the prologue_script.txt file, and I noticed that you can enter cheats. They use the line console_command, and then enter the cheat code.

For example, they make sure you don't lose ur character by making him invulnerable:

console_command invulnerable_general "Gaius Julius"

If we could somehow make this type of script work for other campaigns, then you could write out a very long script which would do this:

Turn one: do nothing (spring)
Turn two: change the season back to summer (summer)
Turn three: change the season back to summer (autumn or fall for the americans)
Turn four: do nothing. (winter, the date would then automatically advance by one at the end of this turn)

It would do this in cycle for the whole game period, and there you go, four turns to a year.

Now I don't know if it would work, but its an idea worth looking into.

Myrddraal
11-26-2004, 13:38
I take it no-one knows better than me...

Kraxis
11-26-2004, 14:46
Let me ask... You have to do this all the time right? And you sure the characters don't as they shouldn't?

Bacchon
11-27-2004, 11:54
That looks like it would work to me... Only problem I could think of was that it'd still advance the year after every two turns, regardless of the season. You'd thus have two years per season cycle according to the game display, unless you could script that to change as well, but that would take a huge amount of work, as you'd probably have to script it to change each and every year manually. I, personally, could live with having two years/season cycle, wouldn't matter to me. Characters would only live through half as many years by the season cycle, though the same as by the clock.

Excellent idea, though.

-edit-

If the years do advance as one year/two seasons and not one year/season cycle, you'd also have to double the number of playable years. Also not a big deal for me, my games never finish after 100BC. 'Course, I never made it into Late Era in MTW. *shrug*

Kaiser of Arabia
11-27-2004, 16:02
Hope there's a way around that, I need it for my AmericanConquestTotalWar mod. It would be long but I need more than an 8 turn Civil War (I was gonna make the turns into months)
-Capo

Myrddraal
12-01-2004, 23:22
Its easy enought to do in the prologue script, but I can't make script files for any other campaign. Am I wasting my time?

dclare4
12-02-2004, 05:10
I don't think its useless if you can get away from the 'year/age' paradigm. Like if you thought of turns as turns and modified the game likewise. For instance I was thinking instead of born, coming of age and died it could be - "A new officer is commissioned/arrives at (theater of war) and is beginning HQ staff duties" for born, "A new officer receives his command" for coming of age and "Officer retired/dies of natural causes/transferred out of (theater of war)" for dies. I for one would like to see more turns per year and if you got the script working that will give RTW four seasons thats great, maybe you could post it?

Cheers,
Clare

tommh
12-02-2004, 05:24
Have you tried this:

script
Prologue_Campaign_Script.txt



At the bottom of the appropriate desc_strat file? This is going to be difficult without some idea of the script language and format. For more ideas see the scripts in the show_me directory.

Myrddraal
12-02-2004, 14:07
My god, I can't believe I missed it...

Thx Tommh, I'll see what I can do...

Myrddraal
12-03-2004, 13:49
I have a script that works:


declare_counter PressEndTurn


console_command date -50
set_counter PressEndTurn 101

while I_CompareCounter PressEndTurn = 101
monitor_event ButtonPressed ButtonPressed end_turn
set_counter PressEndTurn 1
terminate_monitor
end_monitor
end_while


while I_CompareCounter PressEndTurn = 1
console_command date -50
console_command season summer
set_counter PressEndTurn 100
end_while

while I_CompareCounter PressEndTurn = 100
monitor_event ButtonPressed ButtonPressed end_turn
set_counter PressEndTurn 2
terminate_monitor
end_monitor
end_while


while I_CompareCounter PressEndTurn = 2
console_command date -50
console_command season summer
set_counter PressEndTurn 200
end_while

while I_CompareCounter PressEndTurn = 200
monitor_event ButtonPressed ButtonPressed end_turn
set_counter PressEndTurn 3
terminate_monitor
end_monitor
end_while


while I_CompareCounter PressEndTurn = 3
console_command date -50
console_command season winter
set_counter PressEndTurn 300
end_while

while I_CompareCounter PressEndTurn = 300
monitor_event ButtonPressed ButtonPressed end_turn
set_counter PressEndTurn 4
terminate_monitor
end_monitor
end_while


while I_CompareCounter PressEndTurn = 4
console_command date -51
console_command season summer
set_counter PressEndTurn 400
end_while

while I_CompareCounter PressEndTurn = 400
monitor_event ButtonPressed ButtonPressed end_turn
set_counter PressEndTurn 5
terminate_monitor
end_monitor
end_while


terminate_script

This makes the game run from the date -50 and has four seasons for the first turn.

There are a few bugs. The seasons don't seem to want to change, there is currenly one summer, and three winters. I'll see what I can do.

Myrddraal
12-03-2004, 18:23
Ok, ignore that previous post, the code was flawed. The flaw was that the year ends some time after the player presses end turn.

Here is the new and shiny, bugless and concise ~;) Script:


console_command date -50

while I_TurnNumber = 0
end_while

console_command date -50
console_command season summer

while I_TurnNumber = 1
end_while

console_command date -50
console_command season summer

while I_TurnNumber = 2
end_while

console_command date -50
console_command season winter

while I_TurnNumber = 3
end_while

console_command date -51
console_command season summer

console_command date -51
console_command season summer

while I_TurnNumber = 4
end_while

console_command date -51
console_command season summer

while I_TurnNumber = 5
end_while

console_command date -51
console_command season winter

terminate_script

This can be repeated as much as you like.
Hope someone finds this usefull. Please tell me if your using it, I'd like to know how many people use it.

Now all we need is a way of increasing life spans.

To the Mods: Is this worthy of the Guides Forum?

tommh
12-04-2004, 02:02
I wonder if this will affect character lifespan? It will depend on if the current year counter is used or if it keeps count of turns.

eadingas
12-04-2004, 11:46
What happens when the script ends? Does the game end or does it go 'normal' ?

Myrddraal
12-04-2004, 11:59
I used that bit of script from the prologue. Next to it there is a comment that says:

;No more scripty bits, just normal game.

Or something like that. I must admit, I haven't tested the script that far, I just got through about 5 turns, saw it was working, and quit. I assume it just carries on as normal.

@Tommh, I think it counts turns.

Duke John
12-04-2004, 21:46
Excellent find, myrddaal! I didn't know this was possible. Perhaps it's a good idea to collect all scripting commands and see if there are more combinations/effects possible.

Cheers,
Duke John

MR EGG
12-05-2004, 01:09
Hello I've moddified your script extended it to 104 turns.
Each turn now equalls 1 week and the year changes on the 53rd turn.
one thing is no body ages at all not even when the year changes.

thanks myrddaal for your info

MR EGG ~:cheers:

GodsPetMonkey
12-05-2004, 02:36
Great discovery! As we learn more, it’s sure to revolutionise RTW modding. I hope CA helps us a little here, in many games scripting is a very powerful tool.

But, for changing the number of turns per year, its way too much typing for my liking. So, being the lazy person that I am, I quickly wrote a program to do all the hard work for me!

Grab it here -
http://www.totalwar.org/Downloads/Rtw_Uploads/RTWupload/ScriptGen.zip

As far as I can tell, it works great. ~:)

dclare4
12-05-2004, 07:20
Hi Myrddraal,

Should I put it in the scripts folder or the *campaign_name* folder? Really excited about this!

You rule!
Clare

Myrddraal
12-05-2004, 14:07
You should put it in the campaign folder, and make a line at the bottom of the descr_strat.txt like this:

script
descr_Script.txt

Or whatever ur script file is called.

MR_EGG thats great, as I said I hadn't tested it much and I had assumed that aging would be doubled. I can see this is going to be useful for my Wheel of Time Mod as well...

@GodsPetMonkey, U got there first! Thats what I was about to do. Thx.

Myrddraal
12-05-2004, 14:16
I noticed your script generator generates 2 winters and 2 summers if you put it to 4 turns a year.

Maybe you could add an extra option:

Number of these turns to be summers.

This would be convinent for those who want to do Months, and have the winter months snowy.

[cF]HanBaal
12-05-2004, 17:19
hi Myrddraal! Great job you got here! I always wanted RTW to have 4 turns also :thumbsup:

Three questions:

1-Reading MR.EGG's post, can we assume the characters' lifespan is related to years and not turns? If not, have you (or anyone else) found a way to make it so?

2- Reading your script sample, I also assume you managed to make 3 summer seasons and one winter season per year right?

3- Considering conditions 1 and 2 as achievable, would you mind if we implement this feature into the EuropaBarbarorum mod? All credits due of course ~:wave:

Myrddraal
12-05-2004, 21:03
As far as I know, 1 is true, though I haven't tested it myself.

2 is true.

And of course I don't mind. If I didn't wan't people using it, I would never have posted, but I do like people to appreciate, so the credits are welcome ;)

barbarian warchief
12-05-2004, 22:26
ok, I made each turn represent 1 month but now I cant save and it doesnt autosave either. Also, generals dont age for 6 turns then they age every turn after that then process repeats itself at the start of the year. ~:confused:

GodsPetMonkey
12-05-2004, 22:42
I noticed your script generator generates 2 winters and 2 summers if you put it to 4 turns a year.

Maybe you could add an extra option:

Number of these turns to be summers.

This would be convinent for those who want to do Months, and have the winter months snowy.

Well, I admit I just knocked it up in like 20 mins, pretty simple to do, but I guess I can work in such a feature, give me a bit of time and I'll get back to you ~;)

EDIT -
Actually, that was alot easier then I expected, and only took me about 5 minutes to implement and test, grab the new version here;
http://www.totalwar.org/Downloads/Rtw_Uploads/RTWupload/ScriptGen_101.zip

eadingas
12-05-2004, 23:24
You two guys have made whole new worlds open to the modding community ~:cheers:

GodsPetMonkey
12-05-2004, 23:50
You two guys have made whole new worlds open to the modding community ~:cheers:

If your talking about me, all credit mist go to Myrddraal, I just wrote a bit of code to do it over and over and over again, anyone with same spare time could have done it.

MR EGG
12-06-2004, 02:29
Hello
when I tested this I was using the original code and no one aged.
now with this exellent tool from GodsPetMonkey and Myrddraal's new code thx guys it works great and characters do age. through testing I've found that if all the turns are summer then they age normaly once per year and at different times per character within the year,but if you have a winter turn then all the characters will age by one year and will increase there age every winter turn thereafter.So if you have two winter turns in a row then everybody ages two years.
cheers MR EGG. :dizzy2:

[cF]HanBaal
12-06-2004, 02:54
through testing I've found that if all the turns are summer then they age normaly once per year and at different times per character within the year,but if you have a winter turn then all the characters will age by one year and will increase there age every winter turn thereafter.So if you have two winter turns in a row then everybody ages two years.

Thx a lot for the testing info mate ! The solution (at least for now) is then to have only a winter season per year to make aging work correctly. Again, thx a lot guys, especially to Myrddraal, for making this possible ~:cheers:

GodsPetMonkey
12-06-2004, 05:05
I'd like to know which nutter bound ageing to it being winter...

Then again, I dont think they expected us to end up doing this.... at all.

tommh
12-06-2004, 19:18
SO lets try to figure out all the possibilities:

We can have more turns per year and that means that turn based things can be adjusted relative to time based things:


Time based:
Aging, time based - (kind of wierdly)
Weather time based - (but linked to aging)
Events - I believe these are time based
End of game
seasonal crop income? I think this is seasonal?
Triggers? - does anyone know of any time based triggers (i.e. based on the current date)

Turn based:
Building
Recruitment & training
movement rates
VnV & Ancillary triggers - most are based on a per turn chance of occurance

So effectivly we now have the capability to change the relative relationship between one column and the other.

Some remaining issues:

Agricultural income will increase significantly if you add two extra summers. Needs to be adjusted.
Adjustment to building and recruitment rates as nessecary.
Adjustment to VnV & ANcillary triggers (essentially to keep the same occurance rates you would have to halve the points accumulated or the chance of occurance if you double the turns per year)

Nice catch, good detective work!

tommh
12-06-2004, 19:19
Oh, another issue is birth and marriage rates. These are turn based. This might need some adjustments.

eadingas
12-06-2004, 19:24
Just thinking - re agriculture, wouldn't it be more realistic to have two winters: one in the beginning, one in the end of the year? Most of late autumn and early spring can be considered winter for vegetational purposes in the northern climate...
Although if the year and ageing is bound to winter, this means even more trouble. So maybe this isn't such a good idea after all.

Dux of Earl
12-06-2004, 20:31
Salvete Milites,

Not trying to be party-pooper here, but unless a practical fix is found for the 'no savegame' and 'recurring winter' problems... then it would seem that all further discussion about the potential of this 4 season scripting mod is just academic..

No one is going to put this into a campaign game if they can't save and reload the game later... and if the script falls apart after 5 or 6 turns and and every other turn is a winter turn with snow, then what's the point of have 4 seasons?

Valete, Dux of Earl

GodsPetMonkey
12-06-2004, 22:25
I haven't experianced the constant winter issue, but I did do some work into trying to work out the save/load problem.

Sadly, its not good, at all.... It seems as if the game is set so that save/load functionality is disabled whilst a script is running, as soon as the script ends, save/load goes back to normal. Im guessing this is due to fact that the save functionalty doesn't save any scripting, like where the player is up to in the script, and the variables set in the script are set to at that point in time.

So, to enable save/load-ing, I am guessing you need to stop the script alright, and I can't find a way to restart it, especially half way through. I wish we could bind it to be run when a turn ends (like when they press the button!) we could do something with it that way, but it doesn't appear to be.

Sigh, why do I feel that this was one of those really cool features that only got half completed.... perhaps in the expansion? I think that's a long shot really, but we must hope.

Dux of Earl
12-06-2004, 23:17
@GPM... yeah, this reminds me of the blood mod... it started out pretty good too... and then hit a big brick wall with the RTW coding.. just like this one..

I'm not expecting that CA will do anything to facilitate the incorporation of either a blood mod or the 4 season mod in an expansion pack... that would be too much customer satisfaction for them to handle..

Vale, Dux of Earl

Myrddraal
12-07-2004, 13:43
That sounds defeatist to me, I won't have it! You can save during the Prologue can't you? There is a script running through most of that. I'll have a look at the commands they use and come back to you.

GodsPetMonkey
12-07-2004, 13:52
That sounds defeatist to me, I won't have it! You can save during the Prologue can't you? There is a script running through most of that. I'll have a look at the commands they use and come back to you.

Untill the script ends, you can't save in the prologue, I even went and tried it (and damn, the prologue is long and boring!).

Anyway, I ran a simple test, I made a simple script like this



console_command add_money 10000
campaign_wait 20
console_command add_money 10000
terminate_script


When I start a game with it, it gives me 10000 denarii, which tells me the script has loaded, then it pauses itself for 20 seconds, and in that time I can't save ro load, then it gives me another 10000 denarii, which tells me the pause is over, the script will then unload (as the next line terminates it) and hey presto, I can save and load again.

I am hopeing there is a way arround this problem, but I'm not very optimistic on the matter.

Myrddraal
12-07-2004, 13:55
Damn. Maybe CA can give us a hint???

Dux of Earl
12-07-2004, 17:46
@Myrddraal,

Enrique Ordono (Camera Hack mod) has suggested a possibility... use the show-me folder for the script.. and then rig a trigger in the game to start and stop the script... sounds too complicated for me to do though..

But, it does work for his Camera Hack script.. I can still save campaign games with the Camera Hack script loaded up...

However, the Camera Hack only runs during campaign battles... when the battle is done and I return to the Campaign map, I presume that the script is turned off again...

In the current problem, it would be probably necessary to trigger the start of the 4 season script by doing something concurrent with loading a game... and then trigger the termination of the 4 season script concurrent with pressing the ESC key (to bringup the savegame menu)..

How this can be setup I do not know.. maybe using the show-me sliding menu thingie can help...

Vale, Dux of Earl

tommh
12-07-2004, 18:56
the other problem is saving any global data. Once the script terminates it's variable values are gone. This means that the script can't store any info between runs. So how would you know to advance the year counter every fourth run of the script?

Myrddraal
12-07-2004, 19:57
It might be possible, to make it so you can only save every four turns (i.e. at the end of the year). Then you could have one script file which runs for one cycle. I assume that the turns are counted from the moment the script is run. Also the script would have to have more variables in. At the moment it sets the date to a fixed number.

The other problem is how to trigger the script.

SwordsMaster
12-07-2004, 20:01
What if:

Your script only runs through 3 summer seasons and leaves the winter to the machine, so the autosaves/saves/loads would occur in winter.

This way you dont need storing anything as the script will be generating summers only. Then will be called again and generate 3 summers and so on. As aging is related to winters you have no problem there.

I havent actually read the code, so forgive me if Im wrong.

Myrddraal
12-07-2004, 20:18
Or another idea. If the script runs from the start, but terminates itself if:
the player goes to the menu scroll
and
its in the first season of the turn.

Then the player can save/load.

This would mean that you could only save/load on the first turn of each year.
To restart the script once you've loaded a game, we put a copy of the script in the show me folder etc.

GodsPetMonkey
12-08-2004, 00:04
I took Enrique Orduno’s advice, and started working on a way to load the script using the show_me method.

This is what I have come up with, and it works!

First, open data/export_descr_advice.txt

Find the entry AdviceThread City_Construction_Build_mines_Next_Thread and add this to it;


Script scripts\show_me\turn_script.txt


Then scroll to the bottom of the file, and add


Trigger 9999_Fix_Turns
WhenToTest ButtonPressed

Condition ButtonPressed faction_button

AdviceThread City_Construction_Build_mines_Next_Thread 1


Finally copy your script into /data/scripts/show_me and call it turn_script.txt (or what ever you used for a file name in the first bit of code). Make sure your script starts with the ‘script’ statement, and ends with a ‘end-script’ not ‘terminate_script’.
For example,


script

console_command date 0

while I_TurnNumber = 0
end_while

console_command date 0
console_command season summer

while I_TurnNumber = 1
end_while

console_command date 0
console_command season summer

while I_TurnNumber = 2
end_while

console_command date 0
console_command season summer

while I_TurnNumber = 3
end_while

console_command date 0
console_command season winter

while I_TurnNumber = 4
end_while

console_command date 1
console_command season summer

while I_TurnNumber = 5
end_while

console_command date 1
console_command season summer

while I_TurnNumber = 6
end_while

console_command date 1
console_command season summer

while I_TurnNumber = 7
end_while

console_command date 1
console_command season winter

end_script


Now run the game, turn on advice, and click the faction information button, then hit the “Show Me How” button, and away we go! You can now turn off advice, but this needs to be done at the start of each game.

A bit of an inconvenience, but it does work, so it’s a big step forward!
What I would like to do is have it automatically run the script when ever the end turn button is pressed, I can set up a trigger for it, but I still have to press the “Show Me How”. Anyone got an idea on this one?

eadingas
12-08-2004, 00:24
That should be easy. There's plenty of auto-launching advices in the prologue script. On a quick glance, I see that 'dismiss_advice' is a command for,well, dismissing advice ;) And perhaps advance_advice_thread launches advice? Or maybe declare_show_me?

Myrddraal
12-08-2004, 09:36
but then you would need another script to launch the second script... that wouldn't work.

Also remember that if you want the turns to work, you need to save during the first summer of a year.

To save the script needs to be stopped. As far as i can see, your script would also need to be run every 2 years.

GodsPetMonkey
12-08-2004, 13:00
but then you would need another script to launch the second script... that wouldn't work.

Also remember that if you want the turns to work, you need to save during the first summer of a year.

To save the script needs to be stopped. As far as i can see, your script would also need to be run every 2 years.

You talking about my adaptation?

If you are, nope on all counts (from my limited testing anyway, I felt after 2 years of 4 turns each with a few saves then loads, it was pretty sound), the save game keeps track of the turn number, so when you load a game, regardless of when you saved it, and then run the script (with out ending the turn first) by the show me method it will effectively fast forward through the script to the last point (really, all the iteration conditions evaluate as true untill the one concerning the current turn is hit).

Apart from having to load the script each time you want to play, its pretty much exactly what we are looking for. If we could solve the loading part, it would be perfect (or as close as we can get). Sadly I can't find any examples of the game automatically launching a show me sequence.

Myrddraal
12-08-2004, 13:53
No i wasn't, I was talking about eadingas' suggestion. He mentions script commands to launch a script.

As for urs, wouldn't it need to be re-launced every time the script ended. You should make the script last ages and put in a way of terminating it so you can save.

That shouldn't be too hard. Monitor a condition like clicking on the faction button again. And make a new counter that changes to 1 on the first turn of each year, and 0 otherwise. If these two conditions are met, the script ends, and you can save your game. The script then has to be re-launched after saving.

GodsPetMonkey
12-08-2004, 14:26
Or don't bother and save anyway ~:)

As its a show me script, the game can be saved/loaded whilst its running.

That's right, CA made it so that you can't save during a script loaded by the campaign files, but those started by the advisor proves no problem.

Though who said it had to make sense?

eadingas
12-08-2004, 14:30
If I read correctly what you say, then the only problem is automatically launching the Show Me script at the beginning of the campaign, right? Then it shouldn't be a problem at all, since the same thing is done in Prologue, IIRC, we just have to check what commands are used for it...

GodsPetMonkey
12-08-2004, 14:50
If I read correctly what you say, then the only problem is automatically launching the Show Me script at the beginning of the campaign, right? Then it shouldn't be a problem at all, since the same thing is done in Prologue, IIRC, we just have to check what commands are used for it...

Sadly no, it doesnt load an external script, it just contains the code of those scripts in the prologue script.

And using a prologue style script (one that loads with the start of a campaign) is what we tried originally.

Sigh.

Still, at least its not a major issue.

Myrddraal
12-08-2004, 16:45
In which case, make a short script which loads up the advisor on the right thread. The player then clicks 'show me' and away we go. The original script ends and its done.

Myrddraal
12-08-2004, 17:31
Ok here is a script which should be run from the beginning. It should end the script if the player presses the escape key and it is the first turn of a year. This will enable the player to save/load. He then needs to start up an identical script in the show_me folder. I haven't done that yet, and I haven't tested this one either. It may or may not work:


declare_counter IsFirstTurn

monitor_event EscPressed TrueCondition
and I_CompareCounter IsFirstTurn = 1
end_script
terminate_monitor
end_monitor

console_command date -50
set_counter IsFirstTurn 1

while I_TurnNumber = 0
end_while

console_command date -50
console_command season summer
set_counter IsFirstTurn 0

while I_TurnNumber = 1
end_while

console_command date -50
console_command season summer

while I_TurnNumber = 2
end_while

console_command date -50
console_command season winter

while I_TurnNumber = 3
end_while

console_command date -51
console_command season summer
set_counter IsFirstTurn 1

while I_TurnNumber = 4
end_while

console_command date -51
console_command season summer
set_counter IsFirstTurn 0

while I_TurnNumber = 5
end_while

console_command date -51
console_command season summer

while I_TurnNumber = 6
end_while

console_command date -51
console_command season winter

while I_TurnNumber = 7
end_while

console_command date -52
console_command season summer
set_counter IsFirstTurn 1

terminate_script

GodsPetMonkey
12-09-2004, 00:00
I'm confused.

I don't really see the point of running a script with campaign load, when the only way they are going to be able to save or load is if they end it, then when they do that, make them run a show me script in order to continue.

Why not just get them to run a show me script from the very begining? You never need to worry about saveing/loading then, you wont need an exit clause, and they can do it at any time they choose. You do have to make them run the script every time they load a game of that campaign, but you have to do that either way.

Myrddraal
12-09-2004, 09:43
I guess so, I don't know why I did that then...

Myrddraal
12-15-2004, 09:35
Seeing as nobody else has done anything. I though I'd try and develop some of the ideas we had:

First of all I made a new trigger in export_descr_advice.txt:


;------------------------------------------
Trigger 2123_fourseasons
WhenToTest FactionTurnStart

Condition FactionIsLocal
and I_TurnNumber = 0
and FactionType romans_julii
and not I_MapName data/world/maps/campaign/sons_of_mars/descr_strat.txt

AdviceThread Seasons_Thread 1

Then I made a new thread above this:


;------------------------------------------
AdviceThread Seasons_Thread
GameArea Campaign

Item Seasons
Suppressible y
Uninhibitable
Verbosity 1
Priority 1
Threshold 1
MaxRepeats 100
RepeatInterval 1
Attitude Concerned
Presentation Default
Title Settlement_Rebels_Take_Action_Text_01_Title
Script scripts\show_me\fourturns_script.txt
Text Settlement_Rebels_Take_Action_Text_01_Text1

This is just so that whenever you run a new game as the Julii (I guess that condition could be removed) the advisor asks you to run the script, I'll make a personalised text for it eventually.

This is the script called fourturns_script.txt:


script

suspend_unscripted_advice true
suspend_during_battle on

console_command date -50
console_command season summer

while I_TurnNumber = 0
end_while

disable_shortcuts options_button true
console_command date -50
console_command season summer

while I_TurnNumber = 1
end_while

console_command date -50
console_command season summer

while I_TurnNumber = 2
end_while

console_command date -50
console_command season winter

while I_TurnNumber = 3
end_while

disable_shortcuts options_button false
console_command date -51
console_command season summer

while I_TurnNumber = 4
end_while

disable_shortcuts options_button true
console_command date -51
console_command season summer

while I_TurnNumber = 5
end_while

console_command date -51
console_command season summer

while I_TurnNumber = 6
end_while

console_command date -51
console_command season winter

while I_TurnNumber = 7
end_while

disable_shortcuts options_button false
console_command date -52
console_command season summer

while I_TurnNumber = 8
end_while

disable_shortcuts options_button true
console_command date -52
console_command season summer

while I_TurnNumber = 9
end_while

console_command date -52
console_command season summer

while I_TurnNumber = 10
end_while

console_command date -52
console_command season winter

while I_TurnNumber = 11
end_while

disable_shortcuts options_button false
console_command date -53
console_command season summer

while I_TurnNumber = 12
end_while

disable_shortcuts options_button true
console_command date -53
console_command season summer

while I_TurnNumber = 13
end_while

console_command date -53
console_command season summer

while I_TurnNumber = 14
end_while

console_command date -54
console_command season summer

while I_TurnNumber = 15
end_while


end_script


As you can see at the top I used 'suspend_during_battle on. It worked! The script no longer ends when I play a battle. This is great news.

You'll also see I added 'disable_shortcuts options_button' at some points in the script. I haven't tested this yet, but it should stop the player going to the main menu unless it is the first turn of a year. This will stop the player saving at the wrong time.

Now all we need is a trigger and advice which askes the player to run the script when you load a game.


Now for some more interesting stuff I found. I found the following commands whilst looking through files:



e_select_settlement
select_ui_element selected_item_button
simulate_mouse_click rclick_up
reveal_advice

I know that 'advisor_portrait_button' is the correct term for that button. I might be possible to put it in a startup script like this:


select_ui_element advisor_portrait_button
simulate_mouse_click rclick_up


This might not seem usefull at first glance, but. What if the show me button was called 'advisor_show_me_button' or something like that. Then we could have a startup script which goes something like:


Script
Wait 2 ;Wait two seconds for the advisor portrait to appear.
Reveal_advice ;Start the advisor talking (assuming that is what this command does)
select_ui_element advisor_show_me_button
simulate_mouse_click rclick_up ;Start the script
dissmiss_advice ;Stop the advisor
end_script ;Stop the script

This would mean there would be no need for the player to do anything, the script would run itself. Of course this wouldn't work for loading games but it would still be amazing, I have yet to test it.

eadingas
12-15-2004, 09:50
You say no saving between years - does that disable quicksave?

Myrddraal
12-15-2004, 10:07
No, I didn't think of that, but players should know that saving between years screws up the dates system.

Enrique Orduno
12-15-2004, 19:15
The show_me button is named "advisor_show_me_button". I've always have had trouble monitoring wether a button was pressed or not, so it might not work to simulate it.

Anyway, nice implementation of the scripting stuff.

Myrddraal
12-15-2004, 21:22
Thx Enrique, I thought it was, but I hadn't seen it anywhere.

I can't test it right now (problems with my computer) but if it works it means we have a way of running startup scripts without stopping the player saving.

dclare4
12-17-2004, 04:32
Hi Myrddraal,

Just a note to say that you guys rock! Please don't give up on this, it's really going to expand the RTW universe WHEN you crack this :)

Cheers,
Clare

Paul Peru
12-17-2004, 12:37
Is there a general scripting guide/reference somewhere?

Myrddraal
12-17-2004, 16:45
No, I guess this is just a research thread really. We should eventually get round to making a guide, what do you want to know?

dclare4
12-18-2004, 15:00
I'm a bit confused... which of the above scripts is like three seasons and then the script ends so the computer can make it winter? I'd like to try that (save on the winter turns or something) with the show me how thingee...

just wondering,
Clare

Myrddraal
12-18-2004, 18:24
I don't really know what you mean, the best script is the one in my last post.

Hopefully tomorrow, I'll have the defininitve script and post that.

Enrique Orduno
12-19-2004, 00:04
Yeah...there are no real guides to scripting, but it's not that hard to learn. Just heaps of commands to find out and know how to use them(which is not that hard once you got the logic). They are all in the exe iirc.

Oh and Myr, you should check and see if variables can be used in those scripts because that'd save you a lot of time (increase date variables + turns variables) and effort. I'm sorta busy nowadays, so I can't check to see if variables work.

Monkwarrior
12-19-2004, 11:22
Sorry if it is a silly question (I am a blissfuly ignorant about scripting :embarassed: ):
Could it be possible to simulate invasions with scripts?

An example:
We place only 19 factions in the map and keep one as "invader horde", let's say goths. We set a date and a place for the invasion, and the composition of the invader army. Thus when the date arrives, an army (coming from nowhere) suddenly appears in one corner of the map.
Would it be possible?

Thx.

GodsPetMonkey
12-19-2004, 12:34
Sorry if it is a silly question (I am a blissfuly ignorant about scripting :embarassed: ):
Could it be possible to simulate invasions with scripts?

An example:
We place only 19 factions in the map and keep one as "invader horde", let's say goths. We set a date and a place for the invasion, and the composition of the invader army. Thus when the date arrives, an army (coming from nowhere) suddenly appears in one corner of the map.
Would it be possible?

Thx.

This is entirely theoretical, but the answer is yes/no.

Why yes/no? Well, it’s possible to spawn armies through scripts (its done in the tutorial) and it should be possible to spawn a rebel army no problems, but you may run into issues when it comes to spawning essentially a new faction in the middle of a game, I don't know how well that would go down.
Actually, I'm not sure if re-appearing factions is in RTW, I remember reading someplace that they can, but I can't say if I really did or my imagination got me all hopeful. If factions can re-appear, then I would guess the game is capable of starting a new faction in the middle of a game (though don't quote me on that).

Only one way to find out though!

Botis
12-19-2004, 12:49
Monkwarrior

I like your idea, I'm coming up to a few weeks off for christmas and thought I'd like to make a few changes meself in this time,,, I've been thinking about how to do something like what you suggest and find a way around the factions not returning --- I want revolts from factions and barbarian invasions... on top of the SPQR mod it would make the game more like what I want... anyway...

One idea I had for barbarians with AI (such that there is) attached - what if you made a "goth" capital in an isolated island region in the west in the atlantic (using the Mr Hide map editor) or something and made that island somehow inviolable, and then scripted some regular invasions to appear in the EAST... you could have them turn up regularly to harrass you... (Wonder what problems that Island might cause...)

I do wonder if you can make new-units-for-faction, events, random... that would be interesting.

Myrddraal
12-19-2004, 21:10
Thats entirely possible. No need for an island, you make a new settlement in the middle of a big patch of inpenetrable forest. Then when the date arrives, the script (all using console commands) gives a settlement in the east to that faction (The existing factions men are automatically ousted), give that settlement loads of troops, and there you go, a new faction is born. Of course, the faction could never be officially defeated as there would be no way to kill the people in the woodland province.

And another problem would be the one I'm trying to tackle, the fact that loading a game stops the script. I've devised a way of launching a show_me automatically at the start of a campaign, but I've no idea what to do about loading.

In the meantime, the idea for running the show_me script automatically at the start of the campaign worked, but I'm having trouble getting it to start again after a saved game. There are no triggers that I can find which would launch the advisor when you load it.

But there is other good news, the game actually saves the number of turns which have elapsed, so you can save on any turn, and load on any turn, the script will pick up where you left off.

GodsPetMonkey
12-20-2004, 07:34
But there is other good news, the game actually saves the number of turns which have elapsed, so you can save on any turn, and load on any turn, the script will pick up where you left off.

Sorry to beat this dead horse, but thats been the case since I first started working on a show_me script. I'm sure I mentioned it back then too.

As for getting a script to launch when we load a game, that may have to be something that we pray CA implements in a patch. Scripting could prove to be very powerful, I'm disapointed that they haven't made any effort to help us.

Paul Peru
12-20-2004, 10:40
No, I guess this is just a research thread really. We should eventually get round to making a guide, what do you want to know?
I don't need to know anything as such, just curious. If there were a doc of all the events, commands etc, I'd have wanted to play around with some scripting. I'm probably too lazy/busy/something to reasearch all that stuff myself, though. Perhaps we could petition/nag/pester CA for some info?


Of course, the faction could never be officially defeated as there would be no way to kill the people in the woodland province.

Couldn't you just give the woodland province to the rebels after you've given the "emerging" faction the new province?

Myrddraal
12-20-2004, 16:19
Sorry to beat this dead horse, but thats been the case since I first started working on a show_me script. I'm sure I mentioned it back then too.

Oops :embarassed:

Enrique Orduno
12-21-2004, 08:40
I don't need to know anything as such, just curious. If there were a doc of all the events, commands etc, I'd have wanted to play around with some scripting. I'm probably too lazy/busy/something to reasearch all that stuff myself, though. Perhaps we could petition/nag/pester CA for some info?

Well, all the commands are available already. That's how I made the CamHack script. You need to look in the EXE (a cracked exe) and you can find anything or so...scripting commands, console commands, command line arguments, constants and about everything you need. It's all there, it's just that no one has really bothered to compile every important stuff in the exe(well I did a while ago for testing purposes, though I doubt I kept the file).

Monkwarrior
12-21-2004, 09:38
Well, all the commands are available already. That's how I made the CamHack script. You need to look in the EXE (a cracked exe) and you can find anything or so...scripting commands, console commands, command line arguments, constants and about everything you need.

~:confused:
Ehhhh, could you please explain all this stuff for ignorants as me? Or at least give an indication of a web page where it is possible to learn something about it.

(Translation: ¿podrías explicar todo este galimatías para ignorantes completos como yo? O indicar dónde podemos aprender algo acerca de esto.
Perdón por el paréntesis en español.)

INO_Exodus
12-22-2004, 02:49
Well, all the commands are available already. That's how I made the CamHack script. You need to look in the EXE (a cracked exe) and you can find anything or so...scripting commands, console commands, command line arguments, constants and about everything you need. It's all there, it's just that no one has really bothered to compile every important stuff in the exe(well I did a while ago for testing purposes, though I doubt I kept the file).


~:eek:
ALL OF THEM!? Damn! What a gold mine! I would LOVE to get my hands on those! Do you think I could get a copy via email Enrique? This could mean everthing for modders.

Paul Peru
12-22-2004, 11:08
Well, all the commands are available already. []You need to look in the EXE (a cracked exe) and you can find anything or so...scripting commands, console commands, command line arguments, constants and about everything you need.
Goodness! ~:eek:
But how, exactly, do I crack my EXE? Actually, could I booze it or pot it instead? I try to lay off the crack... :help:
Here's a thought: Some crackhead extracts the whole bucketfull and posts it somewhere. I could do some formatting and basic commenting on it if that's helpful. ~:)

INO_Exodus
12-23-2004, 05:17
.... I have a Cracked Execute file. I see what I can do. I'll get back to you guys later on it.

Enrique Orduno
12-24-2004, 22:39
Sorry for the lack of details...anyway, you need a hex editor and some patience. In the Hex Editor(I use a freeware version of Hex Workshop), run a search for a command that exists(like ScrollOpened) and you'll get other commands...About everything is in the EXE(most games are like that, though in some, it might be in a dll).

Monkwarrior
12-25-2004, 12:27
Sorry for the lack of details...anyway, you need a hex editor and some patience. In the Hex Editor(I use a freeware version of Hex Workshop), run a search for a command that exists(like ScrollOpened) and you'll get other commands...About everything is in the EXE(most games are like that, though in some, it might be in a dll).

Bufff! It seems too much complicated for me.
I am an absolute ignorant in this field.
I will wait for somebody else to do it.
Thx. :bow:

ProgrammerX
01-24-2005, 05:02
Hi im new to this site.
Im curious about this discussion.

I have a cracked exe >.< too.
I just finished copying and pasting all the "text" that is in my cracked Rome exe. Its around 500 kb of text! its a bit jumbled up since i directly copy and pasted it from a hex editor....i used Frhed....

So far it looks like it contains all kinds of commands for battle scripts,campaignes, etc.

Anyways i can send it to somebody via email or something if ya want. Just pm me.

Monkwarrior
01-26-2005, 10:54
Anyways i can send it to somebody via email or something if ya want. Just pm me.

I am interested. PM sent.
~:cheers:

Myrddraal
01-26-2005, 11:39
Have you seen this post by Khelvan (https://forums.totalwar.org/vb/showthread.php?p=679197&posted=1#post679197):

Monkwarrior
01-26-2005, 11:51
Have you seen this post by Khelvan (https://forums.totalwar.org/vb/showthread.php?p=679197&posted=1#post679197):

Yes, thanks.
I wonder if both things, cracked exe and console commands, are the same.
(sorry if this doubt seems dumm).
:bow:

Myrddraal
01-26-2005, 13:16
The second to last post contains many scripting commands, not console commands.

Crassus
01-30-2005, 18:46
Would it be possible to now get a list of the required changes to implement 4 turns a year, with any show me how limitations etc, or whatever. I have gathered that the saving problem can be solved, but is the problem with loading messing up the years/turns still around?

If we can save and load, even if show me how must be used to start the script each time we load, without other side effects, could a simple and complete tutorial be put together. I find this thread hard to follow.

Crassus

Paul Peru
02-07-2005, 17:24
Well, paint me plaid and refer to me as a filthy cataphract camel!
The CA has bestowed upon us a list of conditions and commands and a so-called scripting_manual!!!
~:cheers: :charge: ~D :balloon2: etc.

dreamweaver
02-08-2005, 04:43
First I want to tell that the short script below is created from the idea of Myrdraal ( what a name ! ) and The One ( sorry fix u later :D ) who test the Myrdraal's script and told that when set to winter then year will change .

I want to use if .. end_if rather than monitor_conditions but it don't run correctly , so I guess that the monitor_XXX is run asynchronous and give best result .
A small bug is when winter come then the year increase ? Please test .
4 SEASON SCRIPT .


script

declare_counter GameRun
declare_counter endQuarter
declare_counter hasSetSeason

set_counter endQuarter 0
set_counter GameRun I_TurnNumber ;; don't need it

;; when the event FactionTurnEnd is catched then the
;; condition FactionIsLocal is TrueCondition will be checked
monitor_event FactionTurnEnd FactionIsLocal TrueCondition
inc_counter endQuarter 1
set_counter GameRun I_TurnNumber

end_monitor

;; if don't come to the winter yet so set season is summer
;; Count from 0 to 4 so winter will be 3 .
;; we can change the number to anything :D
monitor_conditions I_CompareCounter endQuarter < 3
console_command season summer
end_monitor

;; if winter the set season to winter , if don't set it still winter
;; but year won't increase , perhap cause of season command . Will
;; fix it later
monitor_conditions I_CompareCounter endQuarter = 3
console_command season winter
;;;set_counter endQuarter 1
end_monitor
;; if counter increased over 3 we must reset counter to 0 in order it
;; can be summer
monitor_conditions I_CompareCounter endQuarter > 3
campaign_wait 1 ;; need check when remove it work or not
;; check command when over 3
;; console_command add_money 20000
set_counter endQuarter 0
end_monitor

;; don't do anything when don't have end turn . Perhap it cause the bug.
while FactionTurnEnd FalseCondition
end_while

end_script


Please check it and tell me the result .
Thanks MyDraal , I see scripting in RTW is very competing cause we don't know anything about construction of a script .

Myrddraal
02-08-2005, 17:20
This may or may not stop the script from working, but you must remember that the FactionTurnEnd is not the same as the Year ending. There is a period in which the other factions have their turn. I would change FactionTurnEnd to FactionTurnStart. Then the season is changed at the beginning of the turn. As it should be.

The year ends on the transition from winter to summer.

May I ask who wrote this script? And where is the Scripting manual, me want...

dreamweaver
02-09-2005, 08:12
The difficult in here that I don't know whether RTW support calculus operation in scripting . How about we ask the "Guy" of CA ?
If it support calculus at lease minus (- ) then the modify will be very easy . I even don't need any extra constants counter , just a temp counter use to check whether it's end year or not . That script can be modify as easy as follow :


monitor_event FactionTurnStart FactionIsLocal TrueCondition
declare_counter temp
set_counter temp I_TurnNumber
while temp > 3
set_counter temp temp - 3 ;; If it work , evrything is VERY EASY
end_while
;; After end the while , temp will be in 1 - 3 range . Sure of it :D
;; So we check the condition
if I_CompareCounter temp = 3
;; winter , do st here
end_if
if if I_CompareCounter temp < 3
;; another seasons , do st here
end_if

end_monitor



It very short and when run "advice thread " after FactionTurnStart , though the game it was be saved or not , timer always work :D
But please test whether it work or not .

And another question I want to know that the "advice thread " really run or not ?

dreamweaver
02-10-2005, 16:07
I have found a thing that could be interest you :

AdviceThread Seasons_Thread 0

If we replace the number from 1 to 0 then advice thread will run every turn .
Please anyone know email of CA coder ?

DimeBagHo
03-31-2005, 18:40
I'm trying to write a script that gives missions to other factions beside the Romans. I have three questions:

(1) Did the problem with restarting a script after reload ever get solved?
(2) Where is the scripting manual that was mentioned above?
(3) Is there a command that triggers a message?

Myrddraal
03-31-2005, 22:01
Hi DimeBagHo, and welcome to the forums. The problem of restarting a script was corrected using a roundabout way by relaunching it every time you load. Check out the several turns a year thread in the general forum for more details..

There is no scripting manual as such, just a list of commands with a few notes. Is this what you mean?

I don't think there is a command that triggers a general message, but there is a command which allocates senate missions... I think it might be a console command, I can't remember off the top of my head, but it does exist.

DimeBagHo
03-31-2005, 23:28
Thanks Myrddraal. I'm trying to set up missions for a Greek Cities mod. Unfortunately giving Senate missions to the Greeks causes a CTD (no big surprise there). I think I might be able to use the advice system to do it though.

twilight
04-13-2005, 14:00
Sorry, perhaps I missed that posting, but I was unable to locate a description of how to write and run a script. Okay, perhaps It's not here because you all know how to ;)

It seems to be a simple .txt-file and is located in data/scrips or in the campaign-folder? Can it be run in the command line itself? Or can I edit the strat-file like in the prologue, so it's executed after beginning? Because Thrace caused a ctd in my game (the problem seems to be solved) Simetrical suggested to create a script including this:

script
console_command kill_faction thrace
end_script

But how to run? I tried several things but I always get the message "err. command not recognized"

Myrddraal
04-13-2005, 14:40
Read this:
https://forums.totalwar.org/vb/showthread.php?t=44648

Contains instructions on how to run a script using a show_me script.

mark07040
07-14-2014, 01:31
okay i know this is nearly a decade after the last post but if someone still reads this coud you help me i have an error with my script and or advice thread

my advice thread:
;------------------------------------------
AdviceThread My_Script_Thread
GameArea Campaign

Item my_script_Item_1
Uninhibitable
Verbosity 0
Threshold 1
MaxRepeats 0
RepeatInterval 1
Attitude Normal
Presentation Default
Title my_script_Title_1
On_display scripts\show_me\my_script.txt
Text my_script_Text_1



;------------------------------------------

my trigger:
;------------------------------------------
Trigger my_script_trigger_1
WhenToTest ButtonPressed

Condition I_ThreadCount My_Script_Thread = 0

AdviceThread My_Script_Thread 1

;------------------------------------------
Trigger my_script_trigger_2
WhenToTest CharacterSelected

Condition I_ThreadCount My_Script_Thread = 0

AdviceThread My_Script_Thread 1

;------------------------------------------
Trigger my_script_trigger_3
WhenToTest SettlementSelected

AdviceThread My_Script_Thread 1

My script:
script
spawn_army
faction romans_julii
character Flavius Julius, general, command 0, influence 0, management 0, subterfuge 0, age 20, x 95, y 77
unit roman generals guard cavalry early, soldiers 25 exp 3 armour 1 weapon_lvl 1
unit roman hastati, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman hastati, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman hastati, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman hastati, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman hastati, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman principes, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman principes, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman principes, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman principes, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman principes, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman light cavalry, soldiers 108 exp 3 armour 1 weapon_lvl 1
unit roman light cavalry, soldiers 108 exp 3 armour 1 weapon_lvl 1
unit roman light cavalry, soldiers 108 exp 3 armour 1 weapon_lvl 1
unit roman light cavalry, soldiers 108 exp 3 armour 1 weapon_lvl 1
unit roman triarii, soldiers 162 exp 3 armour 1 weapon_lvl 1
unit roman triarii, soldiers 162 exp 3 armour 1 weapon_lvl 1
unit roman triarii, soldiers 162 exp 3 armour 1 weapon_lvl 1
unit roman velite, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman velite, soldiers 160 exp 3 armour 1 weapon_lvl 1
unit roman velite, soldiers 160 exp 3 armour 1 weapon_lvl 1
end_script



could someone help and mebay fix it for me that would be appriciated

Barbarian Axeman
09-05-2018, 00:27
Hi Did this work