View Full Version : need help with depopulation script
Galloper
06-18-2006, 12:05
I already wrote about this script in "An Intermediate Guide to Scripting" but it looks like I choose a wrong thread. :oops:
I'm trying implement script which can reduce population in city.
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!!! :wall: 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 :help:
Monkwarrior
06-18-2006, 20:05
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:
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. :no:
Galloper
06-18-2006, 23:11
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 :no:
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 :balloon2:
Monkwarrior
06-19-2006, 08:41
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 :no:
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 :balloon2:
What's your mother language? I imagine that it is not Spanish.:laugh4:
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
;------------------------------------------
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
;------------------------------------------
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):
{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:
script
console_command add_population -7000
end_script
Good luck!:2thumbsup:
Myrddraal
06-19-2006, 17:54
This is odd. A monitor should repeat again and again unless you include the terminate_monitor line...
Try this syntax:
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?
Galloper
06-21-2006, 21:56
Monkwarrior
My mother language is russian, but I'm dreaming learn spanish someday ~;)
I tried made script in your way with advice threads, but again without success. Cheked all several times started new campaign but it seemes that script doesnt' run.
There is one condition that not very suitable for me "SettlementIsLocal". In this way script affects only on human player but I suppose that AI suffers from overflowing cities much more than player. I want include all settlements on the map in the script and I believe that decrease of population can improve AI behaviour.
alpaca
I tried your syntax and it doesn't work ~:mecry:
If I put your original script nothing happened.
I tried add "and Carthago SettlementPopulationMaxedOut" beacuse in docudemon written that SettlementPopulationMaxedOut need settlement. In this way population level decrease till 400 men on next turn.
I tried run script without conditions
declare_counter break_counter
monitor_event SettlementTurnStart Carthago
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
In this way nothing happened.
If I leave only and I_CompareCounter break_counter = 0 as condition the population level fall till 400 men level on next turn.
I tried different syntax with your code but I cannot discover any solution to make "SettlementTurnStart" work. It seemes that "ButtonPressed ButtonPressed end_turn" works better but in this way end turn button triggered console_command and script run without checking "SettlementPopulationMaxedOut".
Any new ideas gladly appreciated! :knuddel:
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.