View Full Version : scripting question
Ian Altano
05-22-2007, 06:13
I'm trying to make a script to spawn an army after a certain amount of turns.
(for now I tried after 2 turns)
script
monitor_event FactionTurnStart FactionType slave
and I_TurnNumber = 2
if spawn_armyA=0
spawn_army
faction macedon
character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
set_counter spawn_armyA 1
end_if
terminate_monitor
end_monitor
end_script
I put it with the rest of the scripts in the scripts/showme folder, but it does nothing.
And when I add it to descr_strat, it crashes without showing an error.
What do I have to change to make it work?
Monkwarrior
05-22-2007, 08:42
script
monitor_event FactionTurnStart FactionType slave
and I_TurnNumber = 2
if spawn_armyA=0
spawn_army
faction macedon
character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
unit levy pikemen, exp 5 armour 0 weapon_lvl 2
set_counter spawn_armyA 1
end_if
terminate_monitor
end_monitor
end_script
Some points:
- The correct synthax of the spawn_army comand is:
spawn_army
faction macedon
character Alexander, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 104, y 67
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
end
- Which type of script is this?
If it is a background script I think you need to include some loop. If not the script will be read and, as the event doesn't happen, it will be ignored.
The simplest way is to put this piece of code before the end of the script:
while I_CompareCounter loop = 0
end_while
Another method is to launch the script as a show_me script with the trigger (event) in export_descr_advice. In that case you need only the spawn_army code in the script.
Good luck!:2thumbsup:
Ian Altano
05-22-2007, 15:18
How exactly do you do the second option? :-/
Dol Guldur
05-22-2007, 17:43
There is a tutorial on scripting in the scriptorium here at the Org which shows how to do this. Perhaps, if you cannot get the tutorials to work, you may wish to post back here...
Monkwarrior
05-22-2007, 17:49
How exactly do you do the second option? :-/
Try this configuration:
export_descr_advice.txt (Data folder)
In the first part of the file (advices):
;------------------------------------------
AdviceThread Alexander_army_Thread
GameArea Campaign
Item Alexander_army_Text_01
Uninhibitable
Verbosity 0
Threshold 1
MaxRepeats 0
RepeatInterval 1
Attitude Excited
Presentation Default
Title Alexander_army_Text_01_Title
Script scripts\show_me\alexander_army.txt
Text Alexander_army_Text_01_Text1
In the second part (triggers):
;------------------------------------------
Trigger Alexander_army
WhenToTest FactionTurnStart
Condition FactionIsLocal
and I_TurnNumber = 2
AdviceThread Alexander_army_Thread 1
I don't know if you want any other conditions, as the name of the faction played by the human (for example, and not FactionType macedon)
export_advice.txt (Data/text folder)
{Alexander_army_Text_01_Title} Alexander army arrives
{Alexander_army_Text_01_Text1} Insert your explaining text here.
create a new text file named
alexander_army.txt (Data/scripts/show_me folder)
script
declare_show_me
spawn_army
"insert the correct piece of code here"
end
end_script
Good luck.:2thumbsup:
Just a quick note:
The "soldiers" parameter to spawn_army is optional. This is nice because you don't need to concern yourself with the unit scale. If you DO use the "soldiers" option, you get the specified number of soldiers in the unit regardless of whether you're playing using small, normal, large, or huge.
Monkwarrior
05-23-2007, 01:38
Just a quick note:
The "soldiers" parameter to spawn_army is optional. This is nice because you don't need to concern yourself with the unit scale. If you DO use the "soldiers" option, you get the specified number of soldiers in the unit regardless of whether you're playing using small, normal, large, or huge.
Is that right?
I didn't know. :embarassed:
I was annoyed because of that problem (fixed number of soldiers irrespective of the scale small-huge).
Thanks. :2thumbsup:
Is that right?
I didn't know. :embarassed:
I was annoyed because of that problem (fixed number of soldiers irrespective of the scale small-huge).
Yeah, I was annoyed with it too. Tried to use create_unit instead, but that has its own set of problems. Then I stumbled across some code which used spawn_army and omitted "soldiers". I figured that was wrong, but luckily I decided to test it.
Ian Altano
05-23-2007, 06:05
Thx for the help so far: when I play 2 turns now, the advisor tells me of Alexander, but when I click the ShowMeHow button, it CTDs...
Monkwarrior
05-23-2007, 08:26
Thx for the help so far: when I play 2 turns now, the advisor tells me of Alexander, but when I click the ShowMeHow button, it CTDs...
Post here exactly the script you use. Let's see if there is any mistake.:juggle2:
Ian Altano
05-23-2007, 11:06
script
declare_show_me
spawn_army
faction macedon
character Gyras, named character, command 9, influence 9, management 9, subterfuge 0, age 28, , x 86, y 97
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
unit levy pikemen, soldiers 80 exp 5 armour 0 weapon_lvl 2
end
end_script
that's it. filename alexander_army.txt
other bits of code have been implemented in the correct files, no errors there.
If you're modding vanilla RTW, there's no unit with the name "levy pikemen", you need "greek levy pikemen" or something else. Everything else looks non-toxic. As an aside, the command, management, influence, and subterfuge settings are ignored by this command for some reason.
Ian Altano
05-24-2007, 15:17
ok, that got it to work (silly mistake)
thanks for helping out guys ;)
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.