Results 1 to 7 of 7

Thread: need help with depopulation script

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default need help with depopulation script

    I already wrote about this script in "An Intermediate Guide to Scripting" but it looks like I choose a wrong thread.
    I'm trying implement script which can reduce population in city.
    Code:
    script
    	declare_counter loop
    	set_counter loop 0
    
    	monitor_event ButtonPressed ButtonPressed end_turn
    	and Carthago SettlementPopulationMaxedOut
    	console_command add_population Carthago -7000
    	end_monitor
    
    	while I_CompareCounter loop = 0
    	end_while
    end_script
    In this way script start decrease population each turn if there 24000 in the settlement, but it doesn't stop!!! It' stop only when there are 400 men in the settlement(as I understand lowest level)
    If I use terminate_monitor script reduce population only once...
    What I should change If I want that script decrease population depending on it's size

  2. #2
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: need help with depopulation script

    There is one thing that I don't understand:

    Is the starting population of Carthago lower than 24000?

    I mean, does the script recognize the syntax of "and Carthago SettlementPopulationMaxedOut" or simply use endturn button pressed as condition?

    This is a trigger in export_descr_advice:
    Code:
    Trigger 1994_Settlement_Population_Limit_Reached_Trigger
        WhenToTest SettlementTurnStart
    
        Condition SettlementIsLocal
              and SettlementPopulationMaxedOut
    
        AdviceThread Settlement_Population_Limit_Reached_Thread  1
    In view of that I will try a different syntax. For example:

    monitor_event SettlementTurnStart Carthago
    and SettlementPopulationMaxedOut
    console_command add_population Carthago -7000
    end_monitor

    But this is only a quick answer. Never tried.

  3. #3

    Default Re: need help with depopulation script

    Thanks for your hint Monkwarrior!
    I tried your syntax but again without success,for one turn population level fall on lowest level of 400 men
    It's seems that script recognize "Carthago SettlementPopulationMaxedOut" as condition it also works well with if statement, but problem is that this "recognition mechanism" works only one time and if it works script begin reducing population all time.
    I used endturn button because I tried prevent script from momental falling of population level.

    PS:pardon my bad english

  4. #4
    CeltiberoRamiroI Member Monkwarrior's Avatar
    Join Date
    Apr 2004
    Location
    Salduie/Caesaraugusta/ Sarakusta/Saragossa
    Posts
    828

    Default Re: need help with depopulation script

    Quote Originally Posted by Galloper
    Thanks for your hint Monkwarrior!
    I tried your syntax but again without success,for one turn population level fall on lowest level of 400 men
    It's seems that script recognize "Carthago SettlementPopulationMaxedOut" as condition it also works well with if statement, but problem is that this "recognition mechanism" works only one time and if it works script begin reducing population all time.
    I used endturn button because I tried prevent script from momental falling of population level.

    PS:pardon my bad english
    What's your mother language? I imagine that it is not Spanish.
    Let's continue in English then.

    I was wondering why do you need a background script for this purpose.
    One alternative would be an advice with a script for "depopulation".

    In export_descr_advice:
    in the bottom of the file, the trigger
    Code:
    ;------------------------------------------
    Trigger 9000_Carthago_Population_Limit_Reached_Trigger
        WhenToTest SettlementTurnStart
    
        Condition SettlementIsLocal
              and SettlementName Carthago
              and SettlementPopulationMaxedOut
    
        AdviceThread Carthago_Population_Limit_Reached_Thread  1

    then you need the advice thread
    Code:
    ;------------------------------------------
    AdviceThread Carthago_Population_Limit_Reached_Thread
        GameArea Campaign
    
        Item Carthago_Population_Limit_Reached_Text_01
            Uninhibitable
            Verbosity  0 
            Priority  1 
            Threshold  1 
            Attitude Normal
            Presentation Default
            Title Carthago_Population_Limit_Reached_Text_01_Title
            Script scripts\show_me\depopulation.txt
            Text Carthago_Population_Limit_Reached_Text_01_Text1


    In export_advice (text folder):

    Code:
    {Carthago_Population_Limit_Reached_Text_01_Title}	Too Many People in Carthago
    
    {Carthago_Population_Limit_Reached_Text_01_Text1}
    Carthago has reached its maximum population level. 7,000 inhabitants have been evicted from the city.


    And in data\scripts\show_me folder you create the file depopulation.txt:

    Code:
    script
    
    console_command add_population -7000
    
    end_script
    Good luck!

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

    Default Re: need help with depopulation script

    This is odd. A monitor should repeat again and again unless you include the terminate_monitor line...

  6. #6
    Harbinger of... saliva Member alpaca's Avatar
    Join Date
    Aug 2003
    Location
    Germany
    Posts
    2,767

    Default Re: need help with depopulation script

    Try this syntax:
    Code:
    declare_counter break_counter
    monitor_event SettlementTurnStart Carthago
    and SettlementPopulationMaxedOut
    and I_CompareCounter break_counter = 0
    console_command add_population Carthago -7000
    set_counter break_counter 1
    end_monitor
    
    while TrueCondition
    if I_CompareCounter break_counter = 1
    set_counter break_counter 0
    end_if
    end_while
    Edit: As an afterthought it probably won't work very well. Could you test if it only executes once each time you press end turn when you provide no condition for the monitor?
    Last edited by alpaca; 06-20-2006 at 17:55.

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