Results 1 to 7 of 7

Thread: Does the AI 'select' in the script sense?

  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Does the AI 'select' in the script sense?

    In a follow on a recent thread I wonder if the AI controlled factions can be scripted to "select" a character (or settlement), playing as England in Bare Geomod I can see a French general moving, the script underneath however doesn't fire.

    Code:
        monitor_event CharacterSelected FactionType france
            and AgentType = general
            historic_event first_windmill
        end_monitor
    Can anyone confirm this? My point is that 'select' scripts should have an IF terminate loop (for good housekeeping) when the faction is AI controlled.
    Last edited by Gigantus; November 02, 2015 at 11:55 PM.










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

    Default Re: Does the AI 'select' in the script sense?

    CharacterSelected and SettlementSelected never fire on AI factions.

    This...

    Code:
    monitor_event CharacterSelected not FactionIsLocal      
      historic_event WORLD_IS_ROUND
    end_monitor
    
    monitor_event EnemyCharacterSelected
      historic_event FIRST_OIL_PAINTING
    end_monitor
    ...shows no such messages despite AI characters moving about.

    I do wonder what EnemyCharacterSelected is for. If "Selected" is a player-only thing, and AI characters can't be selected by the player (which they can't), then it seems like an oxymoron: it will NEVER fire. Assassination missions perhaps ...when the player clicks on the mission's magnifying glass? Or a leftover from RTW ... can AI characters be selected in that game?

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Does the AI 'select' in the script sense?

    Don't just love modding?










  4. #4
    Medusa0's Avatar Artifex
    Join Date
    Apr 2009
    Location
    Nowhere
    Posts
    379

    Default Re: Does the AI 'select' in the script sense?

    The AI in RTW and probably M2TW never needed to use a mouse action to "click" on anything, which was why this old "loyal allies" mod did not function back then (this mod makes it so that players cannot click to attack an ally): http://www.twcenter.net/forums/showt...s-an-true-Ally

  5. #5
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Does the AI 'select' in the script sense?

    Does this work? Because it would solve my problem and allow restriction of the trait given (faction, number of times given etc):
    Code:
    monitor_event CharacterTurnEnd
       ; add conditions here
       e_select_character
       console_command give_trait this [traitname] 1
       ; add other commands
    end_monitor
    The goal is a unique trait restricted to one faction - only one character at a time can get the trait. Essentially a FactionWideTrait condition (which CA in it's wisdom did not implement).










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

    Default Re: Does the AI 'select' in the script sense?

    Could cursor actions be modified to allow selecting AI characters/settlements? If so then EnemyCharacterSelected might fire after all. (Not that this helps your problem Gigantus.)

    e_select_character is really flaky unless used in a CharacterSelected event monitor. And still only works for the player faction I believe.

    FactionWideTrait: tricky but it looks like this works...

    Script:

    Code:
    declare_counter faction_has_trait_xxx
    
    monitor_event PreFactionTurnStart
      set_counter faction_has_trait_xxx 0
    end_monitor
    
    monitor_event CharacterTurnStart Trait xxx > 0
      set_counter faction_has_trait_xxx 1
    end_monitor
    
    monitor_event CharacterTurnEnd
      set_event_counter give_trait_xxx 0
    end_monitor
    
    monitor_event CharacterTurnEnd I_CompareCounter faction_has_trait_xxx = 0
      and TrueCondition
      set_event_counter give_trait_xxx 1
      set_counter faction_has_trait_xxx 1
    end_monitor
    EDCT:

    Code:
    (a Trait "xxx" with one level of threshold = 1)
    
    ;------------------------------------------
    Trigger give_trait_xxx_trigger1
        WhenToTest CharacterTurnEnd
        Condition I_EventCounter give_trait_xxx = 1
          and TrueCondition
        
        Affects xxx 1 Chance  100
    At the start of the turn it sets faction_has_trait_xxx to 1 if the trait currently exists (0 if not).

    At the end of the turn, for each character:
    a) give_trait_xxx set to 0
    b) give_trait_xxx set to 1 only if the faction does not already have it AND the character meets specific conditions (see below) ... at which time faction_has_trait_xxx is also set to 1 (they don't yet but will in the next step)
    c) EDCT's trigger fires only if give_trait_xxx = 1, i.e. was set to 1 in the previous step, giving him the trait

    So if a character does get it then nobody else will for that faction in that turn end because the character getting it set faction_has_trait_xxx = 1 (fourth monitor) which means that the fourth monitor will not fire for anybody else, due to its "faction_has_trait_xxx = 0" condition, thus give_trait_xxx remains as 0 for everybody else and therefore fails the EDCT conditions.

    The fourth script monitor and the EDCT trigger must have the same conditions, the part highlighted in blue. Replace "and TrueCondition" with whatever conditions are actually needed. They must be identical otherwise script might think that the EDCT trigger will be firing when it actually isn't (or vice versa) which breaks everything.

    Also, be wary of the "Characters" attribute of the trait: make sure that it is not introducing a condition (character type) which the script's monitor doesn't also have. Otherwise, again, the script might think that the trait is about to be awarded when in fact it isn't due to character's type not matching the trait's "Characters" type.

    One last thing: say this is the player's faction and the character with the trait dies in battle during the player's turn. faction_has_trait_xxx is still 1 for this faction (as it's set at turn start) so during turn end nobody will get the trait ... not until the turn end of the next turn. So the trait will be absent this turn (after his death) and the next, then appear the turn after that. No way to avoid that that I can see.

    I tested it but not with any special additional conditions.

    It should work for all factions - player and AI - but I didn't test the AI.

  7. #7
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,125
    Blog Entries
    35

    Default Re: Does the AI 'select' in the script sense?

    Thanks for all your effort - I'll see if I can use it coherently










Posting Permissions

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