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

Thread: [Resource] Things that Break when Reloading

Hybrid View

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

    Default [Resource] Things that Break when Reloading

    Ideally, opening a campaign save file should load up the campaign exactly as it was when it was saved and closed. And ideally all UI elements would refresh immediately in response to script events instead of refreshing only once the save has been reloaded. Unfortunately M2 isn't ideal in either of these ways.

    In the interest of not getting blindsided by any more of these 'reloading bugs', I would like to start a list of them here that everyone can use as a reference. Please contribute any you know of that I'm leaving out. Again, these are bugs that are somehow related to or induced by the act of reloading a campaign save by selecting a save game file, fighting a battle and exiting back to the campaign map, or even alt-tabbing.

    Note: In this post, "reloading" the campaign is used as a blanket term to describe any process that brings up the loading bar before returning to the campaign map. There are several ways to induce the loading bar that I know of:

    - loading a save game file - this can be addressed in script by monitoring the GameReloaded event
    - ending a battle and returning to the campaign map - this can be addressed in script by monitoring the PostBattle event
    - alt-tabbing back into the game - this does not appear to count as a true reloading of the campaign map and thus does not need to be accounted for in script, convenient since there is no event for it, aside from the radar map bugging out if was zoomed in prior to the alt-tab the hotseat interface updates (item #3) is the only thing that I've found is affected by reloading the campaign in this way
    - issuing the console command 'reset_display' - this only affects the UI



    1. Portrait Reset after Religion Change - After a faction's religion is changed with the command 'set_religion', the faction's generic general portraits won't be reassigned to the new religion pool until reloading the UI. This can be fixed with reset_display.

    2. All Settlement Commands Turned On - filter_settlement_commands is turned 'on' for all settlements on the map when the campaign is reloaded. This command is used to prevent the player from building or recruiting at a specified settlement when set to 'off' but it is effectively reset to 'on' for all settlements when the campaign is reloaded. This can be fixed with scripting.

    3. Hotseat Interface Updates - UI between controlled factions isn't updated until reloading - i.e. if multiple factions are controlled in hotseat (either at the start of the campaign or by using the 'control' command), the HUD, scrolls, etc. will remain the same from the culture of the first faction loaded unless the UI is reloaded. This can be fixed using reset_display.

    4. Messages Closed - some message scrolls are closed automatically when the campaign is reloaded. This affects single player and hotseat campaigns alike, although the effect is more pronounced in multiplayer hotseats where the campaign must be reloaded between every human faction's turn effectively disabling all historic events unless a script solution is used. Accept/Decline events are also affected by this bug. this can be fixed with scripting. See below for which message scrolls survive a reload and which are closed.
    Spoiler Alert, click show to read: 

    Saved Scrolls (that do pop up again after reloading the map):
    - turn end summary
    - guild offers
    - marriage offers
    - adoption offers
    - player-to-player hotseat messages
    - diplomacy offers

    Unsaved Scrolls (that do not pop up again after reloading the map):
    - historic events
    - disaster news
    - traits & ancillaries news
    - family news (marriages, adoptions, births, coming of age, deaths, man of the hour, etc.)
    - diplomatic stances news
    - diplomatic standings news
    - faction rankings news

    5. Characters w/ Same Display Name Reassigned to Same Internal Name - characters with the same display name but different internal names get reassigned to the same internal names on reloading the campaign. This is not a problem for uniquely named characters so long as only one character with the name is on the map at a time.

    6. Console Commands Don't Reset - console commands (used via the in-game console or campaign_script), such as toggle_fow and bestbuy, change a setting that isn't reset when loading a new campaign. They are only reset when the game is relaunched. I.e. if you start a campaign as england, use toggle_fow to turn fog of war off, then quit that campaign and load a new campaign as france, fog of war will still be toggled off. These console commands fail to reset when reloading the campaign whereas other console commands like filter_settlement_commands reset to a default on/off value when they shouldn't. This can be addressed for individual campaigns using scripting but there is no way to address this bug for different campaigns.

    7. Custom Settlement Strat Models Reset - upon reloading the campaign map (when loading a save, the bug does not appear after fighting a battle), any settlements using faction_variant strat models which are in the fog of war (visible but not within line of sight) will be appear to use the culture default strat models. This bug has been known for Third Age Total War for a long time (Minas Tirith turning into a port, etc.). If there is only one human player, this bug can be addressed by monitoring when the settlement tiles have been revealed (TileSeen, IsPositionInRect) and setting a counter. A GameReloaded monitor checks if the counter == 1 and then issues reveal_tile followed by hide_all_revealed_tiles. This script monitors when the tiles have been 'discovered naturally' and then henceforth reveals and hides these tiles every time the map is reloaded in order to 'refresh' the bugged custom settlement strat models under fog. This concept can be extended to multiplayer hotseats using character spawns instead of reveal_tile (which is not faction-specific).

    8. UI Remains Hidden - scripts can hide the UI using the hide_ui command. If the campaign is reloaded while the UI is hidden, the UI will not be shown when the map is reloaded. If the user has no way to issue the show_ui command (for example, with a hotkey script), then they will be unable to continue their campaign (no way to end the turn, etc.). This can be fixed with scripting.

    9. Agents Spawned with spawn_army Are Killed - It's possible to spawn agents (priests, diplomats, princesses, spies, etc.) using the spawn_army command in script. I credit this trick to Gigantus. However, the game treats the spawned character like a hybrid between an agent and a named character (which would normally be spawned with spawn_army). One of the conditions for a named character to survive is that they have a bodyguard unit. Since agents spawned with this trick do not have a bodyguard unit, they do not survive when a campaign save is reloaded. The only other aspect of a named character that the agent is known to retain, in addition to requiring a bodyguard unit, is that the game will not randomly assign a new name if the agent becomes pope, see here.

    10. 'soldiers 1' Reset to Size - Spawning an elephant mount unit using the 'soldiers 1' tag in campaign_script results in the unit having only a single elephant on the battle map. However, if the unit size is large or huge, the number of elephants will 'return to normal' at 3 upon reloading the campaign. This does not happen for elephant artillery units.

    11. sub_faction Tag Removed for non-slave_faction - If a non-slave faction uses the sub_faction tag in descr_strat for a non-slave_faction faction in order to get a character to use battle animations, name, strat model, and tooltip from another faction, the effect will be lost (all of these things revert to owning faction's versions) upon reloading the campaign map. One of the functions of the slave_faction tag in descr_sm_factions must be to prevent this reset upon reloading.

    12. converted generals get the animation sets of their new faction - generals (named characters and presumably captains as well) that are converted from one faction to another by any means (bribery, give_everything_to_faction, revolt, etc.) will retain the animation set from their original faction until the campaign is reloaded.
    Last edited by Callistonian; July 18, 2022 at 02:44 PM.

  2. #2
    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: Things that Break when Reloading

    Something that really messes things up: saving while a yes\no event is pending and then reloading. withnwar scripted a fix for it:
    Code:
        monitor_event GameReloaded TrueCondition
        ; --- Historic Event resets
            if I_EventCounter [historic event's name] = 1                    ; the message fired
                and I_EventCounter [historic event's name]_accepted = 0        ; but had no response
                and I_EventCounter [historic event's name]_declined = 0        ; but had no response
                campaign_wait 0.1
                set_event_counter [historic event's name] 0                    ; resetting the event's counter (there might be script dependencies, next step will increase counter)
                historic_event [historic event's name] true                    ; fire message again
                [rest of original monitor]
            end_if
        end_monitor










  3. #3

    Default Re: Things that Break when Reloading

    Yes, I forgot about that. I found that it's a good idea to pair that monitor with a PostBattle monitor as GameReloaded doesn't seem to account for reloading the map after a battle. This could be a problem for yes/no events if the player manages to start a battle or there is a script induced battle before they can answer the event. It's definitely a problem for any scripts that use filter_settlement_commands.

  4. #4
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,057

    Default Re: Things that Break when Reloading

    I'm not sure if it's related to this topic, but I've found that when you start a campaign with campaign script in which you've set toggle_fow and toggle_perfect_spy everything's alright when you start the first campaign game, but when you quit the campaign and start a new one, then toggle_fow and toggle_perfect_spy as specified in the campaign_script don't work. If you quit and start yet another campaign then it works again. If you quit and start another then it doesn't work, etc. etc.

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

    Default Re: Things that Break when Reloading

    If you do a toggle_fow to turn FOW off, then quit and start a new campaign without exiting the M2TW program completely, i.e. only back to the menu, then FOW is still off in that new campaign. So at that point a toggle_fow would turn FOW on, therefore seemingly doing nothing (if you didn't realise that it was off before that toggle_fow).

  6. #6
    Razor's Avatar Licenced to insult
    Join Date
    Apr 2004
    Location
    Deventer, The Netherlands
    Posts
    4,057

    Default Re: Things that Break when Reloading

    I had a suspicion that might be the case, but it does come across as a bit silly.

  7. #7

    Default Re: Things that Break when Reloading

    The toggle_fow bug is probably deeply related to the topic of this thread actually. Like filter_settlement_commands, it changes a 'setting' but displays the opposite behavior - i.e. fow and toggle_perfect_spy are not reset to off while settlement_commands is reset to off when reloading. This is as opposed to a console command like move_character or add_money which just does something immediately and that's it. Perhaps it's worth investigating other console commands that change settings such as auto_win, set_campaign_diff, toggle_restrictcam, or basically any of the 'toggle_' commands. It might be the case that all of these fail when reloading the campaign either by resetting when they shouldn't or failing to reset.

  8. #8
    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: Things that Break when Reloading

    toggle == change state of something, I suppose that's why the state remains (gets saved).










  9. #9

    Default Re: Things that Break when Reloading

    Adding to the list of things that break when the campaign map is reloaded: settlement strat models under fog of war. This bug is well known for mods like Third Age where Minas Tirith turns into a port or something under fog when the map is reloaded. It's quite annoying and seems to affect all settlement tiers equally and randomly (from generic faction-creator villages up to "custom" settlements like Minas Tirith).

    Has anyone found a solution to this bug that doesn't involve writing 'reveal_tile/hide_all_revealed_tiles' monitors for every region on the map?

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

    Default Re: Things that Break when Reloading

    Quote Originally Posted by Callistonian View Post
    Has anyone found a solution to this bug that doesn't involve writing 'reveal_tile/hide_all_revealed_tiles' monitors for every region on the map?
    Yes: reveal only the tiles that need it (and hide them again) - the custom-model settlement ones.

  11. #11

    Default Re: Things that Break when Reloading

    I've found that the bug also affects about half of the non-custom settlements around the map (at least for TATW). I've written monitors for all of our custom settlements and the bug is completely fixed (even works with 'region reached' event messages), but I'm hesitant to repeat this for all 100+ of the non-custom settlements that also break under fog.

  12. #12
    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: Things that Break when Reloading

    It's a simple matter of adding the co-ordinates for the settlements. The monitor itself will only run once (terminated immediately) so it will not impact performance:

    Code:
    monitor_event GameReloaded
       reveal_tile lines for all settlements
       wait 1.0    ; just me being overcautious, probably not needed
       hide_all_revealed_tiles
       terminate_monitor
    end_monitor
    One drawback - it will reveal the placement of settlements that were undiscovered until the reload. Basically it's the principle of how settlements in the victory conditions are revealed.

    I am sure one could work with the TileSeen event to set counters and then only reveal the tiles that the player knows about. But that's taking it a tad far I guess as each settlement will require it's own monitor.
    Last edited by Gigantus; April 24, 2020 at 07:05 AM.










  13. #13

    Default Re: Things that Break when Reloading

    I don't think you're allowed to terminate that monitor. It will only fire the first time the map is reloaded. But the settlement strat models will still break under fog for all subsequent times the map is reloaded, no? You also need a PostBattle monitor. I find that I absolutely need a campaign_wait 0.1 before all of the reveal tile commands. Without this wait, I get a CTD. It's very mysterious. The GameReloaded and PostBattle monitors each add about 5-10 seconds to the time to reload the map (on my machine) which I consider acceptable.

    it's the principle of how settlements in the victory conditions are revealed
    Aha! So that's why every faction has revealed settlements at campaign start even though they aren't revealed in campaign_script. I was wondering about that.

    I am sure one could work with the TileSeen event to set counters and then only reveal the tiles that the player knows about. But that's taking it a tad far I guess as each settlement will require it's own monitor.
    That's exactly what I did for all 44 of our custom settlements. Some had 'region discovered' monitors already. However, I don't really want to do this for every region on the map as the reload times will get ridiculous.
    Last edited by Callistonian; April 25, 2020 at 08:56 AM.

  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: Things that Break when Reloading

    Quote Originally Posted by Callistonian View Post
    I don't think you're allowed to terminate that monitor. It will only fire the first time the map is reloaded. But the settlement strat models will still break under fog for all subsequent times the map is reloaded, no? You also need a PostBattle monitor. I find that I absolutely need a campaign_wait 0.1 before all of the reveal tile commands. Without this wait, I get a CTD. It's very mysterious. The GameReloaded and PostBattle monitors each add about 5-10 seconds to the time to reload the map (on my machine) which I consider acceptable
    Ah yes, my mistake - you can't terminate as you need it each time you load the game save.

    wait command = I am guessing the game needs a moment for the event to fully terminate, so a wait command will give it that time as the reveal command involves graphic stuff. Crash won't happen with commands that do not involve graphic\animations stuff if memory serves.

    Game delays are usually a mixture of the number (and type, monitor_condition is the devil) of monitors plus the action executed, especially if it involves animations. The Rage of dark Ages used a lengthy script to change ownership of about 30 regions via 'attack settlement' spawns depending on which faction the player was using. Had to actually write a preceding monitor disabling user input and popping up a historic event message to tell users not to mess around - it froze the game a full 3 minutes while executing at the initial game start, even with (scripted) accelerated animations!!
    Last edited by Gigantus; April 26, 2020 at 11:21 PM.










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

    Default Re: Things that Break when Reloading

    I have seen the CTD too - so a wait between each reveal_tile fixes that does it? Interesting. But yeah, slow if you have many.

    My solution was to trigger the reveal by the player performing an action after a reload - selecting a character or settlement or clicking any button. For some reason ButtonPressed is somehow triggered automatically by a reload so the script below actually fires automatically and immediately after a reload, revealing the tiles, but sometimes ButtonPressed isn't auto-triggered that way so the user-actions bit remains as a fallback: the revealing is performed twice after each reload.

    There's still the issue of this hiding tiles which are supposed to be currently revealed, e.g. mission targets.

    Code:
    declare_counter trm_not_applied_since_reload
    
    monitor_event GameReloaded
      set_event_counter trm_apply_for_reload 0
      set_counter trm_not_applied_since_reload 1
    end_monitor
    
    monitor_event CharacterSelected I_CompareCounter trm_not_applied_since_reload == 1
      inc_event_counter trm_apply_for_reload 1
    end_monitor
    
    monitor_event SettlementSelected I_CompareCounter trm_not_applied_since_reload == 1
      inc_event_counter trm_apply_for_reload 1
    end_monitor
    
    monitor_event ButtonPressed I_CompareCounter trm_not_applied_since_reload == 1
      inc_event_counter trm_apply_for_reload 1
    end_monitor
    
    monitor_event FactionTurnStart
      inc_event_counter trm_apply_for_reload 1
    terminate_monitor
    end_monitor
    
    monitor_event EventCounter EventCounterType trm_apply_for_reload
      and EventCounter > 0
      
      ;reveal custom settlement tiles
      reveal_tile ...
      reveal_tile ...
      reveal_tile ...
      reveal_tile ...
      
      ;hide them again
      hide_all_revealed_tiles
      
      if I_EventCounter trm_apply_for_reload == 2
        set_counter trm_not_applied_since_reload 0
      end_if
    
    end_monitor
    Why is PostBattle needed?

  16. #16

    Default Re: Things that Break when Reloading

    PostBattle is needed because (at least according to tests I ran months ago) GameReloaded only fires when you load a save game file. All the reloading-related bugs which are the subject of this thread still happen after every battle unless you have a PostBattle monitor that is just a duplicate of the GameReloaded monitor.

    I only need the campaign_wait 0.1 once before the first reveal_tile. Here is my script for a single custom settlement:

    Code:
        monitor_event TileSeen not IsFactionAIControlled     ;need to replicate this monitor for all other settlements that are bugged under fog
        and IsPositionInRect 66 433 1 1
            if I_CompareCounter number_of_players > 1     ;disable script in hotseat so that all players aren't alerted when one of them captures a custom settlement, the monitor that sets this counter must fire before this monitor
                terminate_monitor
            end_if
            set_event_counter reached_thorins_halls_settlement 1
            terminate_monitor
        end_monitor
    
        monitor_event PostBattle TrueCondition                                                ;campaign map is reloaded after exiting the battle map
        and not IsFactionAIControlled
            if I_CompareCounter number_of_players == 1
                campaign_wait 0.1
                if I_EventCounter reached_thorins_halls_settlement == 1
                    reveal_tile 66, 433        ;Thorin's Halls
                end_if
    
                ... (if-loops for all other settlements)
    
                hide_all_revealed_tiles
            end_if
        end_monitor
    
        monitor_event GameReloaded TrueCondition
            if I_CompareCounter number_of_players == 1
                campaign_wait 0.1                                                            ;fix all broken CSMs under fog
                if I_EventCounter reached_thorins_halls_settlement == 1
                    reveal_tile 66, 433        ;Thorin's Halls
                end_if
    
                ... (if-loops for all other settlements)
    
                hide_all_revealed_tiles
            end_if
        end_monitor
    My GameReloaded and PostBattle monitors also contain fixes for choice events closed prematurely and filter_settlement_commands reset as described in the OP, but I've removed them here.

    Is there any instantaneous lag when the user performs the character or settlement select actions to trigger your script? That would confirm if I'm actually seeing increased lag from my GameReloaded and PostBattle monitors due to the campaign_wait, reveal_tile, or hide_all_reveal_tiles effects or I'm just imagining it.

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

    Default Re: Things that Break when Reloading

    PostBattle: that makes sense. The campaign map is 'reloaded' after battles, so this problem raises its head then too. I didn't consider that. No point in doing it after autoresolved battles though.

    Is there any instantaneous lag when the user performs the character or settlement select actions to trigger your script?
    Maybe a second... a bit less? That's with about 20 tiles being revealed.

    I just tried the following change to my script and now the lag is gone.

    Code:
    monitor_event EventCounter EventCounterType trm_apply_for_reload
      and EventCounter > 0
      
      campaign_wait 0.1
    
      ;reveal custom settlement tiles
      reveal_tile ...
    I was fairly sure that using a campaign_wait before reveal_tile in a GameReloaded monitor was still CTDing for me, which is why I went down the user-actions path instead. But trying now I'm not seeing it. So I tried the following script instead and all works well..

    Code:
    monitor_event GameReloaded
      inc_event_counter trm_apply_for_reload 1
    end_monitor
    
    monitor_event PostBattle
      inc_event_counter trm_apply_for_reload 1
    end_monitor
    
    monitor_event FactionTurnStart
      inc_event_counter trm_apply_for_reload 1
    terminate_monitor
    end_monitor
    
    monitor_event EventCounter EventCounterType trm_apply_for_reload
      and EventCounter > 0
      
      campaign_wait 0.1
      
      ;reveal custom settlement tiles
      reveal_tile ...
      reveal_tile ...
      reveal_tile ...
      reveal_tile ...
      
      ;hide them again
      hide_all_revealed_tiles
    
    end_monitor
    Much cleaner.

    PostBattle fires on the still-living commander of each army in the battle. And no point doing it for autoresolve. So I might look into that one a bit more.

    BTW, I_HotseatEnabled can be used for "is this hotseat?" tests.

  18. #18

    Default Re: Things that Break when Reloading

    @Withwnar - I like the way you've set it up with a single monitor for the effects. That's much cleaner. Good reminder that when you find yourself rewriting effects multiple times it means you've made a mistake.

    I adapted your solution from the other thread to address the auto-resolves. I had one test where it seemed PostBattle didn't fire for defeats but I wasn't able to reproduce it. Here's what I have currently which seems to be working as intended:

    Code:
        declare_counter battle_fought_on_battle_map
        
        monitor_event BattleConflictPhaseCommenced                    ;this event only happens when the player goes into the battle map
            set_counter battle_fought_on_battle_map 1
        end_monitor
        
        monitor_event PostBattle not IsFactionAIControlled            ;campaign map reloaded after battles, only monitor human-human or human-ai battles
        and I_CompareCounter battle_fought_on_battle_map == 1        ;only trigger the game reloaded effects for battles fought on battle map
            set_counter battle_fought_on_battle_map 0                ;reset the counter so that auto-resolved battles don't fire this monitor in the future
            inc_event_counter game_reloaded_counter 1                ;fire the effects
        end_monitor
        
        monitor_event GameReloaded
            inc_event_counter game_reloaded_counter 1
        end_monitor
    
        monitor_event EventCounter EventCounterType game_reloaded_counter                    ;stuff that needs to happen when the campaign map is reloaded
        and EventCounter > 0
            if I_EventCounter customs_under_fog_option_accepted == 1                        ;fix all broken custom CSMs under fog
                campaign_wait 0.1
                if I_EventCounter reached_thorins_halls_settlement == 1
                    reveal_tile 66, 433        ;Thorin's Halls
                end_if
    etc...
    My only concern now is that BattleConflictPhaseCommenced won't fire during an ambush, but I'm not sure how to go about testing this. The script above will require further to testing to make sure there is no combination of auto-resolves and battle map battles that will break it.

    Edit: I_HotSeatEnabled would always be true for my mod which is developed in hotseat. However, there is still a need to check if there are multiple human factions or only one and this condition does not do that. Why, you might ask, is my mod designed in hotseat even though some scripts are written for only one human faction? There are several reasons. I will have to make a post one of these days about the virtues of hotseat and why everyone should be using it for scripting.
    Last edited by Callistonian; April 27, 2020 at 05:27 PM.

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

    Default Re: Things that Break when Reloading

    I had one test where it seemed PostBattle didn't fire for defeats
    It fires on whomever is now commander after the battle, including captains (generals) if the named character commander-going-in was killed, for example. And fires for both commanders - both armies. But if there are no survivors in one of those armies then it does not fire for them because there's nobody to fire it on for them. But should still fire for the other side unless by some miracle both armies were completely wiped out. However, if the wiped out army was, say, england and the monitor had a "FactionType england" condition, or a FactionIsLocal one (and player is england), then it wouldn't fire at all because it would only have fired for england but won't because they had no survivors.

    BattleConflictPhaseCommenced won't fire during an ambush
    No? Hmm, that's a problem then. I'd expect that there is still such a phase in ambush, just that the battle automatically begins in that phase. But I don't really use battle script so I don't know.

    BattleAiCommenced instead, perhaps?

    make sure there is no combination of auto-resolves and battle map battles that will break it.
    Because PostBattle cannot be relied upon, something like this is needed too...
    Code:
    monitor_event PreBattlePanelOpen
      ;default to "autoresolved"
      set_counter battle_fought_on_battle_map 0
    end_monitor
    ...which then means there's no need to do it in the other monitor...
    Code:
    monitor_event PostBattle not IsFactionAIControlled
      and I_CompareCounter battle_fought_on_battle_map == 1
      set_counter battle_fought_on_battle_map 0
      inc_event_counter game_reloaded_counter 1
    end_monitor
    There's still the risk that that last one won't always fire (as said above).

  20. #20

    Default Re: Things that Break when Reloading

    It fires on whomever is now commander after the battle
    If this is the case, then I prevented it from firing by losing my whole army and specifying that it could only fire for a human faction. To fix this, I can just remove 'not IsFactionAIControlled' since 'and I_CompareCounter battle_fought_on_battle_map' already requires that a human was involved in the battle and it wasn't auto-resolved.

    Code:
        monitor_event PostBattle TrueCondition                        ;campaign map reloaded after battles
        and I_CompareCounter battle_fought_on_battle_map == 1        ;only trigger the game reloaded effects for battles fought on battle map
            set_counter battle_fought_on_battle_map 0                ;reset the counter so that auto-resolved battles don't fire this monitor in the future
            inc_event_counter game_reloaded_counter 1                ;fire the effects
        end_monitor
    PostBattle can be relied upon here because of the counter condition from the BattleConflictPhaseCommenced monitor. Paired with that condition, PostBattle will not give a false positive for auto-resolves nor a false negative for defeats. The counter starts at 0, and only goes to 1 during a human battle map battle. After any such battle, the PostBattle monitor resets the counter to 0. There is no need to reset the counter to 0 externally (with a monitor for PreBattlePanelOpen or etc.) unless there is some way for a human to fight on the battle map without the PostBattle monitor above resetting the counter to 0. I don't see any way for that to happen except in the unlikely scenario that you mentioned where both armies simultaneously kill each other (final catapult shot?). But even then, I'm sure the game still assigns victory to one side or the other and the victor probably gets revived units.

    Perhaps PostBattle isn't assigned for battles ending in a draw? I don't see why that would be the case since it gets assigned for captains/generals even if they lose so long as they survive.
    Last edited by Callistonian; April 28, 2020 at 11:44 AM.

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
  •