Log in

View Full Version : Creative Assembly Some modest results with spawn_army



Dromikaites
09-16-2005, 09:19
Unfortunately it's not good news yet but I've managed to figure out some of the correct syntax. Maybe somebody else would pick up from here, maybe Jerome Grasdyke form CA would give us a hint ;) or maybe I'll find out more in the future.

So here is what I've done and the results I've got so far:

I started with the recommended syntax:


spawn_army
faction romans_julii
character Foedus Chaerea, 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

I knew already that unit was not recognized, so my first test was with this structure:

spawn_army
faction romans_julii
character Foedus Chaerea, general, command 0, influence 0, management 0, subterfuge 0, age 20, , x 89, y 80
end

The game started but Foedus wasn't anywhere to be seen (the coordinates should have made him show up at the crossroad west of Arretium). I closed the game to see the error message and it said that faction is an unrecognized token. Which means the "official" syntax is incorrect also about faction, not only about unit. Even knowing what doesn't work is a step forward ;)

At that moment I realised that the first goal should be to identify what tokens/keywords does that command accept. I removed faction from the structure of the command making it:

spawn_army
romans_julii
character Foedus Chaerea, general, command 0, influence 0, management 0, subterfuge 0, age 20, , x 89, y 80
end

The game loaded again with no Foedus on the map. The error message after closing the program was telling me that end is also an unrecognized token.
However romans_julii and character Foedus Chaerea, general, command 0, influence 0, management 0, were parsed and accepted as valid.

Next logical step was to remove end and see what happens. I expected of course problems because there was no way the computer would know what units should go into Foedus' stack.

The game progressed as far as the end of the loading bar but then crashed to desktop without of an error message. Now this was actually good news, because crashing at the end of the loading bar without an error message means the computer had actually tried to put Foedus on the map. So I turned to the descr_strat.txt to take a closer look at the syntax used there for putting troops on the map.

Here is a sample for Julii:


character Flavius Julius, named character, leader, command 0, influence 0, management 0, subterfuge 0, age 47, , x 89, y 82
traits GoodCommander 2, NaturalMilitarySkill 1, GoodDefender 1, PoliticsSkill 3, GoodAdministrator 2, Austere 1
ancillaries aged_retainer
army
unit roman generals guard cavalry early exp 1 armour 0 weapon_lvl 0
unit roman hastati exp 1 armour 0 weapon_lvl 0
unit roman hastati exp 1 armour 0 weapon_lvl 0
unit roman triarii exp 1 armour 0 weapon_lvl 0
unit roman archer exp 1 armour 0 weapon_lvl 0


and here is one for the rebles:


character, sub_faction carthage, Gelon, general, command 0, influence 0, management 0, subterfuge 0, age 20, , x 96, y 19
army
unit carthaginian city militia exp 1 armour 0 weapon_lvl 0
unit carthaginian city militia exp 1 armour 0 weapon_lvl 0


I notticed that in both cases the parser that handles descr_strat doesn't need the keyword "end" at the end of the army list. It probably uses the keywords character, character_record or a blank line in order to decide when the army list ends. Also I've noticed the army keyword at the begining of the army list.

My new test was with this structure:


script

spawn_army
romans_julii
character character Foedus Chaerea, general, command 0, influence 0, management 0, subterfuge 0, age 20, , x 89, y 80
army
unit roman generals guard cavalry early exp 1 armour 0 weapon_lvl 0
unit roman hastati exp 1 armour 0 weapon_lvl 0
unit roman hastati exp 1 armour 0 weapon_lvl 0
unit roman triarii exp 1 armour 0 weapon_lvl 0
unit roman archer exp 1 armour 0 weapon_lvl 0

end_script


Of course I was expecting unit to return error, but the purpose was to see if army is accepted or not. The game loaded, Foedus was nowhere and after closing RTW the error message said that unit was not recognized. Which means that army is an accepted keyword for the spawn_army command.

I think this discovery is important for two reasons:
1) It's an undocumented feature, unknown to the modding comunity till now (as far as I can tell);
2) The fact the undocumented token is accepted makes me think that probably the command is operational but we don't know the right syntax for it.

