PDA

View Full Version : A Beginner's Guide to Scripting & Scripting "How To"s



Epistolary Richard
04-24-2005, 18:05
This guide was developed from the research of several members of the modding community. The research thread can be found here (https://forums.totalwar.org/vb/showthread.php?t=40178)

A BEGINNER'S GUIDE TO SCRIPTING

Scripting allows modders a way of changing the game’s mechanics in ways that are impossible by other means.

What is a script?
A script is simply a text file that contains series of commands, similar to those that can be entered into the RomeShell console.

There are two types of script, referred to as Campaign scripts and Show Me scripts.

Campaign scripts are scripts that are launched at the very beginning of a new campaign – the most famous example (and indeed the only one provided in the original game) is the Prologue script which runs throughout most of the Sons of Mars prologue campaign and controls much of the automated activity within it.

Show Me scripts are scripts that are activated by the player through the ‘Show Me How’ button on the advisor interface. They were intended to be used to help demonstrate how to do certain actions within the game, but they will run any script and can be used for the modder’s own evil purposes *bwa*ha*ha*ha* :evilgrin:

Due to limitations on Campaign scripts (they only activate at the start of campaigns and you can’t save while one is running) they have only a few uses to the modder and so by far the most common kind of modded script is the Show Me script.

The most significant limitation on the Show Me script is that they can’t be run without the player’s consent (ie, if they don’t click on the show me how button then the script will never be run). But then why the hell are they playing a scripted mod if they’re not prepared to run the scripts in the first place?

In this guide, however, we’re going to walk-through a simple Show Me script (the Mo Money script) in order to familiarise ourselves with a script’s components and terminology.

Components of a Show Me script
A Show Me script is just a text file contained within the data\scripts\show_me\ folder, however to implement a script other components are required:
- a Trigger – contained within export_descr_advice.txt
- an Advice Thread – also contained within export_descr_advice.txt
- a Script – a text file itself contained within data\scripts\show_me\ folder

The Trigger tells the game what actions or events it should be looking for evaluating whether the advisor should appear.

The Advice Thread is a control which sets the number of times a trigger can be activated and other criteria before the advisor appears.

The Script is the series of commands which are run when the player clicks on the ‘show me how’ button in the advisor’s window.

For this example we’re going to work forwards through these steps, just to illustrate the process flow. When you actually come to making your own scripts it may be easier to work backwards or forwards through the steps.

Step One – The Trigger
The triggers are contained within the bottom section of export_descr_advice.txt. There you’ll find the 1,019 triggers that come with the basic game. Most of these are entirely useless to us and so we often have to define our own. In this case, however, we’ll be using a trigger that’s already there.

;------------------------------------------
Trigger 2137_Help_Campaign_Keyboard_Shortcuts_Scroll_Trigger
WhenToTest ScrollAdviceRequested

Condition ScrollAdviceRequested help_scroll

AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread 0

This is just for your information at the moment; no adjustments need to be made as the trigger already exists. We’ll get into the technicalities of what the individual lines mean on another occasion. Suffice it to say that it should be obvious that this trigger is activated when the player clicks on the request advice button on the Help Scroll (otherwise known as the Keyboard Shortcuts scroll). This scroll can be accessed simply by pressing F1 during the game.

Trigger 2137 is very useful for testing out other components because it is slightly tucked away and therefore unlikely to be clicked during the course of play and it is completely within the player’s control. Press the request advice button once and the trigger will be activated once – so a modder can tell if the other components are working properly.

Step Two – The Advice Thread
The advice threads are contained within the top section of export_descr_advice.txt. They provide the connection between the trigger and the script that we want to run and determine whether the activation of a trigger actually results in the appearance of the advisor.

This is the normal version of the advice thread that is connected to Trigger 2137

;------------------------------------------
AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread
GameArea Campaign

Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
Again, we’ll have a look at this line-by-line on another occasion. The significant things to note here are the Advice Thread line at the top – which is how this Advice Thread is linked to the Trigger and also the Title and Text lines at the bottom which are refer to blurb contained with export_descr_advice_enums.txt.

But at the moment this advice contains no reference to a script and therefore we are going to have to add one.

This is the new version:

;------------------------------------------
AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread
GameArea Campaign

Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title
Script scripts\show_me\mo_money.txt
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
The only line we’ve added is the one that begins Script and this refers to our script text file that we are just about to place in the show_me folder.

Step Three – The Script
Create a new text file within data\scripts\show_me\ and copy and paste the following into it.

script
console_command add_money 1000
campaign_wait 5
console_command add_money 1000
end_script
Then save the file as mo_money.txt
In case it’s not obvious, when activated this script adds 1,000 denarii to the player’s treasury, will wait for 5 seconds and then add another 1,000. Big whoop, but it does make it easy to tell when the script has been activated and so again is useful for testing other components.

Congratulations, you have now installed your first script. Launch a campaign as normal, then press F1 to get to the keyboard shortcuts scroll, click on Request Advice and the advisor should appear. Click on the ‘show me how’ button and the script should run as described.

NB - the full parameter for the add_money command is:

add_money (opt:faction) (amount)
so you can also specify which faction gets the money if you wanted to make it a reward for a mission (similar to a senate mission) or to represent a general time of prosperity or donations from clients or allies in times of distress.

More Scripting How tos
How to: Toggle Perfect Spy (https://forums.totalwar.org/vb/showpost.php?p=755245&postcount=2)
How to: Create units ~ including unique units (https://forums.totalwar.org/vb/showpost.php?p=755266&postcount=3)
How to: Capture Settlements (https://forums.totalwar.org/vb/showpost.php?p=755308&postcount=4)
How to: Create Buildings (https://forums.totalwar.org/vb/showpost.php?p=755335&postcount=5)
How to: Change the Date (https://forums.totalwar.org/vb/showpost.php?p=792710&postcount=20)
How to: Spawn an Army (https://forums.totalwar.org/vb/showthread.php?p=931851#post931851)



Scripting links
Events, Conditions & Commands (https://forums.totalwar.org/vb/showthread.php?t=43121) - this is a list of all the Identifiers, Conditions and Events from files included in the RTW demo
Research: Parameters for commands & console commands (https://forums.totalwar.org/vb/showthread.php?t=46877) - an attempt to compile a definitive list of command parameters
Console commands & command line options (https://forums.totalwar.org/vb/showthread.php?t=41775) - this is a list of many possible console commands some of which can be used through scripting
Scripting research thread (https://forums.totalwar.org/vb/showthread.php?t=40178)
Hot Seat Mod - Beta Release (https://forums.totalwar.org/vb/showthread.php?t=45563&page=1)
More than two turns a year - release (https://forums.totalwar.org/vb/showthread.php?t=44648)
Client Kingdoms expansion mod (https://forums.totalwar.org/vb/showthread.php?t=46728)

Epistolary Richard
04-24-2005, 18:20
How to: Toggle Perfect Spy

toggle_perfect_spy was one of those frustrating commands that we were told could be used through the RomeShell console but it turned out that we couldn't.

Fortunately it runs perfectly well from a script. Use the below in place of the mo_money script in Step Three above.

perfect_spy.txt

script
console_command toggle_perfect_spy
end_script

This command is of great use to modders who want to observe how the AI is reacting to their changes. toggle_perfect_spy allows you to look inside each banner and settlement and look at the troop composition and characters therein. It is best used with the toggle_fow RomeShell command which lifts the shroud from the campaign map.

Epistolary Richard
04-24-2005, 18:42
How to: Create units ~ including unique units

The Client Kingdoms mod uses this in order to generate the troops the player is offered though there are many, many other uses.

Here's a sample script:

script
console_command create_unit Campus_Scythii "barb infantry briton" 4
end_script

In this case when the script is activated 4 units of the Briton Warband will be created in Campus Scythii.

It need not necessarily be a settlement, you can also use a character name. This example comes from the Prologue script.


script
console_command create_unit "Gaius Julius" "roman velite" 2
end_script

RomeShell provide these parameters:

create_unit (settlement/character_name) (unit_id) (opt: how many)(opt: exp/armour/weapon)

Here's the relevant points
- the troop description corresponds to their Type line in export_descr_unit
- character names must be in "quotes", settlements not
- double or triple-barrelled settlement names must have an _ instead of spaces
- importantly, the troops become owned by whoever controls the settlement or the character's faction, there is no need for a faction to be able to build the unit or even have ownership in export_descr_unit.

This gives us the potential to have unique units appear not just at the beginning of the game but also as it progresses as you can trigger this script based on date, the capture of a particular settlement, the construction of a building or anything else specified amongst the event identifiers.

And as no changes are needed to export_descr_unit it means that custom battles and bribery are completely unchanged.

Epistolary Richard
04-24-2005, 19:17
How to: Capture Settlements

This script ousts whatever garrison is in the settlement and gives it to the local faction (ie, the player's faction)


script
console_command capture_settlement Londinium
end_script

It can be used in conjunction with the create_unit command to provide an instant garrison loyal to the player, or equally with a negative add_money that would represent the player purchasing the settlement or sponsoring an uprising.

Because this command only gives the settlement to the player, it can't be used on the player's own settlements.

Epistolary Richard
04-24-2005, 19:40
How to: Create Buildings



script
console_command create_building Londinium muster_field
end_script

The building name is referenced from the entry export_descr_buildings.

There are no limitations on which buildings can be given to which faction - even buildings which aren't normally available (such as Royal Barracks or Amphitheatres for the Britons). You can even have duplicate buildings.

Combined with a date trigger, this allows you to build a unique building at a specific time in the game and therefore could be used for "Wonder"-like buildings.

Jason
05-02-2005, 17:48
Ok please pardon my newbishness but I have never done a mod before and I am trying out what you have outlined here in this thread.

This btw was a very well written thread and I found it very easy to understand with only one problem. It doesnt appear to work for me. Im not sure why.

I have no other mods on my system, just the vanilla game, with patch 1.2 installed.

Now as far as I can tell the problem resides in the line:

Script scripts\show_me\mo_money.txt

that is put in the advicethread portion of the file export_descr_advice.


When I install this line in the file and then save, Rome will start up, show me the first Activision screen and then promptly crash to desktop. :furious3:

When I take the line out and save it plays as normal.

I have been over the lines very carefully in an attempt to spot any typos or other stupid things that might have caused the problem and as far as I can tell I have followed your directions to the letter (litterally).

I have even gone so far as to compare my line with other Script lines in other advicethread sections to see if I messed up my syntax somewhere but to no avail.

:help:

Kraxis
05-03-2005, 02:19
Interesting, but will the change of ownership always end up in favour of the player? I was thinking along the lines of a city changing hands to another at some point (obviously early).

Epistolary Richard
05-03-2005, 08:49
Jason - I'm sorry to hear you're having problems. I've noticed that the board formatting has put a couple of spaces in between Title and Text1, but that doesn't sound like what's going wrong if just removing the script line gets it working again.

Can you use show_err (http://www.twcenter.net/forums/index.php?showtopic=28507) in your shortcut line and tell me what the error message is (if there is one)?

Kraxis - yes, it's always in favour of the player as far as I can tell but maybe there's an optional ownership parameters in there.

Meneldil
05-03-2005, 09:09
My question might sound obvious, but I'm trying to create a script that would order a AI character to attack a given settlements during AI turn, but I can't really find out what I should do. Is it a campaign or a show me script ?

Epistolary Richard
05-03-2005, 10:19
It would depend on whether or not you wanted the player to be able to save either before the script ran or while it was running. If it was something that happened at the very start of the campaign you can use a campaign script.

What you can do is what Myrddraal does with his scripts and that is use a campaign script to start a show_me script. This means that the script starts running at the beginning of a campaign without player involvement, but all the campaign script does is advance the advice thread and simulate the show_me buttons being pressed. So a second into the campaign, the campaign script has finished running and therefore the player can save. After that, the show_me script is in control and the player can save as normal.

The campaign/show_me division solely relates to how the script is initiated. Show_me scripts are then further divided into event scripts and background scripts.

The difference between the two is essentially whether the script is intended to have a single, instantaneous effect on the game (such as creating a unit or giving more money) or whether the script is designed to be constantly running in the background of the game (such as the multiple turns script).

Both rely on the player to activate them, however an event script requires player interaction on each and every occasion it wants to make a change to the game, whereas once a background script has been activated it can make lots of changes to the game without the player's approval or even knowledge.

Generally speaking, it's better to use a background script for anything that involves the AI.

Jason
05-03-2005, 15:27
Richard,

Yes I noticed the spaces the board put in your notes but after comparison with the file I saw that they werent supposed to be there so I didnt put them in. So I guess I didnt actually follow your instructions to the letter ~;)

I will try that show_err command when I get home and report back then.

Jason

Jason
05-03-2005, 19:56
Alas show_err did not give me any errors. It just simply crashes to the desktop whenever I put that script line in AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread. ~:confused:

Epistolary Richard
05-03-2005, 20:29
Hmmm... I really can't think what it might be. You are putting the mo_money.txt file in data\scripts\show_me\ and not just in data\scripts\ right? If all else fails, try referencing the advicethread to one of the scripts you get with the original game.

Jason
05-05-2005, 00:30
Yay! I found what my problem was. And this took some finding by the way.

Ok so when I made the mo_money.txt file I right clicked in the show_me folder to create a text file. I then named the file mo_money.txt

This created the problem. It confused the hell out of my poor copy of RTW because even though MS thought it was a txt file it was actually labeled improperly. Once I deleted the file, and named the new one simply mo_money and cut and pasted what was in the original post everything worked as advertised.

So all that being said Im going to go over here and hide in the corner with my stupidity. Thank you for your help and hopefully I will be able to pull of other mods with a little better success rate.

Jason

Epistolary Richard
05-05-2005, 08:13
You know what? I made exactly the same mistake once when messing around with custom tiles (https://forums.totalwar.org/vb/showthread.php?t=43149). I think our computers must be on a setting where they conceal the extension so that you actually named it mo_money.txt.txt.

Jason
05-05-2005, 17:09
Yes Im going to fix that setting really fast.

One last off the wall question. Are there lists of all the cities (maybe a map) and units and buildings somewhere online so I can try writing scripts while Im here at work waiting for everyone else to get thier acts together so I can get something done? :furious3:

Jason

Epistolary Richard
05-05-2005, 17:27
A chap named rumcajsz does rather a good line in RTW maps, try searching for his name and see if you come up with one of his links. As for units & buildings etc. you can find quite a nice unit list here (http://www.totalwar.co.kr/rome/). Of course I'm very rarely able to be with a copy of RTW so I have all the data folder's text files on a data key.

Jason
05-07-2005, 17:33
Another random question from the modding newb.

I seem to have difficulties making ports. Well that is I can make a port and the port will show up in the view with all the other city buildings but the graphic of the port never shows up on the campain map. And when ever you go to make some boats (it does in fact give you the option to do so) the game crashes. I dont seem to have this problem with any of the other buildings I make. Just ports. I even use the same line from the other buildings just cut and pasted in and then take out the building name and put in port. ex:

console_command create_building Londinium port

I am aware there is show_err and I have put this in my shortcut but it never seems to show any errors.

Also as a side note, how do you upgrade a city and its population?

Jason the Newb

LorDBulA
05-08-2005, 06:28
Also as a side note, how do you upgrade a city and its population?
I think that there is no simple way to upgrate city.
But you can try to add population with console_command add_population, and spawn apropriate Gavernor building.

Epistolary Richard
05-27-2005, 19:47
How to: Change the Date

script
console_command date -220
console_command season summer
end_script
This will change the date to summer 220BC.
Note that you'll get all the historical event messages for the events between the date you jumped from and the date you skipped to.

This command is primarily useful for people who want to skip to the Marian Reforms or change their date altogether. It is also the foundation for Myrddraal's Multiple Turns a Year mod.

Hans Kloss
05-30-2005, 15:53
Here is another quick question for Richard :

is there any way that script can be generated to speed up building process and recruiting for any settlements.So far I have managed to create units but current script only works for one character

Epistolary Richard
05-31-2005, 09:58
No, building and recruitment times are determined in export_descr_building.

Ianofsmeg16
05-31-2005, 18:53
How to: Change the Date

script
console_command date -220
console_command season summer
end_script
This will change the date to summer 220BC.
Note that you'll get all the historical event messages for the events between the date you jumped from and the date you skipped to.

This command is primarily useful for people who want to skip to the Marian Reforms or change their date altogether. It is also the foundation for Myrddraal's Multiple Turns a Year mod.
what file is this in???

Epistolary Richard
06-01-2005, 10:02
Please read the first post in this thread - see Stage Three.

Hans Kloss
07-02-2005, 20:31
Does "console_command create_unit" work for naval units too ?

I have experimented a bit but it does not seem to working

Epistolary Richard
07-02-2005, 21:56
I've never tried it, but the problem I would see with it would be where are you going to put them? Scripting tends to be very blunt, and more than likely it's trying to put them in the settlements themselves rather than in their ports. Try creating them on an existing admiral as you would do on an existing captain or family member.

Hans Kloss
07-03-2005, 10:50
I have tried geograhical location

script
console_command create_unit Athens "naval triremes" 2
end_script


and character :

script
console_command create_unit "Admiral Cassius" "naval triremes" 2
end_script

without much luck

In campaign naval units are sometimes given as reward for completion of Senate missions so there is got to be way of creating them with use of scripts at particular settelments

mike^_^
08-23-2005, 09:35
hello ~:)

I'm having trouble implementing a script, Script Error in export_descr_advice, Line 28986 , column 61 more specifically. " Advice thread increment not supplied "

I copied the samples exact, and fixed the board formatting errors.



;------------------------------------------
Trigger 2137_Help_Campaign_Keyboard_Shortcuts_Scroll_Trigger
WhenToTest ScrollAdviceRequested

Condition ScrollAdviceRequested help_scroll

AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread 0

;------------------------------------------
AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread
GameArea Campaign

Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title
Script scripts\show_me\mo_money.txt
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1


Line 28986 is in red, what's going on here?

:book:
~:confused:

mike^_^
08-23-2005, 23:31
why can't I edit my post?

anyway, the line that is getting the error is the AdviceThread string

AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread

I can't figure out what's going on.. the format is fine, it compares with the samples, and the other advice thread strings in the eda file

It says, "Advice Thread increment not supplied"

I'm really at a loss

:book:
~:confused:

LorDBulA
08-24-2005, 08:30
In campaign naval units are sometimes given as reward for completion of Senate missions so there is got to be way of creating them with use of scripts at particular settelments

If you find a way to do this please post it in this thread. I would also like to know how to do that.



I copied the samples exact, and fixed the board formatting errors.
This AdviceThread already exists, did you copy onother one or did you just edited existing one?

If you copied it then there are now two AdviceThreads with the same name and this can be a problem.

Epistolary Richard
09-23-2005, 22:40
How to: Spawn an Army

script
spawn_army
faction romans_julii
character Flavius Julius, general, command 0, influence 0, management 0, subterfuge 0, age 20, x 89, y 80
unit roman generals guard cavalry, soldiers 20 exp 9 armour 1 weapon_lvl 0
unit roman legionary first cohort ii, soldiers 40 exp 0 armour 0 weapon_lvl 0
unit roman legionary cohort ii, soldiers 60 exp 0 armour 0 weapon_lvl 0
unit roman praetorian cohort i, soldiers 60 exp 0 armour 0 weapon_lvl 0
end
end_script
If you are playing as the Julii this will create an army banner with the relevant captain/family member as you define. Most of the syntax is the same as in descr_strat, however the missing clue was the positioning of the commas after the unit names as discovered here (https://forums.totalwar.org/vb/showthread.php?t=54081)

Family members who are spawned, however, do not appear to join that faction's family tree.

edyzmedieval
09-24-2005, 09:18
Excellent guide Richard. Thanks for gathering all the info! ~:cheers:

PatWest
09-28-2005, 23:04
How to: Spawn an Army

script
spawn_army
faction romans_julii
character Flavius Julius, general, command 0, influence 0, management 0, subterfuge 0, age 20, x 89, y 80
unit roman generals guard cavalry, soldiers 20 exp 9 armour 1 weapon_lvl 0
unit roman legionary first cohort ii, soldiers 40 exp 0 armour 0 weapon_lvl 0
unit roman legionary cohort ii, soldiers 60 exp 0 armour 0 weapon_lvl 0
unit roman praetorian cohort i, soldiers 60 exp 0 armour 0 weapon_lvl 0
end
end_script
If you are playing as the Julii this will create an army banner with the relevant captain/family member as you define. Most of the syntax is the same as in descr_strat, however the missing clue was the positioning of the commas after the unit names as discovered here (https://forums.totalwar.org/vb/showthread.php?t=54081)

Family members who are spawned, however, do not appear to join that faction's family tree.
Do you know if this can be randomized like the Marian Reforms? How would you set the date for the event if possible?

CCFC
12-01-2005, 20:05
im trying to spawn an army but im lost what must i change in the advice thread for the spawn army not the mo money. im a noob modder ~:)

Meneldil
12-04-2005, 19:59
Hum, another issue there. I'm trying to make a simple campaing map perfect spy script.

I edited export descr advice (both in the data and bi/data)

;------------------------------------------
AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread
GameArea Campaign

Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title
Script scripts\show_me\spy.txt
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1

I added the spy.txt file in the correct folder (in fact, since I wasn't sure where to put it, I made a spy.txt for data/scripts/show_me/ and one for bi/data/scripts/show_me/

The campaign works fine, but if I press F1 and click on the advice button ('?'), the advisor appears, but the game freezes.
Any idea about what's going on ?

Monkwarrior
12-04-2005, 21:07
@Meneldil

I think that your problem is in the script. Something similar happened also to me when there were errors in the script.
It would be better if you post it here, or look for the help of the "scripting Gods".~D

Meneldil
12-04-2005, 21:41
Well, I don't think so actually.
With BI, the shortcut advisor apparently doesn't work (there are commas that prevent the script from working) : if you click on the advice button, nothing will happen.
I deleted the commas, both before the trigger and before the advisor thread, and I did not add any script. I launched the campaign, and clicked on '?' in the shortcut panel, and the game stopped aswell.

Edit : Oddly, the script will work with another advisor help request command.

LestaT
02-09-2006, 09:00
I have a little (though annoying problem) regaring this script. Maybe I did it wrong way but here it goes.

In my Imperator mod, I added the spawn army script to make Phyrrus army reappeared in summer 275 BC. I edited base on the 4TPY script. Everything goes fine, the years came and the army 'arrived' and I had another great but difficult battle with the Greeks when I thought that Phyrrus has finally been banished from Italy.

The problem came after the event has passed. Everytime I restarted the game, after save and reloading, everytime I started the 4TPY script the army reappears , even when the Greek Cities has been eliminated. Didn't cause CTD or anything, and the game can goes on with no problem at all (except the battle with Phyrrus with his elephant army again... )

Do note however, this only happened 'after' restarting the game If reload a save game from already on going game this 'bug' wont appear. What I always did is reload again and the spawn thing didn't appear anymore.

I'm at lost....

Epistolary Richard
02-11-2006, 09:46
Are you using a background script or an event script?

Post the bits of your scripting files relevant to this event and we'll have a look.

LestaT
02-12-2006, 15:38
script

while I_TurnNumber < 1840
select_ui_element advisor_dismiss_button
simulate_mouse_click lclick_down
simulate_mouse_click lclick_up

suspend_unscripted_advice true

;;;;;;;; spawn_army ;;;;;;
declare_counter spawn_army

if I_TurnNumber = 0
set_counter spawn_armyA 0
set_counter spawn_armyB 0
set_counter spawn_armyC 0
set_counter spawn_armyD 0
end_if

;;;;;;;; spawn_army ;;;;;;
monitor_event FactionTurnStart FactionType greek_cities
and I_TurnNumber > 21

if spawn_armyA = 0

spawn_army
faction greek_cities
character Pyrrhus of Epirus, named character, command 3, influence 1, management 1, subterfuge 0, age 38, , x 112, y 67
unit greek general's guard cavalry exp 1 armour 0 weapon_lvl 0
unit epirote pikemen exp 2 armour 0 weapon_lvl 0
unit epirote pikemen exp 1 armour 0 weapon_lvl 0
unit greek medium cavalry exp 0 armour 0 weapon_lvl 0
unit greek hoplite exp 2 armour 0 weapon_lvl 0
unit greek hoplite exp 1 armour 0 weapon_lvl 0
unit greek hoplite exp 2 armour 0 weapon_lvl 0
unit greek hoplite exp 1 armour 0 weapon_lvl 0
unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
unit aor greece thessalian cavalry exp 1 armour 0 weapon_lvl 0
unit merc rhodian slingers exp 1 armour 0 weapon_lvl 0
unit merc cretan archers exp 1 armour 0 weapon_lvl 0
unit merc elephants exp 1 armour 0 weapon_lvl 0
unit greek hoplite militia exp 0 armour 1 weapon_lvl 0
unit merc rhodian slingers exp 1 armour 0 weapon_lvl 0
unit merc cretan archers exp 1 armour 0 weapon_lvl 0
set_counter spawn_armyA 1
end_if

terminate_monitor
end_monitor

monitor_event FactionTurnStart FactionType carthage
and I_TurnNumber > 138

if spawn_armyB = 0

spawn_army
faction carthage
character Himilcar Barca, general, command 5, influence 5, management 0, subterfuge 3, age 40, x 96, y 47
unit carthaginian general's cavalry exp 1 armour 0 weapon_lvl 0
unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit libyan spearmen exp 2 armour 1 weapon_lvl 1
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit aor spain infantry exp 2 armour 1 weapon_lvl 1
unit aor spain infantry exp 1 armour 0 weapon_lvl 0
unit aor spain infantry exp 1 armour 0 weapon_lvl 0
unit aor spain infantry exp 1 armour 0 weapon_lvl 0
unit aor spain infantry exp 1 armour 0 weapon_lvl 0
unit merc balearic slingers exp 2 armour 0 weapon_lvl 0
unit merc balearic slingers exp 2 armour 0 weapon_lvl 0
unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
unit merc numidian cavalry exp 2 armour 0 weapon_lvl 0
unit merc numidian cavalry exp 2 armour 0 weapon_lvl 0
unit carthaginian elephant forest exp 0 armour 0 weapon_lvl 0
unit carthaginian elephant forest exp 0 armour 0 weapon_lvl 0
set_counter spawn_armyB 1
end_if

terminate_monitor
end_monitor

monitor_event FactionTurnStart FactionType gauls
and I_TurnNumber > 177

if spawn_armyC = 0

spawn_army
faction gauls
character Dumnorix of Bibrax, general, command 5, influence 0, management 0, subterfuge 0, age 20, , x 89, y 91
unit barb chieftain cavalry gaul exp 1 armour 0 weapon_lvl 0
unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
unit barb infantry gaul exp 0 armour 0 weapon_lvl 0
unit barb infantry gaul exp 1 armour 0 weapon_lvl 0
unit barb peltast gaul exp 1 armour 0 weapon_lvl 0
unit barb peltast gaul exp 1 armour 0 weapon_lvl 0
unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
unit gaul gothic hev inf exp 3 armour 0 weapon_lvl 0
unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
unit barb cavalry gaul exp 3 armour 0 weapon_lvl 0
set_counter spawn_armyC 1
end_if

terminate_monitor
end_monitor

monitor_event FactionTurnStart FactionType carthage
and I_TurnNumber > 249

if spawn_armyD = 0

spawn_army
faction carthage
character Hannibal Barca, general, command 6, influence 5, management 0, subterfuge 3, age 40, x 89, y 91
unit carthaginian general's cavalry exp 1 armour 0 weapon_lvl 0
unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
unit carthaginian sacred band infantry exp 3 armour 1 weapon_lvl 1
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit libyan spearmen exp 2 armour 1 weapon_lvl 1
unit libyan spearmen exp 1 armour 0 weapon_lvl 0
unit aor spain infantry exp 2 armour 1 weapon_lvl 1
unit aor spain infantry exp 1 armour 1 weapon_lvl 0
unit aor spain infantry exp 1 armour 1 weapon_lvl 0
unit aor spain infantry exp 1 armour 1 weapon_lvl 0
unit aor spain infantry exp 1 armour 1 weapon_lvl 0
unit merc balearic slingers exp 2 armour 1 weapon_lvl 1
unit merc balearic slingers exp 2 armour 1 weapon_lvl 1
unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
unit aor spain cavalry exp 2 armour 0 weapon_lvl 0
unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
unit merc numidian cavalry exp 2 armour 1 weapon_lvl 1
unit carthaginian elephant forest exp 1 armour 0 weapon_lvl 0
set_counter spawn_armyD 1
end_if

terminate_monitor
end_monitor

;;;;;;;;;;;;;;; 4 TPY ;;;;;;;;;;;;;;;;

console_command date -280
console_command season summer
declare_counter Season_Year_Turn0_Thread
while I_TurnNumber = 0
monitor_conditions I_CompareCounter Season_Year_Turn0_Thread = 0
if I_CompareCounter Season_Year_Turn0_Thread = 0
advance_advice_thread Season_Year_Turn0_Thread
inc_counter Season_Year_Turn0_Thread 1
end_if
end_monitor
suspend_unscripted_advice true
end_while

console_command date -280
console_command season summer
declare_counter Season_Year_Turn1_Thread
while I_TurnNumber = 1
monitor_conditions I_CompareCounter Season_Year_Turn1_Thread = 0
if I_CompareCounter Season_Year_Turn1_Thread = 0
advance_advice_thread Season_Year_Turn1_Thread
inc_counter Season_Year_Turn1_Thread 1
end_if
end_monitor
suspend_unscripted_advice true
end_while

Back to my earlier question, I think I solved the first part Phyrrus (no respawned second time) , but the rest keeps respawning.. :wall: everytime I reload the game (restart the game). But if then I hit ESC , reload again, start the 4TPY script and it's gone.

Note: I mod it base on the 4TPY script by Marcus Camillus (from RTR.org)

Monkwarrior
02-12-2006, 18:20
Back to my earlier question, I think I solved the first part Phyrrus (no respawned second time) , but the rest keeps respawning.. :wall: everytime I reload the game (restart the game). But if then I hit ESC , reload again, start the 4TPY script and it's gone.

This is because you cannot launch a second time a script if you don't exit the game. When you reload without restarting, the script simply doesn't launch (at least this happened to me).

LestaT
02-13-2006, 03:43
That could be. It's just that I think the first spawn army script is correct, so they only spwan once in 275BC.

But I'm not sure about the rest of the script. Maybe somebody can help me correct it.:help:

Atilius
02-14-2006, 09:30
LestaT,

I don't know much about scripting, though I'm trying to learn about it. I am a software engineer though, and I see some problems with your script based purely on programming principles.




;;;;;;;; spawn_army ;;;;;;
declare_counter spawn_army

if I_TurnNumber = 0
set_counter spawn_armyA 0
set_counter spawn_armyB 0
set_counter spawn_armyC 0
set_counter spawn_armyD 0
end_if

You've declared a counter named spawn_army but you don't use it. You actually use spawn_armyA, spawn_armyB, spawn_armyC, and spawn_armyD, but you haven't declared them as counters.

I'm pretty sure that the counter values are only preserved while your script is being executed, so they ought to be assigned a value before they are used. Your script only does this if I_TurnNumber = 0.

It also doesn't look to me like you need any of your counters. I'd suggest you get rid of everything you posted in red and change


;;;;;;;; spawn_army ;;;;;;
monitor_event FactionTurnStart FactionType greek_cities
and I_TurnNumber > 21

to


;;;;;;;; spawn_army ;;;;;;
monitor_event FactionTurnStart FactionType greek_cities
and I_TurnNumber = 21

You should do likewise for your other spawns.

Shouldn't your Gauls show up about 10 years later for Telamon in 225 BC?

Monkwarrior
02-14-2006, 13:15
There are several mistakes in the script. The correct syntax will depend on your idea about the events:
- Do you want the spawning armies to appear in a specific date or only from a given year (in a randomly chosen date)?
- Do you want the armies to spawn only once in game?
- Do you want the armies to spawn at the same time?

Just to test the syntax, you can prepare a short script that would allow one army to spawn in one early date (let's say turn number 2).

Several advices:
- You must declare all the counters used along the script: declare_counter spawn_armyA, etc.
- If the army must appear when the counter is zero, you must use the command: I_CompareCounter spawn_armyA = 0 (see the docudemon files).
Put it as part of the monitor_event
- Once the army appears, you must change the counter, either setting the value or increasing one unit: set_counter spawn_armyA 1

In any case, if the army is going to appear only once in a given date, forget the counter and set just the turn number.
If the armies appear in different turns (with a given order), you can use only one counter, and put in the event the different values (for army A, I_CompareCounter spawn_armyA = 0; for army B, I_CompareCounter spawn_armyA = 1; etc).

Good luck with the script.:2thumbsup:

LestaT
02-14-2006, 14:34
- Do you want the spawning armies to appear in a specific date or only from a given year (in a randomly chosen date)?
- Do you want the armies to spawn only once in game?
- Do you want the armies to spawn at the same time?

To these questions , my idea is to spawn the army only once at a specific date, for instance the first Greek army (Phyrrus) on summer 275 BC. I've restested my script (without editing from the frist spawn (in 275) to the second (in 246) and it works both times. The only this is if I save the game and reload. The second spawn (hamilcar in Sicily) keeps respawning every time I load the game and so the third one (Gaul) in 236 ..(not quite sure the date , but something like that.. ) :furious3:


Just to test the syntax, you can prepare a short script that would allow one army to spawn in one early date (let's say turn number 2).

Several advices:
- You must declare all the counters used along the script: declare_counter spawn_armyA, etc.
- If the army must appear when the counter is zero, you must use the command: I_CompareCounter spawn_armyA = 0 (see the docudemon files).
Put it as part of the monitor_event
- Once the army appears, you must change the counter, either setting the value or increasing one unit: set_counter spawn_armyA 1

Actually I tried to read the docudemon file .. but coun't make any sense of it. :juggle2: Might be because of my poor command of English or my zero knowledge about codes / pc scripts etc.. :sweatdrop:


In any case, if the army is going to appear only once in a given date, forget the counter and set just the turn number.
If the armies appear in different turns (with a given order), you can use only one counter, and put in the event the different values (for army A, I_CompareCounter spawn_armyA = 0; for army B, I_CompareCounter spawn_armyA = 1; etc).

Guess this is what I'm gonna do. Thanks for the advice and I'm gonna see how it works. Just a quick question, will the script take any effect in middel of campaign ? Or will have to restart a new one ?

Caius
10-17-2006, 19:12
ok.

I explain what im trying to do.I am making a autosave script for RTW 1.5.Yes, there is a feature of autosave, but it is damaged or something that makes a CTD when you click the end turn.
So, I believe if I create a autosave script, this script will fix the problem.
Now, How can I create a script of end turn?

Atilius
10-18-2006, 01:24
Do you see the problem you mention with Autosave in an un-modded game? Autosave (or a manual save) will crash if you've made a mistake character names. I suspect this or some other mod-related change is your real problem.

Caius
10-18-2006, 18:56
Do you see the problem you mention with Autosave in an un-modded game? Autosave (or a manual save) will crash if you've made a mistake character names. I suspect this or some other mod-related change is your real problem.
It is the imperial campaign un-modded.
I'm not the only who haves the same problem

Parenti's Child
10-21-2006, 02:15
tried using the example script for mo_money but that particular section of the txt seems to be disabled in patch 1.5. Tried using the advice thread for the settlements list again no joy.

I'm trying to get force_diplomacy to work so I can play around with that in the early game if anyone has any help they could give I'd love to click their 'show me how' button.

:dizzy2:

Atilius
10-21-2006, 04:13
tried using the example script for mo_money but that particular section of the txt seems to be disabled in patch 1.5.

Just copied and pasted the mo_money code snippet into an existing script of mine and it worked as expected in 1.5. I'd guess you have a problem in the triggering mechanism. The "show me how" button on the advisor should be dark (un-ghosted) until you click it. Is this what you see?

Parenti's Child
10-21-2006, 05:14
that's the problem. For some reason the request advice button in the shortcuts screen doesn't even bring up the advisor.

kungfuserge
11-28-2006, 08:49
Hello:yes: I never mod before but I already can switch side for historical battle; Can you help me with that : How do I make the opposite side (AI) wait for the ennemy (me) .the AI rushes all the time and is not supposed to do so, so the battle turn crazy. I don't know the script and where (which folder) it goes;
many thanks

Tombstone
02-10-2007, 03:19
The "show me how" button on the advisor should be dark (un-ghosted) until you click it. Is this what you see?

Please explain "Dark" and "Ghosted/Un-Ghosted", and how this corresponds to 'greyed-out' vs. 'active'.

I (as far as I can tell) did everything correctly according to Richard's instructions. My problem is; The "Show Me How" button is greyed out and un-clickable.

I reset the advisor in the options, as well as changing the Advice Level to 'High', but the Show Me How button is still greyed out (and now that snotty wench pops up to tell me everything she's told me once before already).

I'm trying to do the force_diplomacy accept thing. Here's my files:

data\export_descr_advice.txt:

;------------------------------------------
AdviceThread Help_Campaign_Keyboard_Shortcuts_Scroll_Thread
GameArea Campaign

Item Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Title
Script scripts\show_me\forcedip.txt
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1

data\scripts\show me\forcedip.txt:

script

command_console force_diplomacy accept

end_script

Now, I added this script while in the middle of an Imperial Campaign, and I'm just wondering if that's the problem...

On another subject;

Where does this game hide the Targas? I've looked for them everywhere. There are data files that refer to them, but the targas themselves don't appear to exist anywhere. Like "roman_official_ancillary.tga" for example.

Atilius
02-10-2007, 05:16
Please explain "Dark" and "Ghosted/Un-Ghosted", and how this corresponds to 'greyed-out' vs. 'active'.
Dark, Un-Ghosted=active
Ghosted=greyed-out

Your export_descr_advice.txt looks OK.

As for the script, you have



command_console force_diplomacy accept


This should be



console_command force_diplomacy accept




Where does this game hide the Targas?

You need to unpack the files in the packs folder. There's a link to Vercingetorix's xpak in this post (https://forums.totalwar.org/vb/showpost.php?p=702976&postcount=1). Usage info here (https://forums.totalwar.org/vb/showpost.php?p=643512&postcount=4).

Ossie The Great
02-27-2007, 14:46
hi
can i have help please.......... i am trying to make a script which adds a building to a settlement on a specific date. please help :thinking2: :grin:

Ossie The Great
02-27-2007, 18:12
hi
i am having trouble activating the script. i tried pressing f1 and clicking on the question mark but the show me button is just greyed out, the same happens if i pree esc and then question mark ...... please help

Dol Guldur
02-27-2007, 18:29
The above tutorials did not work for me - try putting your script inside an existing script file (then deleting the old text) and using that advice thread to activate it. In other words, do not change anything but the contents of the script file you choose.

Moros
08-01-2007, 18:45
Okay I'm a newby when it comes to scripts but I'm trying to learn.
When I just tried doing the simpelist of things I got a bug I can't explain.



if not I_LocalFaction romans_senate
console_command add_money romans_senate, 30000
end_if


This is the part of the script it's all about, it's the first thee lines of a campaignscript called by the descr_strat. Show_err gives this:
error in balablabla/imperial campaign/campaign_script line 3 collumn something
Don't understand this token: "end_if".

Atilius
08-03-2007, 04:29
The first line of a script must be "script", and you should also conclude with "end_script". Try


script
if not I_LocalFaction romans_senate
console_command add_money romans_senate, 30000
end_if
end_script

Moros
08-04-2007, 19:59
Does a campaign script loaded form the Descr_strat also need script at the start? The EB one for example doesn't...
I did have end_script though.

EDIT:
Same error message though. ~:dizzy:

Atilius
08-05-2007, 06:18
Does a campaign script loaded form the Descr_strat also need script at the start?No, that's a bit different. In that case the "script" command actually appears in descr_strat.txt. You should have something like this at the end:


script
campaign_script.txt

Sorry Moros, I don't see what the problem is, and as you're probably aware, the code looks very familiar.

Moros
08-05-2007, 14:15
Yes I know. It looks familiar. You gotta learn it and start with something simple and something you can compare, no? Also I have it like you have in the descr_strat.txt, that's why I had no script in the script itself.

This is wierd, I guess I'll just restart completely maybe that'll help. Thanks for the help though!

Red Spot
08-08-2007, 08:31
kinda new to the TW scripting and more into M2 at the moment, but try this ...



if FactionType romans_senate


G

Atilius
08-08-2007, 19:11
No, Moros wishes to give this faction money only if it isn't controlled by the player. Substituting FactionType for I_LocalFaction won't make this distinction.

Red Spot
08-08-2007, 21:33
yep, thats what I'm refering to, afaik you're not refering to a faction with just "[faction]", but need to use "FactionType [faction]".

anyway thats what the docudemon files make me believe ...:book:


G

Atilius
08-09-2007, 03:19
No. Here's the docudemon entry:


---------------------------------------------------
Identifier: I_LocalFaction
Trigger requirements:
Parameters: faction
Sample use: I_LocalFaction romans_julii
Description: Is the faction the local faction?
Battle or Strat: Either
Class: I_LOCAL_FACTION
Implemented: Yes
Author: Guy

In fact, the FactionType condition has a trigger requirement, so it's not useful in this situation.

The thing is, this expression:


if not I_LocalFaction romans_julii
console_command add_money romans_julii, 30000
end_if

is used in EB. I just tested it to make sure, and it's working.

Red Spot
08-09-2007, 16:57
that'll teach me only reading 1/2 the stuff in the docudemon files ... :sweatdrop:

I just read about this one ....

Identifier: FactionType
Trigger requirements: faction
Parameters: faction type
Sample use: FactionType romans_julii
Description: Test the faction type


Thanks for the correction ..;)
(I was under the impression the I_LocalFaction flag was one without variables)


G

Hannibal Smith
04-09-2008, 19:24
Hi just read the tutorial, great work. Its making me think I can add some features to my mod project I'd given up on. I have managed to get a mo money and a kill character script working.

My only question is, a show-me script that runs in the background was mentioned earlier in the thread how can I construct one of these?

Also it was mentioned that a show-me script could be activated by a campaign script again how?

Thanks:laugh4:

Hannibal Smith
04-09-2008, 21:39
OK may have worked out part of it myself Ive manage to create a loop in the script so it continues to run. Only I have made a new problem for myself :laugh4:
What I'm trying to do is create a backgroung script which will trigger certain events ant certain dates. So I experimented with add_money because I could easily see what was going on. my script is as follows.

script

declare_counter mo_money

set_counter mo_money 0

while I_TurnNumber < 5

if I_TurnNumber = 3
and mo_money < 1

console_command add_money 1000

set_counter mo_money 1
end_if

end_while

end_script

I added the mo_money counter in an effort to make it happen only once on that turn. However when I get to turn three, the money just keeps going up.

:help:

Makanyane
04-10-2008, 06:26
think your check of the counter is wrong try:

and I_CompareCounter mo_money < 1

Dol Guldur
04-10-2008, 16:45
Now here's a question no one will know the answer to :laugh4:

When using the kill character command the game assumes the character to have died in battle - is there a way to do it so that it is categorized as a peaceful death? I appreciate that I could change the textual description but I would rather keep it if possible so that it draws a distinction...Thx.

Hannibal Smith
04-10-2008, 17:00
Thanks Makanyane,
thats the second time you've bailled me out when I've made a stupid mistake :laugh4:

Sorry, but Ive got another question. Ive tested out the script and works fine now, however when I save the game and reload the script wont work. I figured I'd have to reload the script using show-me how but even then it does nothing

Bardo
04-17-2008, 20:53
Yes, the only way to relaunch the script after reloading the game is to use the show-me button.
Depending on how did you implement the script and the show-me advice to launch it, sometimes it is not possible to reactivate the script until you restart the game. At least it happens to me, I'm not sure if other scripts have the same problem...

Monkwarrior
04-18-2008, 12:10
Yes, the only way to relaunch the script after reloading the game is to use the show-me button.
Depending on how did you implement the script and the show-me advice to launch it, sometimes it is not possible to reactivate the script until you restart the game. At least it happens to me, I'm not sure if other scripts have the same problem...
AFAIK you cannot launch another script (for example in another campaign) or even the same script starting the same campaign with another faction, if you don't restart the game.

Bardo
04-19-2008, 10:11
Europa Barbarorum used a workarround in his previous version, that I have been using for long time, but I do not really recomend it since it is possible to duplicate the actived scripts, and after many tested, I still do not know how it acts exactly.
The method is simple, just introduce the whole script inside a while loop. Then it is always possible to relaunch the script without exiting the game. But I recomend always to restart the game before starting a new campaign, as Monkwarrior said.

HouseOfHam
04-24-2008, 19:45
After looking at some historical battle scripts, I thought I'd do a little experimenting with the play_sound_event command. I added a bunch of new events to descr_sounds_narration.txt, plus the mp3s for them. It seems to work in the most basic form, but I ran into some strange behavior when trying to add a counter condition to the monitor.

This works fine:


monitor_event SettlementSelected SettlementName Rome
play_sound_event RomeSelected
end_monitor


This also works:


declare_counter PlaySpeech
set_counter PlaySpeech 1

monitor_event SettlementSelected SettlementName Rome
and I_CompareCounter PlaySpeech = 1
play_sound_event RomeSelected
end_monitor


This produces a "Sound event TEUTOBURG_SPEECH_00 not found." error when closing the game.


declare_counter PlaySpeech
;don't initialize or initilize to something other than 1
;set_counter PlaySpeech 1

monitor_event SettlementSelected SettlementName Rome
and I_CompareCounter PlaySpeech = 1
play_sound_event RomeSelected
end_monitor


Ideally, rather than having them always on, I'd like to let the player toggle them on/off at any time, something along the lines of:



declare_counter PlaySpeech

monitor_event ScrollAdviceRequested ScrollOpened helpScroll
if I_CompareCounter PlaySpeech = 0
set_counter PlaySpeech 1
end_if
if I_CompareCounter PlaySpeech = 1
set_counter PlaySpeech 0
end_if
end_event

monitor_event SettlementSelected SettlementName Rome
and I_CompareCounter PlaySpeech = 1
console_command
play_sound_event RomeSelected
end_monitor


Any thoughts?

HouseOfHam
04-24-2008, 20:01
Err... "Sound event RomeSelected not found."

Bardo
04-24-2008, 20:55
Did you try to initialize the counter in this lastest case?


declare_counter PlaySpeech
set_counter PlaySpeech 0

monitor_event ScrollAdviceRequested ScrollOpened helpScroll
if I_CompareCounter PlaySpeech = 0
set_counter PlaySpeech 1
end_if
if I_CompareCounter PlaySpeech = 1
set_counter PlaySpeech 0
end_if
end_event

monitor_event SettlementSelected SettlementName Rome
and I_CompareCounter PlaySpeech = 1
play_sound_event RomeSelected
end_monitor

HouseOfHam
04-24-2008, 21:36
Yes, but that makes no difference anyways. It's initialized to 0 by default.

Chloe
06-26-2008, 18:06
Hi, Richard, I read your great guide, but still have a few questions. :help:
I made a script to spawn an army, but I do not know where to save it in the game files. Here it is:

script

monitor_event FactionTurnStart FactionType parthia
and I_TurnNumber = 2

if spawn_armyA=0

spawn_army
faction parthia
character Thuxra, named character, command 5, influence 5, management 3, subterfuge 2, age 38, , x 256, y 80
ancillaries galloper
unit hillmen, exp 5 armour 0 weapon_lvl 2
unit hillmen, exp 5 armour 0 weapon_lvl 2
unit east camel cataphract, exp 5 armour 0 weapon_lvl 2
unit east camel cataphract, exp 5 armour 0 weapon_lvl 0
unit east onager, exp 4 armour 0 weapon_lvl 0
unit eastern archers, exp 4 armour 0 weapon_lvl 0
unit eastern archers, exp 4 armour 0 weapon_lvl 0
unit eastern archers, exp 4 armour 0 weapon_lvl 0
unit east slinger, exp 3 armour 0 weapon_lvl 0
unit east slinger, exp 3 armour 0 weapon_lvl 0
unit east slinger, exp 3 armour 0 weapon_lvl 0
unit east archer, exp 3 armour 0 weapon_lvl 0
unit east heavy cataphract, exp 3 armour 0 weapon_lvl 0
unit east heavy cataphract, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
unit east infantry, exp 3 armour 0 weapon_lvl 0
set_counter spawn_armyA 1
end_if


terminate_monitor
end_monitor
end_script

anelious phyros
06-26-2008, 22:35
I think it's data/scripts, also here's another guide that might help you -
How to:Script spawn... (http://www.twcenter.net/forums/showthread.php?goto=newpost&t=88608)

Dovlex
06-27-2008, 14:05
Do anyone know a solution to make the enemy AI army, to do as you wants it to? Like scripting, creating a historical battle etc etc. Maybe some editor program (like Caligula & Hadrian) wich make script for you, Is this possible?

Dovlex
06-27-2008, 14:16
This files are from folder Data\world\maps\battle\custom\"Gergovia"
1 - bookmarks.rcb
2 - map.rbm
3 - map.wfc
4 - descr_battle.txt
5 - descr_script.txt
6 - description.txt

This is from same folder but my map

1- bookmarks.rcb
2- map.wfc
3- descr_battle.txt
4- editor_log.txt

How to make descr_script for battle map? What program i must use for this?
I use Battle editor to make battles, there is no tool to make command for AI. :book:

Squid
06-27-2008, 15:15
Any old text editor will do.

Spizania
07-05-2008, 21:39
This might seem silly, but does a counter endure when the game is restarted, or do they have to be redefined each time the game is started? Ie. can they be used to store information through a game restart?

Aradan
07-06-2008, 08:06
No, they can't store info.

Squid
07-07-2008, 00:54
What some mods do to preserve the information, is they have a character who gets traits that correspond to the values of counters in the script. This is quite difficult, as the character has to be placed in a location that can't be reached so it can't interact with the rest of the game. It also has to be a specific character (not just any character) so the character name is known for the various script commands that refer to a character (i.e. spawn, give_trait, etc). This is also used in combination with an unreachable settlement where specific buildings can be built to signify the storing of specific script information.

JoristhePagan
05-17-2009, 17:58
Is it possible to remove random units from an army if it reaches a certain point/region? (In RTW, no expansion)
And if this is not possible, can you add an army to the slave and make it attack the army (and disappear afterwards)

Makanyane
05-17-2009, 18:37
Is it possible to remove random units from an army if it reaches a certain point/region? (In RTW, no expansion) not that I know of


And if this is not possible, can you add an army to the slave and make it attack the army (and disappear afterwards)
you can spawn a slave army - you can't make it attack unless you know the name of the general of the other army (which is unlikely) - but if you spawn it close to area and its big enough it probably will attack.

Don't think you can make it disappear exactly - if its leader is still alive after battle you could try using the move character commands to send it off somewhere else... beware of using the non console_command move commands if you don't know if character is alive, trying to apply the other types of commands to a non-existent character can make game CTD

if you know name of leader you can kill him and hence his bodyguard but I don't know of any way of killing other units by script.

JoristhePagan
05-17-2009, 20:10
Ok thanks, I'll have to find another way.

JoristhePagan
05-18-2009, 08:15
Here's a new idea: Can I make the rebel general invulnerable? that way, I could easily make the army is destroyed and then move it to a save location.

lim_lucky
12-31-2009, 18:10
I seem to have a wierd problem with the following code:



declare_counter aedui_age
set_counter aedui_age 11

;AI - console_command date -300 (BC)
monitor_event FactionTurnStart Factiontype gauls
and not I_LocalFaction gauls
and I_CompareCounter aedui_age >= 10
and I_TurnNumber > 1
set_counter aedui_age 12
terminate_monitor
end_monitor

monitor_event SettlementTurnStart SettlementName Burdigala
and I_SettlementOwner Burdigala = gauls
and I_CompareCounter aedui_age = 12
and not SettlementBuildingExists = agee2
console_command set_building_health Burdigala agee 0
console_command create_building Burdigala "agee2"
end_monitor


When I am using the faction gauls, the building will be created properly in the settlement.
The problem only occurs when I am not using the faction gauls, whereby the game will always crash when the turn for the AI faction gauls start after clicking the end turn.
I initially thought that it may not be possible to create buildings for AI factions... but the code below worked, in which the building agee1 is lower in the hierarchy than agee2 in EDB. So I'm not really sure why the code causes the game to crash and not work as expected.



declare_counter aedui_age
set_counter aedui_age 11

;AI - console_command date -300 (BC)
monitor_event FactionTurnStart Factiontype gauls
and not I_LocalFaction gauls
and I_CompareCounter aedui_age >= 10
and I_TurnNumber > 1
set_counter aedui_age 11
terminate_monitor
end_monitor

monitor_event SettlementTurnStart SettlementName Burdigala
and I_SettlementOwner Burdigala = gauls
and I_CompareCounter aedui_age = 11
and not SettlementBuildingExists = agee1
console_command set_building_health Burdigala agee 0
console_command create_building Burdigala "agee1"
end_monitor


Next, I tried working around the crash by inserting one additional line to building creation code as shown below. The game did not crash like before, but the building agee2 failed to be created. Then I tested it out with agee6 and it worked only for a certain settlement, i.e. rest of the settlements do not have the building agee6 created despite the code being executed.



monitor_event SettlementTurnStart SettlementName Burdigala
and I_SettlementOwner Burdigala = gauls
and I_CompareCounter aedui_age = 12
and not SettlementBuildingExists = agee2
console_command set_building_health Burdigala agee 0
console_command create_building Burdigala "agee1"
console_command create_building Burdigala "agee2"
end_monitor


The building levels are as follows:
building agee
{
levels agee1 agee2 agee3 agee4 agee5 agee6 agee7 agee8
{
...

lim_lucky
01-01-2010, 08:21
Next, I tried working around the crash by inserting one additional line to building creation code as shown below. The game did not crash like before, but the building agee2 failed to be created. Then I tested it out with agee6 and it worked only for a certain settlement, i.e. rest of the settlements do not have the building agee6 created despite the code being executed.
...

The additional line did not prevent the crashes, instead, it seems like that the game crashed only for some factions. Does someone have any advice? I have tried using factions { all, } in EDB but game still crashed.

Makanyane
01-02-2010, 22:28
have you tried it without the

console_command set_building_health Burdigala agee 0

line? that doesn't actually destroy the building just damages it 100%
when you add new building from script it gives settlement both buildings, despite fact they are in same tree. So maybe AI's attempt to repair old building at same time as getting new building is what is causing problem?

Do you have enough spare building trees to split them up to prevent weirdness in the same tree?

If its not that and its only related to certain factions / cultures check for missing EB texts for certain factions, or if its related to Carthaginian new building problem.

lim_lucky
01-07-2010, 10:17
have you tried it without the
console_command set_building_health Burdigala agee 0

line? that doesn't actually destroy the building just damages it 100%.

when you add new building from script it gives settlement both buildings, despite fact they are in same tree. So maybe AI's attempt to repair old building at same time as getting new building is what is causing problem?

I doubt this is the problem. The reason for setting the health to 0 is not to confuse the players - for easy identification to destroy old building. And the script works fine with it because I see the building gets damaged 100%. The problem comes with the building agee2 not being created, whereas agee6 works fine but only for one settlement.
Of course I did check that the console_command is being executed, but the building is simply not built.



If its not that and its only related to certain factions / cultures check for missing EB texts for certain factions, or if its related to Carthaginian new building problem.

Its not the Carthaginian new building problem because I have already commented it out (;) in the DESCR_UI_BUILDINGS.txt.

As for the missing EB texts, I believe it may be the reason which cause it to crash. But I'm testing the script using another barbarian faction to avoid the crash problem.



Do you have enough spare building trees to split them up to prevent weirdness in the same tree?

Thank you very much for the advice.
I think I may have to abandon my script for setting the AI reforms/age and try presetting them using the starting campaign script. I plan to maximize the use of all 64 building trees, so I doubt I will split up the current building tree unless I'm really out of ideas for buildings.

Aulus Caecina Severus
02-16-2010, 11:46
What I've to do for use script during battle?
For example: I want always disable guard mode during battle.

I know there is a decudemon command that switch off guard mode..
For activate script I can use that "help key scroll" (? in F1)..
But, how implemented it correctly?

Mike555
04-22-2010, 23:06
Am,guys,I have a little question:how to make a script,which able/disable recruting units by building foundrys,palaces etc. ?

Myrddraal
04-26-2010, 15:04
Hi Mike, this has nothing to do with scripting. If you want to edit buildings easily, I would suggest these editors:
https://forums.totalwar.org/vb/showthread.php?38858-Tools-Unit-and-Building-Editors-Caligula-amp-Hadrian

Mike555
04-27-2010, 15:26
Oh,someone is live here:beam: I know how to edit buildings.I want make reforms like Marium by script.I want make some units recrutible after buildind, lets say, four foundrys...

Myrddraal
04-27-2010, 22:00
Yeah, the RTW modding forums are a lot quieter these days, but if you want an answer to a question, your best bet is to ask in the Modding Questions forum. This forum is technically for tutorials only. I'm afraid I'm not sure how to do what you want (it's been a while since I played/modded Rome myself), but I would suggest re-posting your question as a new thread in the Modding Questions sub-forum.

Mike555
04-27-2010, 22:46
OK,thanks.

bobob306
01-04-2015, 01:31
This is terrible but, I can't seem to make the initial tutorial on the first post, its odd using show_err i get no errors and i reckon i've followed the instructions to the letter (having gone over them like 100 times) i'm running vista if that makes a difference and its a clean 1.5 install