Page 1 of 2 12 LastLast
Results 1 to 20 of 27

Thread: New Script: Each unit recruited draws from local population

  1. #1

    Default New Script: Each unit recruited draws from local population

    I was always bothered when towns of 3,000 could recruit thousands of troops over time... in theory only about 25% are actually available for recruitment anyway... and many a war has been decided by attrition and m2tw does not have that as a factor....

    As a noob I created this very clunky script to make Bree Archer Militia draw from the local population...

    1. Others can take this and make it better if they like... it does work... my Bree population when from 3600 to 3470 when the unit was trained.
    2. Is there a more efficient way to make the same outcome where I don't have to create 10000 monitors to make it global?
    .... ie... I am pretty sure we can check unit size... and could make the population drop based off of that check and not dependent on faction.
    3. Would this script be applied to the AI as well?


    I think this is powerful script because it will make the game more challenging as a person has to keep a strong eye on their population and whether they are too careless. And at some point factions will just run out of available men which is consistent with history

    monitor_event UnitTrained UnitType Bree Archer Militia
    and SettlementName Bree
    and FactionType Turks
    and FactionIsLocal
    and I_UnitExists Bree Archer Militia
    console_command, add_population Bree -150
    end_monitor

    monitor_event UnitTrained UnitType Bree Archer Militia
    and SettlementName Staddle
    and FactionType Turks
    and FactionIsLocal
    and I_UnitExists Bree Archer Militia
    console_command, add_population Bree -150
    end_monitor

  2. #2
    leo.civil.uefs's Avatar É nóis que vôa bruxão!
    Join Date
    Sep 2010
    Location
    Brazil
    Posts
    3,135

    Default Re: New Script: Each unit recruited draws from local population

    Really good idea...

    It would also be interesting to see your population increase when you disband a unit in its region.

  3. #3

    Default Re: New Script: Each unit recruited draws from local population

    Cool idea, though it might make life for the Elven factions unduly difficult since they have such low population rates.

  4. #4

    Default Re: New Script: Each unit recruited draws from local population

    Leo here is a less cumbersome script for disbanding units...its works in turn so if you need an extra thousand population you can just disband your garrison.
    Seems like it could get pretty hefty to globally script this function... does the AI even disband?

    I think we can add a huge amount of unit types in this one monitor... basically all of the missiles... then have to copy paste for each settlement. I would have to organize them by unit size...so the add_population was correct. Seems fun


    monitor_event UnitDisbanded TrainedUnitClass missile
    and UnitType Bree Archer Militia
    console_command, add_population Bree 150
    end_monitor
    Last edited by orclover5; December 15, 2013 at 02:28 PM.

  5. #5

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by Jmonstra View Post
    Cool idea, though it might make life for the Elven factions unduly difficult since they have such low population rates.

    I make my elven factions have fewer troops but 3 hit points each, 4 for the elite elves, and the best armor, weapons, morale, and abilities. That way you are basically playing with a pre-made army of amazing soldiers who can retrain and occasionally be replaced. Elves should never have 1 hit point. They have had a thousand years at least to train, make weapons and armor, and are hard to kill just naturally.

  6. #6
    paradamed's Avatar Praepositus
    Join Date
    Jun 2006
    Location
    Brasília, Brasil
    Posts
    5,806

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by leo.civil.uefs View Post
    Really good idea...

    It would also be interesting to see your population increase when you disband a unit in its region.
    I like this idea. This is one thing I miss from RTW.

  7. #7

    Default Re: New Script: Each unit recruited draws from local population

    A quick suggestion cut down on the coding thus:

    monitor_event UnitTrained UnitCategory infantry
    and SettlementName Bree
    and FactionIsLocal
    console_command, add_population Bree -150
    end_monitor

    monitor_event UnitTrained UnitCategory infantry
    and SettlementName Staddle
    and FactionIsLocal
    console_command, add_population Staddle -150
    end_monitor

    . . . repeat for all settlements

    monitor_event UnitTrained UnitCategory cavalry
    and SettlementName Bree
    and FactionIsLocal
    console_command, add_population Bree -75
    end_monitor

    monitor_event UnitTrained UnitCategory cavalry
    and SettlementName Staddle
    and FactionIsLocal
    console_command, add_population Staddle -75
    end_monitor


    . . . repeat for all settlements

    This would apply for any player faction in any settlement. It would draw the same number from the population for units of the same category but different sizes, but then elite units with smaller numbers of actual fighting men could just be assumed to require a certain number of support personnel (squires, attendants, and servants maybe?).

    Haven't tested this myself.

  8. #8

    Default Re: New Script: Each unit recruited draws from local population

    Thanks spice master for the help... I like the categories idea.... it is way easier than the version below....

    monitor_event UnitTrained TrainedUnitClass missile
    and UnitType Bree Archer Militia
    console_command, add_population Bree -150
    end_monitor


    monitor_event UnitDisbanded TrainedUnitClass missile
    and UnitType Bree Archer Militia
    console_command, add_population Bree 150
    end_monitor


    So i have the population drop and add working... now I was to freeze recruitment if the population gets too low... is there a way to do this?

    There is really no point in dropping population if recruitment can't be stopped at 404 or whatever. Does anyone have any ideas?
    Last edited by orclover5; December 15, 2013 at 11:11 PM.

  9. #9

    Default Re: New Script: Each unit recruited draws from local population

    I really like this idea! Hope it will come to work.

  10. #10
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: New Script: Each unit recruited draws from local population

    Good idea orclover. To expand on Spice Master's idea...

    Code:
    declare_counter trained_unit_cat
    
    monitor_event UnitTrained TrueCondition
      set_counter trained_unit_cat 0
    end_monitor
    
    monitor_event UnitTrained UnitCategory infantry
      set_counter trained_unit_cat 1
    end_monitor
    
    monitor_event UnitTrained UnitCategory cavalry
      set_counter trained_unit_cat 2
    end_monitor
    
    monitor_event UnitTrained UnitCategory siege
      set_counter trained_unit_cat 3
    end_monitor
    
    ;settlement monitors...
    
    monitor_event UnitTrained SettlementName Bree
      and FactionIsLocal
    
      if I_CompareCounter trained_unit_cat = 1
        console_command add_population Bree -150
      end_if
      if I_CompareCounter trained_unit_cat = 2
        console_command add_population Bree -75
      end_if
      if I_CompareCounter trained_unit_cat = 3
        console_command add_population Bree -50
      end_if
    
    end_monitor
    
    monitor_event UnitTrained SettlementName Staddle
      and FactionIsLocal
    
      if I_CompareCounter trained_unit_cat = 1
        console_command add_population Staddle -150
      end_if
      if I_CompareCounter trained_unit_cat = 2
        console_command add_population Staddle -75
      end_if
      if I_CompareCounter trained_unit_cat = 3
        console_command add_population Staddle -50
      end_if
    
    end_monitor
    
    ...and all other settlements...
    This way only one monitor per settlement is needed.

    monitor_event UnitDisbanded TrainedUnitClass missile
    and UnitType Bree Archer Militia
    console_command, add_population Bree 150
    end_monitor
    Does TrainedUnitClass work with UnitDisbanded? Its name implies that it would work with UnitTrained only. It might just be poorly named but it might be worth testing that TrainedUnitClass is actually working on the unit in question and not the most-recently-trained unit.

    Not sure why you need both the Class and Type conditions here.

    UnitDisbanded does not export settlement. Or region. There's no way to know where the unit is being disbanded, so no way to know where to add population.

    now I was to freeze recruitment if the population gets too low
    Sadly, there is no way to test the population size. It never drops below a certain number anyway, even via add_population. Can't remember what it is - around 400?

    P.S. There should not be a comma after console_command.

  11. #11

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by Withwnar View Post
    Good idea orclover. To expand on Spice Master's idea...

    Code:
    declare_counter trained_unit_cat
    
    monitor_event UnitTrained TrueCondition
      set_counter trained_unit_cat 0
    end_monitor
    
    monitor_event UnitTrained UnitCategory infantry
      set_counter trained_unit_cat 1
    end_monitor
    
    monitor_event UnitTrained UnitCategory cavalry
      set_counter trained_unit_cat 2
    end_monitor
    
    monitor_event UnitTrained UnitCategory siege
      set_counter trained_unit_cat 3
    end_monitor
    
    ;settlement monitors...
    
    monitor_event UnitTrained SettlementName Bree
      and FactionIsLocal
    
      if I_CompareCounter trained_unit_cat = 1
        console_command add_population Bree -150
      end_if
      if I_CompareCounter trained_unit_cat = 2
        console_command add_population Bree -75
      end_if
      if I_CompareCounter trained_unit_cat = 3
        console_command add_population Bree -50
      end_if
    
    end_monitor
    
    monitor_event UnitTrained SettlementName Staddle
      and FactionIsLocal
    
      if I_CompareCounter trained_unit_cat = 1
        console_command add_population Staddle -150
      end_if
      if I_CompareCounter trained_unit_cat = 2
        console_command add_population Staddle -75
      end_if
      if I_CompareCounter trained_unit_cat = 3
        console_command add_population Staddle -50
      end_if
    
    end_monitor
    
    ...and all other settlements...
    This way only one monitor per settlement is needed.



    Does TrainedUnitClass work with UnitDisbanded? Its name implies that it would work with UnitTrained only. It might just be poorly named but it might be worth testing that TrainedUnitClass is actually working on the unit in question and not the most-recently-trained unit.

    Not sure why you need both the Class and Type conditions here.

    UnitDisbanded does not export settlement. Or region. There's no way to know where the unit is being disbanded, so no way to know where to add population.



    Sadly, there is no way to test the population size. It never drops below a certain number anyway, even via add_population. Can't remember what it is - around 400?

    P.S. There should not be a comma after console_command.

    Thanks for the reply... I will definitely use the more succinct version that has been provided by you masters. I could definitely disband multiple units and add the population in turn... I was trying to test the low population limit and see if I could freeze recruitment. I would recruit two units of arnorian archers at 700 population in staddle... population dropped to around 450 after they were recruited, I then disbanded them both and it went back up to 800 or so. I am hoping to work with Tsarsies to bring some resource scripts and population scripts over to TATW, minimalist versions of course. If I want to do the disband script I will need to do every single unit for every single faction. My units only add population If I have scripted the unit type for that city, but they can migrate. Doesn't seem like the unitcategory will work... maybe I will try.
    Last edited by orclover5; December 17, 2013 at 12:17 AM.

  12. #12
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: New Script: Each unit recruited draws from local population

    My units only add population If I have scripted the unit type for that city, but they can migrate.
    To use your example: if you disband any unit of Arnorian Archers anywhere on the map - that could have been recruited from any settlement - then it raises Staddle's population. This particular unit type (A.Archers) would boost only Staddle, a different unit type would boost e.g. Bree, and so on ... is that what you're saying?

  13. #13

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by Withwnar View Post
    To use your example: if you disband any unit of Arnorian Archers anywhere on the map - that could have been recruited from any settlement - then it raises Staddle's population. This particular unit type (A.Archers) would boost only Staddle, a different unit type would boost e.g. Bree, and so on ... is that what you're saying?
    monitor_event UnitDisbanded TrainedUnitClass missile
    and UnitType Arnorian Archersconsole_command, add_population Arthedain 150
    end_monitormonitor_event

    UnitDisbanded TrainedUnitClass missile
    and UnitType Arnorian Archersconsole_command, add_population Evendim 150
    end_monitor

    The second monitor allowed me to trained a unit of arnorian archers which subtracted... in evendim, I could then move this unit to Amon Sul and disband them to increase the population. Cool, but not sustainable... I think this will end up being like 20000 lines of script, and is not worth it considering we can't even stop recruitment this way. A citadel for example could use up its entire population down to 400 and still recruit 1000 population a turn... I need a solution that creates a real man power shortage.

  14. #14

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by orclover5 View Post
    Cool, but not sustainable... I think this will end up being like 20000 lines of script, and is not worth it considering we can't even stop recruitment this way. A citadel for example could use up its entire population down to 400 and still recruit 1000 population a turn... I need a solution that creates a real man power shortage.
    Maybe I shouldn't actually be commenting here because I have no idea what's going on "under the hood" here, but I don't think that's actually possible, is it? Even with a growth rate of 5% per turn, that works out to be a population of 420 next turn (a net growth of 20). Is there really something in the script that inflates the population growth that severely?

  15. #15

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by Ulfgard the Unmaker View Post
    Maybe I shouldn't actually be commenting here because I have no idea what's going on "under the hood" here, but I don't think that's actually possible, is it? Even with a growth rate of 5% per turn, that works out to be a population of 420 next turn (a net growth of 20). Is there really something in the script that inflates the population growth that severely?

    Sorry if I misunderstood... the lowest I can drop the population seems to be 404... TATW has a check that looks for low population but never activates because it never seems to get to 400 after a turn... and there is no way to count the exact population...there are ways to limit recruitment... you have to tie an event counter to the unit in the EDB, when an event occurs such as "population" low then the unit is not recruited.

  16. #16
    Senator
    Join Date
    Mar 2013
    Location
    Home
    Posts
    1,050

    Default Re: New Script: Each unit recruited draws from local population

    This gives me an Idea!. I will use something like this in the next version of my patch. Have sup rep for the Idea.

  17. #17
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by orclover5 View Post
    monitor_event UnitDisbanded TrainedUnitClass missile
    and UnitType Arnorian Archers
    console_command, add_population Arthedain 150
    end_monitormonitor_event

    UnitDisbanded TrainedUnitClass missile
    and UnitType Arnorian Archers
    console_command, add_population Evendim 150
    end_monitor

    The second monitor allowed me to trained a unit of arnorian archers which subtracted... in evendim, I could then move this unit to Amon Sul and disband them to increase the population.
    Quote Originally Posted by Withwnar View Post
    UnitDisbanded does not export settlement. Or region. There's no way to know where the unit is being disbanded, so no way to know where to add population.
    Your script is not saying "if disbanded in Arthedain then add population to Arthedain". Disbanding that unit anywhere on the map will add population to both Arthedain and Evendim.

    @Ulfgard
    The script is directly adding/subtracting population. It has nothing to do with the normal population growth mechanism.

  18. #18

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by orclover5 View Post
    The second monitor allowed me to trained a unit of arnorian archers which subtracted... in evendim, I could then move this unit to Amon Sul and disband them to increase the population. Cool, but not sustainable... I think this will end up being like 20000 lines of script, and is not worth it considering we can't even stop recruitment this way. A citadel for example could use up its entire population down to 400 and still recruit 1000 population a turn... I need a solution that creates a real man power shortage.
    Only thing I can think of is duplicating all the units in export_descr_buildings so you can use a script counter to switch between regular replenishment and the duplicates with extremely low replenishment (like 99 turns). You can set this up to switch when the population is below a certain number.

    I thought of creating such a script using a similar script I already have set up which monitors all settlements already, but I don't have the time and I have no idea if it would really alter gameplay that much in PCP to be worth it. For vanilla TATW it shouldn't be too much work though and would really help with stack spam I think.

    If you do decide to create such a huge script it will cause much less strain on your CPU if you use "if" and "end_if" commands in one long condition rather than make a crap load of separate conditions to monitor. It is a little more work but totally worth it when it doesn't slow down turn times at all.
    Last edited by alreadyded; December 18, 2013 at 07:57 PM.

  19. #19

    Default Re: New Script: Each unit recruited draws from local population

    Quote Originally Posted by alreadyded View Post
    Only thing I can think of is duplicating all the units in export_descr_buildings so you can use a script counter to switch between regular replenishment and the duplicates with extremely low replenishment (like 99 turns). You can set this up to switch when the population is below a certain number.

    I thought of creating such a script using a similar script I already have set up which monitors all settlements already, but I don't have the time and I have no idea if it would really alter gameplay that much in PCP to be worth it. For vanilla TATW it shouldn't be too much work though and would really help with stack spam I think.

    If you do decide to create such a huge script it will cause much less strain on your CPU if you use "if" and "end_if" commands in one long condition rather than make a crap load of separate conditions to monitor. It is a little more work but totally worth it when it doesn't slow down turn times at all.


    Thanks for the response. I don't know of any counter that can detect when population is low...there is a POPULATIONTOOLOW condition but it doesn't seem to activate and may be from RTW when the population could drop and units could not be recruited. They dropped that from M2TW because the AI is too stupid and settlements would never get developed and units never recruited... likely going to be a problem for us as well.

  20. #20

    Default Re: New Script: Each unit recruited draws from local population

    GarrisonToPopulationRatio works, I use it a lot. With one or more units garrisoned you can set it so you can't recruit with too low of a population if you set the ratio to the right number maybe. If they have no units garrisoned they might be able to get around it though, not sure. I suppose you could set it up so they need a garrison before recruiting as well to prevent this, not sure though. I lost all my docudemons files so I need to re-download before I can be too much help.

Page 1 of 2 12 LastLast

Posting Permissions

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