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

Thread: what is wrong with this script cant get it to work

  1. #1
    Obeseus's Avatar Laetus
    Join Date
    Feb 2012
    Location
    united states
    Posts
    18

    Default what is wrong with this script cant get it to work

    ;
    ;campaign script
    ;
    script
    restrict_strat_radar false
    ; --- Keep Venice and France at war ---
    monitor_event FactionTurnStart FactionType venice
    and I_TurnNumber >= 1
    and I_IsFactionAIControlled venice
    console_command diplomatic_stance venice france war
    end_monitor
    monitor_event FactionTurnStart FactionType france
    and I_TurnNumber >= 1
    and I_IsFactionAIControlled france
    console_command diplomatic_stance france venice war
    end_monitor
    monitor_event FactionTurnStart FactionType france
    and I_IsFactionAIControlled
    and I_TurnNumber >= 2
    spawn_army
    faction france
    character random_name, general, age 30, x 181, y 182
    unit Frankguard exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit
    end
    terminate_monitor
    end_monitor

    wait_monitors
    end_script

  2. #2
    Obeseus's Avatar Laetus
    Join Date
    Feb 2012
    Location
    united states
    Posts
    18

    Default Re: what is wrong with this script cant get it to work

    well it didnt paste right and i cant edit that post.... the units used are the same as on descr strat il try again
    ;
    ;campaign script
    ;
    script


    restrict_strat_radar false
    ; --- Keep Venice and France at war ---


    monitor_event FactionTurnStart FactionType venice
    and I_TurnNumber >= 1
    and I_IsFactionAIControlled venice
    console_command diplomatic_stance venice france war
    end_monitor


    monitor_event FactionTurnStart FactionType france
    and I_TurnNumber >= 1
    and I_IsFactionAIControlled france
    console_command diplomatic_stance france venice war
    end_monitor


    monitor_event FactionTurnStart FactionType france
    and I_IsFactionAIControlled
    and I_TurnNumber >= 2


    spawn_army
    faction france
    character random_name, general, age 30, x 181, y 182
    unit Frankguard exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    unit Germanic_levy exp 0 armour 0 weapon_lvl 0
    end

    terminate_monitor

    end_monitor


    wait_monitors
    end_script

  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: what is wrong with this script cant get it to work

    How do you know it's not working? Radar restriction showing? No message about diplomatic changes? Spawn failed?

    Note: turn count zero is the first turn\game start, which means your stuff only starts happening in the second turn (turn count one).
    More note: use the code tag to display script stuff properly. Either go into advanced edit and highlight the text and choose the hash symbol or 'wrap' it manually into code tags:

    Example: [code]my text with weird spacing[/code]
    will show thus:
    Code:
    my     text with             weird spacing
    instead of:
    my text with weird spacing

    I have removed your post count (25) based edit restrictions, you are certainly long enough here do let me know if it hasn't worked.
    Last edited by Gigantus; December 09, 2019 at 01:13 AM.










  4. #4

    Default Re: what is wrong with this script cant get it to work

    The faction name after I_IsFactionAIControlled is missing in this section:
    Code:
    monitor_event FactionTurnStart FactionType france
        and I_IsFactionAIControlled france
        and I_TurnNumber >= 2
            spawn_army
                 faction france
                 character random_name, general, age 30, x 181, y 182
                 unit Frankguard exp 0 armour 0 weapon_lvl 0
                 unit Germanic_levy exp 0 armour 0 weapon_lvl 0
                 unit Germanic_levy exp 0 armour 0 weapon_lvl 0
                 unit Germanic_levy exp 0 armour 0 weapon_lvl 0
                 unit Germanic_levy exp 0 armour 0 weapon_lvl 0
                 unit Germanic_levy exp 0 armour 0 weapon_lvl 0
            end
            terminate_monitor
    end_monitor

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

    Default Re: what is wrong with this script cant get it to work

    And always check the log. If there's an error in it then its message will help you or us determine where the problem is.

  6. #6
    Obeseus's Avatar Laetus
    Join Date
    Feb 2012
    Location
    united states
    Posts
    18

    Default Re: what is wrong with this script cant get it to work

    ok i tried again on a un edited gigantis campaign map and managed to get a stack of default units to spawn .. I think my other mod may just be too screwed up to fix but thanks for the help guys

  7. #7
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    I don't want to start another thread, but if somebody could tell me why it doesn't work (no error, but simply money is not

    Code:
        monitor_event CharacterTurnStart FactionIsLocal
            and IsGeneral
            and Trait ArmyCost = 1
    
    
            console_command add_money -250
    
    
        end_monitor
    
    
        monitor_event CharacterTurnStart FactionIsLocal
            and IsGeneral
            and Trait ArmyCost = 2
    
    
            console_command add_money -500
    
    
        end_monitor
    These don't seem to work either:
    Code:
        ;================== CRUSADE OUTLAYS ===================================
        monitor_event GeneralJoinCrusade CharacterIsLocal
    
    
           console_command add_money -3000
    
    
        end_monitor
    
    
        ;================== CROWN UPKEEP ======================================
        monitor_event CharacterTurnStart CharacterIsLocal
            and Trait Crownholder > 3
    
    
            console_command add_money -5000
    
    
        end_monitor
    
    
        ;================== NEW GENERAL =======================================
        monitor_event CharacterTurnEnd CharacterIsLocal
            and Trait NewGeneral > 0
            
            console_command add_money -1000
    
    
        end_monitor
    
    
        ;================== MARRIAGE ==========================================
        monitor_event CharacterMarries CharacterIsLocal
            and Trait NewGeneral < 1
            
            console_command add_money -1000
    
    
        end_monitor

  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: what is wrong with this script cant get it to work

    I prefer triggering one of the default historic_events for testing, (FIRST_WINDMILL is my favorite) more conclusive in my mind.










  9. #9

    Default Re: what is wrong with this script cant get it to work

    In the first script, you have written "FactionIsLocal" instead of "CharacterIsLocal", and in both you need a faction name after add_money (afaik).

  10. #10
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Quote Originally Posted by Erken View Post
    In the first script, you have written "FactionIsLocal" instead of "CharacterIsLocal", and in both you need a faction name after add_money (afaik).
    Previously I've used "CharacterIsLocal" - it didn't work either.
    add_money should be for the current, local faction. I don't think you need a faction name.

    @Gigantus: I've tested it in this way and it didn't work either (no event info appeared)

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

    Default Re: what is wrong with this script cant get it to work

    Yeah, money can be a difficult thing to test when its happening during turn starts/ends. I'd go with historic events too, to suss out of the monitor is firing and meeting the conditions. If it is then it's a problem with what's inside: add_money in this case. Or bump up the money amount a long way, e.g. -5000: maybe it is working but the amounts aren't enough for you to notice.

    Quote Originally Posted by Erken View Post
    In the first script, you have written "FactionIsLocal" instead of "CharacterIsLocal", and in both you need a faction name after add_money (afaik).
    FactionIsLocal works too, certainly in triggers but not sure I've tried it on characters in script.

    add_money needs a faction but "console_command add_money" doesn't. It should give the money to the faction whose turn it is, if I remember rightly, maybe the player instead? Either way it should work as written.

    It's worth trying "add_money england -5000", or whatever faction you're using to test it. (Note: no "console_command" there.) If that doesn't work either then I'd say the add_money line isn't the problem.

    In those first two triggers, is it possible they don't have the trait yet? e.g. The trigger that is giving it is also using CharacterTurnStart, and you only tested one turn? Script executes before trait triggers do, generally speaking, so your monitor is testing for something he doesn't yet have but is about to get?

    EDIT: too slow to write that! Right, so in light of that last post it's probably not the add_money because the historic event isn't working either.
    Last edited by Withwnar; March 01, 2020 at 03:30 AM.

  12. #12
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Thanks guys, for the replies.

    I've started to get the console_command add_money working.

    What I've discovered is that this trigger in EDCT works only with DifficultyLevel condition. Otherwise it mixes up with many other triggers and does not appear. I have no idea why - the trait is a normal as the other are. And there're many triggers working without this condition. No idea why.

    Code:
    ;------------------------------------------
    Trigger CoA_NewNoble_Starter
     WhenToTest CharacterComesOfAge
    
    
     Condition I_EventCounter DifficultyLevel > 2
        and not FactionReligion pagan
    
    
     Affects NewGeneral 1 Chance 100
    BTW - do you know if CharacterMarries and CharacterMarriesPrincess are exclusive (only triggers for one fire) or if a character marries a princess the triggers will fire for both?

    And another go:

    Why does this code doesn't work:
    Code:
       monitor_event PreFactionTurnStart not IsFactionAIControlled        and Treasury < -4000
    
    
            if I_CompareCounter pl_ec_id = 2
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements venice > 4 
    			destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements sicily > 4 
                destroy_units sicily, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 4
    			and not I_JihadInProgress
    			and I_NumberOfSettlements abbasid > 4 
                destroy_units abbasid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 5
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements papal_states > 4 
                destroy_units papal_states, mercenary_unit
    
            historic_event mercenaries_disband
    
    
        end_monitor
    while this one does
    Code:
        monitor_event PreFactionTurnStart not IsFactionAIControlled        and Treasury < -4000
    
    
            if I_CompareCounter pl_ec_id = 2
    			and I_NumberOfSettlements venice > 4 
    			destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
    			and I_NumberOfSettlements sicily > 4 
                destroy_units sicily, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 4
    			and I_NumberOfSettlements abbasid > 4 
                destroy_units abbasid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 5
    			and I_NumberOfSettlements papal_states > 4 
                destroy_units papal_states, mercenary_unit
            end_if
    
            historic_event mercenaries_disband
    
    
        end_monitor
    Last edited by Jurand of Cracow; March 01, 2020 at 11:38 AM.

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

    Default Re: what is wrong with this script cant get it to work

    Code:
    if I_CompareCounter pl_ec_id = 5
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements papal_states > 4 
                destroy_units papal_states, mercenary_unit
    
            historic_event mercenaries_disband
    That "if" is missing an "end_if". The log was surely complaining about that, in some obscure way probably but still.

  14. #14
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Quote Originally Posted by Withwnar View Post
    That "if" is missing an "end_if". The log was surely complaining about that, in some obscure way probably but still.
    No, no, I've just erronously cut-and-paste the fragment of the code, there're 30 factions. There was end_if at the end of the code.

    Full code was as follows:
    Code:
        monitor_event PreFactionTurnStart not IsFactionAIControlled        and Treasury < -4000
    
    
            if I_CompareCounter pl_ec_id = 2
                and I_NumberOfSettlements venice > 4 
                destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
                and I_NumberOfSettlements sicily > 4 
                destroy_units sicily, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 4
                and I_NumberOfSettlements abbasid > 4 
                destroy_units abbasid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 5
                and I_NumberOfSettlements papal_states > 4 
                destroy_units papal_states, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 6
                and I_NumberOfSettlements denmark > 6 
                destroy_units denmark, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 7
                and I_NumberOfSettlements egypt > 4 
                destroy_units egypt, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 8
                and I_NumberOfSettlements scotland > 6
                destroy_units scotland, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 9
                and I_NumberOfSettlements cumans > 8
                destroy_units cumans, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 10
                and I_NumberOfSettlements mongols > 8
                destroy_units mongols, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 11
                and I_NumberOfSettlements turks > 4 
                destroy_units turks, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 12
                and I_NumberOfSettlements france > 4 
                destroy_units france, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 13
                and I_NumberOfSettlements hre > 4 
                destroy_units hre, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 14
                and I_NumberOfSettlements england > 4 
                destroy_units england, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 15
                and I_NumberOfSettlements portugal > 4 
                destroy_units portugal, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 16
                and I_NumberOfSettlements poland > 4 
                destroy_units poland, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 17
                and I_NumberOfSettlements byzantium > 4 
                destroy_units byzantium, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 18
                and I_NumberOfSettlements moors > 4 
                destroy_units moors, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 19
                and I_NumberOfSettlements russia > 4 
                destroy_units russia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 20
                and I_NumberOfSettlements spain > 4 
                destroy_units spain, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 21
                and I_NumberOfSettlements hungary > 4 
                destroy_units hungary, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 22
                and I_NumberOfSettlements aragon > 4 
                destroy_units aragon, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 23
                and I_NumberOfSettlements lithuania > 8
                destroy_units lithuania, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 24
                and I_NumberOfSettlements kievan_rus > 4 
                destroy_units kievan_rus, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 25
                and I_NumberOfSettlements serbia > 4 
                destroy_units serbia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 26
                and I_NumberOfSettlements georgia > 4 
                destroy_units georgia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 27
                and I_NumberOfSettlements norway > 6
                destroy_units norway, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 28
                and I_NumberOfSettlements jerusalem > 4 
                destroy_units jerusalem, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 29
                and I_NumberOfSettlements zengid > 4 
                destroy_units zengid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 30
                and I_NumberOfSettlements pisa > 4 
                destroy_units pisa, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 31
                and I_NumberOfSettlements rum > 4 
                destroy_units rum, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    I've also tried an alternative - didn't work either.

    Code:
        ;======= Mercs Disband cumans ===================    
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements cumans > 8
            
            if I_CompareCounter pl_ec_id = 9
                destroy_units cumans, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
    
    
        ;======= Mercs Disband kievan_rus ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements kievan_rus > 4
            
            if I_CompareCounter pl_ec_id = 2
                destroy_units kievan_rus, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband russia ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements russia > 4
            
            if I_CompareCounter pl_ec_id = 24
                destroy_units russia, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband lithuania ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements lithuania > 8
            
            if I_CompareCounter pl_ec_id = 23
                destroy_units lithuania, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband poland ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements poland > 4
            
            if I_CompareCounter pl_ec_id = 16
                destroy_units poland, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband hungary ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements hungary > 4
            
            if I_CompareCounter pl_ec_id = 21
                destroy_units hungary, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband hre ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements hre > 4
            
            if I_CompareCounter pl_ec_id = 13
                destroy_units hre, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband denmark ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements denmark > 6
            
            if I_CompareCounter pl_ec_id = 6
                destroy_units denmark, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband norway ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements norway > 6
            
            if I_CompareCounter pl_ec_id = 27
                destroy_units norway, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband scotland ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements scotland > 6
            
            if I_CompareCounter pl_ec_id = 8
                destroy_units scotland, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband england ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements england > 4
            
            if I_CompareCounter pl_ec_id = 14
                destroy_units england, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband france ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements france > 4
            
            if I_CompareCounter pl_ec_id = 12
                destroy_units france, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband aragon ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements aragon > 4
            
            if I_CompareCounter pl_ec_id = 22
                destroy_units aragon, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    
    
        ;======= Mercs Disband spain ===================
        
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
            and I_NumberOfSettlements spain > 4
            
            if I_CompareCounter pl_ec_id = 20
                destroy_units spain, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    Withwnar, do you know if CharacterMarries and CharacterMarriesPrincess are exclusive (only triggers for one fire) or if a character marries a princess the triggers will fire for both?
    Last edited by Jurand of Cracow; March 02, 2020 at 01:11 AM.

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

    Default Re: what is wrong with this script cant get it to work

    That "full code" looks like the one which you earlier said did work.

    Nothing in that "alternative" looks wrong. In fact, all of these scripts look fine, assuming the conditions of your monitors and "if"s are all true.

    What does "doesn't work" mean exactly? Units not destroyed but historic message shown? Or message not shown either?

    No idea on the marriages.

  16. #16
    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: what is wrong with this script cant get it to work

    Little note on the full code: the historic event message will fire regardless if any of the IF conditions are true, which may not be a problem in this particular monitor (all 31 factions appear to be present), but you may want to keep that in mind for other situations.

    I am a bit wary of the IsFactionAIControlled condition, I'd rather do the IF loop thus:
    Code:
        ;======= Mercs Disband russia all, russia sample===================
    
        monitor_event PreFactionTurnStart Treasury < -4000
            
            if I_CompareCounter pl_ec_id = 24
                and not I_IsFactionAIControlled russia
                and I_NumberOfSettlements russia > 4
                destroy_units russia, mercenary_unit
                historic_event mercenaries_disband
            end_if
    
        end_monitor
    Last edited by Gigantus; March 02, 2020 at 02:58 AM.










  17. #17
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Quote Originally Posted by Withwnar View Post
    That "full code" looks like the one which you earlier said did work.

    Nothing in that "alternative" looks wrong. In fact, all of these scripts look fine, assuming the conditions of your monitors and "if"s are all true.

    What does "doesn't work" mean exactly? Units not destroyed but historic message shown? Or message not shown either?
    CTD on one of the first turns. Log doesn't say anything.

    I'll try the Gigantus' way.

    Thanks, Guys!

  18. #18
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Quote Originally Posted by Gigantus View Post
    Little note on the full code: the historic event message will fire regardless if any of the IF conditions are true, which may not be a problem in this particular monitor (all 31 factions appear to be present), but you may want to keep that in mind for other situations.

    I am a bit wary of the IsFactionAIControlled condition, I'd rather do the IF loop thus:
    Code:
        ;======= Mercs Disband russia all, russia sample===================
    
        monitor_event PreFactionTurnStart Treasury < -4000
            
            if I_CompareCounter pl_ec_id = 24
                and not I_IsFactionAIControlled russia
                and I_NumberOfSettlements russia > 4
                destroy_units russia, mercenary_unit
                historic_event mercenaries_disband
            end_if
    
        end_monitor
    It seems that Gigantus was again right. This surprisingly works, no CTD. So it's better to be wary of IsFactionAIControlled .

  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: what is wrong with this script cant get it to work

    Sometimes I scare myself....










  20. #20
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,488

    Default Re: what is wrong with this script cant get it to work

    Quote Originally Posted by Gigantus View Post
    Sometimes I scare myself....
    I've applauded you too early. It still doesn't work. Namely:

    This works:
    Code:
     monitor_event PreFactionTurnStart not IsFactionAIControlled        and Treasury < -2500
    
    
            if I_CompareCounter pl_ec_id = 2
                destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
                destroy_units sicily, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 4
                destroy_units abbasid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 5
                destroy_units papal_states, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 6
                destroy_units denmark, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 7
                destroy_units egypt, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 8
                destroy_units scotland, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 9
                destroy_units cumans, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 10
                destroy_units mongols, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 11
                destroy_units turks, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 12
                destroy_units france, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 13
                destroy_units hre, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 14
                destroy_units england, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 15
                destroy_units portugal, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 16
                destroy_units poland, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 17
                destroy_units byzantium, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 18
                destroy_units moors, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 19
                destroy_units russia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 20
                destroy_units spain, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 21
                destroy_units hungary, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 22
                destroy_units aragon, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 23
                destroy_units lithuania, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 24
                destroy_units kievan_rus, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 25
                destroy_units serbia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 26
                destroy_units georgia, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 27
                destroy_units norway, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 28
                destroy_units jerusalem, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 29
                destroy_units zengid, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 30
                destroy_units pisa, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 31
                destroy_units rum, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    This doesn't:
    Code:
        monitor_event PreFactionTurnStart Treasury < -4000
            
            if I_CompareCounter pl_ec_id = 2
                and not I_IsFactionAIControlled venice
                and I_NumberOfSettlements venice > 4
                destroy_units venice, mercenary_unit
                historic_event mercenaries_disband
            end_if
    
    
        end_monitor
    
    
        monitor_event PreFactionTurnStart Treasury < -4000
            
            if I_CompareCounter pl_ec_id = 3
                and not I_IsFactionAIControlled sicily
                and I_NumberOfSettlements sicily > 4
                destroy_units sicily, mercenary_unit
                historic_event mercenaries_disband
            end_if
    
    
        end_monitor
    ....
    This doesn't either:
    Code:
     monitor_event PreFactionTurnStart not IsFactionAIControlled        and Treasury < -4000
    
    
            if I_CompareCounter pl_ec_id = 2
    			and I_NumberOfSettlements venice > 4 
    			destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
    			and I_NumberOfSettlements sicily > 4 
                destroy_units sicily, mercenary_unit
            end_if
    ....
     if I_CompareCounter pl_ec_id = 31
    			and I_NumberOfSettlements rum > 4 
                destroy_units rum, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    This doesn't either:
    Code:
    ;======= Mercs Disband Venice ===================	
        monitor_event PreFactionTurnStart not IsFactionAIControlled
            and Treasury < -4000
    
    
            if I_CompareCounter pl_ec_id = 2
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements venice > 4 
    			destroy_units venice, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 3
    			and not I_CrusadeInProgress 
    			and I_NumberOfSettlements sicily > 4 
                destroy_units sicily, mercenary_unit
            end_if
            if I_CompareCounter pl_ec_id = 4
    			and not I_JihadInProgress
    			and I_NumberOfSettlements abbasid > 4 
                destroy_units abbasid, mercenary_unit
            end_if
    .....
    
    if I_CompareCounter pl_ec_id = 31
    			and not I_JihadInProgress 
    			and I_NumberOfSettlements rum > 4 
                destroy_units rum, mercenary_unit
            end_if
    
    
            historic_event mercenaries_disband
    
    
        end_monitor
    I've got no clue why...

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
  •