Results 1 to 19 of 19

Thread: EDCT: WhenToTest BecomesFactionLeader causes crashes

  1. #1

    Default EDCT: WhenToTest BecomesFactionLeader causes crashes

    I have been investigating a crash together with Kull, where the game crashes when the faction leader gets killed in the battle where the last settlement of his faction falls, unless the rest of the family dies too. At least in EBII's case, this was narrowed down to be because of trait triggers using WhenToTest BecomesFactionLeader.

    While these triggers work perfectly fine for normal succession, they are also tested when the faction dies and crash the game if any of them get fired (they have all conditions evaluating to true).

    The workaround I found was to postpone processing of succession related triggers to the end of the turn. It introduces these traits as flags:

    Code:
    Trait NotFactionLeader
        Characters family
        Hidden
    
       Level NotFactionLeader
            Description Hidden_desc
            EffectsDescription Hidden_effects_desc
            Threshold  1
    
    
    Trait BecameFactionLeader
        Characters family
        Hidden
    
        Level BecameFactionLeader
            Description hidden_desc
            EffectsDescription hidden_effects_desc
            Threshold  1
    These triggers below must be placed before any succession triggers to set these flags - keep NotFactionLeader on all generals, and switch to BecameFactionLeader whenever the faction leader has this flag, signalling succession.

    Code:
    Trigger NotAFactionLeader
        WhenToTest CharacterTurnEnd
    
      Condition IsGeneral
            and not IsFactionLeader
            and Trait NotFactionLeader < 1
    
      Affects NotFactionLeader 1 Chance  100
    
    Trigger IsNowFactionLeader
        WhenToTest CharacterTurnEnd
    
      Condition IsGeneral
            and IsFactionLeader
            and Trait NotFactionLeader > 0
    
      Affects BecameFactionLeader 1 Chance  100
      Affects NotFactionLeader -1 Chance  100
    Each trigger currently using BecomesFactionLeader then has to change like this:

    Code:
    Trigger ArmenianBecomesLeader
      WhenToTest BecomesFactionLeader CharacterTurnEnd
    
      Condition FactionType f_hayasdan
            and Trait Arkah < 1
            and Trait BecameFactionLeader > 0
    
      Affects Arkah  1  Chance  100
    Finally, after all succession triggers, the flag that someone became faction leader must be reset to avoid them firing each turn.

    Code:
    Trigger BecomingFactionLeaderFinished
        WhenToTest CharacterTurnEnd
    
      Condition IsGeneral
            and Trait BecameFactionLeader > 0
    
      Affects BecameFactionLeader -1 Chance  100
    Last edited by bovi; September 02, 2018 at 06:55 AM. Reason: I forgot to make BecameFactionLeader hidden.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  2. #2

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    This bug is OLD, and has affected at least one other mod and goes back to vanilla M2TW:

    1) A completely different mod (Third Age CTD)

    2) Seems to be a bug present in vanilla M2TW

    So if your mod uses traits as part of the "Faction Heir to Faction Leader" transition, you probably have this bug. Fortunately, the fix is described above.
    EBII Council

  3. #3

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    great fix here!can every mod use this fix?

    edit;thank you for showing us this fix,manny times i had a ctd when last settlement was falling,now am in turn 430,but only because i had not a ctd with the last settlement of an faction getting destroyed.

    then this is a ctd too with this problem,a campaign around 380 turns;
    Code:
    14:36:36.876 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA14:36:36.910 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:36.942 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:36.979 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.024 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.081 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.143 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.199 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.263 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.330 [data.transgression] [info] Applied transgression TC_INVASION from transgressor faction 237BBCB0 against faction 237EB0BA
    14:36:37.664 [bink] [debug] [data/fmv/faction/minor_lose.bik]Pause on
    14:36:37.664 [bink] [debug] [data/fmv/faction/minor_lose.bik]Pause on
    14:36:40.979 [system.rpt] [error] Medieval 2: Total War encountered an unspecified error and will now exit.
    a great campaign but sadly ended in sorrow and pain after a ctd.
    Last edited by stevietheconquer; September 04, 2018 at 12:06 PM.

  4. #4

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by stevietheconquer View Post
    great fix here!can every mod use this fix?
    I cannot know whether every mod will prefer stability over immediate processing of succession traits. The workaround imposes a delay in awarding traits on succession to the end of the turn, which may cause problems if the script or other trait triggers depend on them always being present on the faction leader. Possibly applying it will therefore require significant rewriting of logic elsewhere.

    But yes, the workaround I laid out here should be universally applicable. No attribution necessary.
    Last edited by bovi; September 04, 2018 at 04:20 PM.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  5. #5

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    ok,thank you for the answer,i will first test the codes in a new game and then i can see if it works good for mine little mod traits.maybe it will work in a already started campaign i will test it in campaign of already 430 turns.

  6. #6

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by stevietheconquer View Post
    maybe it will work in a already started campaign i will test it in campaign of already 430 turns.
    No. Because it adds traits, the change is savegame incompatible, sorry.

    To clarify, it will probably allow you to bypass a faction destruction crash, but it will also make the traits saved on each character wrong. The game saves which traits a character has by a number, which corresponds to the order those traits appear in EDCT. When adding traits anywhere except the very bottom of the traits, you also change that order, and so the game will think completely different traits are on the characters.

    With all processing happening based on which traits are already on the character, you are likely to see very weird results after even just one turn, and also even if you turn back to the original EDCT after bypassing the crash.

    By the way, the easiest way for bypassing such a crash in an ongoing campaign is much simpler. Just take a backup copy of EDCT, then delete or comment out all trait triggers. Restore the original EDCT after the battle.
    Last edited by bovi; September 06, 2018 at 11:27 AM.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  7. #7

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    i could not resist to try it yesterday,it al seems to work good,there was even one faction destroyed,and if mine campaign goes wrong it is not the end of the world,then i just start a new one,am already about 10 turn further and i can see no errors,maybe the next turn it will happen.

  8. #8

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    ok i had only one problem,it was about the pope,getting the wright model strat,but as they are priest becoming pope,factionleader they never get those traits

    trigger pope was first( Whentotest becomesfactionleaderleader) so changed into like it says in the code.

    trigger now
    Code:
    ;------------------------------------------Trigger factionleader_pope
    WhenToTest CharacterTurnEnd
    
    
    Condition FactionType papal_states
    and Trait BecameFactionLeader > 0
    
    
    Affects IAmPope 1 Chance 100
    guest i just change it in this one;
    Code:
    ;------------------------------------------Trigger factionleader_pope
    WhenToTest CharacterTurnEnd
    
    
    Condition FactionType papal_states
    and IsFactionLeader 
    and not Trait IAmPope = 1
    
    
    Affects IAmPope 1 Chance 100
    and it will be good
    Last edited by stevietheconquer; September 06, 2018 at 03:59 PM.

  9. #9
    Gigantus's Avatar I am thinking more about running away now then I did as a kid, but by the time I put my teeth in, my glasses on and find my car keys I forget why I am going.
    Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    48,266
    Blog Entries
    24

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes





  10. #10
    _Tartaros_'s Avatar "Harzschütze"
    Join Date
    Aug 2009
    Location
    kvet.lɪnˌbuʁk
    Posts
    4,202

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    observed this too, when factions with only one or two regions and a small familytree got besieged and fl + fh got killed in battle the game ctd. implanted your suggested workaround.

    question:
    keep NotFactionLeader on all generals
    can i leave the rebel faction generals out in descr_strat?
    Spoiler Alert, click show to read: 
    Quote Originally Posted by k/t View Post
    "But I don't know how to mod!!!!"
    Learn. I didn't know how to do anything when I got this game, and now I know how to do quite a bit. Volunteer. Struggle. Figure it out.
    There are lots of cool mods that never see the light of day because people don't realize that mods need workers, not watchers, or realize it but continue to watch anyway.

    The Great Conflicts
    872-1071
    public alpha 15.01.2020
    The Great Preview 01.12.2019 + Special 06.12.2019

  11. #11

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by stevietheconquer View Post
    ok i had only one problem,it was about the pope
    Right. There could be a special case for that one, as in this case it is not a general becoming faction leader.
    Quote Originally Posted by stevietheconquer View Post
    guest i just change it in this one;
    Code:
    ;------------------------------------------Trigger  factionleader_pope
    WhenToTest CharacterTurnEnd
    
    Condition FactionType papal_states
    and IsFactionLeader 
    and not Trait IAmPope = 1
    
    
    Affects IAmPope 1 Chance 100
    That looks sound, yes.

    Quote Originally Posted by _Tartaros_ View Post
    can i leave the rebel faction generals out in descr_strat?
    The trait will be assigned to all non-FLs at the end of the first turn by Trigger NotAFactionLeader. There should be no need to ever put the NotFactionLeader trait on anyone in descr_strat, unless your mod specifically has a situation where a faction leader can be killed in his single settlement on the very first turn while another family member is outside of the settlement. This sounds unlikely to me.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  12. #12
    _Tartaros_'s Avatar "Harzschütze"
    Join Date
    Aug 2009
    Location
    kvet.lɪnˌbuʁk
    Posts
    4,202

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    haha, no...
    ok then - will go on to test this issue in my mod
    Spoiler Alert, click show to read: 
    Quote Originally Posted by k/t View Post
    "But I don't know how to mod!!!!"
    Learn. I didn't know how to do anything when I got this game, and now I know how to do quite a bit. Volunteer. Struggle. Figure it out.
    There are lots of cool mods that never see the light of day because people don't realize that mods need workers, not watchers, or realize it but continue to watch anyway.

    The Great Conflicts
    872-1071
    public alpha 15.01.2020
    The Great Preview 01.12.2019 + Special 06.12.2019

  13. #13

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by bovi View Post
    The trait will be assigned to all non-FLs at the end of the first turn by Trigger NotAFactionLeader. There should be no need to ever put the NotFactionLeader trait on anyone in descr_strat, unless your mod specifically has a situation where a faction leader can be killed in his single settlement on the very first turn while another family member is outside of the settlement. This sounds unlikely to me.
    Thinking about it, this was imprecise. The unhandled situation using this workaround is when a faction leader dies on the very first turn, by any cause. In that case, succession triggers will not fire as NotFactionLeader has not been set on the rest of the family yet. Still, a faction leader dying on the first turn should be a rare occurrence in any mod, I think.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  14. #14
    QuintusSertorius's Avatar EBII Hod Carrier
    Artifex

    Join Date
    Feb 2008
    Location
    UK
    Posts
    11,729

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by bovi View Post
    Thinking about it, this was imprecise. The unhandled situation using this workaround is when a faction leader dies on the very first turn, by any cause. In that case, succession triggers will not fire as NotFactionLeader has not been set on the rest of the family yet. Still, a faction leader dying on the first turn should be a rare occurrence in any mod, I think.
    It's a bit of a blunt workaround for this possibility and might be overkill, but you could give all the non-FL characters that NotFactionLeader trait in the descr_strat. That would mean the only character lacking it at the start of the game would be the starting FL.

  15. #15

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Quote Originally Posted by QuintusSertorius View Post
    you could give all the non-FL characters that NotFactionLeader trait in the descr_strat
    True, and this was what Tartaros was planning to do in the first place. I was arguing that the work to do so is probably not necessary, except if you foresee a faction leader dying on the first turn. I was clarifying that this concerns any FL death, not only if it happens in the last settlement as I first said.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  16. #16

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    just forget about it,thank you for this great fix and great traits!am gonna use it in mine descr_export_charater_trait file.
    and mine campaign is now in turn 475 and still is goin good,but i am a turtle player and was waiting for gunpowder event too do mine invasions.
    Attached Thumbnails Attached Thumbnails 0006.jpg  
    Last edited by stevietheconquer; September 11, 2018 at 10:21 AM.

  17. #17

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    Hi all. 1 question
    In file descr_faction_standing i found this trigger:

    ;------------------------------------------
    Trigger New_Faction_Leader_trigger
    WhenToTest BecomesFactionLeader


    FactionStanding exclude_factions { slave } normalise 0.25 10
    FactionStanding global normalise 0.25 10
    Do I need to change the entry in that file as indicated here?



    If necessary, what should it look like?
    like this:?

    Trigger New_Faction_Leader_trigger
    WhenToTest CharacterTurnEnd

    Condition Trait BecameFactionLeader > 0
    FactionStanding exclude_factions { slave } normalise 0.25 10
    FactionStanding global normalise 0.25 10

    Or do I need to change nothing at all in this file?
    Thanks in advance
    Last edited by Leeekaaa; January 06, 2020 at 03:31 AM.

  18. #18

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    i think you can let it stay as i am playing with these traits a long time and got the same text in descr_faction_standing file and no ctd

  19. #19
    Gigantus's Avatar I am thinking more about running away now then I did as a kid, but by the time I put my teeth in, my glasses on and find my car keys I forget why I am going.
    Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    48,266
    Blog Entries
    24

    Default Re: EDCT: WhenToTest BecomesFactionLeader causes crashes

    I think the crash reason is that a trait\ancillary needs to be a applied to a character who in the time between triggering the BecomesFactionLeader event and the time of applying the effects simply vanishes.

    Faction standing does not apply anything to a character so it will be fine.




Posting Permissions

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