The next structure tried was:

script

spawn_army
romans_julii
character character Foedus Chaerea, general, command 0, influence 0, management 0, subterfuge 0, age 20, , x 89, y 80
army
roman generals guard cavalry early exp 1 armour 0 weapon_lvl 0
roman hastati exp 1 armour 0 weapon_lvl 0
roman hastati exp 1 armour 0 weapon_lvl 0
roman triarii exp 1 armour 0 weapon_lvl 0
roman archer exp 1 armour 0 weapon_lvl 0

end_script


which allowed the game to load but upon exit showed that roman is an unrecognized token. It was kind of what I was expecting because the units are either refered to like unit roman generals guard cavalry early (keyword unit in front, descr_strat.txt style) or "roman generals guard cavalry early" (with quotes, like in console_command create_unit "Gaius Julius" "roman generals guard cavalry early") and I haven't used any of those forms.

Putting in quotes the units' names also didn't help. Then I thought that maybe the command would look up the units in some table based on their rank, so i replaced the whole unit lines with numbers. The numbers themselves were considered unrecognized tokens.

To summarize, we know now that:
1) faction names are accepted;
2) army is accepted;
3) end and unit are not accepted;
4) unit names are not accepted neither with nor without quotes;
5) numbers instead of unit names seem not to work either
6) the game does try to put the army on the map if the command contains only accepted tokens/keywords but crashes because so far we don't know how to add units. So what we need to research now is the accepted encoding for units for this command.

I'll keep trying various formats for coding the units. Maybe Jerome Grasdyke would be kind enough to point us in the right direction.

Edit:
After some more testing I discovered that traits is accepted but ancillaries not

Dol Guldur
09-16-2005, 10:10
Good research Drom!


Can spawn_army be used outside of a "show me" script?

Dromikaites
09-16-2005, 13:22
Good research Drom!


Can spawn_army be used outside of a "show me" script?
I'm testing it as a campaign script: the last lines of descr_strat.txt point to the file containing the the script. This way it saves testing time: if something is wrong, the game CTDs quicker than in case of a show-me script.

The_Mark
09-16-2005, 15:36
Beautiful job, Drom!

We too have played with the spawn_army command, but with no considerable results. If the syntax of the command could be cracked it'd make us all very happy modders.

Jerome, any interest in throwing us a bone here? Please? Pretty please?

Dromikaites
09-16-2005, 17:45
Beautiful job, Drom!

We too have played with the spawn_army command, but with no considerable results. If the syntax of the command could be cracked it'd make us all very happy modders.

Jerome, any interest in throwing us a bone here? Please? Pretty please?

The fact it does parsing and that recognisez "undocumented" tokens like army makes me think it is there and operational. It also accepts arguments being passed to it by the script files (at least the faction name, the character name, the traits). So it means it has to accept other arguments, as long as they are in the right format.

The worst case scenario is it has been transformed in "do nothing" by some other piece of code. In which case it would accept the right arguments, report no error and...do nothing. Like the "bribery" trait (I'm sure you guys at EB have already discovered it's useless even if given to diplomats).

However, if I know enough about programmers' behavior, "spawn_army" is a very useful function for making bandits pop up so I doubt they wrote 2 distinct pieces of code, one this we are trying to activate and another one that spawns the rebels. It would be possible but not likely.

I've also noticed something else some months ago but at that time I wasn't interested in modding. Yet now I realized it might also point in the direction of a functioning "spawn_army" command.

The thing I've discovered then was that a rejected candiate to the hand of one of the daughters was sometimes showing up full of rage, at the head of a stack of rebels. That has happened too often to be just a coincidence that the names were randomly generated twice: once for the suitor and once for the rebel named character.

To me it looks like there might be a function that generates a list of suitors. If one guy is rejected, his name becomes eligible for "spawn_army". As we can see from the descr_rebel_factions.txt, those armies are ready-made, just waiting for a general to lead 'em. Not all the rebel armies are led by a named character in-game (family member), even though they field general's bodyguard units. So the function which spawns bandits probably takes the standard rebel army and places it under the named character.

