View Full Version : Scripting Help!!!
Roman_Man#3
02-10-2007, 00:47
I have been trying to make a background script to spawn a legion when you train a designated legions unit, but to no avail. I managed to get show_me scripts working, but no spawn_army for either show_me or background.
script
declare_counter loop
set_counter loop 0
monitor_event UnitTrained FactionIsLocal Arretium roman_hastati
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_monitor
while I_CompareCounter loop = 0
end_while
end_script
That is my background script. I assumed that is the only thing you need for a background script. As you can see, it was only a test with units, but it CTDs with no show_err message.
Any help would be appreciated,
RM3:bow:
I assume you are familiar with ER's scripting tutorials and the docudaemon files for events, conditions, commands, and console commands.
The UnitTrained event exports faction, settlement, resource_description, and unit_category. You can use these in subsequent conditionals. However, since UnitTrained and FactionIsLocal take no parameters, "Arretium" and "roman_hastati" have no place on your monitor_event line. What you need to do is add conditions which take these as parameters. I think you want SettlementName and UnitType.
Roman_Man#3
02-10-2007, 03:00
I have read both of ER's guides, and understood it. Yet I am still not 100% sure of the lingo(altho I can spek stoopid), and have trouble understanding where certain things go. So your saying that the monitor event line would look something like this maybe?
monitor_event UnitTrained FactionIsLocal SettlementName Arretium UnitType roman hastati
An event monitor line must always contain an event followed by at least one condition. The simplest condition is TrueCondition, so you might begin with:
monitor_event UnitTrained TrueCondition
(spawn)
end_monitor
This will spawn your army when any unit is trained anywhere on the map. This isn't what you want, so you want to make your first condition more restrictive: I think you want to spawn when a unit of Hastati is trained so:
monitor_event UnitTrained UnitType roman hastati
(spawn)
end_monitor
It looks like you'd also like to restrict the spawn to when the Hastati are trained in the city of Arretium and if the player is the Julii. After the first condition, all the rest must be added with an "and", so:
monitor_event UnitTrained UnitType roman hastati
and SettlementName Arretium
and FactionType romans_julii
and FactionIsLocal
(spawn)
end_monitor
Some time ago I did something similar and my code looked very much like this.
Roman_Man#3
02-10-2007, 04:58
Thank you very much. I will test it now, and see if it works.
RM3
No, it didn't work. here is my script:
script
declare_counter loop
set_counter loop 0
monitor_event UnitTrained UnitType roman hastati
and SettlementName Arretium
and FactionType romans_julii
and FactionIsLocal
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_monitor
while I_CompareCounter loop = 0
end_while
end_script
If there is anything I should remove or add, please tell me.
And one question. Is it true that this is the only file I need for a background script?
Roman_Man#3
02-17-2007, 06:41
Can no one help me? I would love to get this to work. It would be great if a scripting god came and helped me.
I don't mean to sound whiny, but
Pleeeeeeaaaaassseee help me,
RM3
And one question. Is it true that this is the only file I need for a background script?
I'm not sure what you mean by this. You need to modify export_descr_advice.txt in order to actually launch the script. Have you done this?
Roman_Man#3
02-17-2007, 18:57
In what way would you have to modify the export_descr_advice to run a background script?
In ER's first scripting tutorial (https://forums.totalwar.org/vb/showthread.php?t=46738)it's done by adding the line in red to the Advice thread shown below:
;------------------------------------------
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\yourScriptNameHere.txt
Text Help_Campaign_Keyboard_Shortcuts_Scroll_Text_01_Text1
To run the script, you must hit the F1 key and click the "?" button on the scroll that appears. This causes the advisor to pop up; then you click the "Show me how" button on the advisor.
Roman_Man#3
02-18-2007, 03:36
YES!!!!! Thanks you atilius, it worked perfectly. Now I can start incorporating the rest of the script.
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.