-
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: