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

Thread: Just another freeze attempt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Just another freeze attempt

    I have been tossing some ideas around on how to restrict recruiting to avoid those monstrous stack numbers the AI sometimes manages to accumulate because of the 'recruit first - build later' policy. I came up with this script that uses income and upkeep percentage as criteria and then freezes regional pools based on faction ownership. It obviously resets the pools to zero like any other change\stop in recruiting does.

    Any ideas are welcome (yes, I know, it will be a thankless task to create the script , even with GED's script replicator)


    Code:
    ; --- checking the upkeep level ---
    declare_counter exceedlimit_[faction]
    monitor_event FactionTurnStart FactionType [faction]
        if not I_IsFactionAIControlled            ; terminate monitor if faction is player controlled
            terminate_monitor
        end_if
        and IsFactionAIControlled                ; faction is AI controlled
        and SupportCostPercentage > 75            ; upkeep exceeds this percentage (upkeep\income*100)
        and FactionIncome > 11000                ; based on average upkeep cost of a full stack (8.5K) and the SupportCostPercentage value
        set_counter exceedlimit_[faction] 1    ; set the 'limit' counter true
    end_monitor
    
    monitor_event FactionTurnStart FactionType [faction]
        if not I_IsFactionAIControlled
            terminate_monitor
        end_if
        and IsFactionAIControlled
        and SupportCostPercentage < 75            ; upkeep is below this percentage
        set_counter exceedlimit_[faction] 0        ; set the 'limit' counter false
    end_monitor
    
    ; --- setting the regional recruit pools ---
    declare_counter [region]_frozen
    monitor_event FactionTurnStart FactionType [faction]
        if not I_IsFactionAIControlled            ; terminate monitor if faction is player controlled
            terminate_monitor
        end_if
        if I_SettlementOwner [settlement] [faction]                ; does this faction own this settlement
            and I_CompareCounter exceedlimit_[faction] > 0        ; has this faction exceeded the upkeep limit
            and I_CompareCounter [region]_frozen < 1                ; is this pool NOT frozen
            freeze_recruit_pool [region] true                    ; freeze the regional recruit pool
            set_counter [region]_frozen 1                        ; set the 'region' counter true
        end_if
        if I_SettlementOwner [settlement] [faction]
            and I_CompareCounter exceedlimit_[faction] < 1        ; is this faction below the upkeep limit
            and I_CompareCounter [region]_frozen > 0            ; is this pool frozen
            freeze_recruit_pool [region] false                    ; unfreeze the pool
            set_counter [region]_frozen 0                        ; set the 'region' counter false
        end_if
    end_monitor
    An alternative to the regional recruit pool freeze would be faction specific event counters that get applied to individual (single faction condition) recruitment lines. This would be 'easier' but may not always be feasible due to complicated condition 'lists'.

    Code:
    ; --- checking the upkeep level ---
    monitor_event FactionTurnStart FactionType [faction]
        if not I_IsFactionAIControlled            ; terminate monitor if faction is player controlled
            terminate_monitor
        end_if
        and IsFactionAIControlled                ; faction is AI controlled
        and SupportCostPercentage > 75            ; upkeep exceeds this percentage (upkeep\income*100)
        and FactionIncome > 11000                ; based on average upkeep cost of a full stack and the SupportCostPercentage value
        and not I_EventCounter exceedlimit_[faction] 1
        set_event_counter exceedlimit_[faction] 1    ; set the 'limit' event counter true
    end_monitor
    
    monitor_event FactionTurnStart FactionType [faction]
        if not I_IsFactionAIControlled
            terminate_monitor
        end_if
        and IsFactionAIControlled
        and SupportCostPercentage < 75            ; upkeep is below this percentage
        and not I_EventCounter exceedlimit_[faction] 0
        set_event_counter exceedlimit_[faction] 0        ; set the 'limit' event counter false
    end_monitor
    Last edited by Gigantus; April 30, 2015 at 11:51 PM.










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

    Default Re: Just another freeze attempt

    Interesting. SupportCostsPercentage is a new one on me ... never used it and probably because I never understood its Demons description.

    There's a syntax error in what you posted: you can't put anything between the "and" conditions, including IF statements. (Comments are legal.) This would fix it...

    Code:
    monitor_event FactionTurnStart FactionType [faction]
        and IsFactionAIControlled                ; faction is AI controlled
        and SupportCostPercentage > 75            ; upkeep exceeds this percentage (upkeep\income*100)
        and FactionIncome > 11000                ; based on average upkeep cost of a full stack (8.5K) and the SupportCostPercentage value
    
        if not I_IsFactionAIControlled [faction]            ; terminate monitor if faction is player controlled
            terminate_monitor
        end_if
    
        set_counter exceedlimit_[faction] 1    ; set the 'limit' counter true
    end_monitor

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    Thanks for pointing out the issue, that will save me a lot of heart ache. Must be getting rusty...

    I came across the SupportCostsPercentage condition when I was trawling the Demons for economic\income stuff. My basic idea was to give it a shot at a financial script initally, but seeing that the underlying problem is the "recruiting before building" issue I thought this might have value. Now I just have to find a good value for the percentage.

    My previous attempt failed because I used global freezing (dooooh) and a system of assigning counter points to unit categories. The obvious drawbacks of trying to count units in play eventually grounded that.










  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    The whole stuff didn't work because of a spelling issue: it's SupportCostsPercentage

    And I have to figure out what it actually calculates, this script fires both historic events:
    Code:
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    > 0.9
            historic_event limit_exceed
        end_monitor
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    < 1.1
            historic_event limit_below
        end_monitor
    The treasury looks like this (using Bare Geomod):

    Last edited by Gigantus; May 02, 2015 at 12:32 AM.










  5. #5
    KEA's Avatar Senator
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    1,104

    Default Re: Just another freeze attempt

    Quote Originally Posted by Gigantus View Post
    And I have to figure out what it actually calculates, this script fires both historic events:
    Code:
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    > 0.9
            historic_event limit_exceed
        end_monitor
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    < 1.1
            historic_event limit_below
        end_monitor
    In this case it is either exactly "1" - or SupportCostsPercentage is broken

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

    Default Re: Just another freeze attempt

    Quote Originally Posted by Gigantus View Post
    this script fires both historic events:
    Code:
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    > 0.9
            historic_event limit_exceed
        end_monitor
        monitor_event FactionTurnStart FactionType england
            and SupportCostsPercentage    < 1.1
            historic_event limit_below
        end_monitor
    If the percentage was between 0.9 and 1.1 then both will fire. And it is. I tried this...

    Code:
    monitor_event CharacterSelected FactionType england
        and SupportCostsPercentage > 1.0
        console_command add_money 1
    end_monitor
    
    monitor_event CharacterSelected FactionType england
        and SupportCostsPercentage < 1.0
        console_command add_money 2
    end_monitor
    
    monitor_event CharacterSelected FactionType england
        and SupportCostsPercentage = 1.0
        console_command add_money 4
    end_monitor
    ...where my finance scroll showed 7000 army upkeep and 3000 wages (and 0 everything else). When selecting a character I got 4 money => the third monitor was firing => SupportCostsPercentage = 1.0.

    If I added some construction to the queue then the second monitor fired instead.

    My guess is that for SupportCostsPercentage's percentage value, 1.0 = 100%, 0.5 = 50%, and so on, and that "support costs" include wages, not just army upkeep.

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    I am having a feeling that the condition measures the percentage in relation to total expenditure - not income. Hence exactly 1.0 when there was only wages and upkeep.
    That the value is in decimal, not percentage as you assume seems to be a given.

    This also makes it pointless to test at the beginning of a faction's turn, apart from corruption this would always be 100%

    Code:
        monitor_event FactionTurnEnd FactionIsLocal
            and SupportCostsPercentage    < 0.95
            historic_event level_1
        end_monitor
        monitor_event FactionTurnEnd FactionIsLocal
            and SupportCostsPercentage    => 0.95
            and SupportCostsPercentage    < 0.96
            historic_event level_2
        end_monitor
        monitor_event FactionTurnEnd FactionIsLocal
            and SupportCostsPercentage    => 0.96
            and SupportCostsPercentage    < 0.97
            historic_event level_3
        end_monitor
        monitor_event FactionTurnEnd FactionIsLocal
            and SupportCostsPercentage    => 0.97
            and SupportCostsPercentage    < 0.98
            historic_event level_4
        end_monitor
        monitor_event FactionTurnEnd FactionIsLocal
            and SupportCostsPercentage    => 0.98
            historic_event level_5
        end_monitor
    I used this script with the moors and build for 7k against 4k wages and upkeep - all 5 events fired in the next round (starting with level 5). Seems FactionTurnEnd doesn't do the job either.
    Last edited by Gigantus; May 02, 2015 at 04:05 AM.










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

    Default Re: Just another freeze attempt

    Quote Originally Posted by Gigantus View Post
    I am having a feeling that the condition measures the percentage in relation to total expenditure - not income.
    That is what the Demons say, yes...

    Does the percentage of expenditure devoted to support costs exceed the threshold?
    That the value is in decimal, not percentage as you assume seems to be a given.
    Yet the Demons example uses "35.8". An error, it would seem.

    This also makes it pointless to test at the beginning of a faction's turn, apart from corruption this would always be 100%
    Ah yes, I see what you mean. Because a building that is added to the queue this turn will not be an expense next turn, for example. Dang, it does seem like a largely pointless condition and completely pointless for your purposes.

    I used this script with the moors and build for 7k against 4k wages and upkeep - all 5 events fired in the next round (starting with level 5).
    Should be:

    and SupportCostsPercentage >= 0.95

    No doubt the log is screaming at you on those ones. I reckon those errors are resulting in the last four monitors ignoring those conditions and therefore always executing.

  9. #9
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    A few months no scripting and I forget half the stuff.

    With the corrected token it appears to work - no building or recruiting triggers level 5. Doing so triggers other levels. It might still come useful:
    If I am testing for level 1 and then freeze the recruit pool because too much non support expenses occur the AI might have been building, in which case it will not prevent him to continue doing so.
    If he has been recruiting then he will not be able to do so further.
    The problem will come if he then only builds and thereby keeps the percentage low. Which means I would need to know if there are buildings in the queue, the two QueueIdle conditions are not helpful here as they only test if any slot is used

    May be make the 'trainingqueue' a condition for the freeze?

    percentage lower then 0.96 and not trainingqueueidle
    Last edited by Gigantus; May 02, 2015 at 07:19 AM.










  10. #10
    Junaidi83 de Bodemloze's Avatar Dont Mess With Me
    Join Date
    Feb 2011
    Location
    Indonesia
    Posts
    2,616

    Default Re: Just another freeze attempt

    A few months no scripting and I forget half the stuff.
    Sir Gigantus may i ask why you not move to other level of total war game, i mean you are briliant modder who understand to use script, like creating romance three kingdom mods, etc etc.

    Its just its very rare looking great modder from med 2 , like kingkong, You, and several other modder , move up toward other lvl twc game. Considering warhammer finnally happens

    Hey before i got this title artifek i always look up to you guys, spending my days as lurker download various cool mod in TWC, i still remember when three kingdom mod still wip,and i post my comment to support that project.
    Last edited by Junaidi83 de Bodemloze; May 02, 2015 at 08:32 AM.
    Modding is like accursed wine, you try a sip and you ended empty the whole glass
    Under Proud Patronage of Shankbot de Bodemloze

  11. #11
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    Simple reason actually - the scripting in the warscape engine is pretty much non existing or needs a doctoral degree. The mapping, other then historical battle maps (takes a download of 60GB of terrain data I believe), is non existing, too. Without those two I consider it not worth trying to move onto the new engine.

    You have seen the Cao Cao mission chain in RotK - think something like this is possible in Attila? Or the intricate trait development? It's very much what I consider the soul of the game. How often can you play Attila? It's still the same hills and fields, the same 'traits' (don't get me started on the ancillaries). What changes are start positions and soldiers, a few tweaks and color splashes on the UI thrown in.










  12. #12
    Junaidi83 de Bodemloze's Avatar Dont Mess With Me
    Join Date
    Feb 2011
    Location
    Indonesia
    Posts
    2,616

    Default Re: Just another freeze attempt

    Yeah i understand pretty much, its just great idea if looking Sir Gigantus create overhaul mod for Attila, who know what you guys can do
    Modding is like accursed wine, you try a sip and you ended empty the whole glass
    Under Proud Patronage of Shankbot de Bodemloze

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

    Default Re: Just another freeze attempt

    I don't know, Gig, it seems to me that there are too many variables involved for SupportCosts to be reliable. e.g. The other expenses: Corruption and Diplomacy.

    What if FactionScore [military] was used as the measure instead? e.g. If >=90% of the strongest faction's military strength, including the strongest faction itself of course, then cut off their recruitment. It is a relative measure and therefore has its own shortcomings (e.g. won't stop weaker factions from spending all of their money on recruitment) but it would be more reliable and certainly easier.

    Quote Originally Posted by Gigantus View Post
    It obviously resets the pools to zero like any other change\stop in recruiting does.
    For mercenaries the pool updates are done some time between FactionTurnEnd of the slave turn and the beginning of the next (first) faction's turn (see this thread). I am pretty sure that building recruitment pools behave the same way. Assuming it is then...

    You could use the EDB event counter mechanism to toggle recruitment availability (your second script in the OP), set all of those event counters to 1 in a "FactionTurnEnd FactionType slave" monitor, and set them to 0 only if and when they need to be: in a FactionTurnStart [faction] monitor. That way, even if toggled off during their own turn so they can't recruit, the pools will continue to grow normally.

    Of course that would mean that when recruitment is re-made available to them they might have a large pool, which is either a positive or a negative depending on how you look at it: a question of should the pools continue to grow during periods of recruitment lockdown.

  14. #14
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    Thanks for the ideas\input. It would seem that the larger problem remains how to define a reliable trigger mechanism for the actual recruitment stop.

    I am actually thinking of revisiting the unit point system (originally used in DLV I believe), that appears to be the most accurate so far. It's points granted by settlements (the higher the level the more points) versus units trained\disbanded. There was a provision for non-scriptable events like bribing, I'll have to go through the various (38) parts.

    Edit: I have run into a bit of a messy situation. I want to test the loss of a settlement and make it IF compliant because of all the factions and the multiple levels of settlements. Now the capture of a settlement is straight forward as I can simply test whose faction's round (faction_turn counter) it was:
    Code:
    ; --- Settlement captured level 5 ---
    monitor_event GeneralCaptureSettlement TrueCondition
        and SettlementBuildingExists == huge_stone_wall_stone_wall
            if I_Compare_Counter [faction]_turn > 0
                inc_counter factionsize_[faction] 30
            end_if
    end_monitor
    It get's messy when I want to test for the loss as it appears I will have to use the TargetFactionType condition without possible use of IF to reduce the number of monitors:

    Code:
    ; --- Settlement lost level 2 ---
    monitor_event GeneralCaptureSettlement TargetFactionType [faction]
        and SettlementBuildingExists == wooden_wall
        inc_counter factionsize_[faction] -15
    end_monitor
    I was thinking of resetting the factionsize counter at slave turn end or PreFactionTurnStart and then using SettlementTurnStart to build up that number again - but somehow I think that will not work if I want to disable the recruiting, certainly not in the present round. It just isn't feasible to have 5 monitors (wall level check) per faction instead of just 5 monitors.

    This won't work either (unless I have the turn counters for factions 2-31 listed in one IF loop and then in 29 combinations - I rather shoot myself).

    Code:
    ; --- Settlement lost level 1 ---
    monitor_event GeneralCaptureSettlement TrueCondition
        and SettlementBuildingExists == wooden_pallisade
        if I_Compare_Counter [faction1]_turn < 1           ; possible defender (not the faction's turn)
            and I_Compare_Counter [faction2]_turn > 0       ; attacker (it's this faction's turn)
            inc_counter factionsize_[faction1] -10
        end_if
            if I_Compare_Counter [faction1]_turn < 1
            and I_Compare_Counter [faction3]_turn > 0
            inc_counter factionsize_[faction1] -10
        end_if
       ...
       ...
       ...
    end_monitor
    What would happen if I use the 'smaller' token for faction 1 and the 'bigger\equal' token for all others? (I can live with scripting that - it's actually extremely easy in two steps)

    Code:
    ; --- Settlement lost level 1 ---
    monitor_event GeneralCaptureSettlement TrueCondition
        and SettlementBuildingExists == wooden_pallisade
        if I_Compare_Counter [faction1]_turn < 1
            and I_Compare_Counter [faction2]_turn >= 0
            and I_Compare_Counter [faction3]_turn >= 0
            and I_Compare_Counter [faction4]_turn >= 0
            ...
            ...
            inc_counter factionsize_[faction1] -10
            end_monitor
        end_if
        if I_Compare_Counter [faction2]_turn < 1
            and I_Compare_Counter [faction1]_turn >= 0
            and I_Compare_Counter [faction3]_turn >= 0
            and I_Compare_Counter [faction4]_turn >= 0
            ...
            ...
            inc_counter factionsize_[faction2] -10
            end_monitor
        end_if
    end_monitor
    Last edited by Gigantus; May 03, 2015 at 04:19 AM.










  15. #15
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    Right, that last monitor contraption (obviously) didn't work. So I came up with another, slightly more involved one:

    Code:
    ; --- Settlement lost level 1 ---
    monitor_event GeneralCaptureSettlement TrueCondition
        and SettlementBuildingExists == wooden_pallisade
        if I_Compare_Counter [faction1]_turn < 1
            and I_Compare_Counter [faction2]_turn > 0
            inc_counter factionsize_[faction1] -10
        end_if
        if I_Compare_Counter [faction1]_turn < 1
            and I_Compare_Counter [faction3]_turn > 0
            inc_counter factionsize_[faction1] -10
        end_if
        
        ; add lines for all factions, then start with the second faction again
        
            if I_Compare_Counter [faction2]_turn < 1
            and I_Compare_Counter [faction1]_turn > 0
            inc_counter factionsize_[faction2] -10
        end_if
        if I_Compare_Counter [faction2]_turn < 1
            and I_Compare_Counter [faction3]_turn > 0
            inc_counter factionsize_[faction2] -10
        end_if
    end_monitor
    I guess I simply won't get around listing every permutation for attacker and defender.










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

    Default Re: Just another freeze attempt

    If the defender sallied out and lost the battle with no survivors then the sieger would move in and trigger GeneralCaptureSettlement - but it was the defender's turn so the [faction]_turn won't be correct from your script's point of view. (Would it?)

    It's I_CompareCounter by the way. Not I_Compare_Counter.

    One way to cut down on the monitor count would be this...

    Code:
    declare_counter captured_wall_size
    declare_counter captured_by_faction
    declare_counter captured_from_faction
    
    ;----- wall checks ----
    
    monitor_event GeneralCaptureSettlement
      set_counter captured_wall_size 0  ;default to "village"
      set_counter captured_by_faction 0
      set_counter captured_from_faction 0
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == wooden_pallisade
      set_counter captured_wall_size 1
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == wooden_wall
      set_counter captured_wall_size 2
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == stone_wall
      set_counter captured_wall_size 3
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == large_stone_wall
      set_counter captured_wall_size 4
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == huge_stone_wall
      set_counter captured_wall_size 5
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == motte_and_bailey
      set_counter captured_wall_size 1
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == wooden_castle
      set_counter captured_wall_size 2
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == castle
      set_counter captured_wall_size 3
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == fortress
      set_counter captured_wall_size 4
    end_monitor
    
    monitor_event GeneralCaptureSettlement SettlementBuildingExists == citadel
      set_counter captured_wall_size 5
    end_monitor
    
    ;----- captured_by checks ----
    
    monitor_event GeneralCaptureSettlement FactionType england
      set_counter captured_by_faction 1
    end_monitor
    
    monitor_event GeneralCaptureSettlement FactionType france
      set_counter captured_by_faction 2
    end_monitor
    
    ;...other factions...
    
    ;----- captured_from checks ----
    
    monitor_event GeneralCaptureSettlement TargetFactionType england
      set_counter captured_from_faction 1
    end_monitor
    
    monitor_event GeneralCaptureSettlement TargetFactionType france
      set_counter captured_from_faction 2
    end_monitor
    
    ;...other factions...
    
    ;----- main monitor ----
    
    monitor_event GeneralCaptureSettlement
    
      ;can use captured_wall_size, captured_by_faction and captured_from_faction in IF statements here
    
    end_monitor
    That's still quite a few monitors, 11 + (2 x relevant faction count), but better than what attacker+defender+wall permutations would create.

    (I would have said this earlier but your previous post was an edit so I had no visual cue that the thread had been added to. I hate that shortcoming of forums.)

  17. #17
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    I didn't think of that scenario, thanks. I am just a bit vary of monitors: my complete script at the moment only has 62 plus 10 outstanding for the castle stuff. Let me do the numbers if it makes sense to make provision for this possibility.

    The BuildingExists lines remind me that I haven't coded the castle line yet, and correct the I_CompareCounter stuff while I am at it.

    I am just having a mild nightmare thinking of how many IF permutations that will make, now that there are three variables (even GED's replicator will require a good number of rounds to create this script):

    Code:
    if I_CompareCounter captured_from_faction 1
        and I_CompareCounter captured_from_faction 2
        and I_CompareCounter captured_wall_size 1
        inc_counter factionsize_faction1 -10
        inc_counter factionsize_faction2 10
    end_if
    Last edited by Gigantus; May 07, 2015 at 01:05 PM.










  18. #18
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    I think I solved my template night mare:

    Code:
    monitor_event GeneralCaptureSettlement
    
        if I_CompareCounter captured_by_faction == [counter1]
            and I_CompareCounter captured_from_faction == [counter2]
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction1] 10
                    inc_counter factionsize_[faction2] -10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction1] 15
                    inc_counter factionsize_[faction2] -15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction1] 20
                    inc_counter factionsize_[faction2] -20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction1] 25
                    inc_counter factionsize_[faction2] -25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction1] 30
                    inc_counter factionsize_[faction2] -30
                end_if
        end_if
    
    end_monitor
    Still quite some replicate fiesta, have to really think hard how to proceed - 4 variables.

    Probably first replicate faction1. Then the individual results with faction2, manually changing counter1 before replicating and counter2 after replicating. For good housekeeping then a removal of IF loops where the 'from' and 'by' are the same faction.

    Just as well I am retired.
    Last edited by Gigantus; May 07, 2015 at 09:44 PM.










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

    Default Re: Just another freeze attempt

    If faction1 captures a settlement then you just need to increase a counter based only on wall size; it is irrelevant who the captured faction was. And vice versa.

    You could just do this...

    Code:
    monitor_event GeneralCaptureSettlement
    
        ;--- captured settlement ---
    
        if I_CompareCounter captured_by_faction == 1
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction1] 10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction1] 15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction1] 20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction1] 25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction1] 30
                end_if
        end_if
    
        if I_CompareCounter captured_by_faction == 2
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction2] 10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction2] 15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction2] 20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction2] 25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction2] 30
                end_if
        end_if
        
        ;...other factions...
        
        
        ;--- lost settlement ---
    
        if I_CompareCounter captured_from_faction == 1
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction1] -10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction1] -15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction1] -20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction1] -25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction1] -30
                end_if
        end_if
    
        if I_CompareCounter captured_from_faction == 2
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction2] -10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction2] -15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction2] -20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction2] -25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction2] -30
                end_if
        end_if
        
        ;...other factions...
    
    end_monitor
    It won't ease your replication woes but the resulting script will be much shorter. It might actually be quicker to code it by hand than use a replicator.

  20. #20
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

    Default Re: Just another freeze attempt

    You are right, way shorter (IF loops = 2*faction count) - I was unnecessarily complicating things. It's very easy to replicate this: use [faction] as variable and then change the 'captured_from' value by hand according to the faction's counter value from the relevant monitor. Which should be in the same order as the replicated parts as it originates from the same faction variable list. So I don't even have to look up the number.

    [faction1]=england=1
    [faction2]=france=2
    etc

    part to replicate:

    Code:
        if I_CompareCounter captured_by_faction == 1
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction] 10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction] 15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction] 20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction] 25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction] 30
                end_if
        end_if
        if I_CompareCounter captured_from_faction == 1
                if I_CompareCounter captured_wall_size == 1
                    inc_counter factionsize_[faction] -10
                end_if
                if I_CompareCounter captured_wall_size == 2
                    inc_counter factionsize_[faction] -15
                end_if
                if I_CompareCounter captured_wall_size == 3
                    inc_counter factionsize_[faction] -20
                end_if
                if I_CompareCounter captured_wall_size == 4
                    inc_counter factionsize_[faction] -25
                end_if
                if I_CompareCounter captured_wall_size == 5
                    inc_counter factionsize_[faction] -30
                end_if
        end_if
    A somewhat related question: I remember that there is a way to merge txt files via a batch file command. I have this script split up into the various replicated parts (38 before this change) - can they be merged using a command like that? My first 'splicing' took 15 minutes and the result of a script with 227K lines was truly noteworthy, considering it had only 62 monitors.

    Edit
    I found it: copy PDERBigMapcfg.txt+medieval2.preference.cfg PDER_BigMap.cfg (truly old - from the PDeR 1.0 development time)

    Which means I have to list all files with their full names and extension and join them with a plus sign, output name and extension at the end. I'll use the file list without sub directories command to create the list: dir *.* /s /b > filelisting.txt

    Edit2
    It appears to be working (file names may not have spaces), just have to make sure to leave an empty line at the bottom of each script file. I am just curious about the SUB symbol added at the end of the newly created file (nowhere else in the compilation). Any idea what that means?

    Last edited by Gigantus; May 07, 2015 at 11:17 PM.










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
  •