Log in

View Full Version : Help with SAR mission



chrisb
04-23-2011, 16:05
I'm trying to write a background script that would add a "search and rescue" mission to the game (=e.g. ImportantDude being taken captive). Using BI engine. I'm very new in scripting so I hope someone would be kind enough to help me out. I've tried to read all tutorials on the topic, but many questions remain. I've followed the basic advice by HouseOfHam on how to add a background script. I'm trying to proceed step-by-step and the first task would be to create a status of ImportantDude being captive. I've succeeded in that with a counter, but for some reason my script does not prevent the same thing happening multiple times. Why on earth does the message "PromptThreadCaptive" appear every time the unit is attacked and loses more than 10 % of its men?


declare_counter captive
set_counter captive 0

monitor_event PostBattle FactionIsLocal
if I_LocalFaction sarmatians
and if I_PercentageUnitKilled importantdude_bodyguard > 10 ; here 10 % just an example of loss
and if I_CompareCounter captive = 0
advance_advice_thread PromptThreadCaptive 1 ; this works, i.e. the message appears after battle
set_counter captive 1 ; I don't know if this goes through...
console_command add_money 20000 ; this works too
end_if ; should here be one or two rows of "end_if"?
end_monitor


I have created a unit type importantdude_bodyguard and assuming that the captain of that unit would be the ImportantDude. I'm not making him a general on purpose as I do not want to lose him due to high age and I do not want to use Alex engine (if I have understood correctly, Alex is the only engine with which you can make very long-living generals).

Myrddraal
04-28-2011, 01:14
Hi chrisb, welcome to the .org.

First of all, you don't need to write 'and if' simply 'and' will do (then you only need one end_if).

Have you declared the counter anywhere using declare_counter?

EDIT: sorry just noticed that you have declared it....

EDIT2: It's been a while since I did anything like this, but I don't think you need the if statements at all. Try this:


declare_counter captive
set_counter captive 0

monitor_event PostBattle FactionIsLocal
and I_LocalFaction sarmatians
and I_PercentageUnitKilled importantdude_bodyguard > 10
and I_CompareCounter captive = 0
advance_advice_thread PromptThreadCaptive 1
set_counter captive 1
console_command add_money 20000
end_monitor

chrisb
05-04-2011, 22:30
Thanks Myrddraal! There has been more discussion on the same topic here, plz let's continue there: http://www.twcenter.net/forums/showthread.php?t=446038

Still many problems to be solved ;-)

chrisb
06-09-2011, 22:51
And finally a solution available for testing here (http://www.twcenter.net/forums/showthread.php?t=458521)!