Page 1 of 5 12345 LastLast
Results 1 to 20 of 92

Thread: Campaign Script Optimizations

  1. #1

    Icon1 Campaign Script Optimizations

    Trying to optimize the campaign script

    we shall use this thread for discussing possible tweaks and ideas sharing

    Starting with Faction Killer Workaround section
    Discussion from other thread, is quite long
    Quote Originally Posted by gsthoed View Post
    About "Faction Killer Workaround" section in the campaign_scripts:

    a) Since papal_states and teutonic_order are indestructible, it is meaningless to have monitors and triggers for the FactionKillers of these factions. This means 4 less monitors in campaign script and two triggers in the ECDT file.

    b) Withwnar has posted this tutorial http://www.twcenter.net/forums/showt...3#post13890413 about the Faction destroyed event. I like it, it is more efficient than the one in SS v6.4. I wrote and tested this script as substitute of the old one (SS v6.4):

    Spoiler Alert, click show to read: 
    Code:
    ;============== FACTION KILLER WORKAROUND ===============
    ; Thanks to this tutorial: http://www.twcenter.net/forums/showthread.php?655272-Faction-destroyed-event&p=13890413#post13890413
    declare_counter faction_is_dead
    
    monitor_event PreFactionTurnStart TrueCondition
          set_event_counter factionsdestroyed 0 ; in order to count how many factions will get destroyed until the end of each factions turn
    end_monitor
    
    monitor_event IncomingMessage IncomingMessageType faction_defeated
    set_counter faction_is_dead 1 ;default to dead=true
    if I_FactionLeaderAttribute venice Command < 999 ;they are alive: set dead=false
    set_counter faction_is_dead 0
    end_if
    if I_CompareCounter faction_is_dead = 1 ;yes, they are dead
    inc_event_counter factionsdestroyed 1
    terminate_monitor
    end_if
    end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute sicily Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute milan Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute denmark Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute egypt Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute scotland Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute cumans Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute turks Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute france Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute hre Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute england Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute portugal Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute poland Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute byzantium Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute moors Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute russia Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute spain Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute hungary Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute aragon Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute lithuania Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute kievan_rus Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute norway Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute jerusalem Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute kwarezm Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated and I_EventCounter mongols_invasion > 5 set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute mongols Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor monitor_event IncomingMessage IncomingMessageType faction_defeated and I_EventCounter timurids_invasion > 2 set_counter faction_is_dead 1 ;default to dead=true if I_FactionLeaderAttribute timurids Command < 999 ;they are alive: set dead=false set_counter faction_is_dead 0 end_if if I_CompareCounter faction_is_dead = 1 ;yes, they are dead inc_event_counter factionsdestroyed 1 terminate_monitor end_if end_monitor


    Then, in the ECDT file, the section which contains all the triggers that affect trait FactionKiller was replaced with only these four:
    ;------------------------------------------
    Spoiler Alert, click show to read: 
    Code:
    Trigger TriumphsOverFaction_a
     WhenToTest CharacterTurnEnd
    
     Condition IsFactionLeader
           and I_EventCounter factionsdestroyed = 1
    
     Affects FactionKiller 10 Chance 100
    
    ;------------------------------------------
    Trigger TriumphsOverFaction_b
     WhenToTest CharacterTurnEnd
    
     Condition IsFactionLeader
           and I_EventCounter factionsdestroyed = 2
    
     Affects FactionKiller 20 Chance 100
    
    ;------------------------------------------
    Trigger TriumphsOverFaction_c
     WhenToTest CharacterTurnEnd
    
     Condition IsFactionLeader
           and I_EventCounter factionsdestroyed = 3
    
     Affects FactionKiller 30 Chance 100
    
    ;------------------------------------------
    Trigger TriumphsOverFaction_d
     WhenToTest CharacterTurnEnd
    
     Condition IsFactionLeader
           and I_EventCounter factionsdestroyed > 3
    
     Affects FactionKiller 40 Chance 100

    I tested by killing all the family members of a faction via script -during the start of a turn of the local faction. A "faction destroyed" message poped up; next turn my faction leader had the "conqueror" in his traits' list.
    Quote Originally Posted by Melooo182 View Post
    Hmmm after further inspecting that script, i think it wouldnt work good with re-emerging factions, as once it determinates a faction is dead it terminates that monitor so if that same faction comes back again later and gets killed it will not be taken in account.
    Quote Originally Posted by gsthoed View Post
    Some tweaking is necessary in order to work with re-emerging factions. Here is an example with venice and sicily. After each re-emerge, the corresponding counter(venice_is_dead etc) should be set to zero.

    Spoiler Alert, click show to read: 
    Code:
    ;============== FACTION KILLER WORKAROUND ===============
    declare_counter venice_is_dead
    declare_counter sicily_is_dead
    ; you can declare a counter for every destructible faction
    
    monitor_event PreFactionTurnStart TrueCondition
        set_event_counter factionsdestroyed 0
    end_monitor
    
    
    monitor_event IncomingMessage IncomingMessageType faction_defeated
    
        if I_CompareCounter venice_is_dead = 0
            set_counter venice_is_dead 1
            if I_FactionLeaderAttribute venice Command < 999 ;they are alive
                set_counter venice_is_dead 0
            end_if
            if I_CompareCounter venice_is_dead = 1  ;yes, they are dead
                inc_event_counter factionsdestroyed 1
            end_if
        end_if
    
        if I_CompareCounter sicily_is_dead = 0
            set_counter sicily_is_dead 1
            if I_FactionLeaderAttribute sicily Command < 999 ;they are alive
                set_counter sicily_is_dead 0
            end_if
            if I_CompareCounter sicily_is_dead = 1  ;yes, they are dead
                inc_event_counter factionsdestroyed 1
            end_if
        end_if
    
     ; you can do the same for all other destructible faction
    
    end_monitor


    Actually, this monitor could be a better idea even if we have no re-emerging factions .

    Another example: Let's say venice can re-emerge only once and an event_counter named venice_is_alive_again is set to 1 when this event takes place. Then the monitor for the destruction of venice can be this:
    Spoiler Alert, click show to read: 
    Code:
    monitor_event IncomingMessage IncomingMessageType faction_defeated
        and I_CompareCounter venice_is_dead = 0
    
        set_counter venice_is_dead 1
        
        if I_FactionLeaderAttribute venice Command < 999 ;they are alive
            set_counter venice_is_dead 0
        end_if
    
        if I_CompareCounter venice_is_dead = 1  ;yes, they are dead
            inc_event_counter factionsdestroyed 1
    if I_EventCounter venice_is_alive_again = 1
    terminate_monitor
    end_if
    end_if end_monitor
    Quote Originally Posted by Melooo182 View Post
    Actually think the ceasedfactionleader and becomesfactionleader would be quite useful for setting up a global check of factions alive, AFAIK is the only true accurate way for a "real-time" check.

    So instead of having them embeded within the factionkiller workaround, they could have their own section running the whole campaign and providing accurate "event counters" for external uses like EDCT/EDA/EDB/EDG

    so the factionkiller workaround could look like this:
    Code:
    declare_counter venice_died
        ...etc rest of factions
    
    monitor_event PreFactionTurnStart TrueCondition
        set_event_counter factionsdestroyed 0
    end_monitor
    
    monitor_event PreFactionTurnStart FactionIsLocal
    
        if I_EventCounter Ceased_venice = 1 ; dead before player's turn, value from global faction status check
        and I_CompareCounter venice_died < 1
            set_counter venice_died 1
        end_if
        if I_EventCounter Ceased_venice = 0 ; alive again?
        and I_CompareCounter venice_died >= 1
            set_counter venice_died 0
        end_if
        ...etc rest of factions
    
    end_monitor
    
    monitor_event IncomingMessage IncomingMessageType faction_defeated
    
        if I_EventCounter Ceased_venice = 1
        and I_CompareCounter venice_died < 1  ;yes, they just died this turn
            inc_event_counter factionsdestroyed 1
        end_if
        ...etc rest of factions
    
    end_monitor
    what do you think?
    Quote Originally Posted by gsthoed View Post
    About the real time check, it's a matter of discussion that deserves a new thread or joining a discussion in the Mod Workshop (I'll PM you a question relevant to this). Sure thing is that the "IncomingMessage" monitor fires only when a faction gets destroyed, while the ceasedfactionleader and becomesfactionleader monitors fire more times.
    Event_counters for externals uses can be included easily in the faction killer workaround. This too needs more analysis. I'll a brief example for my claim:
    Venice is a living faction from the begining of the campaign until it dies (of course we can resurrect them; then they are alive from the moment of their ressurection until they die again). So, it is a matter to detect the moment of death. I'll use a event_counter to detect if they are alive or dead and a simple monitor like the ones in the "new" faction killer workaround script I described previously for detecting their death:

    Code:
    declare_counter faction_is_dead ; default value 0, dummy counter only used in this section, as for elsewhere we'll use the Cease_venice etc
     set_event_counter Cease_venice 0 ;they are alive in the begining of the campaign. We can omit it in several cases, depends on where we want to use it
     
    monitor_event PreFactionTurnStart TrueCondition
         set_event_counter factionsdestroyed 0 ; An event counter I use in ECDT for the triggers about Trait FactionKiller
    end_monitor
    
    monitor_event IncomingMessage IncomingMessageType faction_defeated
         and I_EventCounter Cease_venice = 0  ; or "and not I_EventCounter Cease_venice = 1" 
    
             set_counter faction_is_dead 1
             if I_FactionLeaderAttribute venice Command < 999 ;they are alive, bear in mind this is a "free" condition, can be used in several tests 
                set_counter faction_is_dead 0
            end_if
             if I_CompareCounter faction_is_dead = 1  ;yes, they are dead
    set_event_counter Cease_venice 1 inc_event_counter factionsdestroyed 1
    end_if end_monitor
    So, if I_EventCounter Cease_venice = 0, this means venice faction is alive; if I_EventCounter Cease_venice = 1, then venice faction is dead. If resurrected, they need a command "set_event_counter Cease_venice 0" to be included in that script. These two values of the event_counter Cease_venice can be used externally too.

    Now about the script you wrote: I suppose we set the Ceased_venice event_counter in the"Faction Killer Workaround" section, aren't we? Since we have the Ceased_venice event_counter, what is the use of the (simple) counter venice_died?
    Quote Originally Posted by Melooo182 View Post
    True, I suppose emerging factions like mongols would need a monitor and condition for their Cease_faction event counter, maybe factionturnstart FactionType faction and a terminate monitor.

    Yep I like it, is much more streamlined like this
    will include it in the bugfix compilation after some tests
    and afterward tweak VivaLaRebelion for adding the set_event_counter Cease_faction 0
    Quote Originally Posted by gsthoed
    I wrote about a question in the post. I had some cases in mind. To cut a long story short: when the CeasedFactionLeader event takes place, the FL is still alive and, so, it is his faction. The question is if there can be an event between the CeasedFactionLeader and the destruction of the faction. If this is the case, then setting the event_counter for the death of the faction (for example set_event_counter Ceased_venice 1) in a monitor for the CeasedFactionLeader event can lead to a bad "real time" check...
    I dont know when ceasedfactionleader actually happens, if its after the character dies, during or just before, in game it all appears to be simultaneous, same as faction destroyed.

    There is still a thing that doesnt satisfy me about the script and is about what happens when the faction is killed outside player's turn, I think the faction_defeated message does not fires until player's turn starts, right? if so, then faction that was destroyed outside the player's turn will have to wait until player's turn to update the Ceased_faction value...a whole deal of possibilities missed during AI turns :/

  2. #2

    Default Re: Campaign Script Optimizations

    Have you read this: http://www.twcenter.net/forums/showt...8#post11879768 ?

    Maybe you can get some more ideas from him.

  3. #3

    Default Re: Campaign Script Optimizations

    Quote Originally Posted by Melooo182 View Post
    There is still a thing that doesnt satisfy me about the script and is about what happens when the faction is killed outside player's turn, I think the faction_defeated message does not fires until player's turn starts, right? if so, then faction that was destroyed outside the player's turn will have to wait until player's turn to update the Ceased_faction value...a whole deal of possibilities missed during AI turns :/
    It seems you are right! Playing as Scotland, I used the "surrender_regions kwarezm" command during England's turn. Finally, only Scotland's king gained points of FactionKiller (actually, he gained two levels while the command run once ), while the english king gain none. I'll keep testing, as I found some other peculiar things about the destruction of a faction. I'll report back if I have something different. I'll check also about the event_counters you said.

  4. #4

    Default Re: Campaign Script Optimizations

    Oh that too, i was thinking 1st that the factionkiller trait was supposed to be for the player only
    giving all that i think we should keep it as it was but with one small change that could make it work with your EDCT tweak



    Code:
    monitor_event PreFactionTurnStart TrueCondition
        set_event_counter killed_factions_count 0
    
        ;we don't want to reset Ceased_faction each turn, as the killed_factions will be used for FactionKiller trait triggers 
    end_monitor
    
    
    monitor_event CeasedFactionLeader FactionType venice
        inc_event_counter killed_factions_count 1
        set_event_counter Ceased_venice 1
    end_monitor
    monitor_event BecomesFactionLeader FactionType venice
        inc_event_counter killed_factions_count -1
    
        set_event_counter Ceased_venice 0; when the campaign start faction leaders get assigned thus triggering this
    end_monitor
    I think like this should work fine, still don't know if the transition from CeasedFL to BecomesFL is flawless but it there seems to be nothing between them. the downside is that there are no way of condensing all in a single monitor, as I've read it elsewhere before like in the link K/T posted, less monitors with lots of IFs is always better than many monitors...so no much gain in processing will be done here aside the reduction of triggers in the EDCT.

  5. #5

    Default Re: Campaign Script Optimizations

    I am testing the transition for CeasedFL to BecomesFL in some extreme senarios. If it works, this script of yours has the benefit of providing event_counters for the destruction of each faction the moment it takes place. One question though: does the BecomesFl fires when a faction emerges or re-emerges?

  6. #6

    Default Re: Campaign Script Optimizations

    Haven't tested that but it does for starting factions in turn 0, I found that out when was testing the traits for Civil Unrest, part of KER submod. I had to add the I_TurnNumber > 0 condition so they didn't fired at the start of the campaign whith starting Faction Leaders...so i suppose BecomesFL also kicks in when a horde faction emerges...and by extension when a faction re-emerges too...i need to confirm this though.

  7. #7

    Default Re: Campaign Script Optimizations

    I can confirm this. Playing scotland, at the start of England's turn I killed the last member of kwarezm faction and ran a "Teutonic Order Emergent" script, while monitoring BecomesFL - CeasedFL for only Kwarezm and teutonic_order. The event_counter killed_factions_count can't work in these situations and that's why we have so many triggers for the trait FactionKiller in the EDCT. Maybe we need two event_counters for each faction; one resetting in each prefactionturnstart and one not....

  8. #8

    Default Re: Campaign Script Optimizations

    maybe this can work then
    Code:
    declare_counter venice_died
    monitor_event PreFactionTurnStart TrueCondition
        set_event_counter killed_factions_count 0; used for FactionKiller trait triggers
        set_counter venice_died 0; Reseted every turn
    end_monitor
    
    
    monitor_event CeasedFactionLeader FactionType venice
        if I_CompareCounter venice_died = 0
            inc_event_counter killed_factions_count 1
        end_if
        set_event_counter status_venice 1; replaces Ceased_venice, not emerged=0 dead=1 alive=2
        set_counter venice_died 1
    end_monitor
    monitor_event BecomesFactionLeader FactionType venice
        if I_CompareCounter venice_died = 1; this should filter emerging/re-emerging
            inc_event_counter killed_factions_count -1
        end_if
        set_event_counter status_venice 2
        set_counter venice_died 0; just in case two or more FL are killed in a same turn before the faction being destroyed
    end_monitor

  9. #9

    Default Re: Campaign Script Optimizations

    It seems ok. Nevertheless, I cannot understand the use of the "if" in the CeasedFL monitor.
    I think these new counters can be applied in the Player notifications of death of leaders; I' ll try this later.

  10. #10

    Default Re: Campaign Script Optimizations

    you mean it could be like this?

    Code:
    monitor_event CeasedFactionLeader FactionType venice
        inc_event_counter killed_factions_count 1
        set_event_counter status_venice 1; replaces Ceased_venice, not emerged=0 dead=1 alive=2
        set_counter venice_died 1
    end_monitor
    monitor_event BecomesFactionLeader FactionType venice
        if I_CompareCounter venice_died = 1; this should filter emerging/re-emerging
            inc_event_counter killed_factions_count -1
        end_if
        set_event_counter status_venice 2
    end_monitor
    I think i'll make venice_died an event counter as well just for shortening the codelines, because of laziness xD
    there's no drawback, performance impact in that right?

  11. #11

    Default Re: Campaign Script Optimizations

    Quote Originally Posted by Melooo182 View Post
    I think i'll make venice_died an event counter as well just for shortening the codelines, because of laziness xD
    there's no drawback, performance impact in that right?
    I don't know if there's any performance impact. If there is, I believe it is negligible.
    Usually, when I see an event_counter, I suspect it might be used in other file. Besides, you can't avoid the "resetting" the "venice_died" counters in every PreFactionTurnStart...
    Just name it "died_venice" etc instead of "venice_died" and batch rename the old "Ceased_venice" counters .
    Furthemore, in order to avoid the first monitor (the one that sets the counters to zero), we can use the monitors in the "Is the AI?" section of the CS
    I 'll do all this stuff and I' ll post it here when ready.

    What really bothers me is that I cannot think of any use for the new "status_venice" event_counters in the "vanilla" SS6.4, except -maybe- in the "death of leader" section of "Player Notifications" in the CS...

  12. #12

    Default Re: Campaign Script Optimizations

    What does this FactionKiller stuff do anyway? It's a trait for Faction Leaders?

  13. #13

    Default Re: Campaign Script Optimizations

    yeah, it adds extra authority and dunno if something else

    @gsthoed: sounds good

  14. #14

    Default Re: Campaign Script Optimizations

    FactionKiller is a trait for Faction Leaders. It adds to Authority, Command and dread. It used to be triggered when a faction leader destroyed an enemy faction.
    Last versions of SS, it is triggered when the last faction leader of a faction dies during a faction's turn.

    Our purpose here was a) to have less triggers that affect the trait in the EDCT and b) to define event_counters that "informs" us if a faction is "alive" or has been destroyed (or, simply, to define the exact moment a faction get destroyed)

    In the attached file, there are the result of this discussion so far. The tweaked parts of the campaign_script, along with the changes to EDCT, are showed in 3 sections:
    a) changes in "Is the AI?" section of campaign_script.
    b) changes in "Faction Killer Workaround" section of campaign_script.
    c) changes in the EDCT.

    Note: Monitors, counters etc for papal_states and teutonic_order are disabled by default, as these factions are indestructible.
    Attached Files Attached Files
    Last edited by gsthoed; June 29, 2014 at 08:02 PM.

  15. #15

    Default Re: Campaign Script Optimizations

    well TO will be destructible with upcoming Bugfix Comp i can add that part when compiling the stuff

  16. #16

    Default Re: Campaign Script Optimizations

    Quote Originally Posted by Melooo182 View Post
    well TO will be destructible with upcoming Bugfix Comp i can add that part when compiling the stuff
    One of the reasons I didn't erased tha part. Nevertheless, I worry about the condition "not having family members requires them to have this": Even without family members, TOs can do a lot of things: they can have settlements (and maybe recruit generals), they're priests keep on spreading their faith (and they can become cardinals) etc. I'm looking forward for v1.25.

    Now, on topic: Some tweaking on the "Great People Ancillaries". Nothing fancy: Ifs that were refering to the same I_TurnNumber (two pairs in each CS) are merged, a separate monitor for I_TurnNumber = 0 was created and monitors are terminated after the last command is issued. Melooo182 may have already prepared something like this for the upcoming version of the Bugfix Compilation; I am posting it here as it fits to the topic and, just in case, to save him some time.

    For early campaign:
    Spoiler Alert, click show to read: 
    Code:
     ;============= GREAT PEOPLE ANCILLARIES =================
    
    monitor_event FactionTurnStart FactionType slave
        set_event_counter peter_the_hermit_in 1
        set_event_counter pierre_abelard_in 1
        terminate_monitor
    end_monitor
    
    monitor_event FactionTurnStart FactionType slave
    
        if I_TurnNumber = 464
            set_event_counter michaelangelo_in 0
            terminate_monitor
        end_if
        if I_TurnNumber = 385
            set_event_counter michaelangelo_in 1
        end_if
    
        if I_TurnNumber = 322
            set_event_counter joan_of_arc_in 1
        end_if
        if I_TurnNumber = 331
            set_event_counter joan_of_arc_in 0
        end_if
    
        if I_TurnNumber = 15
            set_event_counter peter_the_hermit_in 0
        end_if
    
        if I_TurnNumber = 230
            set_event_counter bertrand_du_guesclin_in 1
        end_if
        if I_TurnNumber = 280
            set_event_counter bertrand_du_guesclin_in 0
        end_if
    
        if I_TurnNumber = 370
            set_event_counter vasco_de_gama_in 1
        end_if
        if I_TurnNumber = 373
            set_event_counter chevalier_de_bayard_in 1
        end_if
        if I_TurnNumber = 424
            set_event_counter chevalier_de_bayard_in 0
            set_event_counter vasco_de_gama_in 0
        end_if
    
        if I_TurnNumber = 42
            set_event_counter pierre_abelard_in 0
        end_if
    
        if I_TurnNumber = 214
            set_event_counter francesco_petrarca_in 1
        end_if
        if I_TurnNumber = 274
            set_event_counter francesco_petrarca_in 0
        end_if
    
        if I_TurnNumber = 130
            set_event_counter roger_bacon_in 1
        end_if
        if I_TurnNumber = 192
            set_event_counter roger_bacon_in 0
        end_if
    
        if I_TurnNumber = 253
            set_event_counter geoffrey_chaucer_in 1
        end_if
        if I_TurnNumber = 300
            set_event_counter geoffrey_chaucer_in 0
        end_if
    
        if I_TurnNumber = 238
            set_event_counter john_wycliffe_in 1
        end_if
        if I_TurnNumber = 284
            set_event_counter john_wycliffe_in 0
        end_if
    
        if I_TurnNumber = 118
            set_event_counter simon_de_montfort_in 1
        end_if
        if I_TurnNumber = 165
            set_event_counter simon_de_montfort_in 0
        end_if
    
        if I_TurnNumber = 364
            set_event_counter amerigo_vespucci_in 1
        end_if
        if I_TurnNumber = 412
            set_event_counter amerigo_vespucci_in 0
        end_if
    
        if I_TurnNumber = 218
            set_event_counter niels_ebbesen_in 1
        end_if
        if I_TurnNumber = 240
            set_event_counter niels_ebbesen_in 0
        end_if
    
        if I_TurnNumber = 341
            set_event_counter vlad_tepes_in 1
        end_if
        if I_TurnNumber = 376
            set_event_counter vlad_tepes_in 0
        end_if
    
        if I_TurnNumber = 170
            set_event_counter meister_eckhart_in 1
        end_if
        if I_TurnNumber = 227
            set_event_counter meister_eckhart_in 0
        end_if
    
        if I_TurnNumber = 250
            set_event_counter arnold_von_winkelried_in 1
        end_if
        if I_TurnNumber = 286
            set_event_counter arnold_von_winkelried_in 0
        end_if
    
        if I_TurnNumber = 307
            set_event_counter john_gutenberg_in 1
        end_if
        if I_TurnNumber = 368
            set_event_counter john_gutenberg_in 0
        end_if
    
        if I_TurnNumber = 8
            set_event_counter hildegard_von_bingen_in 1
        end_if
        if I_TurnNumber = 79
            set_event_counter hildegard_von_bingen_in 0
        end_if
    
        if I_TurnNumber = 393
            set_event_counter martin_luther_in 1
            set_event_counter raphael_in 1
        end_if
        if I_TurnNumber = 446
            set_event_counter martin_luther_in 0
        end_if
        if I_TurnNumber = 420
            set_event_counter raphael_in 0
        end_if
    
        if I_TurnNumber = 403
            set_event_counter paracelsus_in 1
        end_if
        if I_TurnNumber = 441
            set_event_counter paracelsus_in 0
        end_if
    
        if I_TurnNumber = 390
            set_event_counter johannes_faustes_in 1
        end_if
        if I_TurnNumber = 440
            set_event_counter johannes_faustes_in 0
        end_if
    
        if I_TurnNumber = 359
            set_event_counter aldus_manutius_in 1
        end_if
        if I_TurnNumber = 415
            set_event_counter aldus_manutius_in 0
        end_if
    
        if I_TurnNumber = 164
            set_event_counter marco_polo_in 1
        end_if
        if I_TurnNumber = 224
            set_event_counter marco_polo_in 0
        end_if
    
        if I_TurnNumber = 296
            set_event_counter donatello_in 1
        end_if
        if I_TurnNumber = 366
            set_event_counter donatello_in 0
        end_if
    
        if I_TurnNumber = 379
            set_event_counter machiavelli_in 1
        end_if
        if I_TurnNumber = 427
            set_event_counter machiavelli_in 0
        end_if
    
        if I_TurnNumber = 5
            set_event_counter george_of_antioch_in 1
        end_if
        if I_TurnNumber = 52
            set_event_counter george_of_antioch_in 0
        end_if
    
        if I_TurnNumber = 91
            set_event_counter francis_of_assisi_in 1
        end_if
        if I_TurnNumber = 126
            set_event_counter francis_of_assisi_in 0
        end_if
    
        if I_TurnNumber = 105
            set_event_counter anthony_of_padua_in 1
        end_if
        if I_TurnNumber = 131
            set_event_counter anthony_of_padua_in 0
        end_if
    
        if I_TurnNumber = 383
            set_event_counter nicolau_copernicus_in 1
        end_if
        if I_TurnNumber = 443
            set_event_counter nicolau_copernicus_in 0
        end_if
    
        if I_TurnNumber = 242
            set_event_counter ibn_khaldun_in 1
        end_if
        if I_TurnNumber = 306
            set_event_counter ibn_khaldun_in 0
        end_if
    
        if I_TurnNumber = 106
            set_event_counter albertus_magnus_in 1
        end_if
        if I_TurnNumber = 180
            set_event_counter albertus_magnus_in 0
        end_if
    
        if I_TurnNumber = 270
            set_event_counter jan_zizka_in 1
        end_if
        if I_TurnNumber = 324
            set_event_counter jan_zizka_in 0
        end_if
    
        if I_TurnNumber = 289
            set_event_counter zawisza_czarny_in 1
        end_if
        if I_TurnNumber = 328
            set_event_counter zawisza_czarny_in 0
        end_if
    
        if I_TurnNumber = 50
            set_event_counter roger_de_moulins_in 1
        end_if
        if I_TurnNumber = 87
            set_event_counter roger_de_moulins_in 0
        end_if
    
        if I_TurnNumber = 49
            set_event_counter gerard_de_ridefort_in 1
        end_if
        if I_TurnNumber = 89
            set_event_counter gerard_de_ridefort_in 0
        end_if
    
        if I_TurnNumber = 288
            set_event_counter fastolf_in 1
        end_if
        if I_TurnNumber = 355
            set_event_counter fastolf_in 0
        end_if
    
    end_monitor
    
     ;======== MERCHANT&PRIEST&SHIP SUPPORT SPAWN ============


    For late campaign:
    Spoiler Alert, click show to read: 
    Code:
    ;============= GREAT PEOPLE ANCILLARIES =================
    
    monitor_event PreFactionTurnStart FactionType slave
        set_event_counter albertus_magnus_in 1
        set_event_counter simon_de_montfort_in 1
        terminate_monitor
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType slave
    
        if I_TurnNumber = 344
            set_event_counter michaelangelo_in 0
            terminate_monitor
        end_if
        if I_TurnNumber = 265
            set_event_counter michaelangelo_in 1
        end_if
    
        if I_TurnNumber = 202
            set_event_counter joan_of_arc_in 1
        end_if
        if I_TurnNumber = 211
            set_event_counter joan_of_arc_in 0
        end_if
    
        if I_TurnNumber = 110
            set_event_counter bertrand_du_guesclin_in 1
        end_if
        if I_TurnNumber = 160
            set_event_counter bertrand_du_guesclin_in 0
        end_if
    
        if I_TurnNumber = 250
            set_event_counter vasco_de_gama_in 1
        end_if
        if I_TurnNumber = 253
            set_event_counter chevalier_de_bayard_in 1
        end_if
        if I_TurnNumber = 304
            set_event_counter vasco_de_gama_in 0
            set_event_counter chevalier_de_bayard_in 0
        end_if
    
        if I_TurnNumber = 94
            set_event_counter francesco_petrarca_in 1
        end_if
        if I_TurnNumber = 154
            set_event_counter francesco_petrarca_in 0
        end_if
    
        if I_TurnNumber = 10
            set_event_counter roger_bacon_in 1
        end_if
        if I_TurnNumber = 72
            set_event_counter roger_bacon_in 0
        end_if
    
        if I_TurnNumber = 133
            set_event_counter geoffrey_chaucer_in 1
        end_if
        if I_TurnNumber = 180
            set_event_counter geoffrey_chaucer_in 0
        end_if
    
        if I_TurnNumber = 118
            set_event_counter john_wycliffe_in 1
        end_if
        if I_TurnNumber = 164
            set_event_counter john_wycliffe_in 0
        end_if
    
        if I_TurnNumber = 45
            set_event_counter simon_de_montfort_in 0
        end_if
    
        if I_TurnNumber = 244
            set_event_counter amerigo_vespucci_in 1
        end_if
        if I_TurnNumber = 292
            set_event_counter amerigo_vespucci_in 0
        end_if
    
        if I_TurnNumber = 98
            set_event_counter niels_ebbesen_in 1
        end_if
        if I_TurnNumber = 120
            set_event_counter niels_ebbesen_in 0
        end_if
    
        if I_TurnNumber = 221
            set_event_counter vlad_tepes_in 1
        end_if
        if I_TurnNumber = 256
            set_event_counter vlad_tepes_in 0
        end_if
    
        if I_TurnNumber = 50
            set_event_counter meister_eckhart_in 1
        end_if
        if I_TurnNumber = 107
            set_event_counter meister_eckhart_in 0
        end_if
    
        if I_TurnNumber = 130
            set_event_counter arnold_von_winkelried_in 1
        end_if
        if I_TurnNumber = 166
            set_event_counter arnold_von_winkelried_in 0
        end_if
    
        if I_TurnNumber = 187
            set_event_counter john_gutenberg_in 1
        end_if
        if I_TurnNumber = 248
            set_event_counter john_gutenberg_in 0
        end_if
    
        if I_TurnNumber = 273
            set_event_counter martin_luther_in 1
            set_event_counter raphael_in 1
        end_if
        if I_TurnNumber = 300
            set_event_counter raphael_in 0
        end_if
        if I_TurnNumber = 326
            set_event_counter martin_luther_in 0
        end_if
    
        if I_TurnNumber = 283
            set_event_counter paracelsus_in 1
        end_if
        if I_TurnNumber = 321
            set_event_counter paracelsus_in 0
        end_if
    
        if I_TurnNumber = 270
            set_event_counter johannes_faustes_in 1
        end_if
        if I_TurnNumber = 320
            set_event_counter johannes_faustes_in 0
        end_if
    
        if I_TurnNumber = 239
            set_event_counter aldus_manutius_in 1
        end_if
        if I_TurnNumber = 295
            set_event_counter aldus_manutius_in 0
        end_if
    
        if I_TurnNumber = 44
            set_event_counter marco_polo_in 1
        end_if
        if I_TurnNumber = 104
            set_event_counter marco_polo_in 0
        end_if
    
        if I_TurnNumber = 176
            set_event_counter donatello_in 1
        end_if
        if I_TurnNumber = 246
            set_event_counter donatello_in 0
        end_if
    
        if I_TurnNumber = 259
            set_event_counter machiavelli_in 1
        end_if
        if I_TurnNumber = 307
            set_event_counter machiavelli_in 0
        end_if
    
        if I_TurnNumber = 5
            set_event_counter anthony_of_padua_in 1
        end_if
        if I_TurnNumber = 31
            set_event_counter anthony_of_padua_in 0
        end_if
    
        if I_TurnNumber = 263
            set_event_counter nicolau_copernicus_in 1
        end_if
        if I_TurnNumber = 323
            set_event_counter nicolau_copernicus_in 0
        end_if
    
        if I_TurnNumber = 122
            set_event_counter ibn_khaldun_in 1
        end_if
        if I_TurnNumber = 186
            set_event_counter ibn_khaldun_in 0
        end_if
    
        if I_TurnNumber = 60
            set_event_counter albertus_magnus_in 0
        end_if
    
        if I_TurnNumber = 150
            set_event_counter jan_zizka_in 1
        end_if
        if I_TurnNumber = 204
            set_event_counter jan_zizka_in 0
        end_if
    
        if I_TurnNumber = 169
            set_event_counter zawisza_czarny_in 1
        end_if
        if I_TurnNumber = 208
            set_event_counter zawisza_czarny_in 0
        end_if
    
        if I_TurnNumber = 168
            set_event_counter fastolf_in 1
        end_if
        if I_TurnNumber = 235
            set_event_counter fastolf_in 0
        end_if
    
    end_monitor
    
    ;======== MERCHANT&PRIEST&SHIP SUPPORT SPAWN ============

  17. #17

    Default Re: Campaign Script Optimizations

    Here is a reworking of the "Merchant&Priest&Ship Support Spawn" section. The changes are quite obvious. Now the conditions
    if I_IsFactionAIControlled <faction>
    and I_NumberOfSettlements <faction> > 1

    are tested only when they should, instead at every (Pre)start of slave_faction's turn. And the big bad monitor terminates after the last command has been run (I_TurnNumber = 140), instead at I_TurnNumber = 120.
    Spoiler Alert, click show to read: 
    Code:
    ;======== MERCHANT&PRIEST&SHIP SUPPORT SPAWN ============
    
    monitor_event PreFactionTurnStart FactionType slave
        spawn_character slave random_name, merchant, age 20, x 138, y 101
        spawn_character slave random_name, merchant, age 20, x 66, y 131
        spawn_character slave random_name, merchant, age 20, x 349, y 89
        spawn_character slave random_name, merchant, age 20, x 428, y 218
        spawn_character slave random_name, merchant, age 20, x 234, y 218
        spawn_character slave random_name, merchant, age 20, x 81, y 184
        spawn_character slave random_name, merchant, age 20, x 57, y 233
        spawn_character slave random_name, merchant, age 20, x 178, y 248
        spawn_character slave random_name, merchant, age 20, x 184, y 144
        spawn_character slave random_name, merchant, age 20, x 223, y 157
        spawn_character slave random_name, merchant, age 20, x 482, y 104
        spawn_character slave random_name, merchant, age 20, x 20, y 125
        spawn_character slave random_name, merchant, age 20, x 30, y 237
        spawn_character slave random_name, merchant, age 20, x 238, y 118
        terminate_monitor
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType slave
        and I_TurnNumber = 5
    
        if I_IsFactionAIControlled england
        and I_NumberOfSettlements england > 1
            spawn_character england random_name, merchant, age 20, x 222, y 238
        end_if
    
        if I_IsFactionAIControlled france
        and I_NumberOfSettlements france > 1
            spawn_character france random_name, merchant, age 20, x 94, y 199
        end_if
    
        if I_IsFactionAIControlled hre
        and I_NumberOfSettlements hre > 1
            spawn_character hre random_name, merchant, age 20, x 156, y 201
        end_if
    
        if I_IsFactionAIControlled spain
        and I_NumberOfSettlements spain > 1
            spawn_character spain random_name, merchant, age 20, x 38, y 152
        end_if
    
        if I_IsFactionAIControlled venice
        and I_NumberOfSettlements venice > 1
            spawn_character venice random_name, merchant, age 20, x 165, y 173
        end_if
    
        if I_IsFactionAIControlled sicily
        and I_NumberOfSettlements sicily > 1
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
        end_if
    
        if I_IsFactionAIControlled milan
        and I_NumberOfSettlements milan > 1
            spawn_character milan random_name, merchant, age 20, x 139, y 168
        end_if
    
        if I_IsFactionAIControlled scotland
        and I_NumberOfSettlements scotland > 1
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
        end_if
    
        if I_IsFactionAIControlled cumans
        and I_NumberOfSettlements cumans > 1
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
        end_if
    
        if I_IsFactionAIControlled byzantium
        and I_NumberOfSettlements byzantium > 1
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
        end_if
    
        if I_IsFactionAIControlled russia
        and I_NumberOfSettlements russia > 1
            spawn_character russia random_name, merchant, age 20, x 301, y 269
        end_if
    
        if I_IsFactionAIControlled moors
        and I_NumberOfSettlements moors > 1
            spawn_character moors random_name, merchant, age 20, x 44, y 119
        end_if
    
        if I_IsFactionAIControlled turks
        and I_NumberOfSettlements turks > 1
            spawn_character turks random_name, merchant, age 20, x 312, y 119
        end_if
    
        if I_IsFactionAIControlled egypt
        and I_NumberOfSettlements egypt > 1
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
        end_if
    
        if I_IsFactionAIControlled denmark
        and I_NumberOfSettlements denmark > 1
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
        end_if
    
        if I_IsFactionAIControlled portugal
        and I_NumberOfSettlements portugal > 1
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
        end_if
    
        if I_IsFactionAIControlled poland
        and I_NumberOfSettlements poland > 1
            spawn_character poland random_name, merchant, age 20, x 215, y 210
        end_if
    
        if I_IsFactionAIControlled hungary
        and I_NumberOfSettlements hungary > 1
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
        end_if
    
        if I_IsFactionAIControlled kievan_rus
        and I_NumberOfSettlements kievan_rus > 1
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
        end_if
    
        if I_IsFactionAIControlled aragon
        and I_NumberOfSettlements aragon > 1
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
        end_if
    
        if I_IsFactionAIControlled norway
        and I_NumberOfSettlements norway > 1
            spawn_character norway random_name, merchant, age 20, x 116, y 279
        end_if
    
        if I_IsFactionAIControlled lithuania
        and I_NumberOfSettlements lithuania > 1
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
        end_if
    
        if I_IsFactionAIControlled kwarezm
        and I_NumberOfSettlements kwarezm > 1
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
        end_if
    
        if I_IsFactionAIControlled jerusalem
        and I_NumberOfSettlements jerusalem > 1
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
        end_if
    
        terminate_monitor
    end_monitor
    
    
    monitor_event PreFactionTurnStart FactionType slave
        
    if I_TurnNumber = 30
    
        if I_IsFactionAIControlled england
        and I_NumberOfSettlements england > 1
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, priest, age 20, x 222, y 238
        end_if
    
        if I_IsFactionAIControlled france
        and I_NumberOfSettlements france > 1
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, priest, age 20, x 94, y 199
        end_if
    
        if I_IsFactionAIControlled hre
        and I_NumberOfSettlements hre > 1
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, priest, age 20, x 156, y 201
        end_if
    
        if I_IsFactionAIControlled spain
        and I_NumberOfSettlements spain > 1
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, priest, age 20, x 38, y 152
        end_if
    
        if I_IsFactionAIControlled venice
        and I_NumberOfSettlements venice > 1
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, priest, age 20, x 165, y 173
        end_if
    
        if I_IsFactionAIControlled sicily
        and I_NumberOfSettlements sicily > 1
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, priest, age 20, x 170, y 117
        end_if
    
        if I_IsFactionAIControlled milan
        and I_NumberOfSettlements milan > 1
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, priest, age 20, x 139, y 168
        end_if
    
        if I_IsFactionAIControlled scotland
        and I_NumberOfSettlements scotland > 1
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, priest, age 20, x 62, y 247
        end_if
    
        if I_IsFactionAIControlled cumans
        and I_NumberOfSettlements cumans > 1
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, priest, age 20, x 431, y 250
        end_if
    
        if I_IsFactionAIControlled byzantium
        and I_NumberOfSettlements byzantium > 1
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, priest, age 20, x 282, y 143
        end_if
    
        if I_IsFactionAIControlled russia
        and I_NumberOfSettlements russia > 1
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, priest, age 20, x 301, y 269
        end_if
    
        if I_IsFactionAIControlled moors
        and I_NumberOfSettlements moors > 1
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, priest, age 20, x 44, y 119
        end_if
    
        if I_IsFactionAIControlled turks
        and I_NumberOfSettlements turks > 1
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, priest, age 20, x 312, y 119
        end_if
    
        if I_IsFactionAIControlled egypt
        and I_NumberOfSettlements egypt > 1
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, priest, age 20, x 302, y 59
        end_if
    
        if I_IsFactionAIControlled denmark
        and I_NumberOfSettlements denmark > 1
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, priest, age 20, x 147, y 246
        end_if
    
        if I_IsFactionAIControlled portugal
        and I_NumberOfSettlements portugal > 1
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, priest, age 20, x 19, y 128
        end_if
    
        if I_IsFactionAIControlled poland
        and I_NumberOfSettlements poland > 1
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, priest, age 20, x 215, y 210
        end_if
    
        if I_IsFactionAIControlled hungary
        and I_NumberOfSettlements hungary > 1
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, priest, age 20, x 215, y 188
        end_if
    
        if I_IsFactionAIControlled kievan_rus
        and I_NumberOfSettlements kievan_rus > 1
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, priest, age 20, x 295, y 209
        end_if
    
        if I_IsFactionAIControlled aragon
        and I_NumberOfSettlements aragon > 1
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, priest, age 20, x 76, y 147
        end_if
    
        if I_IsFactionAIControlled norway
        and I_NumberOfSettlements norway > 1
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, priest, age 20, x 116, y 279
        end_if
    
        if I_IsFactionAIControlled lithuania
        and I_NumberOfSettlements lithuania > 1
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, priest, age 20, x 258, y 239
        end_if
    
        if I_IsFactionAIControlled kwarezm
        and I_NumberOfSettlements kwarezm > 1
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, priest, age 20, x 449, y 93
        end_if
    
        if I_IsFactionAIControlled jerusalem
        and I_NumberOfSettlements jerusalem > 1
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, priest, age 20, x 331, y 77
        end_if
    
    end_if
    
    if I_TurnNumber = 70
    
        spawn_character slave random_name, merchant, age 20, x 138, y 101
        spawn_character slave random_name, merchant, age 20, x 66, y 131
        spawn_character slave random_name, merchant, age 20, x 349, y 89
        spawn_character slave random_name, merchant, age 20, x 428, y 218
        spawn_character slave random_name, merchant, age 20, x 234, y 218
        spawn_character slave random_name, merchant, age 20, x 81, y 184
        spawn_character slave random_name, merchant, age 20, x 57, y 233
        spawn_character slave random_name, merchant, age 20, x 178, y 248
        spawn_character slave random_name, merchant, age 20, x 184, y 144
        spawn_character slave random_name, merchant, age 20, x 223, y 157
        spawn_character slave random_name, merchant, age 20, x 482, y 104
        spawn_character slave random_name, merchant, age 20, x 20, y 125
        spawn_character slave random_name, merchant, age 20, x 30, y 237
        spawn_character slave random_name, merchant, age 20, x 238, y 118
    
    end_if
    
    
    if I_TurnNumber = 80
    
        if I_IsFactionAIControlled england
        and I_NumberOfSettlements england > 1
            spawn_army
                faction england
                character random_name, admiral, age 20, x 76, y 211
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled venice
        and I_NumberOfSettlements venice > 1
            spawn_army
                faction venice
                character random_name, admiral, age 20, x 171, y 170
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled sicily
        and I_NumberOfSettlements sicily > 1
            spawn_army
                faction sicily
                character random_name, admiral, age 20, x 170, y 122
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled milan
        and I_NumberOfSettlements milan > 1
            spawn_army
                faction milan
                character random_name, admiral, age 20, x 76, y 211
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
                unit    galley        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled scotland
        and I_NumberOfSettlements scotland > 1
            spawn_army
                faction scotland
                character random_name, admiral, age 20, x 61, y 253
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled egypt
        and I_NumberOfSettlements egypt > 1
            spawn_army
                faction egypt
                character random_name, admiral, age 20, x 76, y 211
                unit    dhow        exp 0 armour 0 weapon_lvl 0
                unit    dhow        exp 0 armour 0 weapon_lvl 0
                unit    dhow        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled denmark
        and I_NumberOfSettlements denmark > 1
            spawn_army
                faction denmark
                character random_name, admiral, age 20, x 170, y 242
                unit    longboat        exp 0 armour 0 weapon_lvl 0
                unit    longboat        exp 0 armour 0 weapon_lvl 0
                unit    longboat        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled portugal
        and I_NumberOfSettlements portugal > 1
            spawn_army
                faction portugal
                character random_name, admiral, age 20, x 12, y 144
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled aragon
        and I_NumberOfSettlements aragon > 1
            spawn_army
                faction aragon
                character random_name, admiral, age 20, x 96, y 143
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
                unit    cog        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    
        if I_IsFactionAIControlled norway
        and I_NumberOfSettlements norway > 1
            spawn_army
                faction norway
                character random_name, admiral, age 20, x 154, y 270
                unit    longboat        exp 0 armour 0 weapon_lvl 0
                unit    longboat        exp 0 armour 0 weapon_lvl 0
                unit    longboat        exp 0 armour 0 weapon_lvl 0
            end
        end_if
    end_if
    
    
    if I_TurnNumber = 90
    
        if I_IsFactionAIControlled england
        and I_NumberOfSettlements england > 1
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, priest, age 20, x 222, y 238
        end_if
    
        if I_IsFactionAIControlled france
        and I_NumberOfSettlements france > 1
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, priest, age 20, x 94, y 199
        end_if
    
        if I_IsFactionAIControlled hre
        and I_NumberOfSettlements hre > 1
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, priest, age 20, x 156, y 201
        end_if
    
        if I_IsFactionAIControlled spain
        and I_NumberOfSettlements spain > 1
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, priest, age 20, x 38, y 152
        end_if
    
        if I_IsFactionAIControlled venice
        and I_NumberOfSettlements venice > 1
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, priest, age 20, x 165, y 173
        end_if
    
        if I_IsFactionAIControlled sicily
        and I_NumberOfSettlements sicily > 1
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, priest, age 20, x 170, y 117
        end_if
    
        if I_IsFactionAIControlled milan
        and I_NumberOfSettlements milan > 1
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, priest, age 20, x 139, y 168
        end_if
    
        if I_IsFactionAIControlled scotland
        and I_NumberOfSettlements scotland > 1
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, priest, age 20, x 62, y 247
        end_if
    
        if I_IsFactionAIControlled cumans
        and I_NumberOfSettlements cumans > 1
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, priest, age 20, x 431, y 250
        end_if
    
        if I_IsFactionAIControlled byzantium
        and I_NumberOfSettlements byzantium > 1
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, priest, age 20, x 282, y 143
        end_if
    
        if I_IsFactionAIControlled russia
        and I_NumberOfSettlements russia > 1
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, priest, age 20, x 301, y 269
        end_if
    
        if I_IsFactionAIControlled moors
        and I_NumberOfSettlements moors > 1
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, priest, age 20, x 44, y 119
        end_if
    
        if I_IsFactionAIControlled turks
        and I_NumberOfSettlements turks > 1
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, priest, age 20, x 312, y 119
        end_if
    
        if I_IsFactionAIControlled egypt
        and I_NumberOfSettlements egypt > 1
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, priest, age 20, x 302, y 59
        end_if
    
        if I_IsFactionAIControlled denmark
        and I_NumberOfSettlements denmark > 1
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, priest, age 20, x 147, y 246
        end_if
    
        if I_IsFactionAIControlled portugal
        and I_NumberOfSettlements portugal > 1
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, priest, age 20, x 19, y 128
        end_if
    
        if I_IsFactionAIControlled poland
        and I_NumberOfSettlements poland > 1
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, priest, age 20, x 215, y 210
        end_if
    
        if I_IsFactionAIControlled hungary
        and I_NumberOfSettlements hungary > 1
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, priest, age 20, x 215, y 188
        end_if
    
        if I_IsFactionAIControlled kievan_rus
        and I_NumberOfSettlements kievan_rus > 1
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, priest, age 20, x 295, y 209
        end_if
    
        if I_IsFactionAIControlled aragon
        and I_NumberOfSettlements aragon > 1
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, priest, age 20, x 76, y 147
        end_if
    
        if I_IsFactionAIControlled norway
        and I_NumberOfSettlements norway > 1
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, priest, age 20, x 116, y 279
        end_if
    
        if I_IsFactionAIControlled lithuania
        and I_NumberOfSettlements lithuania > 1
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, priest, age 20, x 258, y 239
        end_if
    
        if I_IsFactionAIControlled kwarezm
        and I_NumberOfSettlements kwarezm > 1
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, priest, age 20, x 449, y 93
        end_if
    
        if I_IsFactionAIControlled jerusalem
        and I_NumberOfSettlements jerusalem > 1
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, priest, age 20, x 331, y 77
        end_if
    end_if
    
    
    if I_TurnNumber = 140
    
        if I_IsFactionAIControlled england
        and I_NumberOfSettlements england > 1
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, merchant, age 20, x 222, y 238
            spawn_character england random_name, priest, age 20, x 222, y 238
        end_if
    
        if I_IsFactionAIControlled france
        and I_NumberOfSettlements france > 1
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, merchant, age 20, x 94, y 199
            spawn_character france random_name, priest, age 20, x 94, y 199
        end_if
    
        if I_IsFactionAIControlled hre
        and I_NumberOfSettlements hre > 1
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, merchant, age 20, x 156, y 201
            spawn_character hre random_name, priest, age 20, x 156, y 201
        end_if
    
        if I_IsFactionAIControlled spain
        and I_NumberOfSettlements spain > 1
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, merchant, age 20, x 38, y 152
            spawn_character spain random_name, priest, age 20, x 38, y 152
        end_if
    
        if I_IsFactionAIControlled venice
        and I_NumberOfSettlements venice > 1
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, merchant, age 20, x 165, y 173
            spawn_character venice random_name, priest, age 20, x 165, y 173
        end_if
    
        if I_IsFactionAIControlled sicily
        and I_NumberOfSettlements sicily > 1
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, merchant, age 20, x 170, y 117
            spawn_character sicily random_name, priest, age 20, x 170, y 117
        end_if
    
        if I_IsFactionAIControlled milan
        and I_NumberOfSettlements milan > 1
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, merchant, age 20, x 139, y 168
            spawn_character milan random_name, priest, age 20, x 139, y 168
        end_if
    
        if I_IsFactionAIControlled scotland
        and I_NumberOfSettlements scotland > 1
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, merchant, age 20, x 62, y 247
            spawn_character scotland random_name, priest, age 20, x 62, y 247
        end_if
    
        if I_IsFactionAIControlled cumans
        and I_NumberOfSettlements cumans > 1
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, merchant, age 20, x 431, y 250
            spawn_character cumans random_name, priest, age 20, x 431, y 250
        end_if
    
        if I_IsFactionAIControlled byzantium
        and I_NumberOfSettlements byzantium > 1
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, merchant, age 20, x 282, y 143
            spawn_character byzantium random_name, priest, age 20, x 282, y 143
        end_if
    
        if I_IsFactionAIControlled russia
        and I_NumberOfSettlements russia > 1
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, merchant, age 20, x 301, y 269
            spawn_character russia random_name, priest, age 20, x 301, y 269
        end_if
    
        if I_IsFactionAIControlled moors
        and I_NumberOfSettlements moors > 1
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, merchant, age 20, x 44, y 119
            spawn_character moors random_name, priest, age 20, x 44, y 119
        end_if
    
        if I_IsFactionAIControlled turks
        and I_NumberOfSettlements turks > 1
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, merchant, age 20, x 312, y 119
            spawn_character turks random_name, priest, age 20, x 312, y 119
        end_if
    
        if I_IsFactionAIControlled egypt
        and I_NumberOfSettlements egypt > 1
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, merchant, age 20, x 302, y 59
            spawn_character egypt random_name, priest, age 20, x 302, y 59
        end_if
    
        if I_IsFactionAIControlled denmark
        and I_NumberOfSettlements denmark > 1
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, merchant, age 20, x 147, y 246
            spawn_character denmark random_name, priest, age 20, x 147, y 246
        end_if
    
        if I_IsFactionAIControlled portugal
        and I_NumberOfSettlements portugal > 1
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, merchant, age 20, x 19, y 128
            spawn_character portugal random_name, priest, age 20, x 19, y 128
        end_if
    
        if I_IsFactionAIControlled poland
        and I_NumberOfSettlements poland > 1
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, merchant, age 20, x 215, y 210
            spawn_character poland random_name, priest, age 20, x 215, y 210
        end_if
    
        if I_IsFactionAIControlled hungary
        and I_NumberOfSettlements hungary > 1
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, merchant, age 20, x 215, y 188
            spawn_character hungary random_name, priest, age 20, x 215, y 188
        end_if
    
        if I_IsFactionAIControlled kievan_rus
        and I_NumberOfSettlements kievan_rus > 1
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, merchant, age 20, x 295, y 209
            spawn_character kievan_rus random_name, priest, age 20, x 295, y 209
        end_if
    
        if I_IsFactionAIControlled aragon
        and I_NumberOfSettlements aragon > 1
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, merchant, age 20, x 76, y 147
            spawn_character aragon random_name, priest, age 20, x 76, y 147
        end_if
    
        if I_IsFactionAIControlled norway
        and I_NumberOfSettlements norway > 1
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, merchant, age 20, x 116, y 279
            spawn_character norway random_name, priest, age 20, x 116, y 279
        end_if
    
        if I_IsFactionAIControlled lithuania
        and I_NumberOfSettlements lithuania > 1
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, merchant, age 20, x 258, y 239
            spawn_character lithuania random_name, priest, age 20, x 258, y 239
        end_if
    
        if I_IsFactionAIControlled kwarezm
        and I_NumberOfSettlements kwarezm > 1
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, merchant, age 20, x 449, y 93
            spawn_character kwarezm random_name, priest, age 20, x 449, y 93
        end_if
    
        if I_IsFactionAIControlled jerusalem
        and I_NumberOfSettlements jerusalem > 1
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, merchant, age 20, x 331, y 77
            spawn_character jerusalem random_name, priest, age 20, x 331, y 77
        end_if
    
        terminate_monitor
    end_if
    
    end_monitor


    ΕDIT: Changed the conditions for the second monitor. As it was, the second condition was checked 29 times; now it's only 6 times.
    Last edited by gsthoed; July 01, 2014 at 11:38 AM.

  18. #18

    Default Re: Campaign Script Optimizations

    Great work on these

    btw TO faction destroyed workaround only kills them if they've lost all settlements and don't have any general left, so should be without trouble. Remaining agents (priests/merchants/etc) either are killed or turned into rebels.

    I have an improvement for great peoples script

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
    	set_event_counter peter_the_hermit_in 1
    	set_event_counter pierre_abelard_in 1
    	terminate_monitor
    end_monitor
    that way they're available from the start of the campaign as was intended i suppose
    no conflict with Hotseat as player 1 is always human anyway, and once is triggered the terminate_monitor prevents it from firing again

    i'm also ordering it by death date, so it's a little bit more human readable hehe

  19. #19

    Default Re: Campaign Script Optimizations

    Quote Originally Posted by Melooo182 View Post
    well TO will be destructible with upcoming Bugfix Comp i can add that part when compiling the stuff
    Oh man that's great. Is it going to be save game compatible? If not I'll hold off on starting my new campaign so I can play without worrying about the TO ruining everything.

  20. #20

    Default Re: Campaign Script Optimizations

    Quote Originally Posted by Melooo182 View Post
    btw TO faction destroyed workaround only kills them if they've lost all settlements and don't have any general left, so should be without trouble. Remaining agents (priests/merchants/etc) either are killed or turned into rebels.
    Can't wait to see this!

    Quote Originally Posted by Melooo182 View Post
    I have an improvement for great peoples script

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
        set_event_counter peter_the_hermit_in 1
        set_event_counter pierre_abelard_in 1
        terminate_monitor
    end_monitor
    that way they're available from the start of the campaign as was intended i suppose
    If you want these ancillaries to be available from the start of the campaign, you can simply simply set these event_counters to 1 instead of 0 in the part above that monitor.
    Note these ancillaries are available only to HRE and England respectively. I believe it was intented to be available from the second turn.

    One small detail I noticed today (but I didn't bothered -yet- to do anything about this): In early campaign, it is "monitor_event FactionTurnStart FactionType slave". In late campaign it is "monitor_event PreFactionTurnStart FactionType slave". If the case is the former, then generals that die (by disaster like earthquake etc) or turn into rebels in this time space and rebel generals (if the trigger in EDA is in CharacterTurnStart) are excluded, which is nice, as these ancillaries are unique.

Page 1 of 5 12345 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
  •