Log in

View Full Version : Help with scripting for my Alexandros mod



Lusted
09-19-2006, 21:13
I've had several ideas for scripts for my Alexandros mod and i'd like to know if they are feasible and doable, as scripting is perhpas the only major area of RTw modding i've got no friggin clue about.

-Firstly, i wonder if it is possible to have a script that gives the player a certain amount of money when they take Susa, which was the Persian treasury to reflect the monetray boos tthis gave to Alexander. How would i go about doing this?

-Secondly, is it possible to have a script that once Thebes and Athens are taken give the player the option of accpeting money and troops from Greek cities and make an alliance between the greeks and macedon/give all the Greek cities to macedon at once. If the plaer clicks no they will have to cnquer the cities themselves.

Epistolary Richard
09-20-2006, 00:00
Yes, they both sound possible.

If this is all you want then I would recommend using event scripts rather than a background script - as it would mean the player would only have to do anything when the event occurred rather than every time they reloaded the game.

First off read the Beginner Guide to Scripting (https://forums.totalwar.org/vb/showthread.php?t=46738).

For an event script you need three things-
- 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

For the Susa event this is the sort of thing you would start off with:

The script (Susa_event.txt) would be straightforward:


script
console_command add_money 1000
end_script

The Advice thread would look something like this:


;------------------------------------------
AdviceThread Susa_event_Thread
GameArea Campaign

Item Susa_event_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Susa_event_Text_01_Title
Script scripts\show_me\Susa_event.txt
Text Susa_event_Text_01_Text1
Note that you would have add entries into text/export_advice.txt to make the new text appear. The text would read something like "Would you like to receive lots of money? Click the show me how button to accept."

And the trigger would look something like this:


;------------------------------------------
Trigger Susa_event_Trigger
WhenToTest GeneralCaptureSettlement

Condition CharacterIsLocal
and FactionType macedon
and SettlementName Susa

AdviceThread Susa_event_Thread 0

Now, this will work so long as Susa is captured by an army led by a general and not a captain. There's a workaround for this which I can go into if you want.


The second one is more complicated:

Similar advice thread:


;------------------------------------------
AdviceThread Capture_Greece_Thread
GameArea Campaign

Item Capture_Greece_Text_01
Uninhibitable
Verbosity 0
Threshold 1
Attitude Normal
Presentation Default
Title Capture_Greece_Text_01_Title
Script scripts\show_me\Capture_Greece.txt
Text Capture_Greece_Text_01_Text1

You'd want two different triggers:


;------------------------------------------
Trigger Capture_Greece_Athens_Trigger
WhenToTest GeneralCaptureSettlement

Condition CharacterIsLocal
and FactionType macedon
and SettlementName Athens
and I_SettlementOwner Thebes = macedon

AdviceThread Capture_Greece_Thread 0

;------------------------------------------
Trigger Capture_Greece_Thebes_Trigger
WhenToTest GeneralCaptureSettlement

Condition CharacterIsLocal
and FactionType macedon
and SettlementName Thebes
and I_SettlementOwner Athens = macedon

AdviceThread Capture_Greece_Thread 0

And the script (Capture_Greece.txt) would be:



script
console_command add_money 1000
console_command create_unit Athens "greek hoplite" 2
console_command create_unit Thebes "greek hoplite" 2
console_command diplomatic_stance macedon greek_cities allied
end_script


This would be the basics and it should all work, it's not completely foolproof or polished though and savvy/goldfish brain players can either exploit it or miss the benefits completely and the AI can break the alliance - but there are ways to offset that and to do some of the alternate things you suggested if you want to get more complicated.

Lusted
09-20-2006, 00:15
Thank you for your help on this.

Im gonna have a 12tpy script running as well, so should i include these 2 events in it, or have them as event scripts so the message pops up? And would my other idea for the greece capture script work, eg where thebes and athens get captured and all greek cities become macedon. Could you also add in yearly tribute to the capture greece script. And i don't mind if the Greeks break the alliance, they came close to doing so several times in history.

Epistolary Richard
09-20-2006, 08:42
If you want lasting effects then a background script would be best. You'd add this above your 12 turn script.



; Susa event
monitor_event GeneralCaptureSettlement CharacterIsLocal
and FactionType macedon
and SettlementName Susa

console_command add_money 5000

terminate_monitor
end_monitor


; Turnly tribute
monitor_event FactionTurnStart FactionIsLocal
and FactionType macedon
and I_SettlementOwner Thebes = macedon
and I_SettlementOwner Athens = macedon
and DiplomaticStanceFromFaction greek_cities = allied

console_command add_money 10

terminate_monitor
end_monitor

If you want to give the player the choice with the Capture_Greece event then you'll probably want to use an event script - though it can be integrated in the background script with some trouble.


Yes, you can give the other settlements to Macedon using the capture_settlement console command, however it would ejected their garrisons so you'd end up with a lot of Greek armies (or rebel if the faction has been destroyed) around the place.

Lusted
09-20-2006, 11:30
So if i give players the choice with the greece event, it will be difficult to implement tribute then?

Epistolary Richard
09-20-2006, 18:45
No, you put the choice element (including alliance/capturing cities) in the event script and you put the tribute in the background script.

Lusted
09-21-2006, 00:12
And it would only work as long as the greek cities and macedon are allied, which the event script would do(begins to understand more). I think ill do the Susa in the background script(dont want to give the player the option of saying no), and have the greek cities thing as even script and background script.

Bardo
09-27-2006, 17:29
Now, this will work so long as Susa is captured by an army led by a general and not a captain. There's a workaround for this which I can go into if you want.

Please, Epistolary Richard, could you explain this workaround. I thought that "GeneralCaptureSettlement" worked also with Captains.
Thanks

Epistolary Richard
09-27-2006, 19:02
No, it only works for family members as it was designed to be used for traits.

The work around is to use a CharacterTurnStart or SettlementTurnStart event with a I_SettlementOwner conditional for that settlement. Easy to start, but it's hard to stop it triggering on subsequent turns (terminate_monitor will not stop it triggering when you reload the game) - you can block it either by using having the script place a blocker building and adding a SettlementBuildingExists condition (TFT does this) - or by using a trait that is added through the traits file and which subsequently blocks the monitor triggering again (I believe EB does this, maybe RG as well).

Bardo
09-27-2006, 20:05
Thank you a lot for the fast answer.
About "terminate_monitor will not stop it triggering when you reload the game" issue, the idea of using traits/buildings to save information before reloads is great, and this reminds me a related question:
Do you know if someone has checked the "GameReloaded" event. Has somebody been able to use this event succesfully?
I was thinking if it could be used to detect when you reload a game, and maybe, we could use it to relaunch a background script.

Epistolary Richard
09-27-2006, 21:01
It got added in 1.5, I think. But I've never tested it. It couldn't be used to relaunch a script, but it might be able to be used to prompt the adviser to reappear.

Atilius
09-27-2006, 23:59
No, it only works for family members as it was designed to be used for traits.

I was quite surprised to find that the GeneralCaptureSettelment is triggered if an army commanded by a captain captures a city. I have been using this in a campaign script for many months now.

Epistolary Richard
09-28-2006, 00:19
Ah, you learn something new everyday. :thumbsup:

Bardo
09-28-2006, 15:59
I was quite surprised to find that the GeneralCaptureSettelment is triggered if an army commanded by a captain captures a city. I have been using this in a campaign script for many months now.
I have been making some tests and I can confirm this: Captains also triggers the GeneralCaptureSettelment event.
I have seen that EB script uses I_SettlementOwner. If someone from EB read this, you can save a lot of lines in your script if you change to GeneralCaptureSettelment.