-
A Beginner's Guide to Scripting & Scripting "How To"s
This guide was developed from the research of several members of the modding community. The research thread can be found here
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.
Code:
;------------------------------------------
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
Code:
;------------------------------------------
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:
Code:
;------------------------------------------
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.
Code:
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:
Code:
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
How to: Create units ~ including unique units
How to: Capture Settlements
How to: Create Buildings
How to: Change the Date
How to: Spawn an Army
Scripting links
Events, Conditions & Commands - this is a list of all the Identifiers, Conditions and Events from files included in the RTW demo
Research: Parameters for commands & console commands - an attempt to compile a definitive list of command parameters
Console commands & command line options - this is a list of many possible console commands some of which can be used through scripting
Scripting research thread
Hot Seat Mod - Beta Release
More than two turns a year - release
Client Kingdoms expansion mod
-
How to: Toggle Perfect Spy
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
Code:
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.
-
How to: Create units ~ including unique units
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:
Code:
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.
Code:
script
console_command create_unit "Gaius Julius" "roman velite" 2
end_script
RomeShell provide these parameters:
Code:
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.
-
How to: Capture Settlements
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)
Code:
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.
-
How to: Create Buildings
How to: Create Buildings
Code:
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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).
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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 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.
-
Re : A Beginner's Guide to Scripting & Scripting "How To"s
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 ?
-
Re: Re : A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
You know what? I made exactly the same mistake once when messing around with custom tiles. I think our computers must be on a setting where they conceal the extension so that you actually named it mo_money.txt.txt.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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. 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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
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.
-
How to: Change the Date
How to: Change the Date
Code:
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
No, building and recruitment times are determined in export_descr_building.
-
Re: How to: Change the Date
Quote:
Originally Posted by Epistolary Richard
How to: Change the Date
Code:
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???
-
Re: How to: Change the Date
Please read the first post in this thread - see Stage Three.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Does "console_command create_unit" work for naval units too ?
I have experimented a bit but it does not seem to working
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
Code:
;------------------------------------------
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
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.
Quote:
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.
-
How to: spawn an army
How to: Spawn an Army
Code:
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
Family members who are spawned, however, do not appear to join that faction's family tree.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Excellent guide Richard. Thanks for gathering all the info! ~:cheers:
-
Re: How to: spawn an army
Quote:
Originally Posted by Epistolary Richard
How to: Spawn an Army
Code:
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
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?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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 ~:)
-
Re : A Beginner's Guide to Scripting & Scripting "How To"s
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)
Quote:
;------------------------------------------
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 ?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
@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
-
Re : A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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....
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
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)
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by LestaT
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).
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
Code:
;;;;;;;; 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
Code:
;;;;;;;; spawn_army ;;;;;;
monitor_event FactionTurnStart FactionType greek_cities
and I_TurnNumber > 21
to
Code:
;;;;;;;; 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?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
- 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:
Quote:
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:
Quote:
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 ?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Atilius
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Parenti's Child
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?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
that's the problem. For some reason the request advice button in the shortcuts screen doesn't even bring up the advisor.
-
Re : A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Atilius
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:
Code:
;------------------------------------------
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:
Code:
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Tombstone
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
Code:
command_console force_diplomacy accept
This should be
Code:
console_command force_diplomacy accept
Quote:
Originally Posted by Tombstone
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. Usage info here.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
Quote:
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".
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
The first line of a script must be "script", and you should also conclude with "end_script". Try
Code:
script
if not I_LocalFaction romans_senate
console_command add_money romans_senate, 30000
end_if
end_script
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Moros
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:
Code:
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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!
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
kinda new to the TW scripting and more into M2 at the moment, but try this ...
Code:
if FactionType romans_senate
G
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
No. Here's the docudemon entry:
Code:
---------------------------------------------------
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:
Code:
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
that'll teach me only reading 1/2 the stuff in the docudemon files ... :sweatdrop:
I just read about this one ....
Code:
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
think your check of the counter is wrong try:
and I_CompareCounter mo_money < 1
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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...
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Quote:
Originally Posted by Bardo
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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:
Code:
monitor_event SettlementSelected SettlementName Rome
play_sound_event RomeSelected
end_monitor
This also works:
Code:
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.
Code:
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:
Code:
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?
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Err... "Sound event RomeSelected not found."
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Did you try to initialize the counter in this lastest case?
Quote:
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
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
Yes, but that makes no difference anyways. It's initialized to 0 by default.
-
Re: A Beginner's Guide to Scripting & Scripting "How To"s
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