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

Thread: FactionIsLocal vs IsFactionAIControlled

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,009

    Default FactionIsLocal vs IsFactionAIControlled

    Recently i've held a lot of auto-games on my system as a part of balance tests.
    It came to my attention that the finance script (actually the part of it which removes excessive money from the AI), does not fire for the faction i choose at the loading screen. Seems that even after 'control <faction>' the faction was marked as the Local Faction. So i swapped around FactionIsLocal with 'not IsFactionAIControlled' inside all of my files, and it seems that the scripts now work properly.
    So it seems that either i'm very wrong somewhere, or using IsFactionAIControlled/not IsFactionAIControlled is a lot more hotseat-wise.

    The way i've 'tested' this, is by checking money graphs after each campaign (im mostly reaching up to turn 200).
    If anyone has some kind of explanation for this, i'd be happy to hear it.

  2. #2
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Show us a script fixed by swapping around 'FactionIsLocal' with 'not IsFactionAIControlled', please

    Is the problem only happening in hotseat games?

  3. #3
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,009

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Only hotseat.

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

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    In a hotseat game you can give control to the AI, meaning there will be no player controlled faction. So using IsFactionAIControlled makes a lot more sense.










  5. #5

    Default Re: FactionIsLocal vs IsFactionAIControlled

    digging this up...so there are no drawbacks using IsFactionAIControlled instead of not FactionIsLocal?

  6. #6
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: FactionIsLocal vs IsFactionAIControlled

    In single player, no; in a script made to be hotseat-friendly, it is preferable to use IsFactionAIControlled

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    So in hotseat this...

    I_LocalFaction egypt

    ...would be true only during player egypt's turn, yes?. During any other player faction turn - and any AI turn - it would be false, even if egypt is a player faction.

    In single player that condition is true at any time, including during AI turns, so long as the player is egypt.

    Which means that "local" takes on a different meaning in hotseat. In single player it means "is the player" and in hotseat it means "is a player and it is their turn".

    Or do I have it wrong? It seems odd that the game would change the operation of the Local conditions during hotseat. Especially when I_LocalFaction and "not I_IsFactionAIControlled" are exactly the same thing in single player so we don't need I_LocalFaction ... why not just make I_LocalFaction mean "is a player AND it is their turn" in single player as well?

  8. #8

    Default Re: FactionIsLocal vs IsFactionAIControlled

    maybe the answer is in how it is used in vanilla M2 scripts?
    i've only seen it in Kingdom's campaign scripts

    In America's campaign script

    not FactionIsLocal is used for giving money to the AI, while IsFactionAIControlled is used for military reinforments spawn...and king's purse incremenetals too...not very diferentiating patterns there

    Kingdom's campaigns were supposed to be hotseat compatible right?

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Quote Originally Posted by Melooo182 View Post
    Kingdom's campaigns were supposed to be hotseat compatible right?
    I don't know.

    I could answer my own question with some testing but I was hoping that somebody already knew the answer.

    In America's campaign script ... not FactionIsLocal is used for giving money to the AI
    And other player factions too, it would seem, based on the theme of this thread. But it would depend on the context of other conditions and the event in question. If it's an event that can only trigger during the faction's own turn (e.g. xxxTurnEnd/Start) then "not FactionIsLocal" can only mean "is the AI".

    It's when "faction" is exported in an event that can fire in somebody else's turn that the danger lies, that "not FactionIsLocal" does not necessarily mean "is the AI" in hotseat and is therefore potentially hotseat incompatible. Some examples spring to mind: PostBattle and (if scripted to do so) such things as CharacterSelected, MultiTurnMove, GeneralAssaultsResidence, etc.

  10. #10

    Default Re: FactionIsLocal vs IsFactionAIControlled

    I 'll use a simple example to demonstrate how I_LocalFaction and I_IsFactionAIControlled operate. For this example, we start a hotseat campaign with egypt_faction (Player 1) and scotland_faction (Player 2) under human control.

    Spoiler Alert, click show to read: 
    Code:
    ; --- TurnNumber indicator
    declare_counter turn_no
    set_counter turn_no 1
    log_counter turn_no
    
    monitor_event FactionTurnEnd FactionType slave
         inc_counter turn_no 1
         log_counter turn_no
    end_monitor
    
    ;----- Campaign Starts ------
    declare_counter local_egypt
    declare_counter local_scotland
    declare_counter notAIControlled_egypt
    declare_counter notAIControlled_scotland
    
    if I_LocalFaction egypt
        set_counter local_egypt 1
    end_if
    if I_LocalFaction scotland
        set_counter local_scotland 1
    end_if
    log_counter local_egypt
    log_counter local_scotland
    
    if not I_IsFactionAIControlled egypt
        set_counter notAIControlled_egypt 1
    end_if
    if not I_IsFactionAIControlled scotland
        set_counter notAIControlled_scotland 1
    end_if
    log_counter notAIControlled_egypt
    log_counter notAIControlled_scotland
    
    ;----------Campaign is on-----------------------------
    ; --- Egypt's turn ---
    monitor_event FactionTurnStart FactionType egypt
    
        log egypt_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
    
    end_monitor
    
    ; --- Scotland's turn ---
    monitor_event FactionTurnStart FactionType scotland
    
        log scotland_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
    
    end_monitor
    
    ;---  Milan's turn ----
    monitor_event FactionTurnStart FactionType milan
    
        log milan_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
    
    end_monitor


    Playing for a couple of turns, we take a log output like this:
    Spoiler Alert, click show to read: 
    Code:
    18:40:42.625 [game.script] [always] turn_no = 1
    
    18:40:42.625 [game.script] [always] local_egypt = 1
    18:40:42.625 [game.script] [always] local_scotland = 0
    18:40:42.625 [game.script] [always] notAIControlled_egypt = 1
    18:40:42.625 [game.script] [always] notAIControlled_scotland = 1
    
    18:40:44.436 [game.script] [always] egypt_turn
    18:40:44.436 [game.script] [always] local_egypt = 1
    18:40:44.436 [game.script] [always] local_scotland = 0
    18:40:44.436 [game.script] [always] notAIControlled_egypt = 1
    18:40:44.436 [game.script] [always] notAIControlled_scotland = 1
    
    18:40:57.910 [game.script] [always] scotland_turn
    18:40:57.910 [game.script] [always] local_egypt = 0
    18:40:57.910 [game.script] [always] local_scotland = 1
    18:40:57.910 [game.script] [always] notAIControlled_egypt = 1
    18:40:57.911 [game.script] [always] notAIControlled_scotland = 1
    
    18:41:01.752 [game.script] [always] milan_turn
    18:41:01.752 [game.script] [always] local_egypt = 0
    18:41:01.752 [game.script] [always] local_scotland = 1
    18:41:01.752 [game.script] [always] notAIControlled_egypt = 1
    18:41:01.752 [game.script] [always] notAIControlled_scotland = 1
    
    
    18:41:11.222 [game.script] [always] turn_no = 2
    
    18:41:11.362 [game.script] [always] egypt_turn
    18:41:11.362 [game.script] [always] local_egypt = 1
    18:41:11.362 [game.script] [always] local_scotland = 0
    18:41:11.362 [game.script] [always] notAIControlled_egypt = 1
    18:41:11.363 [game.script] [always] notAIControlled_scotland = 1
    
    18:41:20.065 [game.script] [always] scotland_turn
    18:41:20.065 [game.script] [always] local_egypt = 0
    18:41:20.065 [game.script] [always] local_scotland = 1
    18:41:20.066 [game.script] [always] notAIControlled_egypt = 1
    18:41:20.066 [game.script] [always] notAIControlled_scotland = 1
    
    18:41:28.243 [game.script] [always] milan_turn
    18:41:28.243 [game.script] [always] local_egypt = 0
    18:41:28.243 [game.script] [always] local_scotland = 1
    18:41:28.243 [game.script] [always] notAIControlled_egypt = 1
    18:41:28.243 [game.script] [always] notAIControlled_scotland = 1


    We see in this output that the condition "not I_IsFactionAIControlled" always indicate if a particular faction is under human control. However, "I_LocalFaction" is something different:

    When we start the campaign and during egypt's turns, the condition "I_LocalFaction egypt" is true and "I_LocalFaction scotland" is false.

    "I_LocalFaction egypt" is false and "I_LocalFaction scotland" is true in scotland's turn and in milan's (an AI-controlled faction). Since milan's turn is after scotlands's turn, it seems that the previous statement keeps being true until next (egypt's) turn.

    We can repeat testing by changing the control of one or more factions from human to AI control and vice versa in game and we will see that the "I_LocalFaction" is positine for a faction under human control from the preturnstart of this faction until the preturnstart of a different human controlled faction, while "not I_IsFactionAIControlled" indicate always factions under human control.

    However, there are some times that the game keeps poping up messages like "do you want adopt this general" etc during the turn of an AI-controlled faction that was previously under human control.
    In those cases, sincerely, I don't know if "I_LocalFaction <this faction's name>" or "I_IsFactionAIControlled <this faction's name>" are true or false...

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Quote Originally Posted by gsthoed View Post
    "I_LocalFaction" is positine for a faction under human control from the preturnstart of this faction until the preturnstart of a different human controlled faction
    Ah, thank you.

    That makes sense and means that LocalFaction does not take on different meanings in single player and hotseat. It always means "the most recent faction that was human controlled, including this turn". In single player that can only be one faction and it remains so for the campaign.

  12. #12

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Quote Originally Posted by gsthoed View Post
    We can repeat testing by changing the control of one or more factions from human to AI control and vice versa in game and we will see that the "I_LocalFaction" is positine for a faction under human control from the preturnstart of this faction until the preturnstart of a different human controlled faction, while "not I_IsFactionAIControlled" indicate always factions under human control.

    However, there are some times that the game keeps poping up messages like "do you want adopt this general" etc during the turn of an AI-controlled faction that was previously under human control.
    In those cases, sincerely, I don't know if "I_LocalFaction <this faction's name>" or "I_IsFactionAIControlled <this faction's name>" are true or false...
    Quote Originally Posted by Withwnar View Post
    That makes sense and means that LocalFaction does not take on different meanings in single player and hotseat. It always means "the most recent faction that was human controlled, including this turn". In single player that can only be one faction and it remains so for the campaign.
    I performed some additional tests and I believe that I found what happens in those irregular cases I described in post #10. Unfortunately, it seems that the general rule which was better described from Withwnar does not apply in several not-so-rare cases.

    A) We 'll start a hotseat campaign with us controlling egypt. In our first turn, we 'll take control of the slave_faction and give control of egypt_faction to the AI:

    Spoiler Alert, click show to read: 
    Code:
    ; --- TurnNumber indicator
    declare_counter turn_no
    set_counter turn_no 1
    log_counter turn_no
    
    monitor_event FactionTurnEnd FactionType slave
         inc_counter turn_no 1
         log_counter turn_no
    end_monitor
    
    ;----- Campaign Starts ------
    declare_counter local_egypt
    declare_counter local_slave
    declare_counter notAIControlled_egypt
    declare_counter notAIControlled_slave
    
    
    ;----------Campaign is on-----------------------------
    ; --- Egypt's turn ---
    monitor_event PreFactionTurnStart FactionType egypt
    
        log egypt_turn
    
        set_counter local_egypt 0
        set_counter local_slave 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_slave 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction slave
            set_counter local_slave 1
        end_if
        log_counter local_egypt
        log_counter local_slave
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled slave
            set_counter notAIControlled_slave 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_slave
    
    end_monitor
    
    ; --- Scotland's turn ---
    monitor_event PreFactionTurnStart FactionType scotland
    
        log scotland_turn
    
        set_counter local_egypt 0
        set_counter local_slave 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_slave 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction slave
            set_counter local_slave 1
        end_if
        log_counter local_egypt
        log_counter local_slave
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled slave
            set_counter notAIControlled_slave 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_slave
    end_monitor
    
    ;---  Slave's turn ----
    monitor_event PreFactionTurnStart FactionType slave
    
        log slave_turn
    
        set_counter local_egypt 0
        set_counter local_slave 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_slave 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction slave
            set_counter local_slave 1
        end_if
        log_counter local_egypt
        log_counter local_slave
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled slave
            set_counter notAIControlled_slave 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_slave
    
    end_monitor
    
    
    monitor_event ButtonPressed ButtonPressed end_turn
    
        console_command control slave
        console_command control egypt
    terminate_monitor
    end_monitor

    Our log output this time is:
    Spoiler Alert, click show to read: 
    Code:
    [game.script] [always] turn_no = 1
    
    [game.script] [always] egypt_turn
    [game.script] [always] local_egypt = 1
    [game.script] [always] local_slave = 0
    [game.script] [always] notAIControlled_egypt = 1
    [game.script] [always] notAIControlled_slave = 0
    
    [game.script] [always] scotland_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_slave = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_slave = 1
    
    [game.script] [always] slave_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_slave = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_slave = 1
    
    [game.script] [always] turn_no = 2
    
    [game.script] [always] egypt_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_slave = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_slave = 1
    
    [game.script] [always] scotland_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_slave = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_slave = 1
    
    [game.script] [always] slave_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_slave = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_slave = 1


    So, after we give the control of egypt to the AI, the game considers the only non-AI-controlled faction as the LocalFaction?

    B) We start a new campaign controlling egypt and scotland. This time during egypt's first turn, we 'll give both factions to the AI and we take control of kwarezm, which -in the something-like-StainlessSteel-mod I run- is the last faction whose turn is before the slaves' turn.
    When we finish kwarezm's turn, we take back control of scotland and we give kwarezm to the AI.

    Spoiler Alert, click show to read: 
    Code:
    ; --- TurnNumber indicator
    declare_counter turn_no
    set_counter turn_no 1
    log_counter turn_no
    
    monitor_event FactionTurnEnd FactionType slave
         inc_counter turn_no 1
         log_counter turn_no
    end_monitor
    
    ;----- Campaign Starts ------
    declare_counter local_egypt
    declare_counter local_scotland
    declare_counter local_kwarezm
    declare_counter notAIControlled_egypt
    declare_counter notAIControlled_scotland
    declare_counter notAIControlled_kwarezm
    
    if I_LocalFaction egypt
        set_counter local_egypt 1
    end_if
    if I_LocalFaction scotland
        set_counter local_scotland 1
    end_if
    log_counter local_egypt
    log_counter local_scotland
    
    if not I_IsFactionAIControlled egypt
        set_counter notAIControlled_egypt 1
    end_if
    if not I_IsFactionAIControlled scotland
        set_counter notAIControlled_scotland 1
    end_if
    log_counter notAIControlled_egypt
    log_counter notAIControlled_scotland
    
    ;----------Campaign is on-----------------------------
    ; --- Egypt's turn ---
    monitor_event PreFactionTurnStart FactionType egypt
    
        log egypt_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter local_kwarezm 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
        set_counter notAIControlled_kwarezm 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        if I_LocalFaction kwarezm
            set_counter local_kwarezm 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
        log_counter local_kwarezm
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        if not I_IsFactionAIControlled kwarezm
            set_counter notAIControlled_kwarezm 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
        log_counter notAIControlled_kwarezm
    
    end_monitor
    
    ; --- Scotland's turn ---
    monitor_event PreFactionTurnStart FactionType scotland
    
        log scotland_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter local_kwarezm 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
        set_counter notAIControlled_kwarezm 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        if I_LocalFaction kwarezm
            set_counter local_kwarezm 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
        log_counter local_kwarezm
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        if not I_IsFactionAIControlled kwarezm
            set_counter notAIControlled_kwarezm 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
        log_counter notAIControlled_kwarezm
    
    end_monitor
    
    ;---  slaves' turn ----
    monitor_event PreFactionTurnStart FactionType slave
    
        log slave_turn
    
        set_counter local_egypt 0
        set_counter local_scotland 0
        set_counter local_kwarezm 0
        set_counter notAIControlled_egypt 0
        set_counter notAIControlled_scotland 0
        set_counter notAIControlled_kwarezm 0
    
        if I_LocalFaction egypt
            set_counter local_egypt 1
        end_if
        if I_LocalFaction scotland
            set_counter local_scotland 1
        end_if
        if I_LocalFaction kwarezm
            set_counter local_kwarezm 1
        end_if
        log_counter local_egypt
        log_counter local_scotland
        log_counter local_kwarezm
    
        if not I_IsFactionAIControlled egypt
            set_counter notAIControlled_egypt 1
        end_if
        if not I_IsFactionAIControlled scotland
            set_counter notAIControlled_scotland 1
        end_if
        if not I_IsFactionAIControlled kwarezm
            set_counter notAIControlled_kwarezm 1
        end_if
        log_counter notAIControlled_egypt
        log_counter notAIControlled_scotland
        log_counter notAIControlled_kwarezm
    
    end_monitor
    
    
    declare_counter endturn_button_pressed_counter
    
    monitor_event ButtonPressed ButtonPressed end_turn
    
        inc_counter endturn_button_pressed_counter 1
        log_counter endturn_button_pressed_counter
    
        if I_CompareCounter endturn_button_pressed_counter = 1
            console_command control scotland
            console_command control kwarezm
            console_command control egypt
        end_if
    
        if I_CompareCounter endturn_button_pressed_counter = 2
            console_command control scotland
            console_command control kwarezm
            terminate_monitor
        end_if
    
    end_monitor

    Log output:
    Spoiler Alert, click show to read: 
    Code:
    [game.script] [always] turn_no = 1
    [game.script] [always] local_egypt = 1
    [game.script] [always] local_scotland = 0
    [game.script] [always] notAIControlled_egypt = 1
    [game.script] [always] notAIControlled_scotland = 1
    
    [game.script] [always] egypt_turn
    [game.script] [always] local_egypt = 1
    [game.script] [always] local_scotland = 0
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 1
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    [game.script] [always] endturn_button_pressed_counter = 1
    ; Some script execution errors for control <faction> console_commands.
    
    [game.script] [always] scotland_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 0
    [game.script] [always] local_kwarezm = 1
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 0
    [game.script] [always] notAIControlled_kwarezm = 1
    
    [game.script] [always] endturn_button_pressed_counter = 2
    
    [game.script] [always] slave_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    [game.script] [always] turn_no = 2
    
    [game.script] [always] egypt_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    [game.script] [always] scotland_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    [game.script] [always] slave_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    
    [game.script] [always] turn_no = 3
    
    [game.script] [always] egypt_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0
    
    [game.script] [always] scotland_turn
    [game.script] [always] local_egypt = 0
    [game.script] [always] local_scotland = 1
    [game.script] [always] local_kwarezm = 0
    [game.script] [always] notAIControlled_egypt = 0
    [game.script] [always] notAIControlled_scotland = 1
    [game.script] [always] notAIControlled_kwarezm = 0

    We could say that Local Faction is "the most recent faction that was human controlled, including this turn as long as this faction is still under human control, else it is the next human controlled faction". But there is one more case (the "funny" one):

    C) We start controlling only egypt and during its first turn we give the control to the AI. For this test, I'll use something more simple:

    Code:
    monitor_event ButtonPressed ButtonPressed end_turn
    
        console_command control egypt
        terminate_monitor
    end_monitor
    
    
    monitor_event FactionTurnStart FactionIsLocal
        and IsFactionAIControlled
    
        log something_relevant
    end_monitor
    
    monitor_event FactionTurnEnd FactionType slave
        and I_TurnNumber = 2
    
        console_command control venice
    end_monitor
    If the reader cannot guess which faction is this, then he/she should use the previous scripts without the ButtonPressed part or something similar.

    My conclusion: Avoiding using "FactionIsLocal" and "I_LocalFaction" in hotseat campaigns is a must. I just wonder now if CharacterIsLocal, SettlementIsLocal etc will have the same fate in my next hotseat campaign...

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    This is good stuff. One hope is that in a normal (multiplayer) hotseat campaign factions won't be toggled between player and AI controlled.

    Quote Originally Posted by gsthoed View Post
    I just wonder now if CharacterIsLocal, SettlementIsLocal etc will have the same fate
    I expect that they will because surely "Local" means the same thing in any condition.

    As far as I can see every event that exports character_record also exports faction so "not IsFactionAIControlled" could be used instead of "CharacterIsLocal".

    But target_faction is another story: there is no IsTargetFactionAIControlled condition only a TargetFactionIsLocal one.
    Last edited by Withwnar; July 25, 2014 at 11:52 PM.

  14. #14

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Quote Originally Posted by Withwnar View Post
    This is good stuff. One hope is that in a normal (multiplayer) hotseat campaign factions won't be toggled between player and AI controlled.
    In these cases and if we are referring to events that take place during human player's turn (so Local means "is a player and it is their turn" as you said in post #7, example event FactionTurnStart), then, of course, we can use LocalFaction safely, as we see in post #10. As you pointed correctly in post #9 "It's when "faction" is exported in an event that can fire in somebody else's turn that the danger lies". Using post #10 example, if an egyptian general is attacked by a milanese army (that is, during milan's turn), a "PostBattle condition FactionIsLocal" trigger won't fire up, as this momment scotland is the Local faction.

    Quote Originally Posted by Withwnar View Post
    But target_faction is another story: there is no IsTargetFactionAIControlled condition only a TargetFactionIsLocal one.
    I believe the "safest" solution is to repeat monitors, triggers etc for every "TargetFactionType" while checking if each particular faction is AIControlled. Example:
    We want to do something when a war declared against human player:
    In non hotseat, the best option is:
    Code:
    monitor_event FactionWarDeclared TargetFactionIsLocal
    ; do something
    end_monitor
    In Hotseat:
    Code:
    monitor_event FactionWarDeclared TargetFactionType england
        and not I_IsFactionAIControlled england
    ; do something
    end_monitor
    
    monitor_event FactionWarDeclared TargetFactionType scotland
        and not I_IsFactionAIControlled scotland
    ; do something
    end_monitor
    ;repeat for every faction

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Yikes. That last one would need up to 30 monitors but you're right: no simpler way.

    Fortunately the "do something" doesn't need to be duplicated in each monitor. There are two ways to avoid that...

    Code:
    declare_counter war_declared_on_player
    
    monitor_event FactionWarDeclared 
      set_counter war_declared_on_player 0
    end_monitor
    
    monitor_event FactionWarDeclared TargetFactionType england
      and not I_IsFactionAIControlled england
      set_counter war_declared_on_player 1
    end_monitor
    
    monitor_event FactionWarDeclared TargetFactionType scotland
      and not I_IsFactionAIControlled scotland
      set_counter war_declared_on_player 1
    end_monitor
    
    ;...other factions...
    
    monitor_event FactionWarDeclared I_CompareCounter war_declared_on_player = 1
      ;do something  
    end_monitor
    ...or...

    Code:
    monitor_event FactionWarDeclared TargetFactionType england
      and not I_IsFactionAIControlled england
      set_event_counter war_declared_on_player 1
    end_monitor
    
    monitor_event FactionWarDeclared TargetFactionType scotland
      and not I_IsFactionAIControlled scotland
      set_event_counter war_declared_on_player 1
    end_monitor
    
    ;...other factions...
    
    monitor_event EventCounter EventCounterType war_declared_on_player
      and EventCounter = 1
      ;do something  
      set_event_counter war_declared_on_player 0
    end_monitor
    Or announce that the mod is not hotseat compatible.

  16. #16

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Quote Originally Posted by Withwnar View Post
    Yikes. That last one would need up to 30 monitors but you're right: no simpler way.

    Fortunately the "do something" doesn't need to be duplicated in each monitor. There are two ways to avoid that...
    Each time an event exports target_faction, only one target_faction is exported, therefore only one of these monitors will "do something". Therefore, performance-wise, there is no need for additional monitor(s). Moreover, several times this "something" is faction specific. For example:
    If "do something" is "add 1000 denariis to the target faction" then:
    a) In non hotseat: console_command add_money 1000
    b) In hotseat with more than one factions under human control: Even if we had "IsTargetFactionAIControlled", we couldn't avoid writing 30 monitors to find which <faction> to put in "add_money <faction> 1000".

    Quote Originally Posted by Withwnar View Post
    Or announce that the mod is not hotseat compatible.
    As this simple action doesn't seem to be an option in some cases : Call it "optimised for hotseat" up to version 29 and then hide the announcement "not hotseat compatible" in the Readme file or in a post in page 33 (or any other page except 1) in the version-released thread

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Only one will execute but the "something" would need to be duplicated in each monitor. If it's one or two lines then that's fine. If it's more complicated - e.g. spawning armies, setting standings, creating messages - then it's harder to maintain because if it needs adjusting then 30 copies of it need adjusting. And the file overall becomes harder to maintain due to size: +100 lines for this "something" becomes +3,000 lines.

    Or just call it "optimised for single-player" and let the masses figure out for themselves what that really means. And when they do, herald it as a "feature".

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    As this thread explains, and gsthoed's tests confirm, I_LocalFaction can take on a (seemingly) different meaning in hotseat. Wishing to confirm this statement...

    Quote Originally Posted by Withwnar View Post
    It's when "faction" is exported in an event that can fire in somebody else's turn that the danger lies, that "not FactionIsLocal" does not necessarily mean "is the AI" in hotseat and is therefore potentially hotseat incompatible. Some examples spring to mind: PostBattle and (if scripted to do so) such things as CharacterSelected, MultiTurnMove, GeneralAssaultsResidence, etc.
    ... I ran some more tests...

    All tests were done in vanilla Kingdoms Grand Campaign. Therefore the three tested factions - england, france & hre - are in that order.

    Test 1 : faction's own turn

    This checks the results of I_LocalFaction, FactionIsLocal, I_IsFactionAIControlled and IsFactionAIControlled during the faction's own turn. That is, in an event that fires on the faction in its own turn: FactionTurnStart in this case. The same would apply to any event that fires on the faction (or its characters/settlements) in its own turn.

    Script:

    Code:
    monitor_event FactionTurnStart FactionType france
      and FactionIsLocal
      log always france turn: FactionIsLocal (france) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and I_LocalFaction france
      log always france turn: I_LocalFaction france = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and IsFactionAIControlled
      log always france turn: IsFactionAIControlled (france) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and I_IsFactionAIControlled france
      log always france turn: I_IsFactionAIControlled france = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and not FactionIsLocal
      log always france turn: FactionIsLocal (france) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and not I_LocalFaction france
      log always france turn: I_LocalFaction france = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and not IsFactionAIControlled
      log always france turn: IsFactionAIControlled (france) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and not I_IsFactionAIControlled france
      log always france turn: I_IsFactionAIControlled france = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType france
      and I_LocalFaction england
      log always ### france turn: I_LocalFaction england = true
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType england
      and FactionIsLocal
      log always england turn: FactionIsLocal (england) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and I_LocalFaction england
      log always england turn: I_LocalFaction england = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and IsFactionAIControlled
      log always england turn: IsFactionAIControlled (england) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and I_IsFactionAIControlled england
      log always england turn: I_IsFactionAIControlled england = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and not FactionIsLocal
      log always england turn: FactionIsLocal (england) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and not I_LocalFaction england
      log always england turn: I_LocalFaction england = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and not IsFactionAIControlled
      log always england turn: IsFactionAIControlled (england) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and not I_IsFactionAIControlled england
      log always england turn: I_IsFactionAIControlled england = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType england
      and I_LocalFaction france
      log always ### england turn: I_LocalFaction france = true
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType hre
      and FactionIsLocal
      log always hre turn: FactionIsLocal (hre) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and I_LocalFaction hre
      log always hre turn: I_LocalFaction hre = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and IsFactionAIControlled
      log always hre turn: IsFactionAIControlled (hre) = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and I_IsFactionAIControlled hre
      log always hre turn: I_IsFactionAIControlled hre = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and not FactionIsLocal
      log always hre turn: FactionIsLocal (hre) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and not I_LocalFaction hre
      log always hre turn: I_LocalFaction hre = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and not IsFactionAIControlled
      log always hre turn: IsFactionAIControlled (hre) = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and not I_IsFactionAIControlled hre
      log always hre turn: I_IsFactionAIControlled hre = false
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and I_LocalFaction england
      log always ### hre turn: I_LocalFaction england = true
    end_monitor
    
    monitor_event FactionTurnStart FactionType hre
      and I_LocalFaction france
      log always ### hre turn: I_LocalFaction france = true
    end_monitor
    A: Single Player, player = england
    No surprises here of course. As england is the only player "I_LocalFaction england" is true in every faction's turn.
    Code:
    england turn: FactionIsLocal (england) = true
    england turn: I_LocalFaction england = true
    england turn: IsFactionAIControlled (england) = false
    england turn: I_IsFactionAIControlled england = false
    france turn: IsFactionAIControlled (france) = true
    france turn: I_IsFactionAIControlled france = true
    france turn: FactionIsLocal (france) = false
    france turn: I_LocalFaction france = false
    ### france turn: I_LocalFaction england = true
    hre turn: IsFactionAIControlled (hre) = true
    hre turn: I_IsFactionAIControlled hre = true
    hre turn: FactionIsLocal (hre) = false
    hre turn: I_LocalFaction hre = false
    ### hre turn: I_LocalFaction england = true
    B: Single Player, player = france
    Same result, naturally, but for france instead.
    Code:
    france turn: FactionIsLocal (france) = true
    france turn: I_LocalFaction france = true
    france turn: IsFactionAIControlled (france) = false
    france turn: I_IsFactionAIControlled france = false
    england turn: IsFactionAIControlled (england) = true
    england turn: I_IsFactionAIControlled england = true
    england turn: FactionIsLocal (england) = false
    england turn: I_LocalFaction england = false
    ### england turn: I_LocalFaction france = true
    hre turn: IsFactionAIControlled (hre) = true
    hre turn: I_IsFactionAIControlled hre = true
    hre turn: FactionIsLocal (hre) = false
    hre turn: I_LocalFaction hre = false
    ### hre turn: I_LocalFaction france = true
    C: Hotseat, player = england
    These results are identical to test 1A.
    Code:
    england turn: FactionIsLocal (england) = true
    england turn: I_LocalFaction england = true
    england turn: IsFactionAIControlled (england) = false
    england turn: I_IsFactionAIControlled england = false
    france turn: IsFactionAIControlled (france) = true
    france turn: I_IsFactionAIControlled france = true
    france turn: FactionIsLocal (france) = false
    france turn: I_LocalFaction france = false
    ### france turn: I_LocalFaction england = true
    hre turn: IsFactionAIControlled (hre) = true
    hre turn: I_IsFactionAIControlled hre = true
    hre turn: FactionIsLocal (hre) = false
    hre turn: I_LocalFaction hre = false
    ### hre turn: I_LocalFaction england = true
    D: Hotseat, player = france
    These results are identical to test 1B.
    Code:
    france turn: FactionIsLocal (france) = true
    france turn: I_LocalFaction france = true
    france turn: IsFactionAIControlled (france) = false
    france turn: I_IsFactionAIControlled france = false
    england turn: IsFactionAIControlled (england) = true
    england turn: I_IsFactionAIControlled england = true
    england turn: FactionIsLocal (england) = false
    england turn: I_LocalFaction england = false
    ### england turn: I_LocalFaction france = true
    hre turn: IsFactionAIControlled (hre) = true
    hre turn: I_IsFactionAIControlled hre = true
    hre turn: FactionIsLocal (hre) = false
    hre turn: I_LocalFaction hre = false
    ### hre turn: I_LocalFaction france = true
    E: Hotseat, player = england + france
    The only 'oddity' here is that in hre's turn I_LocalFaction=france (not england - the other player faction). But we knew that already: hre is AI and france was the most recent player faction in the sequence before hre's turn, therefore I_LocalFaction remained france and does so until the next player faction's turn.
    Also, in france's turn, I_LocalFaction=france, not england. Which stands to reason: in france's turn france is the most recent player faction. Likewise, in england's turn I_LocalFaction=england.
    FactionIsLocal is true for england in england's turn, true for france in france's turn, and false for hre in hre's turn. As one would expect.
    Code:
    england turn: FactionIsLocal (england) = true
    england turn: I_LocalFaction england = true
    england turn: IsFactionAIControlled (england) = false
    england turn: I_IsFactionAIControlled england = false
    france turn: FactionIsLocal (france) = true
    france turn: I_LocalFaction france = true
    france turn: IsFactionAIControlled (france) = false
    france turn: I_IsFactionAIControlled france = false
    hre turn: IsFactionAIControlled (hre) = true
    hre turn: I_IsFactionAIControlled hre = true
    hre turn: FactionIsLocal (hre) = false
    hre turn: I_LocalFaction hre = false
    ### hre turn: I_LocalFaction france = true
    These tests show that for events happening to a faction in its own turn, FactionIsLocal does not behave any differently between Single Player and Hotseat.

    Neither does I_LocalFaction if the faction being tested is the faction whose turn it is and it is a player faction. Otherwise I_LocalFaction can't be relied upon in Hotseat.

    I_IsFactionAIControlled and IsFactionAIControlled both behave as expected. And always do. They're only included in these tests for completeness, and proof I suppose.

    Okay, so FactionIsLocal is reliable in Hotseat here. In both game modes it always means "the player whose turn it is" and will always be false for an AI faction.


    Test 2 : in another faction's turn

    So what if an event fires on a player faction when it's not their turn?

    This test uses the PostBattle event. This fires on the commander of both armies after the battle (if any soldiers are left alive) for both AI and players. It exports faction so we can use FactionIsLocal on it. AI attacks the player in their (AI's) own turn, so this is a classic case of an event firing on a player faction, where FactionIsLocal can be used, but not within the player faction's own turn.

    Script:
    Only results for england and hre are being tested here.
    Code:
    monitor_event PostBattle FactionType england
      and FactionIsLocal
      log always PostBattle (england): FactionIsLocal (england) = true
    end_monitor
    
    monitor_event PostBattle FactionType england
      and I_LocalFaction england
      log always PostBattle (england): I_LocalFaction england = true
    end_monitor
    
    monitor_event PostBattle FactionType england
      and IsFactionAIControlled
      log always PostBattle (england): IsFactionAIControlled (england) = true
    end_monitor
    
    monitor_event PostBattle FactionType england
      and I_IsFactionAIControlled england
      log always PostBattle (england): I_IsFactionAIControlled england = true
    end_monitor
    
    monitor_event PostBattle FactionType england
      and not FactionIsLocal
      log always PostBattle (england): FactionIsLocal (england) = false
    end_monitor
    
    monitor_event PostBattle FactionType england
      and not I_LocalFaction england
      log always PostBattle (england): I_LocalFaction england = false
    end_monitor
    
    monitor_event PostBattle FactionType england
      and not IsFactionAIControlled
      log always PostBattle (england): IsFactionAIControlled (england) = false
    end_monitor
    
    monitor_event PostBattle FactionType england
      and not I_IsFactionAIControlled england
      log always PostBattle (england): I_IsFactionAIControlled england = false
    end_monitor
    
    
    
    monitor_event PostBattle FactionType hre
      and FactionIsLocal
      log always PostBattle (hre): FactionIsLocal (hre) = true
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and I_LocalFaction hre
      log always PostBattle (hre): I_LocalFaction hre = true
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and IsFactionAIControlled
      log always PostBattle (hre): IsFactionAIControlled (hre) = true
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and I_IsFactionAIControlled hre
      log always PostBattle (hre): I_IsFactionAIControlled hre = true
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and not FactionIsLocal
      log always PostBattle (hre): FactionIsLocal (hre) = false
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and not I_LocalFaction hre
      log always PostBattle (hre): I_LocalFaction hre = false
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and not IsFactionAIControlled
      log always PostBattle (hre): IsFactionAIControlled (hre) = false
    end_monitor
    
    monitor_event PostBattle FactionType hre
      and not I_IsFactionAIControlled hre
      log always PostBattle (hre): I_IsFactionAIControlled hre = false
    end_monitor

    Single Player:
    no tests. We know that everything works as expected there.

    A: Hotseat, player = england, attacking hre in england turn
    Nothing to see here. It's in the player's turn so all is at is should be.
    Code:
    PostBattle (england): FactionIsLocal (england) = true
    PostBattle (england): I_LocalFaction england = true
    PostBattle (england): IsFactionAIControlled (england) = false
    PostBattle (england): I_IsFactionAIControlled england = false
    PostBattle (hre): IsFactionAIControlled (hre) = true
    PostBattle (hre): I_IsFactionAIControlled hre = true
    PostBattle (hre): FactionIsLocal (hre) = false
    PostBattle (hre): I_LocalFaction hre = false
    B: Hotseat, player = england, hre attacking england in hre turn
    Still fine. england is the only player faction so they're still the "local faction" in anybody's turn (hre's in this test).
    Code:
    PostBattle (england): FactionIsLocal (england) = true
    PostBattle (england): I_LocalFaction england = true
    PostBattle (england): IsFactionAIControlled (england) = false
    PostBattle (england): I_IsFactionAIControlled england = false
    PostBattle (hre): IsFactionAIControlled (hre) = true
    PostBattle (hre): I_IsFactionAIControlled hre = true
    PostBattle (hre): FactionIsLocal (hre) = false
    PostBattle (hre): I_LocalFaction hre = false
    C: Hotseat, player = england + france, hre attacking england in hre turn
    Now we have two player factions: england and france. In hre's (AI) turn france was the most recent player faction, therefore france is the "local faction" in hre's turn, not england.
    Boom: FactionIsLocal is false for england, even though they're the player faction in the battle.
    Code:
    PostBattle (england): FactionIsLocal (england) = false
    PostBattle (england): I_LocalFaction england = false
    PostBattle (england): IsFactionAIControlled (england) = false
    PostBattle (england): I_IsFactionAIControlled england = false
    PostBattle (hre): IsFactionAIControlled (hre) = true
    PostBattle (hre): I_IsFactionAIControlled hre = true
    PostBattle (hre): FactionIsLocal (hre) = false
    PostBattle (hre): I_LocalFaction hre = false

    Conclusion

    FactionIsLocal is Hotseat-compatible only for events that fire on a player faction within their own turn. Otherwise it's unreliable at best.

    This is consistent with I_LocalFaction, where that too can only reliably be used for a faction during that faction's own turn. (In Hotseat.)

    Example:

    Code:
    ;--------------------------------		
    Trigger trigger1
        WhenToTest PostBattle
    
        Condition FactionIsLocal
              and WonBattle
    
        Affects TraitA 1 Chance 100
    ;--------------------------------		
    Trigger trigger2
        WhenToTest PostBattle
    
        Condition not FactionIsLocal
              and WonBattle
    
        Affects TraitB 1 Chance 100
    If the intention of the "Local" conditions here is to distinguish between player (trigger1 -> TraitA) and AI (trigger2 -> TraitB) then it can fail in Hotseat.

    In that Test 2C scenario:
    - the england commander (player) would NOT get TraitA if he won
    - the england commander (player) WOULD get TraitB if he won: FactionIsLocal is false for england, therefore "not FactionIsLocal" is true for england.

    It's fine for the hre commander: he's AI therefore FactionIsLocal will always be false for him and "not FactionIsLocal" will always be true.

    Presumably CharacterIsLocal - and any other "xxxLocal" condition - is also broken in Hotseat in this way.

    Therefore, for Hotseat compatibility, if you mean "is the AI" then use IsFactionAIControlled/I_IsFactionAIControlled, and for "is a player" use "not IsFactionAIControlled / not I_IsFactionAIControlled". Use FactionIsLocal/I_LocalFaction (or "not" of them), and any other xxxLocal conditions, only when you're certain that the event is firing within their own turn.
    Last edited by Withwnar; April 10, 2017 at 05:28 AM. Reason: Fixed all "I_FactionLocal" occurrences -> "I_LocalFaction"

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

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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Thanks for the extensive testing.

    I would have been surprised if FactionIsLocal would have worked properly in hotseat, I was always under the assumption that it is the faction played by a player and whose turn it is. Good to know that in the situations you set up it was the last\prior human player. Never tested it, but firing a historic_event based on a FactionIsLocal condition should fire for every player faction and in extension should show up for every player faction after that, theoretically ending up with a number of HEs being displayed equal to the number of human players.










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

    Default Re: FactionIsLocal vs IsFactionAIControlled

    Good to know that in the situations you set up it was the last\prior human player.
    Yeah, that's what gsthoed discovered earlier. What I wasn't sure of was its impact on FactionIsLocal; when precisely it doesn't work in hotseat.

    gsthoed also mentioned (post 12) two cases where the situation is even worse, when using "control" to switch/toggle the player faction. I didn't bother testing those because it's not something anybody would do in a typical hotseat game.

    Never tested it, but firing a historic_event based on a FactionIsLocal condition should fire for every player faction and in extension should show up for every player faction after that, theoretically ending up with a number of HEs being displayed equal to the number of human players.
    It does, yes. In fact it doesn't matter when historic_event is called, in a FactionIsLocal context or otherwise; every player will get the HE in hotseat (unless factions { xxx } is used to limit it to certain faction(s) of course). But it's only one HE seen per player: they each see it in their next turn, not player_count HEs seen by one player (if that's what you're saying).

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
  •