Another thing about the rebel armies: they are listed in reverse order (general bodyguards last in the list) compared to the descr_strat.txt. This makes me think that maybe the order of the params coding the units is also important.

Stuie
09-16-2005, 19:26
Wow - this is an excellent start at cracking the spawn_army code. I have a couple ideas I can try out this weekend... will report back with any decent findings.

Dromikaites
09-16-2005, 19:40
Wow - this is an excellent start at cracking the spawn_army code. I have a couple ideas I can try out this weekend... will report back with any decent findings.

Please report back any attempts, as even errors are important.

Dromikaites
09-19-2005, 20:21
Hi!

Some more tests with negative results. Still they're worth reporting so other people know what was tried already (helps saving time).

I tried feeding the names of those mercenary units that are offered as rewards by the Senate ("you will be given an exotic unit"). My assumption is they are hardcoded because they seem to be always the same. Here is the list:
merc barbarian cavalry

merc numidian cavalry

merc barbarian infantry

merc greek hoplites

merc rhodian slingers

merc sarmatian cavalry

merc horse archers

merc elephants

merc bastarnae


Unfortunately they don't work (error report: "unrecognized token merc"). Maybe only rebels can be spawn? Jerome, please help!!!!

SigniferOne
09-19-2005, 20:58
Maybe try with underscores instead of spaces, i.e. merc_numidian_cavalry, or else try to find some other identifiers for those units that are a single word. Clearly the game gets caught up by the fact that there's more than one word in the identifier, i.e. 1) merc 2) numidian 3) cavalry (because in the error, it shows you that it sees, and does not understand only the first word). Therefore, try to find ways in which to pass that unit in as a ONE word. If this is a general problem for the game to find it hard to process identifiers that consist of multiple words, then there MUST be a description somewhere where a single word is also assigned to the same army, OR it is assumed by convention that the multiple-word identifier is equivalent to some single-word version. Usually, in RTW, this means that

"word1 word2" = "word1_word2"

JeromeGrasdyke
09-20-2005, 13:57
Hm, have you guys ever seen the docudemon output for the scripting language? I believe I've mentioned it before, but it's these three text files... they're a bit long so i'm not going to quote them, but these are the file names:

docudemon_commands.txt
docudemon_conditions.txt
docudemon_events.txt

edyzmedieval
09-20-2005, 14:07
Thanks for throwing us a magic wand, Jerome.

And excellent Dromikaites. Romanians rule!!! ~D

The_Mark
09-20-2005, 14:16
Nice to see you here, Jerome :bow:

