Results 1 to 13 of 13

Thread: Queastion:Population script

Hybrid View

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

    Default Queastion:Population script

    Hi!

    First of all: I don't know nothing about scripting.

    I am just tweaking the population growth rates, and since it is only possible to have growth rates in 0.5% steps (-3%, -2.5% -2% ... 0%,+0.5%, +1%, ... , +3%) I am very limited to include a little randomness in the population growth.

    Now here comes my question: Would it be possible, to make a script, that randomly adds population to a city/castle, depending on it's size?

    For example:
    a village would gain/lose every turn up to 50 citizens (randomly)

    A huge citadel would gain/lose randomly up to 2000 people per turn. (i am just making these numbers up right now, I haven't thought this through yet).

    This would bring some randomness in population growth. It is just stupid, if you have a population growth rate of 0%, that the Population stays exactly the same every turn (a few people always die or are born).

    And yes, I know on the long run statistically the gains/losses would even themselves out, but I still want this randomness.

    So can anyone tell me if this is possible, and if so, how I do it?


    Thanks, mailor.
    Last edited by mailor; October 19, 2007 at 02:58 AM.

    My Home is my Castle.

  2. #2
    Caesar Clivus's Avatar SS Forum Moderator
    Join Date
    May 2007
    Location
    Australia
    Posts
    12,693

    Default Re: Queastion:Population script

    I'll post this here and in the SS thread. Not being an expert scripter myself, a problem I can foresee is that you may have to write a script that includes every settlement on the map by name. Such scripts may slow down the game turns quite a bit, as this is how the garrison scripts work.

    BftB2 UPDATED 22nd DECEMBER. Member of the Complete Byzantine Unit Roster team

  3. #3

    Default Re: Queastion:Population script

    Hmmm... Probably.

    I just had an idea! Is it true, that you only can have a large town (for example) when you build a wooden wall? Do cities/castle only change their "rank" (motte and baily - wood castle - stone castle ect. and village - town - large town) whenm you build the walls?

    If that is the case, it would theoretically possible to "bind" the script to buildings (in this case walls, which define the type of the city/castle anyway)

    My Home is my Castle.

  4. #4
    Caesar Clivus's Avatar SS Forum Moderator
    Join Date
    May 2007
    Location
    Australia
    Posts
    12,693

    Default Re: Queastion:Population script

    I think however you would still need to run a script for every settlement to actually add/subtract the population though...unless there is another way of doing so other than the add_population command.

    BftB2 UPDATED 22nd DECEMBER. Member of the Complete Byzantine Unit Roster team

  5. #5
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Queastion:Population script

    Scripts that are executed for each settlement aren't necessarily slow. The main problem with the garrison scripts is that they use monitor_conditions with a lot of conditions. These are executed with a heartbeat every few fractions of a second - and this is what really slows things down. If you just use monitor_events your AI turns will be a lot faster.

    No thing is everything. Every thing is nothing.

  6. #6

    Default Re: Queastion:Population script

    Alpaca: you seem to be the scripting guru around here. Do you have any suggestions for my idea?

    My Home is my Castle.

  7. #7
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Queastion:Population script

    Quote Originally Posted by mailor View Post
    Alpaca: you seem to be the scripting guru around here. Do you have any suggestions for my idea?
    Well you can't use the actual population but you can use the core building level as a condition.

    Then just write some ifs using RandomPercent as conditions and set it up as you wish.

    No thing is everything. Every thing is nothing.

  8. #8

    Default Re: Queastion:Population script

    Thanks for the info alpaca. I don't understand it though. Could you write this script please?

    Sorry, I am not trying to be an ass here, but I think I am too stupid for this kind of thing

    My Home is my Castle.

  9. #9
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Queastion:Population script

    You arent too stupid you just need to take some time to learn the language and the syntax. Not only that since you havent listed any "hard" numbers, just examples, I doubt alpaca or anyone else will get it right for you on the first shot.

    Check out the docudemons for conditions you would like to apply and try something like this:


    monitor_event SettlementTurnEnd London
    if SettlementBuildingExists = stone_wall
    and RandomPercent >50
    console_command add_population London 500
    end_if
    end_monitor

    Throw your own conditions in that then copy it for each settlement.

  10. #10

    Default Re: Queastion:Population script

    Thanks a lot GrnEyedDvl! I'll try this out right away. I think this is whate I needed to hear! cheers dudes!

    My Home is my Castle.

  11. #11
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Queastion:Population script

    Quote Originally Posted by GrnEyedDvl View Post
    You arent too stupid you just need to take some time to learn the language and the syntax. Not only that since you havent listed any "hard" numbers, just examples, I doubt alpaca or anyone else will get it right for you on the first shot.

    Check out the docudemons for conditions you would like to apply and try something like this:


    monitor_event SettlementTurnEnd London
    if SettlementBuildingExists = stone_wall
    and RandomPercent >50
    console_command add_population London 500
    end_if
    end_monitor

    Throw your own conditions in that then copy it for each settlement.
    Correction:

    monitor_event SettlementTurnEnd SettlementName London
    and SettlementBuildingExists = stone_wall

    if RandomPercent > 50
    console_command add_population London 500
    end_if
    end_monitor

    You have to create a monitor for each settlement/level combination with that script. There's a slightly better (imo) way but it's much more complicated, so I'd just advise you to go with this for now and return if it goes too slowly.

    GrnEyedDvl: Be careful not to give noobs wrong ideas about what works and what doesn't gotta love that smiley

    No thing is everything. Every thing is nothing.

  12. #12
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: Queastion:Population script

    lol yeah I just banged that out late last night. Still it points him in the general direction.

    My own fav smiley:

    Took that off my boards as its not on twc.

  13. #13
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Queastion:Population script

    Quote Originally Posted by GrnEyedDvl View Post
    lol yeah I just banged that out late last night. Still it points him in the general direction.

    My own fav smiley:

    Took that off my boards as its not on twc.
    Yeah I know the problem. Happens to me all the time.

    Actually, my favourite smiley is this one from civfanatics:

    I should maybe write at least one on-topic point in the post, but I'm just too lazy.

    No thing is everything. Every thing is nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •