Page 10 of 13 FirstFirst 12345678910111213 LastLast
Results 181 to 200 of 250

Thread: Skynet AI

  1. #181

    Default Re: Skynet AI

    Good afternoon. Can you please tell me, have you fixed such a bug when the AI sends siege stairs and towers to dilapidated walls during an assault? After all, because of this, the AI begins to freeze and lag.

  2. #182

    Default Re: Skynet AI

    Good evening gentlemen.

    I'm having a problem implementing the battle script of Skynet AI into the campaign_script of a modded Teutonic campaign, as what I've done so far breaks the campaign in the sense that no faction can upgrade castles to fortresses and citadels anymore and some other campaign problems (probably has something to do with counters).

    If you could tell me what I've done wrong in implementing the battle script I would appreciate it a lot.

    Here's the code of the campaign script:
    Spoiler Alert, click show to read: 

    script

    ;show the whole map
    restrict_strat_radar false

    ;setup some event counters
    monitor_event FactionTurnStart

    ;setup LITHUANIA CONVERSION counters

    add_events
    event counter lithuania_conversion_accepted
    event counter lithuania_conversion_declined
    event counter lithuania_conversion_timer
    date 0
    end_add_events

    generate_random_counter lithuania_conversion_timer 0 25
    set_event_counter lithuania_conversion_accepted 0
    set_event_counter lithuania_conversion_declined 0

    ;setup KALMAR UNION counters

    add_events
    event counter kalmar_union
    event counter kalmar_question_accepted
    date 0
    end_add_events

    set_event_counter kalmar_union 0
    set_event_counter kalmar_question_accepted 0

    ;setup HANSEATIC LEAGUE counters

    add_events
    event counter hansaetic_formation_timer
    event counter hanseatic_constructed
    date 0
    end_add_events

    generate_random_counter hanseatic_formation_timer 0 10
    set_event_counter hanseatic_constructed 0 ;DONT RENAME - counter referenced by name in export_descr_guilds

    ;setup CRUSADING NOBLE counters

    declare_counter teutonic_lithuania_allied 0
    declare_counter crusader1_active 0
    declare_counter crusader2_active 0
    declare_counter crusader3_active 0

    add_events
    event counter crusader1_timer
    event counter crusader2_timer
    event counter crusader3_timer
    date 0
    end_add_events

    generate_random_counter crusader1_timer 0 10
    generate_random_counter crusader2_timer 0 10
    generate_random_counter crusader3_timer 0 30

    ;setup TECH TREE counters

    add_events
    event counter pagan_lithuania ;DONT RENAME - counter referenced by name in export_descr_buildings
    event counter not_pagan_lithuania ;DONT RENAME - counter referenced by name in export_descr_buildings
    event counter not_teutonic ;DONT RENAME - counter referenced by name in export_descr_buildings
    date 0
    end_add_events

    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 0
    set_event_counter not_teutonic 0

    terminate_monitor

    end_monitor

    ;------------------- TECHTREE -------------------;

    monitor_event PreFactionTurnStart not FactionType lithuania
    and not FactionType teutonic_order

    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1
    set_event_counter not_teutonic 1

    end_monitor

    monitor_event PreFactionTurnStart FactionType lithuania

    set_event_counter pagan_lithuania 1
    set_event_counter not_pagan_lithuania 0
    set_event_counter not_teutonic 1

    if I_EventCounter lithuania_conversion_accepted = 1
    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1
    end_if


    end_monitor

    monitor_event PreFactionTurnStart FactionType teutonic_order

    set_event_counter not_teutonic 0
    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1

    end_monitor

    ;set counters on FactionTurnStart once only to ensure correct tech tree options are present at turn 0

    monitor_event FactionTurnStart not FactionType lithuania
    and not FactionType teutonic_order

    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1
    set_event_counter not_teutonic 1

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType lithuania

    set_event_counter pagan_lithuania 1
    set_event_counter not_pagan_lithuania 0
    set_event_counter not_teutonic 1

    if I_EventCounter lithuania_conversion_accepted = 1
    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1
    end_if

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType teutonic_order

    set_event_counter not_teutonic 0
    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1

    terminate_monitor

    end_monitor


    ;teutonic_order does not allow the brothel/tavern chain in their cities
    monitor_event GeneralCaptureSettlement FactionType teutonic_order

    destroy_buildings teutonic_order taverns true

    end_monitor

    monitor_event GiveSettlement TargetFactionType teutonic_order

    destroy_buildings teutonic_order taverns true

    end_monitor

    monitor_event CityRebels TargetFactionType teutonic_order

    destroy_buildings teutonic_order taverns true

    end_monitor

    monitor_event GovernorCityRebels TargetFactionType teutonic_order

    destroy_buildings teutonic_order taverns true

    end_monitor

    monitor_event FactionTurnStart FactionType teutonic_order

    destroy_buildings teutonic_order taverns true

    end_monitor

    ;------------------- LITHUANIA CONVERSION TO CATHOLICISM -------------------;

    ;increment the timer for conversion offer
    monitor_event FactionTurnStart FactionType lithuania

    inc_event_counter lithuania_conversion_timer 1

    if I_EventCounter lithuania_conversion_accepted = 1
    terminate_monitor
    end_if

    end_monitor

    ;offer the conversion to Lithuania if the correct conditions are met

    monitor_event FactionTurnStart FactionType lithuania

    if I_NumberOfSettlements lithuania < 5
    and I_EventCounter lithuania_conversion_timer >= 37
    and I_EventCounter lithuania_conversion_accepted = 0

    ;offer conversion to christianity
    historic_event lithuania_conversion true factions { lithuania, }

    ;if AI random chance to accept
    if I_IsFactionAIControlled lithuania

    generate_random_counter random_accept 0 2
    if I_EventCounter random_accept < 2
    set_event_counter lithuania_conversion_accepted 1
    end_if

    end_if

    terminate_monitor

    end_if

    if I_EventCounter lithuania_conversion_timer >= 65
    and I_EventCounter lithuania_conversion_accepted = 0

    ;offer conversion to christianity
    historic_event lithuania_conversion true factions { lithuania, }

    ;if AI random chance to accept
    if I_IsFactionAIControlled lithuania

    generate_random_counter random_accept 0 2
    if I_EventCounter random_accept < 2
    set_event_counter lithuania_conversion_accepted 1
    end_if

    end_if

    terminate_monitor

    end_if

    end_monitor

    monitor_conditions I_EventCounter lithuania_conversion_accepted = 1

    ;Three easy steps for conversion

    ;1 - Convert the people
    set_religion lithuania catholic
    change_population_religion lithuania catholic 75 pagan

    ;2 - Destroy the pagan buildings
    destroy_buildings lithuania temple_dievas true
    destroy_buildings lithuania temple_dievas_castle true
    destroy_buildings lithuania temple_perkunas true
    destroy_buildings lithuania temple_perkunas_castle true
    destroy_buildings lithuania temple_giltine true
    destroy_buildings lithuania temple_giltine_castle true

    ;3 - Disband the pagan units
    retire_characters Lithuania priest
    destroy_units Lithuania pagan_unit

    ;notify all factions that Lithuania has converted and become Catholic
    historic_event lithuania_converts event/Lithuania_converts.bik

    set_event_counter pagan_lithuania 0
    set_event_counter not_pagan_lithuania 1

    ; change teutonic order ai label
    link_faction_ai teutonic_order teutonic_order_non_pagan
    link_faction_ai poland poland_non_pagan
    link_faction_ai lithuania lithuania_non_pagan

    terminate_monitor

    end_monitor

    ;------------------- KALMAR UNION FORMATION -------------------;

    ;Notify the player early in the game about to possibility to form the kalmar union
    monitor_event FactionTurnStart FactionType denmark
    and I_TurnNumber = 8

    historic_event kalmar_notification factions { denmark, }

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and I_TurnNumber > 8
    and I_NumberOfSettlements norway > 0

    if I_SettlementOwner Kalmar denmark
    and I_SettlementOwner Goteborg denmark
    and I_SettlementOwner Uppsala denmark
    and I_SettlementOwner Visby denmark
    and I_SettlementOwner Abo denmark

    historic_event kalmar_stage2 factions { denmark, }

    terminate_monitor

    end_if

    end_monitor

    monitor_event BecomesFactionLeader FactionType norway
    and I_TurnNumber > 9

    if I_SettlementOwner Kalmar denmark
    and I_SettlementOwner Goteborg denmark
    and I_SettlementOwner Uppsala denmark
    and I_SettlementOwner Visby denmark
    and I_SettlementOwner Abo denmark

    historic_event kalmar_question true factions { denmark, }

    if I_IsFactionAIControlled denmark
    set_event_counter kalmar_question_accepted 1
    end_if

    terminate_monitor
    end_if

    end_monitor

    monitor_conditions I_EventCounter kalmar_question_accepted = 1

    ;apply kalmar union faction banner to denmark
    set_faction_banner
    faction denmark
    banner kalmar_union
    end_set_faction_banner

    ;turn over norways assets to denmark
    give_everything_to_faction norway denmark false

    historic_event denmark_joins_kalmar event/Kalmar_union.bik

    terminate_monitor

    end_monitor

    ;------------------- HANSEATIC LEAGUE -------------------;

    ;announcement event
    monitor_event SettlementTurnStart SettlementName Visby

    inc_event_counter hanseatic_formation_timer 1

    if I_EventCounter hanseatic_formation_timer >= 25
    historic_event hanseatic_formation factions { teutonic_order, denmark, novgorod, poland, hre, }
    terminate_monitor
    end_if

    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType teutonic_order

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_built_teutonic factions { lithuania, denmark, novgorod, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_built_teutonic factions { denmark, novgorod, poland, hre, }
    end_if


    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType lithuania

    historic_event hanseatic_built_teutonic factions { teutonic_order, denmark, novgorod, poland, hre, }

    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType denmark

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_built_teutonic factions { lithuania, teutonic_order, novgorod, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_built_teutonic factions { teutonic_order, novgorod, poland, hre, }
    end_if

    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType novgorod

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_built_teutonic factions { lithuania, denmark, teutonic_order, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_built_teutonic factions { denmark, teutonic_order, poland, hre, }
    end_if

    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType poland

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_built_teutonic factions { lithuania, denmark, teutonic_order, novgorod, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_built_teutonic factions { denmark, teutonic_order, novgorod, hre, }
    end_if

    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild
    and FactionType hre


    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_built_teutonic factions { lithuania, denmark, teutonic_order, novgorod, poland, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_built_teutonic factions { denmark, teutonic_order, novgorod, poland, }
    end_if


    end_monitor

    monitor_event GuildUpgraded BuildingName = hanseatic_guild

    set_event_counter hanseatic_constructed 1
    reset_guild_standing hanseatic_guild

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType teutonic_order

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_destroyed factions { lithuania, denmark, novgorod, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_destroyed factions { denmark, novgorod, poland, hre, }
    end_if

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType lithuania

    historic_event hanseatic_destroyed factions { teutonic_order, denmark, novgorod, poland, hre, }

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType denmark

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_destroyed factions { lithuania, teutonic_order, novgorod, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_destroyed factions { teutonic_order, novgorod, poland, hre, }
    end_if

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType novgorod

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_destroyed factions { lithuania, teutonic_order, denmark, poland, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_destroyed factions { teutonic_order, denmark, poland, hre, }
    end_if

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType poland

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_destroyed factions { lithuania, teutonic_order, denmark, novgorod, hre, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_destroyed factions { teutonic_order, denmark, novgorod, hre, }
    end_if

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild
    and FactionType hre

    if I_EventCounter lithuania_conversion_accepted = 1
    historic_event hanseatic_destroyed factions { lithuania, teutonic_order, denmark, novgorod, poland, }
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    historic_event hanseatic_destroyed factions { teutonic_order, denmark, novgorod, poland, }
    end_if

    end_monitor

    monitor_event BuildingDestroyed BuildingName = hanseatic_guild

    set_event_counter hanseatic_constructed 0
    reset_guild_standing hanseatic_guild

    end_monitor

    ;------------------- CRUSADING NOBLES -------------------;

    ;increment crusader spawn timers
    monitor_event FactionTurnStart FactionType teutonic_order

    inc_event_counter crusader1_timer 1
    inc_event_counter crusader2_timer 1
    inc_event_counter crusader3_timer 1

    end_monitor


    ;monitor the alliance status of lithuania and the teutonic order
    monitor_event FactionAllianceDeclared FactionType teutonic_order
    and TargetFactionType lithuania

    set_counter teutonic_lithuania_allied 1

    end_monitor

    monitor_event FactionAllianceDeclared FactionType lithuania
    and TargetFactionType teutonic_order

    set_counter teutonic_lithuania_allied 1

    end_monitor

    monitor_event FactionBreakAlliance FactionType teutonic_order
    and TargetFactionType lithuania

    set_counter teutonic_lithuania_allied 0

    end_monitor

    monitor_event FactionBreakAlliance FactionType lithuania
    and TargetFactionType teutonic_order

    set_counter teutonic_lithuania_allied 0

    end_monitor


    ;spawn an army with the labelled character and 'adv_crusade' tagged unit

    monitor_event FactionTurnStart I_EventCounter crusader1_timer >= 15
    and I_EventCounter crusader1_timer <= 20
    and I_CompareCounter teutonic_lithuania_allied = 0
    and I_NumberOfSettlements lithuania > 0
    and I_EventCounter lithuania_conversion_accepted = 0

    set_counter crusader1_active 1

    spawn_army
    faction teutonic_order
    character Ulrich Salier, admiral, age 31, x 57, y 53, direction SE
    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

    spawn_army
    faction teutonic_order
    character Charles, named character, x 57, y 53, label crus1, battle_model Adv_Northern_General_Eng
    traits LoyaltyStarter 1, ReligionStarter 1, Upright 2, GoodAttacker 1, PublicFaith 2, EnglishCrusader 1
    unit Adv English Bodyguard exp 0 armour 0 weapon_lvl 0
    unit Adv Levy Spearmen exp 0 armour 0 weapon_lvl 0
    unit Adv Levy Spearmen exp 0 armour 0 weapon_lvl 0
    unit Adv Levy Spearmen exp 0 armour 0 weapon_lvl 0
    unit Adv Feudal Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Feudal Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted Feudal Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted Feudal Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted Feudal Knights exp 0 armour 0 weapon_lvl 0
    end

    create_mission adventure_crusader teutonic_order crus1
    create_mission kill_crusader lithuania crus1

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart I_EventCounter crusader2_timer >= 46
    and I_EventCounter crusader2_timer <= 52
    and I_CompareCounter teutonic_lithuania_allied = 0
    and I_NumberOfSettlements lithuania > 0
    and I_EventCounter lithuania_conversion_accepted = 0

    set_counter crusader2_active 1

    spawn_army
    faction teutonic_order
    character Kurt, admiral, age 25, x 57, y 60, direction SE
    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

    spawn_army
    faction teutonic_order
    character Philipp, named character, x 57, y 60, label crus2, battle_model Adv_Northern_General_Fra
    traits LoyaltyStarter 1, ReligionStarter 1, Loyal 3, BadAttacker 2, Girls 3, BadSiegeAttacker 2, FrenchCrusader 1
    unit Adv French Generals Bodyguard exp 0 armour 0 weapon_lvl 0
    unit Adv Religious Fanatics exp 0 armour 0 weapon_lvl 0
    unit Adv Religious Fanatics exp 0 armour 0 weapon_lvl 0
    unit Adv Religious Fanatics exp 0 armour 0 weapon_lvl 0
    unit Adv Religious Fanatics exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted French Archers exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted French Archers exp 0 armour 0 weapon_lvl 0
    unit Adv French Mounted Archers exp 0 armour 0 weapon_lvl 0
    unit Adv Chivalric Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Chivalric Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted Chivalric Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted Chivalric Knights exp 0 armour 0 weapon_lvl 0
    end

    create_mission adventure_crusader teutonic_order crus2
    create_mission kill_crusader lithuania crus2

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart I_EventCounter crusader3_timer > 98
    and I_CompareCounter teutonic_lithuania_allied = 0
    and I_NumberOfSettlements lithuania > 0
    and I_EventCounter lithuania_conversion_accepted = 0

    set_counter crusader3_active 1

    spawn_army
    faction teutonic_order
    character Ortwinus, admiral, age 38, x 53, y 53, direction S
    unit holk exp 0 armour 0 weapon_lvl 0
    unit holk exp 0 armour 0 weapon_lvl 0
    unit holk exp 0 armour 0 weapon_lvl 0
    end

    spawn_army
    faction teutonic_order
    character Henry, named character, x 53, y 53, label crus3, battle_model Adv_Northern_General_Eng
    traits LoyaltyStarter 1, ReligionStarter 1, Upright 1, Drink 5, Stoic 1, Just 1, EnglishCrusader 1
    unit Adv English Late Bodyguard exp 0 armour 0 weapon_lvl 0
    unit Adv Longbowmen exp 0 armour 0 weapon_lvl 0
    unit Adv Longbowmen exp 0 armour 0 weapon_lvl 0
    unit Adv Longbowmen exp 0 armour 0 weapon_lvl 0
    unit Adv Longbowmen exp 0 armour 0 weapon_lvl 0
    unit Adv English Knights exp 0 armour 0 weapon_lvl 0
    unit Adv English Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted English Knights exp 0 armour 0 weapon_lvl 0
    unit Adv Dismounted English Knights exp 0 armour 0 weapon_lvl 0
    end

    create_mission adventure_crusader teutonic_order crus3
    create_mission kill_crusader lithuania crus3

    terminate_monitor

    end_monitor

    monitor_event MissionFinished MissionID adventure_crusader

    ;kill the adventure crusader
    if I_CompareCounter crusader1_active = 1
    kill_character crus1
    destroy_units teutonic_order adv_crusade_eng
    set_counter crusader1_active 0
    end_if

    if I_CompareCounter crusader2_active = 1
    kill_character crus2
    destroy_units teutonic_order adv_crusade_fra
    set_counter crusader2_active 0
    end_if

    if I_CompareCounter crusader3_active = 1
    kill_character crus3
    destroy_units teutonic_order adv_crusade_eng
    set_counter crusader3_active 0
    end_if

    ;kill his units


    end_monitor

    ;--------------- HOCHMEISTER BATTLE MODEL -----------------;

    ;apply the Hochmeister battle_model to the Teutonic Order faction leader whenever a new leader is assigned
    monitor_event BecomesFactionLeader FactionType teutonic_order

    change_battle_model teutonic_order leader Teutonic_Hochmeister

    end_monitor

    ;------------------- REVEALED TILES ------------------------;
    ; reveal certain tiles to certain factions

    monitor_event FactionTurnStart FactionType lithuania
    and not I_IsFactionAIControlled lithuania

    reveal_tile 81, 5
    reveal_tile 92, 1
    reveal_tile 134, 16
    reveal_tile 129, 2
    reveal_tile 118, 27
    reveal_tile 129, 50
    reveal_tile 70, 13

    hide_all_revealed_tiles

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType teutonic_order
    and not I_IsFactionAIControlled teutonic_order

    reveal_tile 30, 37
    reveal_tile 18, 21
    reveal_tile 31, 2
    reveal_tile 2, 25
    reveal_tile 70, 13
    reveal_tile 66, 1
    reveal_tile 82, 58
    reveal_tile 88, 92

    hide_all_revealed_tiles

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType denmark

    if not I_IsFactionAIControlled denmark

    reveal_tile 2, 25
    reveal_tile 18, 21
    reveal_tile 41, 70
    reveal_tile 21, 79
    reveal_tile 55, 74
    reveal_tile 86, 83
    reveal_tile 76, 82
    reveal_tile 120, 88

    hide_all_revealed_tiles

    end_if

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType poland


    if not I_IsFactionAIControlled poland

    reveal_tile 60, 36
    reveal_tile 65, 46
    reveal_tile 60, 36
    reveal_tile 84, 33
    reveal_tile 31, 2
    reveal_tile 32, 21
    reveal_tile 30, 37

    hide_all_revealed_tiles

    end_if

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType poland

    if not I_IsFactionAIControlled poland

    reveal_tile 60, 36
    reveal_tile 65, 46
    reveal_tile 60, 36
    reveal_tile 84, 33
    reveal_tile 31, 2
    reveal_tile 32, 21
    reveal_tile 30, 37

    hide_all_revealed_tiles

    end_if

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType novgorod

    if not I_IsFactionAIControlled novgorod

    reveal_tile 103, 94
    reveal_tile 86, 83
    reveal_tile 100, 59
    reveal_tile 113, 35
    reveal_tile 134, 16
    reveal_tile 85, 68

    hide_all_revealed_tiles

    end_if

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType hre

    if not I_IsFactionAIControlled hre

    reveal_tile 32, 21
    reveal_tile 47, 19
    reveal_tile 3, 43
    reveal_tile 19, 58
    reveal_tile 58, 24
    reveal_tile 60, 36

    hide_all_revealed_tiles

    end_if

    terminate_monitor

    end_monitor

    ;------------------- AI KINGS PURSE BONUS -------------------;
    ;money granted to AI as they do not carry out missions

    monitor_event FactionTurnStart I_TurnNumber >= 0
    and CampaignDifficulty = easy

    if I_IsFactionAIControlled teutonic_order
    increment_kings_purse teutonic_order 1000
    end_if

    if I_IsFactionAIControlled lithuania
    increment_kings_purse lithuania 1000
    end_if

    if I_IsFactionAIControlled denmark
    increment_kings_purse denmark 1000
    end_if

    if I_IsFactionAIControlled novgorod
    increment_kings_purse novgorod 1000
    end_if

    if I_IsFactionAIControlled poland
    increment_kings_purse poland 1000
    end_if

    if I_IsFactionAIControlled hre
    increment_kings_purse hre 1000
    end_if

    if I_IsFactionAIControlled norway
    increment_kings_purse norway 200
    end_if

    if I_IsFactionAIControlled mongols
    increment_kings_purse mongols 1000
    end_if

    terminate_monitor

    end_monitor


    monitor_event FactionTurnStart I_TurnNumber >= 0
    and CampaignDifficulty = medium

    if I_IsFactionAIControlled teutonic_order
    increment_kings_purse teutonic_order 2000
    end_if

    if I_IsFactionAIControlled lithuania
    increment_kings_purse lithuania 2000
    end_if

    if I_IsFactionAIControlled denmark
    increment_kings_purse denmark 2000
    end_if

    if I_IsFactionAIControlled novgorod
    increment_kings_purse novgorod 2000
    end_if

    if I_IsFactionAIControlled poland
    increment_kings_purse poland 2000
    end_if

    if I_IsFactionAIControlled hre
    increment_kings_purse hre 2000
    end_if

    if I_IsFactionAIControlled norway
    increment_kings_purse norway 400
    end_if

    if I_IsFactionAIControlled mongols
    increment_kings_purse mongols 2000
    end_if

    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart I_TurnNumber >= 0
    and CampaignDifficulty = hard

    if I_IsFactionAIControlled teutonic_order
    increment_kings_purse teutonic_order 4000
    end_if

    if I_IsFactionAIControlled lithuania
    increment_kings_purse lithuania 4000
    end_if

    if I_IsFactionAIControlled denmark
    increment_kings_purse denmark 4000
    end_if

    if I_IsFactionAIControlled novgorod
    increment_kings_purse novgorod 4000
    end_if

    if I_IsFactionAIControlled poland
    increment_kings_purse poland 4000
    end_if

    if I_IsFactionAIControlled hre
    increment_kings_purse hre 4000
    end_if

    if I_IsFactionAIControlled norway
    increment_kings_purse norway 800
    end_if

    if I_IsFactionAIControlled mongols
    increment_kings_purse mongols 4000
    end_if

    terminate_monitor
    end_monitor

    monitor_event FactionTurnStart I_TurnNumber >= 0
    and CampaignDifficulty = very_hard

    if I_IsFactionAIControlled teutonic_order
    increment_kings_purse teutonic_order 7000
    end_if

    if I_IsFactionAIControlled lithuania
    increment_kings_purse lithuania 7000
    end_if

    if I_IsFactionAIControlled denmark
    increment_kings_purse denmark 7000
    end_if

    if I_IsFactionAIControlled novgorod
    increment_kings_purse novgorod 7000
    end_if

    if I_IsFactionAIControlled poland
    increment_kings_purse poland 7000
    end_if

    if I_IsFactionAIControlled hre
    increment_kings_purse hre 7000
    end_if

    if I_IsFactionAIControlled norway
    increment_kings_purse norway 1400
    end_if

    if I_IsFactionAIControlled mongols
    increment_kings_purse mongols 7000
    end_if

    terminate_monitor
    end_monitor

    ;------------------- AI LAST STAND BONUS -------------------;
    ; allow each AI faction to make a last stand when they near destruction

    monitor_event FactionTurnStart FactionType teutonic_order
    and I_TurnNumber > 15
    and I_NumberOfSettlements teutonic_order < 4
    and IsFactionAIControlled

    add_money teutonic_order 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType lithuania
    and I_TurnNumber > 15
    and I_NumberOfSettlements lithuania < 4
    and IsFactionAIControlled

    add_money lithuania 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and I_TurnNumber > 15
    and I_NumberOfSettlements denmark < 4
    and IsFactionAIControlled

    add_money denmark 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType novgorod
    and I_TurnNumber > 15
    and I_NumberOfSettlements novgorod < 4
    and IsFactionAIControlled

    add_money novgorod 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType poland
    and I_TurnNumber > 15
    and I_NumberOfSettlements poland < 4
    and IsFactionAIControlled

    add_money poland 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType hre
    and I_TurnNumber > 15
    and I_NumberOfSettlements hre < 4
    and IsFactionAIControlled

    add_money hre 10000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType norway
    and I_TurnNumber > 15
    and I_NumberOfSettlements norway < 2
    and IsFactionAIControlled

    add_money norway 2000

    terminate_monitor

    end_monitor

    monitor_event FactionTurnStart FactionType mongols
    and I_TurnNumber > 15
    and I_NumberOfSettlements mongols < 4
    and IsFactionAIControlled

    add_money mongols 10000

    terminate_monitor

    end_monitor

    ;------------------- AI DEBT -------------------;

    monitor_event FactionTurnStart FactionType teutonic_order
    and IsFactionAIControlled
    and Treasury < -5000

    add_money teutonic_order 10000


    end_monitor

    monitor_event FactionTurnStart FactionType lithuania
    and IsFactionAIControlled
    and Treasury < -5000

    add_money lithuania 10000


    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and IsFactionAIControlled
    and Treasury < -5000

    add_money denmark 10000


    end_monitor

    monitor_event FactionTurnStart FactionType novgorod
    and IsFactionAIControlled
    and Treasury < -5000

    add_money novgorod 10000

    end_monitor

    monitor_event FactionTurnStart FactionType poland
    and IsFactionAIControlled
    and Treasury < -5000

    add_money poland 10000

    end_monitor

    monitor_event FactionTurnStart FactionType norway
    and IsFactionAIControlled
    and Treasury < -5000

    add_money norway 2000

    end_monitor

    monitor_event FactionTurnStart FactionType mongols
    and IsFactionAIControlled
    and Treasury < -5000

    add_money mongols 10000

    end_monitor

    ;------------------- AI ATTACK POWERFUL PLAYER -------------------;
    ; All AI factions turn on the players faction when they nearing their victory conditions

    declare_counter AI_attack_player_level 0
    declare_counter target_human_active 0

    monitor_event FactionTurnStart FactionType teutonic_order
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements teutonic_order >= 35

    set_counter AI_attack_player_level 2

    end_monitor

    monitor_event FactionTurnStart FactionType teutonic_order
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements teutonic_order >= 25
    and I_NumberOfSettlements teutonic_order < 35

    set_counter AI_attack_player_level 1

    end_monitor

    monitor_event FactionTurnStart FactionType teutonic_order
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements teutonic_order < 20

    set_counter AI_attack_player_level 0

    end_monitor

    monitor_event FactionTurnStart FactionType lithuania
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements lithuania >= 35

    set_counter AI_attack_player_level 2

    end_monitor

    monitor_event FactionTurnStart FactionType lithuania
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements lithuania >= 25
    and I_NumberOfSettlements lithuania < 35

    set_counter AI_attack_player_level 1

    end_monitor

    monitor_event FactionTurnStart FactionType lithuania
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements lithuania < 20

    set_counter AI_attack_player_level 0

    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements denmark >= 35

    set_counter AI_attack_player_level 2

    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements denmark >= 25
    and I_NumberOfSettlements denmark < 35

    set_counter AI_attack_player_level 1

    end_monitor

    monitor_event FactionTurnStart FactionType denmark
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements denmark < 20

    set_counter AI_attack_player_level 0

    end_monitor

    monitor_event FactionTurnStart FactionType novgorod
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements novgorod >= 35

    set_counter AI_attack_player_level 2

    end_monitor

    monitor_event FactionTurnStart FactionType novgorod
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements novgorod >= 25
    and I_NumberOfSettlements novgorod < 35

    set_counter AI_attack_player_level 1

    end_monitor

    monitor_event FactionTurnStart FactionType novgorod
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements novgorod < 20

    set_counter AI_attack_player_level 0

    end_monitor

    monitor_event FactionTurnStart FactionType poland
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements poland >= 35

    set_counter AI_attack_player_level 2

    end_monitor

    monitor_event FactionTurnStart FactionType poland
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements poland >= 25
    and I_NumberOfSettlements poland < 35

    set_counter AI_attack_player_level 1

    end_monitor

    monitor_event FactionTurnStart FactionType poland
    and not I_HotseatEnabled
    and CampaignDifficulty > easy
    and not IsFactionAIControlled
    and I_NumberOfSettlements poland < 20

    set_counter AI_attack_player_level 0

    end_monitor

    monitor_conditions I_CompareCounter AI_attack_player_level = 0
    and I_CompareCounter target_human_active = 1

    if I_EventCounter lithuania_conversion_accepted = 1
    link_faction_ai teutonic_order teutonic_order_non_pagan
    link_faction_ai lithuania lithuania_non_pagan
    link_faction_ai poland poland_non_pagan
    end_if

    if I_EventCounter lithuania_conversion_accepted = 0
    link_faction_ai teutonic_order teutonic_order
    link_faction_ai lithuania lithuania
    link_faction_ai poland poland
    end_if

    link_faction_ai denmark denmark
    link_faction_ai novgorod novgorod
    link_faction_ai hre turtle
    link_faction_ai norway turtle
    link_faction_ai mongols turtle

    set_counter target_human_active 0

    end_monitor

    ;Stage 1 attack label
    monitor_conditions I_CompareCounter AI_attack_player_level >= 1
    and I_CompareCounter target_human_active = 0

    if I_CompareCounter AI_attack_player_level = 1

    link_faction_ai teutonic_order target_human_stage1
    link_faction_ai lithuania target_human_stage1
    link_faction_ai poland target_human_stage1
    link_faction_ai denmark target_human_stage1
    link_faction_ai novgorod target_human_stage1
    link_faction_ai hre target_human_stage1
    link_faction_ai norway target_human_stage1
    link_faction_ai mongols target_human_stage1

    end_if

    if I_CompareCounter AI_attack_player_level = 2

    link_faction_ai teutonic_order target_human_stage2
    link_faction_ai lithuania target_human_stage2
    link_faction_ai poland target_human_stage2
    link_faction_ai denmark target_human_stage2
    link_faction_ai novgorod target_human_stage2
    link_faction_ai hre target_human_stage2
    link_faction_ai norway target_human_stage2
    link_faction_ai mongols target_human_stage2

    end_if

    set_counter target_human_active 1

    end_monitor

    wait_monitors

    ;See this post for more information and how to create a campaign script
    ;http://www.twcenter.net/forums/showt...ttle-Scripting

    ; *********************************************************************************************
    ; EBII Battle Scripts
    ; 6/5/2016
    ; z3n
    ; *********************************************************************************************


    while ! I_BattleStarted
    end_while


    ; *********************************************************************************************
    ; EBII Battle Script Counteres/Timers
    ; *********************************************************************************************


    declare_counter command_and_control
    declare_counter deploy_check
    declare_counter start_battle
    declare_counter FaW_and_S
    declare_counter Release_Labels
    declare_counter AI_GRP
    declare_counter AI_HTC
    declare_counter AI_reinforcements
    declare_counter AI_reinforcements_tc
    declare_counter capture_pike
    declare_counter capture_hoplite
    declare_counter medium_battle
    declare_counter large_battle
    declare_timer AI_reinforcements_timer


    log always EBII Campaign Based Battle Scripts
    log always Activated


    ; *********************************************************************************************
    ; EBII Battle Script Frequency Check - sum of battle_wait = total seconds between repeats
    ; *********************************************************************************************


    monitor_conditions I_InBattle


    inc_counter command_and_control 1


    if I_CompareCounter command_and_control = 125
    set_counter command_and_control 0
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Game Reloaded
    ; *********************************************************************************************


    monitor_event GameReloaded


    log always Game Reloaded
    set_counter deploy_check 0
    set_counter Release_Labels 0
    set_counter command_and_control 0
    set_counter AI_GRP 0
    set_counter AI_reinforcements 0
    set_counter AI_HTC 0
    log always Battle Scripts Reset


    end_monitor


    ; *********************************************************************************************
    ; Battle Starting
    ; *********************************************************************************************


    monitor_event ScrollClosed ScrollClosed prebattle_scroll


    prepare_for_battle
    set_counter command_and_control 0
    set_counter Release_Labels 0
    set_counter AI_GRP 0
    set_counter AI_reinforcements 0
    set_counter AI_HTC 0
    set_counter deploy_check 0
    set_counter capture_pike 0
    set_counter capture_hoplite 0
    set_counter medium_battle 0
    set_counter large_battle 0
    restart_timer AI_reinforcements_timer


    if I_CompareCounter deploy_check = 0
    log always Battle Loading
    end_if


    end_monitor




    ; *********************************************************************************************
    ; Shared Reinforcements Monitor
    ; *********************************************************************************************


    monitor_event BattleReinforcementsArrive


    ;AI Reinforcements - Set Counter - Fires Once Per Battle
    set_counter AI_reinforcements 1


    end_monitor




    ; *********************************************************************************************
    ; Battle Started
    ; *********************************************************************************************


    monitor_conditions I_BattleStarted


    inc_counter deploy_check 1


    if I_CompareCounter deploy_check = 1
    log always Battle Started
    set_counter start_battle 1
    end_if




    end_monitor


    ;;;;*************************************************************************************************
    ;;;; Create Labels
    ;;;;*************************************************************************************************


    monitor_conditions I_BattleStarted
    and I_CompareCounter start_battle = 1


    set_counter Release_Labels 1
    set_counter FaW_and_S 1


    if I_CompareCounter Release_Labels = 1
    set_counter start_battle 0
    end_if


    if I_CompareCounter deploy_check = 1
    ; *********************************************************************************************
    ; Main Army unit Labels
    ; *********************************************************************************************
    label_unit 0 0 0 MAu1
    label_unit 0 0 1 MAu2
    label_unit 0 0 2 MAu3
    label_unit 0 0 3 MAu4
    label_unit 0 0 4 MAu5
    label_unit 0 0 5 MAu6
    label_unit 0 0 6 MAu7
    label_unit 0 0 7 MAu8
    label_unit 0 0 8 MAu9
    label_unit 0 0 9 MAu10
    label_unit 0 0 10 MAu11
    label_unit 0 0 11 MAu12
    label_unit 0 0 12 MAu13
    label_unit 0 0 13 MAu14
    label_unit 0 0 14 MAu15
    label_unit 0 0 15 MAu16
    label_unit 0 0 16 MAu17
    label_unit 0 0 17 MAu18
    label_unit 0 0 18 MAu19
    label_unit 0 0 19 MAu20
    label_unit 0 0 20 MAu21
    label_unit 0 0 21 MAu22
    label_unit 0 0 22 MAu23
    label_unit 0 0 23 MAu24
    label_unit 0 0 24 MAu25
    label_unit 0 0 25 MAu26
    label_unit 0 0 26 MAu27
    label_unit 0 0 27 MAu28
    label_unit 0 0 28 MAu29
    label_unit 0 0 29 MAu30
    label_unit 0 0 30 MAu31
    label_unit 0 0 31 MAu32
    label_unit 0 0 32 MAu33
    label_unit 0 0 33 MAu34
    label_unit 0 0 34 MAu35
    label_unit 0 0 35 MAu36
    label_unit 0 0 36 MAu37
    label_unit 0 0 37 MAu38
    label_unit 0 0 38 MAu39
    label_unit 0 0 39 MAu40
    ; *********************************************************************************************
    ; Allied unit Labels
    ; *********************************************************************************************
    label_unit 1 0 0 Eu1
    label_unit 1 0 1 Eu2
    label_unit 1 0 2 Eu3
    label_unit 1 0 3 Eu4
    label_unit 1 0 4 Eu5
    label_unit 1 0 5 Eu6
    label_unit 1 0 6 Eu7
    label_unit 1 0 7 Eu8
    label_unit 1 0 8 Eu9
    label_unit 1 0 9 Eu10
    label_unit 1 0 10 Eu11
    label_unit 1 0 11 Eu12
    label_unit 1 0 12 Eu13
    label_unit 1 0 13 Eu14
    label_unit 1 0 14 Eu15
    label_unit 1 0 15 Eu16
    label_unit 1 0 16 Eu17
    label_unit 1 0 17 Eu18
    label_unit 1 0 18 Eu19
    label_unit 1 0 19 Eu20
    label_unit 1 0 20 Eu21
    label_unit 1 0 21 Eu22
    label_unit 1 0 22 Eu23
    label_unit 1 0 23 Eu24
    label_unit 1 0 24 Eu25
    label_unit 1 0 25 Eu26
    label_unit 1 0 26 Eu27
    label_unit 1 0 27 Eu28
    label_unit 1 0 28 Eu29
    label_unit 1 0 29 Eu30
    label_unit 1 0 30 Eu31
    label_unit 1 0 31 Eu32
    label_unit 1 0 32 Eu33
    label_unit 1 0 33 Eu34
    label_unit 1 0 34 Eu35
    label_unit 1 0 35 Eu36
    label_unit 1 0 36 Eu37
    label_unit 1 0 37 Eu38
    label_unit 1 0 38 Eu39
    label_unit 1 0 39 Eu40
    end_if


    end_monitor


    monitor_conditions I_BattleStarted
    and I_BattlePlayerArmyNumberOfAttribute general_unit > 0
    and I_BattleEnemyArmyNumberOfAttribute general_unit = 0


    if I_CompareCounter deploy_check = 1
    ; *********************************************************************************************
    ; Help The Captain - AI
    ; *********************************************************************************************
    unit_set_experience Eu1 6
    unit_set_experience Eu2 6
    unit_set_experience Eu3 6
    unit_set_experience Eu4 6
    unit_set_experience Eu5 6
    unit_set_experience Eu6 6
    unit_set_experience Eu7 6
    unit_set_experience Eu8 6
    unit_set_experience Eu9 6
    unit_set_experience Eu10 6
    unit_set_experience Eu11 6
    unit_set_experience Eu12 6
    unit_set_experience Eu13 6
    unit_set_experience Eu14 6
    unit_set_experience Eu15 6
    unit_set_experience Eu16 6
    unit_set_experience Eu17 6
    unit_set_experience Eu18 6
    unit_set_experience Eu19 6
    unit_set_experience Eu20 6
    unit_set_experience Eu21 6
    unit_set_experience Eu22 6
    unit_set_experience Eu23 6
    unit_set_experience Eu24 6
    unit_set_experience Eu25 6
    unit_set_experience Eu26 6
    unit_set_experience Eu27 6
    unit_set_experience Eu28 6
    unit_set_experience Eu29 6
    unit_set_experience Eu30 6
    unit_set_experience Eu31 6
    unit_set_experience Eu32 6
    unit_set_experience Eu33 6
    unit_set_experience Eu34 6
    unit_set_experience Eu35 6
    unit_set_experience Eu36 6
    unit_set_experience Eu37 6
    unit_set_experience Eu38 6
    unit_set_experience Eu39 6
    unit_set_experience Eu40 6
    end_if


    end_monitor


    monitor_conditions I_BattleStarted
    and I_CompareCounter Release_Labels = 1


    if I_CompareCounter deploy_check = 1
    ;Must release Main Army, internal army label is recalibrated upon arrival of AI reinforcements causing 1 (previously the main AI army) to become 0 and 1 to become the secondary AI army.
    release_unit MAu1
    release_unit MAu2
    release_unit MAu3
    release_unit MAu4
    release_unit MAu5
    release_unit MAu6
    release_unit MAu7
    release_unit MAu8
    release_unit MAu9
    release_unit MAu10
    release_unit MAu11
    release_unit MAu12
    release_unit MAu13
    release_unit MAu14
    release_unit MAu15
    release_unit MAu16
    release_unit MAu17
    release_unit MAu18
    release_unit MAu19
    release_unit MAu20
    release_unit MAu21
    release_unit MAu22
    release_unit MAu23
    release_unit MAu24
    release_unit MAu25
    release_unit MAu26
    release_unit MAu27
    release_unit MAu28
    release_unit MAu29
    release_unit MAu30
    release_unit MAu31
    release_unit MAu32
    release_unit MAu33
    release_unit MAu34
    release_unit MAu35
    release_unit MAu36
    release_unit MAu37
    release_unit MAu38
    release_unit MAu39
    release_unit MAu40
    release_unit Eu1
    release_unit Eu2
    release_unit Eu3
    release_unit Eu4
    release_unit Eu5
    release_unit Eu6
    release_unit Eu7
    release_unit Eu8
    release_unit Eu9
    release_unit Eu10
    release_unit Eu11
    release_unit Eu12
    release_unit Eu13
    release_unit Eu14
    release_unit Eu15
    release_unit Eu16
    release_unit Eu17
    release_unit Eu18
    release_unit Eu19
    release_unit Eu20
    release_unit Eu21
    release_unit Eu22
    release_unit Eu23
    release_unit Eu24
    release_unit Eu25
    release_unit Eu26
    release_unit Eu27
    release_unit Eu28
    release_unit Eu29
    release_unit Eu30
    release_unit Eu31
    release_unit Eu32
    release_unit Eu33
    release_unit Eu34
    release_unit Eu35
    release_unit Eu36
    release_unit Eu37
    release_unit Eu38
    release_unit Eu39
    release_unit Eu40
    end_if


    end_monitor


    monitor_conditions I_BattleStarted
    and I_CompareCounter deploy_check = 1


    set_counter Release_Labels 0


    if I_CompareCounter Release_Labels = 0
    ; *********************************************************************************************
    ; Group Labels
    ; *********************************************************************************************
    define_unit_group Allies MAu1 MAu2 MAu3 MAu4 MAu5 MAu6 MAu7 MAu8 MAu9 MAu10 MAu11 MAu12 MAu13 MAu14 MAu15 MAu16 MAu17 MAu18 MAu19 MAu20 MAu21 MAu22 MAu23 MAu24 MAu25 MAu26 MAu27 MAu28 MAu29 MAu30 MAu31 MAu32 MAu33 MAu34 MAu35 MAu36 MAu37 MAu38 MAu39 MAu40


    define_unit_group Enemy Eu1 Eu2 Eu3 Eu4 Eu5 Eu6 Eu7 Eu8 Eu9 Eu10 Eu11 Eu12 Eu13 Eu14 Eu15 Eu16 Eu17 Eu18 Eu19 Eu20 Eu21 Eu22 Eu23 Eu24 Eu25 Eu26 Eu27 Eu28 Eu29 Eu30 Eu31 Eu32 Eu33 Eu34 Eu35 Eu36 Eu37 Eu38 Eu39 Eu40


    set_counter FaW_and_S 0
    end_if


    end_monitor


    ; *********************************************************************************************
    ; unit Group Orders - Disabled
    ; *********************************************************************************************


    ;monitor_conditions I_BattleStarted
    ;and I_ConflictType Normal
    ;and I_BattleEnemyArmyNumberOfClassAndCategory missile cavalry > 9
    ;and I_PercentageOfArmyKilled 1 0 >= 5


    ;unit_group_set_morale Enemy routing


    ;end_monitor


    ;Test Order - Player Allies Only
    ; unit_group_order_relative_move_formed Allies 0 200
    ; I_UnitGroupInRangeOfUnitGroup
    ; I_PercentageUnitGroupKilled


    ; *********************************************************************************************
    ; Initialize Battle Plans & Monitors
    ; *********************************************************************************************


    ; *********************************************************************************************
    ; AI Reinforcement Plans
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 10
    and I_BattleStarted
    and I_ConflictType Normal
    and I_CompareCounter AI_reinforcements > 0


    if I_TimerElapsed AI_reinforcements_timer = 5000
    inc_counter AI_reinforcements_tc 1
    end_if


    if I_TimerElapsed AI_reinforcements_timer > 5000
    restart_timer AI_reinforcements_timer
    end_if


    ; *********************************************************************************************
    ; AI Reinforcements Defend Plan
    ; *********************************************************************************************


    if I_CompareCounter AI_GRP = 0
    and I_CompareCounter AI_reinforcements_tc < 30
    ;AI Units from Army 1 Battle Objective
    ;ai_gta_add_objective 0 DEFEND_LINE 999
    ;AI Army 1 Battle Objective
    ai_gta_plan_set 0 DEFEND_FEATURE
    ;AI Units from Army 2 Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Army 2 Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    ; *********************************************************************************************
    ; AI Reinforcements Reaction Plan
    ; *********************************************************************************************


    if I_CompareCounter AI_reinforcements > 0
    and I_CompareCounter AI_GRP > 0
    ;AI Units from Army 1 Battle Objective
    ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Army 1 Battle Objective
    ai_gta_plan_set 0 ATTACK_ALL
    ;AI Units from Army 2 Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Army 2 Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    ; *********************************************************************************************
    ; AI Reinforcements Attack Plan
    ; *********************************************************************************************


    if I_CompareCounter AI_reinforcements_tc > 30
    and not I_BattlePlayerArmyIsAttacker
    ;AI Units from Army 1 Battle Objective
    ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Army 1 Battle Objective
    ai_gta_plan_set 0 ATTACK_ALL
    ;AI Units from Army 2 Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Army 2 Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Normal Attack Plan
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 20
    and I_BattleStarted
    and I_CompareCounter AI_reinforcements = 0
    and I_ConflictType Normal
    and not I_BattlePlayerArmyIsAttacker


    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL


    end_monitor


    ; *********************************************************************************************
    ; Normal Defend Plan
    ; Recurring counters fire above 0
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 30
    and I_BattleStarted
    and I_CompareCounter AI_reinforcements = 0
    and I_ConflictType Normal
    and I_BattlePlayerArmyIsAttacker


    if I_CompareCounter AI_GRP = 0
    ;AI Units Battle Objective Main Army
    ;ai_gta_add_objective 1 DEFEND_LINE 999
    ;AI Alliance Battle Objective Main Army
    ai_gta_plan_set 1 DEFEND_FEATURE
    end_if


    if I_CompareCounter AI_GRP > 0
    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Assault Crossing
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 40
    and I_BattleStarted
    and I_BattleIsRiverBattle
    and not I_BattlePlayerArmyIsAttacker


    if I_CompareCounter AI_reinforcements = 0
    ;AI Units from Army 2 Battle Objective
    ai_gta_add_objective 1 ASSAULT_CROSSING 999
    ;AI Units from Army 2 Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    if I_CompareCounter AI_reinforcements = 1
    and I_CompareCounter AI_reinforcements_tc < 30
    ;AI Alliance Battle Objective
    ai_gta_plan_set 0 DEFEND_FEATURE
    ;AI Alliance Battle Objective 2
    ai_gta_plan_set 1 ATTACK_ALL
    ;AI Units Battle Objective 2
    ai_gta_add_objective 1 ASSAULT_CROSSING 999
    end_if


    ; *********************************************************************************************
    ; Assault Crossing - Reinforcements
    ; *********************************************************************************************


    if I_CompareCounter AI_reinforcements = 1
    and I_CompareCounter AI_reinforcements_tc > 30
    ;AI Units Battle Objective
    ai_gta_add_objective 0 ASSAULT_CROSSING 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 0 ATTACK_ALL
    ;AI Units Battle Objective 2
    ai_gta_add_objective 1 ASSAULT_CROSSING 999
    ;AI Alliance Battle Objective 2
    ai_gta_plan_set 1 ATTACK_ALL
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Assault Settlement
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 50
    and I_BattleStarted
    and I_BattleIsSiegeBattle
    and not I_BattlePlayerArmyIsAttacker


    if I_CompareCounter AI_reinforcements = 0
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_SETTLEMENT
    end_if


    ; *********************************************************************************************
    ; Assault Settlement - Reinforcements
    ; *********************************************************************************************


    if I_CompareCounter AI_reinforcements = 1
    and I_CompareCounter AI_reinforcements_tc > 30
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_SETTLEMENT
    ;AI Alliance Battle Objective 2
    ai_gta_plan_set 0 ATTACK_SETTLEMENT
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Sally Out
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 60
    and I_BattleStarted
    and I_BattleIsSallyOutBattle
    and not I_BattlePlayerArmyIsAttacker


    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL


    if I_CompareCounter AI_reinforcements = 1
    and I_CompareCounter AI_reinforcements_tc > 30
    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL
    ;AI Units Battle Objective 2
    ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective 2
    ai_gta_plan_set 0 ATTACK_ALL
    end_if


    end_monitor


    ; *********************************************************************************************
    ; Custom Formations - Can be based on unit composition - Disabled
    ; *********************************************************************************************


    ; monitor_conditions I_CompareCounter command_and_control = 70
    ; and I_BattleStarted
    ; and I_ConflictType Normal


    ; if I_BattleEnemyArmyNumberOfAttribute rome_gen > 0
    ; unit_group_order_change_group_formation Enemy ordered_triple_line_1
    ; end_if


    ; if I_BattlePlayerArmyNumberOfAttribute rome_gen > 0
    ; unit_group_order_change_group_formation Allies ordered_triple_line_1
    ; end_if


    ; end_monitor


    ; *********************************************************************************************
    ; AI unit Monitors
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 80
    and I_BattleStarted
    and not I_BattleIsSiegeBattle
    and I_PercentageUnitKilled Eu1 > 5


    inc_counter AI_GRP 1


    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL


    end_monitor


    ; *********************************************************************************************
    ; AI Reactions Toward Attacks (Missile/Artillery/Charges)
    ; *********************************************************************************************


    monitor_conditions I_CompareCounter command_and_control = 90
    and I_BattleStarted
    and I_PercentageOfArmyKilled 1 0 > 3
    and I_BattlePlayerArmyIsAttacker
    and not I_BattleIsSiegeBattle


    inc_counter AI_GRP 1


    ;AI Units Battle Objective
    ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
    ;AI Alliance Battle Objective
    ai_gta_plan_set 1 ATTACK_ALL


    end_monitor


    ; *********************************************************************************************
    ; Counters for export
    ; *********************************************************************************************


    ; !! declare and reset counters in 'Battle Starting' section !!


    monitor_conditions I_CompareCounter command_and_control = 100
    and I_BattleStarted


    ; --- testing for number of units with 'rehire_makedones' attribute in AI army - ie Phalangitai ---
    if I_BattleEnemyArmyNumberOfAttribute rehire_makedones > 0 ; at least one unit with this attribute was present in the enemy army
    set_counter capture_pike 1
    end_if


    ; --- testing for number of units with 'rehire_hoplite' attribute in AI army - ie Hoplitai, Etruscans, Liby-Phoenician Infantry or Babylonian Spearmen ---
    if I_BattleEnemyArmyNumberOfAttribute rehire_hoplite > 0 ; at least one unit with this attribute was present in the enemy army
    set_counter capture_hoplite 1
    end_if


    ; --- testing for battle size
    if I_BattleEnemyArmyNumberOfUnits > 7
    and I_BattleEnemyArmyNumberOfUnits < 11
    set_counter medium_battle 1 ; this was a medium sized battle
    end_if
    if I_BattleEnemyArmyNumberOfUnits > 10
    set_counter large_battle 1 ; this was a large sized battle
    end_if


    ; add more tests
    end_monitor


    ; *** DO NOT ADD BATTLE SCRIPT CODE BELOW THIS LINE!! ***


    while I_InBattle ; end of battle script
    end_while

    end_script



    Thank you in advance!

  3. #183
    Jadli's Avatar The Fallen God
    Gaming Emeritus

    Join Date
    Dec 2013
    Location
    Czech Republic
    Posts
    8,528

    Default Re: Skynet AI

    Skynet doesnt itself edit files that deal with upgradability of settlements and so on...

    So my only guess is that you broke the campaign script by importing this incorrectly, as you suggest indeed (though maybe it has more to do with AI not having the bonus money). If there is an error in the script, while campaign_script stops working. You can check this for example by whether some welcome historical/event scrolls show up or not (if you know when the scroll is supposed to show). If it doesnt show up, no script is working. And of course, if there is an error, it should show in the log.

    Anyway, by briefly looking at this, I believe I see the first (and probably only mistake that you could have done when importing the script). You imported the script between "wait_monitors" and "end_script". Afaik, "wait_monitors" need to be at the end of the script (before the "end_script"), so move the line after the Skynet battle script. That should make the script work correctly... though, you will of course need to start a new campaign.
    Last edited by Jadli; December 11, 2021 at 04:58 AM.

  4. #184

    Default Re: Skynet AI

    Quote Originally Posted by Jadli View Post
    Skynet doesnt itself edit files that deal with upgradability of settlements and so on...

    So my only guess is that you broke the campaign script by importing this incorrectly, as you suggest indeed (though maybe it has more to do with AI not having the bonus money). If there is an error in the script, while campaign_script stops working. You can check this for example by whether some welcome historical/event scrolls show up or not (if you know when the scroll is supposed to show). If it doesnt show up, no script is working. And of course, if there is an error, it should show in the log.

    Anyway, by briefly looking at this, I believe I see the first (and probably only mistake that you could have done when importing the script). You imported the script between "wait_monitors" and "end_script". Afaik, "wait_monitors" need to be at the end of the script (before the "end_script"), so move the line after the Skynet battle script. That should make the script work correctly... though, you will of course need to start a new campaign.
    Thank you! Your resolution solved my problem. I now went to check my old Retrofit mod installation in which I also applied Skynet and I did it wrong there as well, thus also breaking my campaign script, however I didn't notice as I finished the campaign in Retrofit in about 75 turns, so I thought for example that the Mongols just didn't arrive yet.

    Good I noticed something's wrong in the Teutonic campaign.

    Maybe including a short explanation on implementing the battle script in the campaign_script file in the README for modding newbs such as myself wouldn't be a bad idea.


    On another note, any idea why the AI would be doing this? VH/VH difficulty, many small armies instead of a larger relief force. It took the AI a couple of turns to do this, and the next turn it brought in the final small army to attack.
    Spoiler Alert, click show to read: 




  5. #185
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Skynet AI

    What about descr_campaign_db section about siege and attack parameters?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  6. #186
    Jadli's Avatar The Fallen God
    Gaming Emeritus

    Join Date
    Dec 2013
    Location
    Czech Republic
    Posts
    8,528

    Default Re: Skynet AI

    Yea, probably, these lines specifically in descr_campaign_db.txt.

    Code:
          <att_str_modifier float = "0.70"/><!--modifies the effective attackers strength when determining the priority of making attack decision (i.e. att_def_strength_ratio = ((att_str*att_str_modifier)/def_str). z3n 0.75 . Set lower to attack with larger force -->
          <siege_att_str_modifier float = "0.55"/><!--modifies the effective sieging attackers strength when determining the priority of making attack decision  z3n 0.75 Set lower to attack with larger force  -->
          <crusade_att_str_modifier float = "1.2"/><!--modifies the effective crusading sieging attackers strength when determining the priority of making attack decision  z3n 1.00 Set lower to attack with larger force -->
          <sally_att_str_modifier float = "1.0"/><!--modifies the effective sallying attackers strength when determining the priority of making attack decision   z3n 0.75 Set lower to attack with larger force -->
          <ambush_att_str_modifier float = "1.25"/><!--modifies the effective ambushing attackers strength when determining the priority of making attack decision -->
          <str_limit_weak float = "0.80"/><!--min ideal strength ratio modifier for determining when an army is far too weak for an attack ( att_def_strength_ratio < (ideal_str_ratio*str_limit_weak) ) z3n 0.75  Set HIGHER to attack with larger force -->
          <str_limit_strong float = "999.0"/><!--max ideal strength ratio modifier for determining when an army is far too strong for a fair attack ( att_def_strength_ratio > (ideal_str_ratio*str_limit_strong) ) -->
    Im using Skynet as well in my mod, though significantly changed some aspects to improve/better fit my mod. I had the same issue as you, so I modified the lines to have larger armies, so just feel free to to copy those lines, should work fine for you, considering this is loosely based on original Skynet values as well.

    Though this ofc doesnt fully get rid of this, as there other thigs that would be much harder to modify, i.e., see the guide on pathfinding and so on in this subforum by z3en

  7. #187

    Default Re: Skynet AI

    Quote Originally Posted by Jadli View Post
    Yea, probably, these lines specifically in descr_campaign_db.txt.

    Code:
          <att_str_modifier float = "0.70"/><!--modifies the effective attackers strength when determining the priority of making attack decision (i.e. att_def_strength_ratio = ((att_str*att_str_modifier)/def_str). z3n 0.75 . Set lower to attack with larger force -->
          <siege_att_str_modifier float = "0.55"/><!--modifies the effective sieging attackers strength when determining the priority of making attack decision  z3n 0.75 Set lower to attack with larger force  -->
          <crusade_att_str_modifier float = "1.2"/><!--modifies the effective crusading sieging attackers strength when determining the priority of making attack decision  z3n 1.00 Set lower to attack with larger force -->
          <sally_att_str_modifier float = "1.0"/><!--modifies the effective sallying attackers strength when determining the priority of making attack decision   z3n 0.75 Set lower to attack with larger force -->
          <ambush_att_str_modifier float = "1.25"/><!--modifies the effective ambushing attackers strength when determining the priority of making attack decision -->
          <str_limit_weak float = "0.80"/><!--min ideal strength ratio modifier for determining when an army is far too weak for an attack ( att_def_strength_ratio < (ideal_str_ratio*str_limit_weak) ) z3n 0.75  Set HIGHER to attack with larger force -->
          <str_limit_strong float = "999.0"/><!--max ideal strength ratio modifier for determining when an army is far too strong for a fair attack ( att_def_strength_ratio > (ideal_str_ratio*str_limit_strong) ) -->
    Im using Skynet as well in my mod, though significantly changed some aspects to improve/better fit my mod. I had the same issue as you, so I modified the lines to have larger armies, so just feel free to to copy those lines, should work fine for you, considering this is loosely based on original Skynet values as well.

    Though this ofc doesnt fully get rid of this, as there other thigs that would be much harder to modify, i.e., see the guide on pathfinding and so on in this subforum by z3en
    I did what you suggested and tested it and...
    Spoiler Alert, click show to read: 



  8. #188
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Skynet AI

    Interesting
    And what about final lines in config_ai_battle?

    And it's a new campaign, with new map.rwm, right?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  9. #189

    Default Re: Skynet AI

    Quote Originally Posted by bitterhowl View Post
    Interesting
    And what about final lines in config_ai_battle?

    And it's a new campaign, with new map.rwm, right?
    Ah, so it is necessary to do that as well for the new descr_campaign_db.xml to start working. The campaign was new, but with an older map.rwm.

    Is there some list of files which are affected by map.rwm when starting a new game? Before I was deleting map.rwm by default as I was working on campaign map changes a while back, but I didn't in this instance as I didn't think it was necessary and I didn't come across the folder of map.rwm.

    I'll go test it now again. Thank you!


    Here's the code you asked, that whole file is from z3n.

    Code:
            <battle-analyser>
                <!-- ratio of friendly to enemy strength to be considered more powerful -->
                <friendly-to-enemy-strength-ratio>1.0</friendly-to-enemy-strength-ratio>
                <!-- ratio of friendly to enemy melee strength to be considered overwhelmingly powerful -->
                <enemy-melee-strength-multiplier>1.1</enemy-melee-strength-multiplier>
                <!-- ratio of friendly strength to enemy melee strength to force attack -->
                <friendly-melee-strength-divisor>0.9</friendly-melee-strength-divisor>
                <!-- ratio of enemy to friendly ranged strength to be considered overwhelmingly powerful -->
                <friendly-ranged-strength-multiplier>3.0</friendly-ranged-strength-multiplier>
                <!-- ratio of friendly strength to enemy ranged strength to force attack -->
                <friendly-ranged-strength-divisor>5.0</friendly-ranged-strength-divisor>
                <!-- distance behind the defensive line the enemy must reach to be considered to have broken through -->
                <enemy-position-buffer-distance>100</enemy-position-buffer-distance>
            </battle-analyser>
        </gta>
    </config>
    
    <variations>
    </variations>
    Last edited by Dominick; December 12, 2021 at 10:43 AM.

  10. #190

    Default Re: Skynet AI

    Eh, I deleted the map.rwm and the game generated a new one, but similar things are still happening.

    Spoiler Alert, click show to read: 







  11. #191
    Jadli's Avatar The Fallen God
    Gaming Emeritus

    Join Date
    Dec 2013
    Location
    Czech Republic
    Posts
    8,528

    Default Re: Skynet AI

    Well, follow the comments (after hashtag) in the lines I provided, and based on the explanations there try to put the values towards even larger armies

  12. #192

    Default Re: Skynet AI

    Quote Originally Posted by Jadli View Post
    Well, follow the comments (after hashtag) in the lines I provided, and based on the explanations there try to put the values towards even larger armies
    I feel the problem isn't in the size of all forces combined, but in the fact they are in different stacks, as if the AI often doesn't take the time to put them all in the same stack, but attacks with divided stacks attacking at the same time. So the AI seems to attack taking the numbers you provided in consideration, but it doesn't attack with only one powerful stack, and that is the problem.

    Can we tell the AI to prefer merging its units in one stack before attacking?

  13. #193
    Jadli's Avatar The Fallen God
    Gaming Emeritus

    Join Date
    Dec 2013
    Location
    Czech Republic
    Posts
    8,528

    Default Re: Skynet AI

    Quote Originally Posted by Jadli View Post
    ...
    Though this ofc doesnt fully get rid of this, as there other thigs that would be much harder to modify, i.e., see the guide on pathfinding and so on in this subforum by z3en
    Not super experienced in this tho, perhaps bitterhowl knows more...
    Last edited by Jadli; December 12, 2021 at 01:13 PM.

  14. #194
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: Skynet AI

    Haven't seen last version of Skynet at the moment. Probably the deal with decisions parameters.

    invade_start known to gather stacks together, at least near capital. Posted link about that somewhere around AI Workshop.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  15. #195
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Skynet AI

    Honestly this problem is not solvable by the modder, unless they wish to neuter the AI completely.

    This is brought out by the fact CA later consolidated all stacks into "forced" general stacks in all the newer TW games; while also limiting the amount of armies factions can have depending on their size. If CA gave up (the ones who can program the code behind the decisions we used), then I'd say it's something of a lost cause...

    bitterhowl is correct however, invade_start can work pretty well. But every decision comes with a sacrifice, either in aggression, compactness (to some degree), or reactivity in terms of defense.

    Maybe, just maybe, you could find a correct rhythm to flip the AI in and out of these long term plans properly by using the campaign script (we already something similar to this in EBII for peace and war ai label "personalities"; so mechanically it's 100% possible). I would be interested in how a test like that would turn out, but I'm currently busy with some RL things.

    Since we know that frontline_balance is completely borked. Free_strength is also kinda messed up from what I recall and military_balance is only moderately useful.

    So an idea using ai_labels flip the invasion decisions within a few turns (maybe use a counter, then reset the counter to 0 once it hits 25, and start the whole pattern again), e.g.
    1) From turn 0-5 turns use invade_start ai label
    2) From turn 5-10 use invade_buildup
    3) From turn 10-15 use invade_opportunistic
    4) From turn 15-20 use invade_immediate
    5) From turn 20-25 use invade_start again

    That way you won't be stuck using 1 invasion decision against a target all the time. Then and again, from what I've seen the AI does also respond pretty well to using just one invasion decision against targets... Like I said though, our main problem is that frontline_balance and free_strength is completely off the walls incorrect sometimes, it just doesn't make sense to use those tests. From what I remember the vanilla file uses frontline_balance + free_strength + military balance pretty often, but I don't think that's even good either. Like 1 unit heads over to the frontline and then suddenly their frontline balance is 50000000000000000000000 : 1. free_strength is often just completely incorrect (since according to cavalrycmdr it uses the slave faction to calculate against as well, or other powerful factions)

    Sometimes their AI even freezes, so "free_strength" is really questionable. It must have all sorts of problems with infinite loops or something pretty off. Their programming is just bugged. Basically the only programming that isn't super bugged might be something somebody creates on their own, within the campaign scripts, and then use that to flip ai labels which seem reasonable. If you want to try that out. That'd be a real challenge though and my opinion is that it isn't solvable. We can probably only at best mitigate weird behaviours.
    Last edited by z3n; December 14, 2021 at 10:12 PM.
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  16. #196

    Default Re: Skynet AI

    Is there any text description of what this mod/resource do specifically, especially regarding the campaign AI?

  17. #197
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Skynet AI

    Well basically it's a complete rewrite of the decision tree the LTGD uses to plan its invasions and defense decisions. I never really kept any complete list of changes since even those get rewritten.
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  18. #198
    Jadli's Avatar The Fallen God
    Gaming Emeritus

    Join Date
    Dec 2013
    Location
    Czech Republic
    Posts
    8,528

    Default Re: Skynet AI

    Quote Originally Posted by z3n View Post
    Honestly this problem is not solvable by the modder, unless they wish to neuter the AI completely.

    This is brought out by the fact CA later consolidated all stacks into "forced" general stacks in all the newer TW games; while also limiting the amount of armies factions can have depending on their size. If CA gave up (the ones who can program the code behind the decisions we used), then I'd say it's something of a lost cause...

    bitterhowl is correct however, invade_start can work pretty well. But every decision comes with a sacrifice, either in aggression, compactness (to some degree), or reactivity in terms of defense.

    Maybe, just maybe, you could find a correct rhythm to flip the AI in and out of these long term plans properly by using the campaign script (we already something similar to this in EBII for peace and war ai label "personalities"; so mechanically it's 100% possible). I would be interested in how a test like that would turn out, but I'm currently busy with some RL things.

    Since we know that frontline_balance is completely borked. Free_strength is also kinda messed up from what I recall and military_balance is only moderately useful.

    So an idea using ai_labels flip the invasion decisions within a few turns (maybe use a counter, then reset the counter to 0 once it hits 25, and start the whole pattern again), e.g.
    1) From turn 0-5 turns use invade_start ai label
    2) From turn 5-10 use invade_buildup
    3) From turn 10-15 use invade_opportunistic
    4) From turn 15-20 use invade_immediate
    5) From turn 20-25 use invade_start again

    That way you won't be stuck using 1 invasion decision against a target all the time. Then and again, from what I've seen the AI does also respond pretty well to using just one invasion decision against targets... Like I said though, our main problem is that frontline_balance and free_strength is completely off the walls incorrect sometimes, it just doesn't make sense to use those tests. From what I remember the vanilla file uses frontline_balance + free_strength + military balance pretty often, but I don't think that's even good either. Like 1 unit heads over to the frontline and then suddenly their frontline balance is 50000000000000000000000 : 1. free_strength is often just completely incorrect (since according to cavalrycmdr it uses the slave faction to calculate against as well, or other powerful factions)

    Sometimes their AI even freezes, so "free_strength" is really questionable. It must have all sorts of problems with infinite loops or something pretty off. Their programming is just bugged. Basically the only programming that isn't super bugged might be something somebody creates on their own, within the campaign scripts, and then use that to flip ai labels which seem reasonable. If you want to try that out. That'd be a real challenge though and my opinion is that it isn't solvable. We can probably only at best mitigate weird behaviours.
    BTW, this is not fully related to AI scripting (in fact, it kinda "overrides" the AI), but what I noticed that is the best and most reliable solution for AI to use full stacks (also led by generals, not just captains), instead of a bunch of small armies, is to spawn those full stacks for them... I noticed that they usually dont split those armies.. and if you spawned a general with the army, he remains leading it ...

  19. #199
    z3n's Avatar State of Mind
    took an arrow to the knee

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Skynet AI

    Quote Originally Posted by Jadli View Post
    BTW, this is not fully related to AI scripting (in fact, it kinda "overrides" the AI), but what I noticed that is the best and most reliable solution for AI to use full stacks (also led by generals, not just captains), instead of a bunch of small armies, is to spawn those full stacks for them... I noticed that they usually dont split those armies.. and if you spawned a general with the army, he remains leading it ...
    Interesting, what happens after they conquer a settlement; the armies split or remain?
    The AI Workshop Creator
    Europa Barbaroum II AI/Game Mechanics Developer
    The Northern Crusades Lead Developer
    Classical Age Total War Retired Lead Developer
    Rome: Total Realism Animation Developer
    RTW Workshop Assistance MTW2 AI Tutorial & Assistance
    Broken Crescent Submod (M2TW)/IB VGR Submod (BI)/Animation (RTW/BI/ALX)/TATW PCP Submod (M2TW)/TATW DaC Submod (M2TW)/DeI Submod (TWR2)/SS6.4 Northern European UI Mod (M2TW)

  20. #200

    Default Re: Skynet AI

    Am I right in thinking if I have installed the mod as instructed and want to switch to "bloodthirsty" I can just extract and rewrite existing files only.

    What exactly does the bloodthirsty version do?

    I have been testing this AI it feels a bit passive so will try bloodthirsty, but it might mainly feel that way because I have the occupy relations bugfix applied which I think is a huge change vs vanilla.

    edit:
    I had to set ai_label for papacy back to papal_faction from default because was too op to get excommunicated by aggressive pope on turn 2-3
    however it doesnt fix it, papacy still aggressive and is not giving player quests such as cease hostilities etc.
    Last edited by jupsto; January 02, 2022 at 01:33 PM.

Posting Permissions

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