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

Thread: Creating a World - Instant garrisons and their disbandment

  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Creating a World - Instant garrisons and their disbandment

    Garrison scripts are a pain in the butt, face it . To avoid the units becoming 'free stacks' for the AI and bankrupting him further the garrison needs to be disbanded after a unsuccessful siege. We did that in 1648 for only a few cities of 'endangered' factions - thought I share the code.

    Due to the nature of the disbanding it is necessary to create copies of suitable units. Simply add a suffix to the name ( we used G for garrison) and copy\edit the text entries in text\export_units. The only difference between the units will be an additional, custom attribute in the EDU, we chose garrison.
    Code:
    attributes       sea_faring, hide_forest, is_peasant, can_run_amok, garrison, no_custom
    The spawning in the campaign_script file is a piece of cake (with a twist): the spawn happens immediately when the settlement gets attacked, no quick attack on an empty city with siege equipment here! We used the create_unit command as
    a) it pops the units right into the settlement and
    b) you need only one line per unit type.
    Units exceeding the total of 20 in a settlement will be ignored\not created, eg 14 existing units plus 10 garrison spawn will still only be 20 total. Units will be added in the sequence of the listing in the monitor.
    Code:
        declare_counter Aschaffenburg_siege
        declare_counter Mainz_siege
        declare_counter Erfurt_siege
        declare_counter Heiligenstadt_siege
        ;--- Garnison einziehen ---
        monitor_event GeneralAssaultsResidence TargetFactionType egypt
            and I_IsFactionAIControlled egypt      ; garrison only for AI
            and IsTargetRegionOneOf Erzbistum_Mainz
            and I_SettlementUnderSiege Aschaffenburg
            if I_TurnNumber < 100
                create_unit Aschaffenburg, BuergerwehrG, num 4, exp 0, arm 0, wep 0
                create_unit Aschaffenburg, GrenadiereG, num 1, exp 0, arm 0, wep 0
                create_unit Aschaffenburg, MusketiereG, num 2, exp 0, arm 0, wep 0
                create_unit Aschaffenburg, PikeniereG, num 3, exp 0, arm 0, wep 0
                set_counter Aschaffenburg_siege 1
            end_if
            if I_TurnNumber > 99
                terminate_monitor
            end_if
        end_monitor
    
        monitor_event GeneralAssaultsResidence TargetFactionType egypt
            and I_IsFactionAIControlled egypt      ; garrison only for AI
            and IsTargetRegionOneOf Stadt_Mainz
            and I_SettlementUnderSiege Mainz
            if I_TurnNumber < 50
                create_unit Mainz, BuergerwehrG, num 4, exp 0, arm 0, wep 0
                create_unit Mainz, GrenadiereG, num 1, exp 0, arm 0, wep 0
                create_unit Mainz, MusketiereG, num 2, exp 0, arm 0, wep 0
                create_unit Mainz, PikeniereG, num 3, exp 0, arm 0, wep 0
                set_counter Mainz_siege 1
            end_if
            if I_TurnNumber > 49
                terminate_monitor
            end_if
        end_monitor
    
        monitor_event GeneralAssaultsResidence TargetFactionType egypt
            and IsTargetRegionOneOf Stadt_Erfurt
            and I_SettlementUnderSiege Erfurt
            if I_TurnNumber < 50
                create_unit Erfurt, BuergerwehrG, num 4, exp 0, arm 0, wep 0
                create_unit Erfurt, GrenadiereG, num 1, exp 0, arm 0, wep 0
                create_unit Erfurt, MusketiereG, num 2, exp 0, arm 0, wep 0
                create_unit Erfurt, PikeniereG, num 3, exp 0, arm 0, wep 0
                set_counter Erfurt_siege 1
            end_if
            if I_TurnNumber > 49
                terminate_monitor
            end_if
        end_monitor
    
        monitor_event GeneralAssaultsResidence TargetFactionType egypt
            and IsTargetRegionOneOf Eichsfeld
            and I_SettlementUnderSiege Heiligenstadt
            if I_TurnNumber < 50
                create_unit Heiligenstadt, BuergerwehrG, num 4, exp 0, arm 0, wep 0
                create_unit Heiligenstadt, GrenadiereG, num 1, exp 0, arm 0, wep 0
                create_unit Heiligenstadt, MusketiereG, num 2, exp 0, arm 0, wep 0
                create_unit Heiligenstadt, PikeniereG, num 3, exp 0, arm 0, wep 0
                set_counter Heiligenstadt_siege 1
            end_if
            if I_TurnNumber > 49
                terminate_monitor
            end_if
        end_monitor
    The monitor terminates after a set number of rounds - if they still need garrisons then, then they might as well perish.

    Then you check if there is no siege for any of the cities that get a garrison (noticed all the set_counter lines?):
    Code:
        ;--- Belagerung ist vorbei ---
        monitor_event FactionTurnEnd not FactionIsLocal
    
            if I_SettlementOwner Aschaffenburg = egypt
                and not I_SettlementUnderSiege Aschaffenburg
                set_counter Aschaffenburg_siege 0
            end_if
            if I_SettlementOwner Mainz = egypt
                and not I_SettlementUnderSiege Mainz
                set_counter Mainz_siege 0
            end_if
            if I_SettlementOwner Erfurt = egypt
                and not I_SettlementUnderSiege Erfurt
                set_counter Erfurt_siege 0
            end_if
            if I_SettlementOwner Heiligenstadt = egypt
                and not I_SettlementUnderSiege Heiligenstadt
                set_counter Heiligenstadt_siege 0
            end_if
    
        end_monitor
    Last not least you remove the garison troops if none of the settlements of a faction are under siege anymore:
    Code:
        ;--- Garnison ausmustern ---
        monitor_event FactionTurnStart FactionType egypt
            and not FactionIsLocal
            if I_CompareCounter Mainz_siege < 1
                and I_CompareCounter Aschaffenburg_siege < 1
                and I_CompareCounter Erfurt_siege < 1
                and I_CompareCounter Heiligenstadt_siege < 1
                destroy_units egypt garrison
            end_if
            if I_TurnNumber > 100
                terminate_monitor
            end_if
    
        end_monitor
    The units should not be available for recruitment, in the script or initially in the descr_strat as mentioned at the beginning (copies of regular units, suffix G = garrison) as they have a custom attribute that allows them to be disbanded in the last monitor, the no_custom entry in the EDU will prevent availability in custom battles.

    This whole code is only for 4 settlements of one faction - you do the math how this will look for all settlements. There would be no problem with processing as this will be two basics monitors plus one (the last one) for each faction involved - nothing to be bothered about.
    Last edited by Gigantus; March 11, 2022 at 11:00 PM. Reason: garrison for AI only










  2. #2

    Default Re: Creating a World - Instant garrisons and their disbandment

    i wanted this scripting done in my BC v2.3.2.2.......which file should i edit to make this happen...i think you forgot to mention that...thanks gigantus..its a great help.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    There is only one file for that - the campaign_script. I'll add it to the opening post.










  4. #4

    Default Re: Creating a World - Instant garrisons and their disbandment

    thanks mate........

  5. #5

    Default Re: Creating a World - Instant garrisons and their disbandment

    Could these instant garrisons differ depending on the buildings in the besieged settlement? For instance, if you have huge_walls, instead of spawning peasants and peasant archers, the garrison spawns milita?
    Last edited by Peanut2bigforyou; May 26, 2014 at 03:15 PM.

  6. #6
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    The GeneralAssaultsResidence event does not export settlement details. To work this in you would need to have a monitor that checks wall levels and then sets a counter. That counter can then be used as condition for the original monitor. (If I_CompareCounter [label wall level city name] = [count])

    So the answer is 'Yes' - but it takes some additional monitors.










  7. #7

    Default Re: Creating a World - Instant garrisons and their disbandment

    How would I go about doing that? If you've played Shogun 2, I would very much like to see settlements arm themselves with troops that increase in number and quality as the settlement upgrades.

  8. #8
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    Let's assume your garrison script is for a settlement that has the building core_building stone_wall entry in descr_strat as the starting wall level. That leaves then large_stone_wall and huge_stone_wall as remaining levels.
    The same principle applies for castles as well but you do not have to worry about conversion as the AI doesn't convert settlements.
    I am also assuming that the script gets terminated at round 100 as in the other script parts.
    Stuff in brackets [ ] are the variables you need to supply. More levels are needed if the wall level starts earlier.
    Code:
    ; --- Testing for wall level ---
        declare_counter wall_level_[settlement name]
        monitor_event SettlementTurnStart FactionIsLocal
                if I_TurnNumber > 99
                    terminate_monitor
                end_if
            and SettlementName [settlement name]
            and SettlementBuildingExists = large_stone_wall
            set_counter wall_level_[settlement name] 1
            terminate_monitor
        end_monitor
        monitor_event SettlementTurnStart not FactionIsLocal
                if I_TurnNumber > 99
                    terminate_monitor
                end_if
            and SettlementName [settlement name]
            and SettlementBuildingExists = huge_stone_wall
            set_counter wall_level_[settlement name] 2
            terminate_monitor
        end_monitor
    
    ; --- spawning garrison based on wall level ---
        declare_counter [settlement name]_siege
        monitor_event GeneralAssaultsResidence TargetFactionType [settlement owner]
            and IsTargetRegionOneOf [region of settlement]
            and I_SettlementUnderSiege [settlement name]
            if I_TurnNumber < 100
                if I_CompareCounter wall_level_[settlement name] = 0 ; your initial wall level
                    create_unit [settlement name], [unit details]
                    create_unit [settlement name], [unit details]
                    set_counter [settlement name]_siege 1
                end_if
                if I_CompareCounter wall_level_[settlement name] = 1 ; next wall level
                    create_unit [settlement name], [unit details]
                    create_unit [settlement name], [unit details]
                    set_counter [settlement name]_siege 1
                end_if
                if I_CompareCounter wall_level_[settlement name] = 2 ; last wall level
                    create_unit [settlement name], [unit details]
                    create_unit [settlement name], [unit details]
                    set_counter [settlement name]_siege 1
                end_if
            end_if
            if I_TurnNumber > 99
                terminate_monitor
            end_if
        end_monitor










  9. #9
    paleologos's Avatar You need burrito love!!
    Join Date
    Feb 2011
    Location
    Variable
    Posts
    8,496

    Default Re: Creating a World - Instant garrisons and their disbandment

    Hey man, just noticed this and it's great!
    It partly answers one of the problems we've been experiencing in Titanium.
    I've been meaning to ask how sophisticated can we get this script to become?
    Is it possible to get it to work without commiting an EDU slot?
    Is it possible to associate the number of units that will rise to defend with the population of the settlement and after the battle reduce that population by the amount of casualties?
    (And I imagine there will be so much more to ask once I begin to understand the workings of it!)

  10. #10
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    The disbanding mechanism uses the custom attribute to identify the units to be removed afterthe siege is over, which means you will have to commit at least one EDU slot as that removal will be faction wide.
    It is possible to link the amount of units spawned with the settlement's population , not sure if with the actual number but it should be possible ia the settlement level. I vaguely remember withnwar making a script like that.
    I don't think that it is possible to determine the number of casualties, hence a deduction from the population based on that cannot be done.










  11. #11

    Default Re: Creating a World - Instant garrisons and their disbandment

    To further (or rather, completely) prevent the newly created units from hurting the AI's finances, set the upkeep of the garrison units to 0.

    If you don't have spare EDU slots, spawn some militia units, that way the AI doesn't get good troops as a reward for leaving its settlements unprotected.
    Last edited by k/t; February 15, 2015 at 10:17 PM.

  12. #12
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Creating a World - Instant garrisons and their disbandment

    I read in similar thread by Withwnar that GeneralAssaultsResidence-script causes a mistake in postbattle bodycount. Something about that new spawned garrison sometimes make percentage army killed at 500% (I can't exactly remember a mechanism from that thread).

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  13. #13
    STELLover's Avatar Senator
    Join Date
    Dec 2008
    Location
    Seoul
    Posts
    1,295

    Default Re: Creating a World - Instant garrisons and their disbandment

    Hey guys


    Currently working on a Game of Thrones Total Conversion using the Garrison script, and I have to say that it works spendidly
    Some few notes to others that are going to attempt this and might ponder with some questions as I initially did:


    Q: Is the " and IsTargetRegionOneOf Erzbistum_Mainz" conditional necessary? AKA, is it necessary to add a conditional explicitely checking that the settlement in question belongs to its respective region?
    A: Not really. I removed this because I used GrnEyedDvl's Scripting Replicator, and since that program does not allow multivariable parsing, I did not include this. I am not sure why Gigantus included this in his code however, but I am pretty sure that the settlement name that the code parses is the name of the settlement in descr_regions.txt, not the visible settlement name in imperial_campaign_regions_and_settlements.

    Thus if two settlements under your code happen to share the same name, as long as they are different in descr_regions you should be fine (settlement names in descr_regions should be unique anyays AFAIK)




    Q: Above tutorial only attempts for one faction ("egypt"). Is it possible to apply to all factions?
    A: Yes, but you need to make sure your formatting is correct.
    Using GrnEyedDvl's script replicator can also save you BIG TIME. and I mean BIG TIME.
    Link
    http://www.twcenter.net/forums/showt...ipt-Replicator

    This is my example

    OPEN FOR DETAILS

    Spoiler Alert, click show to read: 
    Part one of the script I list all the counters for each settlement. The vertical "...." represents the remaining settlements
    Spoiler Alert, click show to read: 
    ;;;;;;;;;;;;;;;;;;;;WESTEROS GARRISON SCRIPT;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;; [1] DECLARE COUNTER ;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    declare_counter Bear_Keep_siege
    declare_counter Antlers_siege
    declare_counter Fair_Castle_siege
    declare_counter Driftmark_siege
    :
    :
    :
    Part two of the script is the main spawner
    Again, the vertical "....." represent the remaining list of the settlements. Notice that the long list of settlements with the unit spawns repeat for each faction (NORTH, STORMLANDS, THE REACH etc)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;; [2] SPAWN GARRISON PER FACTION ;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; NORTH
    monitor_event GeneralAssaultsResidence TargetFactionType scotland
    and I_SettlementUnderSiege Bear_Keep
    if I_TurnNumber < 800
    create_unit Bear_Keep, Northern CavalryG, num 1, exp 0, arm 0, wep 0
    create_unit Bear_Keep, Northern SpearmenG, num 8, exp 0, arm 0, wep 0
    create_unit Bear_Keep, Northern HalberdsG, num 3, exp 0, arm 0, wep 0
    create_unit Bear_Keep, Northern PikemenG, num 2, exp 0, arm 0, wep 0
    create_unit Bear_Keep, Northern BowmenG, num 3, exp 0, arm 0, wep 0
    create_unit Bear_Keep, Northern CrossbowmenG, num 3, exp 0, arm 0, wep 0
    set_counter Bear_Keep_siege 1
    end_if
    end_monitor




    monitor_event GeneralAssaultsResidence TargetFactionType scotland
    and I_SettlementUnderSiege Antlers
    if I_TurnNumber < 800
    create_unit Antlers, Northern CavalryG, num 1, exp 0, arm 0, wep 0
    create_unit Antlers, Northern SpearmenG, num 8, exp 0, arm 0, wep 0
    create_unit Antlers, Northern HalberdsG, num 3, exp 0, arm 0, wep 0
    create_unit Antlers, Northern PikemenG, num 2, exp 0, arm 0, wep 0
    create_unit Antlers, Northern BowmenG, num 3, exp 0, arm 0, wep 0
    create_unit Antlers, Northern CrossbowmenG, num 3, exp 0, arm 0, wep 0
    set_counter Antlers_siege 1
    end_if
    end_monitor
    :
    :
    :



    ;;; STORMLANDS
    monitor_event GeneralAssaultsResidence TargetFactionType spain
    and I_SettlementUnderSiege Bear_Keep
    if I_TurnNumber < 800
    create_unit Bear_Keep, Baratheon CavalryG, num 1, exp 1, arm 0, wep 0
    create_unit Bear_Keep, Baratheon SpearmenG, num 5, exp 1, arm 0, wep 0
    create_unit Bear_Keep, Baratheon SwordsmenG, num 5, exp 1, arm 0, wep 0
    create_unit Bear_Keep, Baratheon HalberdsG, num 3, exp 1, arm 0, wep 0
    create_unit Bear_Keep, Baratheon BowmenG, num 4, exp 1, arm 0, wep 0
    create_unit Bear_Keep, Baratheon CrossbowmenG, num 2, exp 1, arm 0, wep 0
    set_counter Bear_Keep_siege 1
    end_if
    end_monitor




    monitor_event GeneralAssaultsResidence TargetFactionType spain
    and I_SettlementUnderSiege Antlers
    if I_TurnNumber < 800
    create_unit Antlers, Baratheon CavalryG, num 1, exp 1, arm 0, wep 0
    create_unit Antlers, Baratheon SpearmenG, num 5, exp 1, arm 0, wep 0
    create_unit Antlers, Baratheon SwordsmenG, num 5, exp 1, arm 0, wep 0
    create_unit Antlers, Baratheon HalberdsG, num 3, exp 1, arm 0, wep 0
    create_unit Antlers, Baratheon BowmenG, num 4, exp 1, arm 0, wep 0
    create_unit Antlers, Baratheon CrossbowmenG, num 2, exp 1, arm 0, wep 0
    set_counter Antlers_siege 1
    end_if
    end_monitor
    :
    :
    :

    ;;; THE REACH
    etc
    Part three of the script sets the counter to zero if not under siege. I think Gigantus's method with counters is far superior than some other garrison script attempts which creates a new conditional each time for a different scenario. In this case it is all done through counters, saving the need for additional lines. I really think Gigantus's method is superior solely because of this

    Again for EACH faction you must nest all the settlements that will have the garrison generated. This script can get quite long
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;; [3] SET COUNTER TO 0 IF NOT SIEGED ;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; NORTH
    monitor_event FactionTurnEnd not FactionIsLocal
    if I_SettlementOwner Bear_Keep = scotland
    and not I_SettlementUnderSiege Bear_Keep
    set_counter Bear_Keep_siege 0
    end_if
    if I_SettlementOwner Antlers = scotland
    and not I_SettlementUnderSiege Antlers
    set_counter Antlers_siege 0
    end_if
    if I_SettlementOwner Fair_Castle = scotland
    and not I_SettlementUnderSiege Fair_Castle
    set_counter Fair_Castle_siege 0
    end_if
    :
    :
    :
    end_monitor

    ;;; VALE
    monitor_event FactionTurnEnd not FactionIsLocal
    if I_SettlementOwner Bear_Keep = portugal
    and not I_SettlementUnderSiege Bear_Keep
    set_counter Bear_Keep_siege 0
    end_if
    if I_SettlementOwner Antlers = portugal
    and not I_SettlementUnderSiege Antlers
    set_counter Antlers_siege 0
    end_if
    if I_SettlementOwner Fair_Castle = portugal
    and not I_SettlementUnderSiege Fair_Castle
    set_counter Fair_Castle_siege 0
    end_if
    :
    :
    :
    The last part actually destroys the garrison if not under siege. Again, this is easily done because it is setup with counters. Other garrison script tutorials do not destroy the garrison, leading to the player and AI to massive debt

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;; [4] DESTROY GARRISON IF COUNTER = 0 ;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; NORTH
    monitor_event FactionTurnStart FactionType scotland
    and not FactionIsLocal
    if I_CompareCounter Sisterton_siege < 1
    and I_CompareCounter Bear_Keep_siege < 1
    and I_CompareCounter Antlers_siege < 1
    and I_CompareCounter Fair_Castle_siege < 1
    and I_CompareCounter Driftmark_siege < 1
    and I_CompareCounter Hornhook_siege < 1
    and I_CompareCounter Orkmont_siege < 1
    and I_CompareCounter Ten_Towers_siege < 1
    :
    :
    :
    destroy_units scotland garrison
    end_if
    end_monitor

    ;;; VALE
    monitor_event FactionTurnStart FactionType portugal
    and not FactionIsLocal
    if I_CompareCounter Sisterton_siege < 1
    and I_CompareCounter Bear_Keep_siege < 1
    and I_CompareCounter Antlers_siege < 1
    and I_CompareCounter Fair_Castle_siege < 1
    and I_CompareCounter Driftmark_siege < 1
    and I_CompareCounter Hornhook_siege < 1
    and I_CompareCounter Orkmont_siege < 1
    and I_CompareCounter Ten_Towers_siege < 1
    and I_CompareCounter Pyke_siege < 1
    :
    :
    :
    destroy_units portugal garrison
    end_if
    end_monitor


    ;;; STORMLANDS
    monitor_event FactionTurnStart FactionType spain
    and not FactionIsLocal
    if I_CompareCounter Sisterton_siege < 1
    and I_CompareCounter Bear_Keep_siege < 1
    and I_CompareCounter Antlers_siege < 1
    etc


    Q: Does the above garrison script apply to AI and players?
    A: Yes. The above garrison script also applies to

    Player vs AI (aka, you besieging an enemy castle, and the enemy castle spawns the garrison), the original intended goal of the script
    AI vs Player (aka, AI besieges your settlement, and you also benefit from the garrison script). To disable the garrison script for you as a player you can add a IsAI conditional to the code.
    AI vs AI. Yes it seems to work between AI vs AI sieges as well


    Q: Does it lag the campaign??? Seems like a lot of code if applied to all factions and settlements
    A: Indeed, as Gigantus puts it "There would be no problem with processing as this will be two basics monitors plus one"

    To put some perspective, in my Grand Campaign with 12 factions and 126 settlements, with 6 garrison units for each faction, the entire garrison script totalled to about 18,000 lines and 800kb of data, however when I timed the performance of loading times and turn times before and after adding the garrison script, I saw virtually no diference

    Before Garrison Script
    >> New campaign loading: 6.2 seconds
    >> Turn times 1-10 turns: averaging 35 seconds

    After Garrison Script
    >> New campaign loading: 6.5 seconds
    >> Turn times 1-10 turns: averaging 33.5 seconds

    However there is SOME LAG when a siege battle is about to commence as attacker/defender. For me the lag was about 2 seconds at most
    Last edited by STELLover; September 26, 2016 at 11:36 PM.

    ROME 2 Mod: More Cities and Settlements on Campaign Map:
    http://steamcommunity.com/sharedfiles/filedetails/?id=194761024

  14. #14
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    Q: Is the " and IsTargetRegionOneOf Erzbistum_Mainz" conditional necessary? AKA, is it necessary to add a conditional explicitely checking that the settlement in question belongs to its respective region?
    It is necessary as the "GeneralAssaultsResidence" also exports an attack on any fort in that region.

    Code:
        monitor_event GeneralAssaultsResidence TargetFactionType egypt   ; does the attacked residence belong to this faction
            and IsTargetRegionOneOf Erzbistum_Mainz                      ; is the attacked residence in this region
            and I_SettlementUnderSiege Aschaffenburg                     ; is this settlement (belonging to the previously tested region) under siege
    Without the IsTargetRegionOneOf condition the event would also fire if the attack is on Hamburg (if egypt owned) while a siege is happening on Aschaffenburg.
    The names used are the data names (in curly brackets\descr_regions), not the display names.

    Edit: I suppose one could use the TargetSettlementName Aschaffenburg condition instead of region and then omit the I_SettlementUnderSiege Aschaffenburg condition, but I haven't tested it.

    Edit2: I remember now why I didn't use that condition - the event (GeneralAssaultsResidence) does not export a (target) settlement, only a (target) region.


    However there is SOME LAG when a siege battle is about to commence as attacker/defender. For me the lag was about 2 seconds at most
    That's the garison spawning - will only happen if the player is involved in the battle.
    Last edited by Gigantus; September 27, 2016 at 12:45 AM.










  15. #15
    STELLover's Avatar Senator
    Join Date
    Dec 2008
    Location
    Seoul
    Posts
    1,295

    Default Re: Creating a World - Instant garrisons and their disbandment

    Quote Originally Posted by Gigantus View Post
    Edit: I suppose one could use the TargetSettlementName Aschaffenburg condition instead of region and then omit the I_SettlementUnderSiege Aschaffenburg condition, but I haven't tested it.

    Yep. Tested this and doesnt work. Crashes upon battle too.

    ROME 2 Mod: More Cities and Settlements on Campaign Map:
    http://steamcommunity.com/sharedfiles/filedetails/?id=194761024

  16. #16

    Default Re: Creating a World - Instant garrisons and their disbandment

    I am having some trouble with the garrison script. I am using the Westeros one from this thread as my base. The first part is working as intended and the units are being created. The problem happens when I lift a siege - the units do not disappear on the owning factions turn. They end up keeping the unit.
    I am using the garrison tag on the EDU file. I included part of the script here and uploaded the full script as an attachment Any chance for someone to point out my error?


    Spoiler Alert, click show to read: 
    ;;; ENGLAND
    monitor_event FactionTurnEnd not FactionIsLocal
    if I_SettlementOwner Carlisle = england
    and not I_SettlementUnderSiege Carlisle
    set_counter Carlisle_siege 0
    end_if
    if I_SettlementOwner York = england
    and not I_SettlementUnderSiege York
    set_counter York_siege 0
    end_if
    if I_SettlementOwner Lancaster = england
    and not I_SettlementUnderSiege Lancaster
    set_counter Lancaster_siege 0
    end_if
    if I_SettlementOwner Chester = england
    and not I_SettlementUnderSiege Chester
    set_counter Chester_siege 0
    end_if
    if I_SettlementOwner Lincoln = england
    and not I_SettlementUnderSiege Lincoln
    set_counter Lincoln_siege 0
    end_if
    if I_SettlementOwner Nottingham = england
    and not I_SettlementUnderSiege Nottingham
    set_counter Nottingham_siege 0
    end_if
    if I_SettlementOwner Shrewsbury = england
    and not I_SettlementUnderSiege Shrewsbury
    set_counter Shrewsbury_siege 0
    end_if
    if I_SettlementOwner Norwich = england
    and not I_SettlementUnderSiege Norwich
    set_counter Norwich_siege 0
    end_if
    if I_SettlementOwner Oxford = england
    and not I_SettlementUnderSiege Oxford
    set_counter Oxford_siege 0
    end_if
    if I_SettlementOwner Gloucester = england
    and not I_SettlementUnderSiege Gloucester
    set_counter Gloucester_siege 0
    end_if
    if I_SettlementOwner London = england
    and not I_SettlementUnderSiege London
    set_counter London_siege 0
    end_if
    if I_SettlementOwner Winchester = england
    and not I_SettlementUnderSiege Winchester
    set_counter Winchester_siege 0
    end_if
    if I_SettlementOwner Canterbury = england
    and not I_SettlementUnderSiege Canterbury
    set_counter Canterbury_siege 0
    end_if
    if I_SettlementOwner Arundel = england
    and not I_SettlementUnderSiege Arundel
    set_counter Arundel_siege 0
    end_if
    if I_SettlementOwner Launceston = england
    and not I_SettlementUnderSiege Launceston
    set_counter Launceston_siege 0
    end_if
    if I_SettlementOwner Shaftsbury = england
    and not I_SettlementUnderSiege Shaftsbury
    set_counter Shaftsbury_siege 0
    end_if
    if I_SettlementOwner Castleton = england
    and not I_SettlementUnderSiege Castleton
    set_counter Castleton_siege 0
    end_if
    if I_SettlementOwner Durham = england
    and not I_SettlementUnderSiege Durham
    set_counter Durham_siege 0
    end_if
    end_monitor
    ;;; Ireland


    Spoiler Alert, click show to read: 
    ;;; ENGLAND
    monitor_event FactionTurnStart FactionType england
    and not FactionIsLocal
    if I_CompareCounter Carlisle_siege < 1
    and I_CompareCounter York_siege < 1
    and I_CompareCounter Lancaster_siege < 1
    and I_CompareCounter Chester_siege < 1
    and I_CompareCounter Lincoln_siege < 1
    and I_CompareCounter Nottingham_siege < 1
    and I_CompareCounter Shrewsbury_siege < 1
    and I_CompareCounter Norwich_siege < 1
    and I_CompareCounter Oxford_siege < 1
    and I_CompareCounter Gloucester_siege < 1
    and I_CompareCounter London_siege < 1
    and I_CompareCounter Winchester_siege < 1
    and I_CompareCounter Canterbury_siege < 1
    and I_CompareCounter Arundel_siege < 1
    and I_CompareCounter Launceston_siege < 1
    and I_CompareCounter Shaftsbury_siege < 1
    and I_CompareCounter Castleton_siege < 1
    and I_CompareCounter Durham_siege < 1
    destroy_units england garrison
    end_if
    end_monitor
    ;;; IRELAND


    Spoiler Alert, click show to read: 
    type Farmers
    dictionary Farmers
    category infantry
    class spearmen
    voice_type Heavy
    banner faction main_spear
    banner holy crusade
    soldier Breton_peasant, 60, 0, 1.5
    attributes sea_faring, hide_forest, can_withdraw, is_peasant, peasant, free_upkeep_unit, mercenary_unit, garrison
    formation 1.2, 1.2, 2.4, 2.4, 4, square
    stat_health 1, 0
    stat_pri 4, 2, no, 0, 0, melee, melee_simple, piercing, spear, 25, 0.6
    stat_pri_attr no
    stat_sec 0, 0, no, 0, 0, no, melee_simple, blunt, none, 25, 1
    stat_sec_attr no
    stat_pri_armour 1, 2, 0, flesh
    stat_sec_armour 0, 0, flesh
    stat_heat 4
    stat_ground 1, -2, 3, 4
    stat_mental 1, low, untrained
    stat_charge_dist 30
    stat_fire_delay 0
    stat_food 60, 300
    stat_cost 1, 110, 90, 50, 120, 110, 4, 30
    armour_ug_levels 1
    armour_ug_models Breton_peasant
    ownership england, koc, france, hre, denmark, spain, portugal, milan, venice, papal_states, slave, norway, wales, ireland, barons_alliance, scotland
    recruit_priority_offset -5
    Attached Files Attached Files
    Last edited by UBBERDORC; September 09, 2017 at 11:40 PM. Reason: added edu section

  17. #17
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    You haven't declared any of the siege counters, eg Carlisle_siege. You do however declare a Carlisle counter which isn't used.
    Last edited by Gigantus; September 10, 2017 at 12:31 AM.










  18. #18

    Default Re: Creating a World - Instant garrisons and their disbandment

    Looks like you were correct as usual Gigantus, I bow to you MTW2 greatness!
    Thanks again!

  19. #19
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Creating a World - Instant garrisons and their disbandment

    One is glad to be of service

    It should have shown in the log: 'counter does not exist' - Squid's checker will not pick up logic errors like this.

    As a matter of principle as of late I do not use regular counters if I can avoid it due to the need of declaring them. I rather use event_counters which always exist in the zero state, meaning you can test for 'and I_EventCounter DoesNotExist = 0' and the result will always be true. historic_events are event_counters, too.
    There are cases were you are forced to use regular counters, like in battle scripts, but otherwise it's not necessary.










  20. #20

    Default Re: Creating a World - Instant garrisons and their disbandment

    I seem to be having the same issue as UBBERDORC. When I lift the siege, the unit do not disappear on the owning factions turn and they keep the units. A copy of my script is below. Anyone able to catch any errors?


    Code:
        
        declare_counter Caen_siege    
        declare_counter Paris_siege
       
        ;--- Spawn Garrison ---
        monitor_event GeneralAssaultsResidence TargetFactionType france
            and IsTargetRegionOneOf Normandie
            and I_SettlementUnderSiege Caen
            if I_TurnNumber < 800
                create_unit Caen, Dismounted Chivalric KnightsG, num 2, exp 1, arm 1, wep 1
                create_unit Caen, CrossbowmenG, num 2, exp 1, arm 0, wep 0
                create_unit Caen, Pike MilitiaG, num 2, exp 1, arm 0, wep 0
                set_counter Caen_siege 1
            end_if
        end_monitor
    
    
        monitor_event GeneralAssaultsResidence TargetFactionType france
            and IsTargetRegionOneOf Ile_de_France
            and I_SettlementUnderSiege Paris
            if I_TurnNumber < 800
                create_unit Paris, Dismounted Chivalric KnightsG, num 2, exp 1, arm 1, wep 1
                create_unit Paris, CrossbowmenG, num 2, exp 1, arm 0, wep 0
                create_unit Paris, Pike MilitiaG, num 2, exp 1, arm 0, wep 0
                set_counter Paris_siege 1
            end_if
        end_monitor
    
    
        ;--- Check Garrison ---
        monitor_event FactionTurnEnd not FactionIsLocal
    
    
            if I_SettlementOwner Caen = france
                and not I_SettlementUnderSiege Caen
                set_counter Caen_siege 0
            end_if
            if I_SettlementOwner Paris = france
                and not I_SettlementUnderSiege Paris
                set_counter Paris_siege 0
            end_if
        end_monitor
    
    
    
    
        ;--- Remove Garrison ---
        monitor_event FactionTurnStart FactionType france
            and not FactionIsLocal
            if I_CompareCounter Caen_siege < 1
                and I_CompareCounter Paris_siege < 1
                destroy_units france garrison
            end_if
        end_monitor

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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