Yes, they are our holy documents, we have a whole thread dedicated to them here (https://forums.totalwar.org/vb/showthread.php?t=43121), pretty much everything we use is from those. The problem is that they seem to be outdated, so there are quite a lot of commands that don't work for us, e.g. the spawn_army command.

Stuie
09-20-2005, 14:37
Nice to see you here, Jerome :bow:

Yes, they are our holy documents, we have a whole thread dedicated to them here (https://forums.totalwar.org/vb/showthread.php?t=43121), pretty much everything we use is from those. The problem is that they seem to be outdated, so there are quite a lot of commands that don't work for us, e.g. the spawn_army command.

Problem is, we're working off the ones that came with the demo. I don't think anyone has found them (if they exist) in the final release.

If some nice developer were to release them... I'm sure we could pool our money for a case of lager or something as a reward. ~;)

~:cheers:

JeromeGrasdyke
09-20-2005, 14:55
Ok, i've had a quick look at spawn_army for you... the syntax you worked out above is essentially correct -- the command expects a sequence of "unit" commands followed by unit id's as phrases ... the following should work:

spawn_army
faction romans_julii
character Foedus Chaerea, 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

The reason why unit and end appeared not to be recognised was because the data after and before (respectively) were incomplete.

This error is typical; understanding the Rome descr parser could have helped some. Essentially it works by parsing Words, which are letter sequences ended by whitespace, Phrases, which are word sequences ended by comma's, and Lines, which are word and phrase sequences ended by newline characters. In this case, there had to be a phrase terminator (comma) after the unit id, because otherwise the parser couldn't know where the unit id ends as a unit id is a phrase - a sequence of arbitrary words.

This is why some identifiers in the game use underscores and others not - internally some things are typed as Words and others as Phrases. If you look out for this kind of pattern it may help you spot wrongly-formed scripts... I'll see about getting you guys some docudemon files up-to-date for Barbarian Invasion.

Dromikaites
09-20-2005, 14:58
Yes, I can confirm that Jerome's sintax works!

https://img333.imageshack.us/img333/1570/firstarmyspawnever7vo.jpg (https://imageshack.us)
Thank you very much, Jerome!

JeromeGrasdyke
09-20-2005, 15:02
I gave the correct syntax above... look for the comma's ~;)

SigniferOne
09-20-2005, 15:07
Trying the new syntax with the commas, right now.


EDIT: Success! The syntax works just as Jerome said ~D

~:cheers:

The_Mark
09-20-2005, 15:21
Beautiful.. Simply beautiful. Thank you, Jerome, we are ever in debt to you :bow:

I have one question about this phrase parser, would the SettlementName condition check a multi-word settlement name if it was fed into the command as a phrase? It's a curious problem we have faced, as having a settlement name with two words, separated by whitespace, cannot be checked with the condition. We're even more curious about why the SettlementName condition checks the external name of the settlement, as opposed to the internal tag.. but that's not relevant right now.

Dromikaites
09-20-2005, 15:28
The spawned army of Captain Kaeso:https://img333.imageshack.us/img333/1570/firstarmyspawnever7vo.jpg (https://imageshack.us)

Lord Adherbal
09-20-2005, 15:41
wow great, this is gonna be VERY usefull. Thanks for your attention once again Jerome

edyzmedieval
09-20-2005, 15:50
Yeees!!!!

The Turks can finally spawn their army, before attacking Constantinople.
All hail King Jerome!!!!

Epistolary Richard
09-20-2005, 16:11
*swears blindly*

Especial thanks for this one, Jerome. We're still saving up for the performing telegram bearing flowers and chocolate for Guy to tell us why there isn't an 'or' operator, but we'll see what we can do.

Any light you can shed on the below that we've also not been able to get working would be appreciated:

play_video Sample use: play_video fmv/rome_intro.mpg
provoke_rebellion Sample use: provoke_rebellion Segesta
call_object_shortcut Sample use: call_object_shortcut strat_ui speedup_ai - will toggle the fast ai mode

LorDBulA
09-20-2005, 16:29
JeromeGrasdyke thank you. :bow:
As always we apriciate your help.

Now thanks to you we can add money to AI faction.

syntax:

console_command add_money faction, how_much

Thanks again Jerome, this is HUGE help for us. ~:cheers:

JeromeGrasdyke
09-20-2005, 17:38
Any light you can shed on the below that we've also not been able to get working would be appreciated:

play_video Sample use: play_video fmv/rome_intro.mpg
provoke_rebellion Sample use: provoke_rebellion Segesta
call_object_shortcut Sample use: call_object_shortcut strat_ui speedup_ai - will toggle the fast ai mode

play_video is unimplemented in code... sorry about that
provoke_rebellion should work, it takes a Phrase which is matched worldwide to a settlement name and should cause a rebellion in that settlement on the next end-of-turn
call_object_shortcut should work as well, it is used to trigger various pieces of the UI by name; it takes a ui object name and then a ui piece name, both of which are Words... this goes through the tutorial assistant, so there is a chance it will be non-functional outside the prologue

The_Mark
09-20-2005, 17:45
Just occurred to me that the thread title should probably be changed :smile:

Jerome, would you happen to have any idea if a destroy_building command will be included in BI?

LorDBulA
09-20-2005, 18:10
Sorry wrong topic :embarassed:

Dol Guldur
09-20-2005, 18:28
Just to clarify (I have not turned my mind to scripts as of yet)...

Can I have an event in-game which spawns an army? OR must I get the player of the mod to go click the "show me" button? Could I have an event which tells him to click the said button so he at least knows what is going on?

The replication of the senate's "rewards" (but with different units and different circumstances(i.e. not from the senate)) would be nice.

Dromikaites
09-20-2005, 18:44
Just to clarify (I have not turned my mind to scripts as of yet)...

Can I have an event in-game which spawns an army? OR must I get the player of the mod to go click the "show me" button? Could I have an event which tells him to click the said button so he at least knows what is going on?

The replication of the senate's "rewards" (but with different units and different circumstances(i.e. not from the senate)) would be nice.

You can probably use Epistolary Richard's excellent code form his "Client Kingdoms" mod.

The_Mark
09-20-2005, 18:52
An advisor/event script ala CK is a viable choice, if the script used fits into a single event. The other choice is a background script, that the player has to activate every time the game is loaded, but that can be used to do much more complex scripts, as the script runs all the time in the background.

Stuie
09-20-2005, 21:58
I'll see about getting you guys some docudemon files up-to-date for Barbarian Invasion.

:medievalcheers:
~:cheers:

Thanks Jerome!!

Vegas_Bear
09-20-2005, 22:17
Will someone be making a small tutorial on how this is done. ie. which files to put the script into. Kinda new to this. Thnx

Apollodotus
09-21-2005, 00:06
This seems to work with "named character" too.

ararax
09-21-2005, 01:00
JEROME YOU ARE THE MAN!
/me throws away months of trial and error

Myrddraal
09-23-2005, 21:02
BTW, I have used call_object_shortcut before and it works fine

Epistolary Richard
09-23-2005, 22:45
Will someone be making a small tutorial on how this is done. ie. which files to put the script into. Kinda new to this. Thnx

I've incorporated it into my Beginner guide to scripting:
https://forums.totalwar.org/vb/showthread.php?t=46738

Read the first post through fully, that'll tell you how to set up a script, then you can read the specific entry for spawn_army at the top of the second page.

(And if someone with a working copy of RTW wouldn't mind checking my syntax is correct before I look stupid I'd appreciate it :beam: )

Argiod
09-25-2005, 23:09
A suitor scorned becomes a rebel... sounds about right to me. I tend to get fighting mad when I can't get the lady I'm after, too... LOL

alpaca
09-27-2005, 14:36
If anyone gets any CTDs with this and can't figure why, this might be an explanation:
The name of the character must be included in descr_names.txt for the specified faction.

Stuie
05-03-2006, 21:47
provoke_rebellion should work, it takes a Phrase which is matched worldwide to a settlement name and should cause a rebellion in that settlement on the next end-of-turn

Has anyone gotten this to work?

rorarii
05-04-2006, 13:19
I' m sure someone got this to work in RTW awhile ago on the twcenter site.

Legatus_Legionis
05-04-2006, 13:28
Hi rorarii,

Do you mean this?


script
declare_counter loop
set_counter loop 0

monitor_event FactionTurnStart empire_east
and I_TurnNumber = 1

if I_SettlementOwner Alexandria = empire_east
provoke_rebellion Alexandria
end_if
terminate_monitor
end_monitor

while I_CompareCounter loop = 0
end_while
end_script

From here http://www.twcenter.net/forums/showthread.php?t=41981&highlight=provoke_rebellion

I'm going this now....

Cheers

Legatus_Legionis
05-04-2006, 14:03
Hmm, that code doesn't seem to work or variations of it, at least not in B.I :wall:

Anyone had success with provoke_rebellion in B.I ? - Personally i don't think it works...:furious3:

spurs_dan21
03-24-2007, 01:22
any way of applying a date onto the end of spawn_army maybe making for example:

spawn_army summer_184BC
etc...

This would be way better than clicking to activate a new script every time.

Atilius
03-24-2007, 01:37
No.

But you can do what you want by running a background script which executes a spawn on the desired turn.

tai4ji2x
06-27-2007, 10:09
has anyone been able to spawn an actual family member who gets a place on the family tree? so far, all i've been able to spawn are generals.