Results 1 to 19 of 19

Thread: Looking for a battle script

  1. #1

    Default Looking for a battle script

    that can lock control over units charging, once i set a unit to attack and it starts charging i dont have control over that unit until it finished charging and a few seconds passed

    basically the exact same thing as G5 AI's hardcore version but without that annoying bug that makes general bodyguard forever stuck

    but it doesnt have to be exactly same, i am looking for any script/mod that makes battles significantly harder by putting restrictions like that

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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    I don't think one like that exists, but it is not that hard to create.

    You just need to label all the units (no fatal error if one does not exist), for each army. And then after that you need to check for their state (charging).

    Then you remove player control for a set period of time. EG wait 5 or 10 seconds etc.
    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)

  3. #3

    Default Re: Looking for a battle script

    Quote Originally Posted by z3n View Post
    not that hard
    G5's script has 8600 lines


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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    Here's the entirety of the EBII battle scripts. About 600~ lines, most of them unrelated to what you want to do.

    Labels are there however, if you need direction about how to start that.

    Code:
        ;----------------------------------------------------------------------------------------------------
    
        ; 26. Battle Scripts
    
        ;----------------------------------------------------------------------------------------------------
    
        ;    while I_InBattle        ; start of battle script
        ;    end_while
    
        ;See this post for more information and how to create a campaign script
        ;http://www.twcenter.net/forums/showthread.php?708388-MTW2-Battle-Scripting
    
        ; *********************************************************************************************
        ;    EBII Battle Scripts
        ;    15/1/2017
        ;    z3n
        ; *********************************************************************************************
    
        ; *********************************************************************************************
        ;    EBII Battle Script Counters/Timers
        ; *********************************************************************************************
        ;Battle specific
        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_timer AI_reinforcements_timer
    
        ;Counters defined in the campaign script and used in battle.
        ;These exchange values between strat map and battle map.
    ;    declare_counter capture_pike
    ;    declare_counter capture_hoplite
    ;    declare_counter heavy_horse 0
    ;    declare_counter capture_african_elephant
    ;    declare_counter capture_indian_elephant
    ;    declare_counter medium_battle
    ;    declare_counter large_battle
    
        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 heavy_horse 0
            set_counter capture_african_elephant 0
            set_counter capture_indian_elephant 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
                battle_wait 5
                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 Reaction Plan
            ; *********************************************************************************************
    
            if 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_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_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
    
            ; *********************************************************************************************
            ;     Assault Crossing - Reinforcements
            ; *********************************************************************************************
    
            if I_CompareCounter AI_reinforcements > 0
                ;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 > 0
                ;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 > 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
                ;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 number of units with 'barded_cav' attribute in AI army - ie heavy cavalry ---
            if I_BattleEnemyArmyNumberOfAttribute barded_cav > 0     ; at least one unit with this attribute was present in the enemy army
                set_counter heavy_horse 1
            end_if
            ; --- testing for number of units with 'rehire_african_elephant' attribute in AI army - ie African elephants ---
            if I_BattleEnemyArmyNumberOfAttribute rehire_african_elephant > 0     ; at least one unit with this attribute was present in the enemy army
                set_counter capture_african_elephant 1
            end_if
            ; --- testing for number of units with 'rehire_indian_elephant' attribute in AI army - ie Indian elephants ---
            if I_BattleEnemyArmyNumberOfAttribute rehire_indian_elephant > 0     ; at least one unit with this attribute was present in the enemy army
                set_counter capture_indian_elephant 1
            end_if
            ; --- testing for battle size
            if I_BattleEnemyArmyNumberOfUnits > 7
                and I_BattleEnemyArmyNumberOfUnits < 12
                set_counter medium_battle 1  ; this was a medium sized battle
            end_if
            if I_BattleEnemyArmyNumberOfUnits > 11
                set_counter large_battle 1  ; this was a large sized battle
            end_if
            ; add more tests
        end_monitor
    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)

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

    Default Re: Looking for a battle script

    I use berserker ability for mounted units for that purpose.

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

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

    Default Re: Looking for a battle script

    Also heard about feature from EBII about orders delaying in battle. Asked their team but no clear answer granted.

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

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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    What was the question? I wrote it so I should be able to answer.


    There is no delay script written into the EBII one, unless someone added it while I didnt pay attention, if you want to add one I dont think it is very hard though.
    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)

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

    Default Re: Looking for a battle script

    It was about .xml not campaign_script. I'll find the link to that thread.

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

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

    Default Re: Looking for a battle script

    Here we got my question and an answer below
    https://www.twcenter.net/forums/show...1#post15740502

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

  10. #10

    Default Re: Looking for a battle script

    so what are those .xml parameters ? did u get an answer to that yet ?

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

    Default Re: Looking for a battle script

    Nope, good sir. That's why I wrote it here wondering for solution.

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

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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    That delay is from the descr_pathfinding file. It is necessary to delete the corresponding descr_pathfinding_db file to regenerate it (or possibly change the version number, my memory is foggy on that)
    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)

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

    Default Re: Looking for a battle script

    Many thanks! Can you say which parameter in pathfinding answers for that? Correct me if I'm wrong, but replacing the whole file will cause changes in Skynet?

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

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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    It's been a long time since I messed around with the values but from what I remember you'll want to adjust the budget parameter of the scheduler, and also try out different values for the paths and nodes.

    Code:
        scheduler_configuration
        {
            ; low load config
            load low
            {
                max_paths        320        ; maximum paths till shifting to the next loading
                total_nodes        650000        ; total nodes allocated across all paths
            }
    
            ; medium load config
            load medium
            {
                max_paths        380        ; maximum paths till shifting to the next loading
                total_nodes        325000         ; total nodes allocated across all paths
            }
    
            ; high load config
            load high
            {
                max_paths        420        ; maximum paths till shifting to the next loading
                total_nodes        162500        ; total nodes allocated across all paths
            }
            
            ; low priority config
            priority low
            {
                budget            0.98        ; percentage of budget for these paths
                max_nodes        500000        ; maximum nodes per path
                max_zone_nodes    100000        ; maximum zone nodes per path
            }
    
            ; medium priority config
            priority medium
            {
                budget            0.99            ; percentage of budget for these paths
                max_nodes        1000000        ; maximum nodes per path
                max_zone_nodes    30000        ; maximum zone nodes per path
            }
            
            ; high priority config
            priority high
            {
                budget            1.0        ; percentage of budget for these paths
                max_nodes        1500000        ; maximum nodes per path
                max_zone_nodes    400000        ; maximum zone nodes per path
            }
            
            ; real time priority config
            priority real_time
            {
                budget            1.0            ; percentage of budget for these paths
                max_nodes        2000000        ; maximum nodes per path
                max_zone_nodes    800000        ; maximum zone nodes per path
            }
            
            ; quick test priority config
            priority quick_test
            {
                budget            1.0            ; percentage of budget for these paths
                max_nodes        10000        ; maximum nodes per path
                max_zone_nodes    1000        ; maximum zone nodes per path
            }
        }
    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)

  15. #15

    Default Re: Looking for a battle script

    Quote Originally Posted by z3n View Post
    Here's the entirety of the EBII battle scripts. About 600~ lines, most of them unrelated to what you want to do.

    Labels are there however, if you need direction about how to start that.
    can you give me any further direction ?

    cause i am sitting here looking back and forth between that code you posted and g5's script trying to figure out how to do it but still no idea how exactly, it doesnt help that g5's script has a bunch of other things like limited deployment time stuffed up in there making the whole thing even more confusing

    "and I_UnitStatus a1u1 charging" so this must be for checking unit status as you said

    Identifier: release_unit
    Parameters: unit_label
    Description: Unlabels the specified unit and releases it back to player or AI control
    Sample use: release_unit
    Class: RELEASE_UNIT

    so this is what that labeling is for i guess, taking or giving control of a unit

    then the timer, "battle_wait 15" i suppose

    but how do i put together all this stuff to create an actual working script ?

    can you give me an example for 1 unit ?

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

    Join Date
    Aug 2011
    Posts
    4,640

    Default Re: Looking for a battle script

    I haven't touched battle scripts in over 3 years so take from this what you will, here is what you need to do conceptually

    1) Assign unit labels
    2) Check unit state using the label (charging)
    3) Give unit from player to AI control
    4) Release unit back to the player after some time (use battle_wait and then add the "release_unit" after)

    I don't remember what the command is to swap the unit from player to AI sadly... Even though I've done it in the past.
    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)

  17. #17

    Default Re: Looking for a battle script

    Quote Originally Posted by z3n View Post
    I haven't touched battle scripts in over 3 years so take from this what you will, here is what you need to do conceptually

    1) Assign unit labels
    2) Check unit state using the label (charging)
    3) Give unit from player to AI control
    4) Release unit back to the player after some time (use battle_wait and then add the "release_unit" after)

    I don't remember what the command is to swap the unit from player to AI sadly... Even though I've done it in the past.
    the problem i am having is how to actually script it, been looking at some tutorials but havent learnt anything useful for what i am trying to do, those tutorials only teach basic scripts

    do you know any tutorials who might help ?

  18. #18

    Default Re: Looking for a battle script

    If you want make the player lose the control of an unit, the command is "filter_unit_commands on/off [unit label]".

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

    Default Re: Looking for a battle script

    Yes, release_unit will unlabel it and finish entire script. For re-use this feature in same battle don't use release_unit.

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

Posting Permissions

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