Results 1 to 4 of 4

Thread: Help with SAR mission

  1. #1

    Question Help with SAR mission

    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?

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

  2. #2
    Shaidar Haran Senior Member SAM Site Champion Myrddraal's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    5,752

    Default Re: Help with SAR mission

    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:

    Code:
    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
    Last edited by Myrddraal; 04-28-2011 at 01:21.

  3. #3

    Default Re: Help with SAR mission

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

  4. #4

    Default Re: Help with SAR mission

    And finally a solution available for testing here!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO