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).
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).