;####### Germanicu5 Stakes+Reinforcements Script +HA +Sally-Out +Elephants +Siege +Protect General fix +AI exp bonus v3.0 beta ################

script

declare_show_me
console_command clear_messages
suspend_unscripted_advice true

;;;;;;;Stakes
declare_counter label_ready
declare_counter stakes_on
;;;;;;;Reinforcements
declare_counter label2_ready
declare_counter label4_ready
declare_counter label5_ready
declare_counter army_moving
declare_counter reinf_arrive
declare_counter reinf_arrive2
declare_counter reinf_late
declare_counter army3_run
declare_counter army3_run_siege
declare_counter army4_run
declare_counter distance_trigger1
declare_counter distance_trigger2
declare_counter distance_trigger3
declare_counter distance_trigger4
declare_counter distance_trigger5
;;;;;;;HA Fix
declare_counter ha_fix
;;;;;;;Elephant Fix
declare_counter elephant_fix
declare_counter elephant_gate
declare_counter elephant_gate2
declare_counter elephant_gate_tier2
declare_counter elephant_gate_tier3
declare_counter elephant_gate_tier2s
declare_counter elephant_gate_tier3s
declare_counter rally_walls
declare_counter rally_walls_s
declare_counter second_ring
declare_counter third_ring
declare_counter second_ring2
declare_counter third_ring2
declare_counter del_objective
declare_counter del_objective2
;;;;;;;Sally-out
declare_counter sally-out_fix
;;;;;;;Siege
declare_counter siege_fix
declare_counter kill_it
declare_counter army_sieging
declare_counter army_south
declare_counter army_north
declare_counter army_east
declare_counter army_west
declare_counter wall_advance
declare_counter wall_advance_south
declare_counter wall_advance_north
declare_counter wall_advance_west
declare_counter wall_advance_east
declare_counter emergency_stop
declare_counter omfg_cannon_tower
declare_counter omfg_cannon_tower2
declare_counter army2_sally
declare_counter wall_advance2
;;;;;;;Protect General
declare_counter protect_general
declare_counter general_wait
declare_counter in_battle

monitor_event BattleConflictPhaseCommenced FactionIsLocal
	prepare_for_battle			

	;;;Army 1
	label_unit 0 0 0 General1
	label_unit 0 0 1 unit1
	label_unit 0 0 2 unit2
	label_unit 0 0 3 unit3
	label_unit 0 0 4 unit4
	label_unit 0 0 5 unit5
	label_unit 0 0 6 unit6
	label_unit 0 0 7 unit7
	label_unit 0 0 8 unit8
	label_unit 0 0 9 unit9
	label_unit 0 0 10 unit10
	label_unit 0 0 11 unit11
	label_unit 0 0 12 unit12
	label_unit 0 0 13 unit13
	label_unit 0 0 14 unit14
	label_unit 0 0 15 unit15
	label_unit 0 0 16 unit16
	label_unit 0 0 17 unit17
	label_unit 0 0 18 unit18
	label_unit 0 0 19 unit19	
	
	;;;Army 2
	label_unit 1 0 0 General2
	label_unit 1 0 1 unit20
	label_unit 1 0 2 unit21
	label_unit 1 0 3 unit22
	label_unit 1 0 4 unit23
	label_unit 1 0 5 unit24
	label_unit 1 0 6 unit25
	label_unit 1 0 7 unit26
	label_unit 1 0 8 unit27
	label_unit 1 0 9 unit28
	label_unit 1 0 10 unit29
	label_unit 1 0 11 unit30
	label_unit 1 0 12 unit31
	label_unit 1 0 13 unit32
	label_unit 1 0 14 unit33
	label_unit 1 0 15 unit34
	label_unit 1 0 16 unit35
	label_unit 1 0 17 unit36
	label_unit 1 0 18 unit37
	label_unit 1 0 19 unit38
	
	define_unit_group army1 General1 unit1 unit2 unit3 unit4 unit5 unit6 unit7 unit8 unit9 unit10 unit11 unit12 unit13 unit14 unit15 unit16 unit17 unit18 unit19
	define_unit_group army2 General2 unit20 unit21 unit22 unit23 unit24 unit25 unit26 unit27 unit28 unit29 unit30 unit31 unit32 unit33 unit34 unit35 unit36 unit37 unit38

	if I_BattleIsSallyOutBattle
	and I_BattleEnemyArmyNumberOfMountClass elephant = 0
	and I_BattlePlayerArmyIsAttacker
	set_counter sally-out_fix 1
	end_if

	if I_ConflictType Siege
	set_counter siege_fix 1
	end_if

	if I_BattleIsSallyOutBattle
	set_counter siege_fix 1
	end_if

	if I_BattleEnemyArmyNumberOfMountClass elephant > 0
	and I_ConflictType Siege
	set_counter elephant_fix 1
	end_if

	if I_BattleEnemyArmyNumberOfMountClass elephant > 0
	and I_BattleIsSallyOutBattle
	set_counter elephant_fix 1
	end_if

	if I_BattleEnemyArmyNumberOfAttribute stakes > 0
	set_counter label_ready 1
	end_if

	if I_BattleEnemyArmyPercentageOfUnitCategory cavalry >= 60
	set_counter ha_fix 1
	end_if

	battle_wait 1
	ai_active_set on 

	battle_wait 14

	;;;Army 3
	label_unit 1 1 0 General3
	label_unit 1 1 1 unit39
	label_unit 1 1 2 unit40
	label_unit 1 1 3 unit41
	label_unit 1 1 4 unit42
	label_unit 1 1 5 unit43
	label_unit 1 1 6 unit44
	label_unit 1 1 7 unit45
	label_unit 1 1 8 unit46
	label_unit 1 1 9 unit47
	label_unit 1 1 10 unit48
	label_unit 1 1 11 unit49
	label_unit 1 1 12 unit50
	label_unit 1 1 13 unit51
	label_unit 1 1 14 unit52
	label_unit 1 1 15 unit53
	label_unit 1 1 16 unit54
	label_unit 1 1 17 unit55
	label_unit 1 1 18 unit56
	label_unit 1 1 19 unit57
	
	;;;Army 4
	label_unit 0 1 0 General4
	label_unit 0 1 1 unit58
	label_unit 0 1 2 unit59
	label_unit 0 1 3 unit60
	label_unit 0 1 4 unit61
	label_unit 0 1 5 unit62
	label_unit 0 1 6 unit63
	label_unit 0 1 7 unit64
	label_unit 0 1 8 unit65
	label_unit 0 1 9 unit66
	label_unit 0 1 10 unit67
	label_unit 0 1 11 unit68
	label_unit 0 1 12 unit69
	label_unit 0 1 13 unit70
	label_unit 0 1 14 unit71
	label_unit 0 1 15 unit72
	label_unit 0 1 16 unit73
	label_unit 0 1 17 unit74
	label_unit 0 1 18 unit75
	label_unit 0 1 19 unit76
	
	define_unit_group army3 General3 unit39 unit40 unit41 unit42 unit43 unit44 unit45 unit46 unit47 unit48 unit49 unit50 unit51 unit52 unit53 unit54 unit55 unit56 unit57
	define_unit_group army4 General4 unit58 unit59 unit60 unit61 unit62 unit63 unit64 unit65 unit66 unit67 unit68 unit69 unit70 unit71 unit72 unit73 unit74 unit75 unit76

	ai_active_set on
end_monitor

monitor_event BattleReinforcementsArrive TrueCondition
	and ! ArmyIsLocal
	and I_BattlePlayerArmyIsAttacker
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType FailedAmbush
	and I_PercentageOfArmyKilled 1 1 = 0

	battle_wait 17
	set_counter reinf_arrive 1
end_monitor

monitor_event BattleReinforcementsArrive TrueCondition
	and ! ArmyIsLocal
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType FailedAmbush
	and ! I_ConflictType Siege
	and I_PercentageOfArmyKilled 0 1 = 0

	battle_wait 17
	set_counter reinf_arrive2 1
end_monitor

;Normal;
monitor_conditions I_BattleStarted
	and I_CompareCounter reinf_arrive = 1
	and I_BattlePlayerArmyIsAttacker
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType FailedAmbush
	and ! I_ConflictType Siege 

	set_counter label2_ready 1
	set_counter reinf_arrive 0
	battle_wait 90
	set_counter reinf_late 1
end_monitor	

;Siege;
monitor_conditions I_InBattle
	and I_CompareCounter reinf_arrive = 1
	and I_BattlePlayerArmyIsAttacker
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType FailedAmbush
	and I_ConflictType Siege

	set_counter label4_ready 1
	set_counter reinf_arrive 0
	battle_wait 90
	set_counter reinf_late 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1	
	and I_CompareCounter army_moving = 0
	and ! I_UnitEnemyUnitInRadius General3 160
	and ! I_UnitGroupInRangeOfUnitGroup army3 army2
	
	set_counter army3_run 1
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1	
	and I_CompareCounter army_moving = 1
	and I_UnitEnemyUnitInRadius General3 160
	and ! I_UnitGroupInRangeOfUnitGroup army3 army2

	unit_group_order_halt army3	
	ai_active_set on
	
	set_counter army_moving 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter reinf_late = 1
	and I_CompareCounter label2_ready = 1
	and ! I_UnitEnemyUnitInRadius General3 160
	and ! I_UnitGroupInRangeOfUnitGroup army3 army2
	
	set_counter army3_run 1
	set_counter army_moving 1
	set_counter reinf_late 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter army_moving = 1
	and ! I_UnitEnemyUnitInRadius General3 160
	and I_UnitDistanceFromUnit General2 General3 > 150
	and I_IsUnitIdle General3

	set_counter reinf_late 1
	battle_wait 2
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter distance_trigger1 = 0
	and I_UnitDistanceFromUnit General3 General2 < 1000

	set_counter reinf_late 1
	set_counter distance_trigger1 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter distance_trigger2 = 0
	and I_UnitDistanceFromUnit General3 General2 < 750

	set_counter reinf_late 1
	set_counter distance_trigger2 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter distance_trigger3 = 0
	and I_UnitDistanceFromUnit General3 General2 < 500

	set_counter reinf_late 1
	set_counter distance_trigger3 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter distance_trigger4 = 0
	and I_UnitDistanceFromUnit General3 General2 < 300

	set_counter reinf_late 1
	set_counter distance_trigger4 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_CompareCounter distance_trigger5 = 0
	and I_UnitDistanceFromUnit General3 General2 < 200

	set_counter reinf_late 1
	set_counter distance_trigger5 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter army3_run = 1

	label_unit 1 1 0 General3
	label_unit 1 1 1 unit39
	label_unit 1 1 2 unit40
	label_unit 1 1 3 unit41
	label_unit 1 1 4 unit42
	label_unit 1 1 5 unit43
	label_unit 1 1 6 unit44
	label_unit 1 1 7 unit45
	label_unit 1 1 8 unit46
	label_unit 1 1 9 unit47
	label_unit 1 1 10 unit48
	label_unit 1 1 11 unit49
	label_unit 1 1 12 unit50
	label_unit 1 1 13 unit51
	label_unit 1 1 14 unit52
	label_unit 1 1 15 unit53
	label_unit 1 1 16 unit54
	label_unit 1 1 17 unit55
	label_unit 1 1 18 unit56
	label_unit 1 1 19 unit57
	
	unit_group_order_halt army3
	unit_group_move_to_missile_range_of_unit army3 General2 run
	set_counter army3_run 0
end_monitor
	
monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1	
	and I_UnitDistanceFromUnit General3 General2 < 180
	and I_UnitEnemyUnitInRadius General2 100

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_UnitDistanceFromUnit General3 General2 < 100

	set_counter label2_ready 0		
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1	
	and I_PercentageUnitKilled General3 > 60

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_UnitDistanceFromUnit General3 General1 < 200
	and I_UnitDistanceFromUnit General2 General1 < 200

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1	
	and I_PercentageUnitGroupKilled army3 > 50

	set_counter label2_ready 0		
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_UnitDistanceFromUnit General3 General2 < 250
	and I_UnitGroupInRangeOfUnit army3 General2

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_UnitDistanceFromUnit General2 General3 < 250
	and I_IsUnitIdle General3

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_IsUnitRouting General2

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_PercentageUnitKilled General2 > 80

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label2_ready = 1
	and I_UnitDistanceFromUnit General2 General3 < 250
	and I_IsUnitUnderFire General3

	set_counter label2_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor
	
;;;;;;;;;;;Defending Siege;;;;;;;;;;;;;;

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and I_CompareCounter label4_ready = 1	
	and I_CompareCounter army_moving = 0
	and ! I_UnitEnemyUnitInRadius General3 160
	and ! I_UnitGroupInRangeOfUnitGroup army3 army2
		
	set_counter army3_run_siege 1
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1
	and I_CompareCounter army_moving = 1	
	and I_UnitEnemyUnitInRadius General3 160
	
	unit_group_order_halt army3	
	ai_active_set on
	set_counter army_moving 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1
	and I_CompareCounter army_moving = 1
	and ! I_UnitEnemyUnitInRadius General3 160
	and I_UnitDistanceFromUnit General2 General3 > 150
	and I_IsUnitIdle General3

	set_counter army3_run_siege 1
	battle_wait 2
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter army3_run_siege = 1

	label_unit 1 1 0 General3
	label_unit 1 1 1 unit39
	label_unit 1 1 2 unit40
	label_unit 1 1 3 unit41
	label_unit 1 1 4 unit42
	label_unit 1 1 5 unit43
	label_unit 1 1 6 unit44
	label_unit 1 1 7 unit45
	label_unit 1 1 8 unit46
	label_unit 1 1 9 unit47
	label_unit 1 1 10 unit48
	label_unit 1 1 11 unit49
	label_unit 1 1 12 unit50
	label_unit 1 1 13 unit51
	label_unit 1 1 14 unit52
	label_unit 1 1 15 unit53
	label_unit 1 1 16 unit54
	label_unit 1 1 17 unit55
	label_unit 1 1 18 unit56
	label_unit 1 1 19 unit57

	unit_group_order_halt army3
	unit_group_order_move_formed army3 1 1 run
	set_counter army3_run_siege 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1	
	and I_UnitDistanceFromUnit General3 General2 < 200

	set_counter label4_ready 0
	unit_group_order_halt army3		
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1	
	and I_UnitDistanceFromPosition General3 1 1 < 150

	set_counter label4_ready 0		
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1
	and I_UnitDistanceFromUnit General2 General3 < 250
	and I_IsUnitIdle General3

	set_counter label4_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1
	and I_UnitDistanceFromUnit General2 General3 < 250
	and I_IsUnitUnderFire General3

	set_counter label4_ready 0	
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label4_ready = 1	
	and I_PercentageUnitGroupKilled army3 > 50

	set_counter label4_ready 0		
	unit_group_order_halt army3	
	ai_active_set on
end_monitor

;;;;;;;;Attacking;;;;;;;;;

monitor_conditions I_InBattle
	and I_CompareCounter reinf_arrive2 = 1
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_ConflictType Siege
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType FailedAmbush
	
	set_counter label5_ready 1
	set_counter reinf_arrive2 0
	battle_wait 90
	set_counter reinf_late 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1	
	and I_CompareCounter army_moving = 0
	and ! I_UnitEnemyUnitInRadius General4 160
	and ! I_UnitGroupInRangeOfUnitGroup army4 army1
	
	set_counter army4_run 1
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter army_moving = 1	
	and I_UnitEnemyUnitInRadius General4 160
	and ! I_UnitGroupInRangeOfUnitGroup army4 army1
	
	unit_group_order_halt army4	
	ai_active_set on
	set_counter army_moving 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter reinf_late = 1
	and I_CompareCounter label5_ready = 1
	and ! I_UnitEnemyUnitInRadius General4 160
	and ! I_UnitGroupInRangeOfUnitGroup army4 army1
	
	set_counter army4_run 1
	set_counter army_moving 1
	set_counter reinf_late 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter army_moving = 1
	and ! I_UnitEnemyUnitInRadius General4 160
	and I_UnitDistanceFromUnit General1 General4 > 150
	and I_IsUnitIdle General4

	set_counter reinf_late 1
	battle_wait 2
	set_counter army_moving 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter distance_trigger1 = 0
	and I_UnitDistanceFromUnit General4 General1 < 1000

	set_counter reinf_late 1
	set_counter distance_trigger1 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter distance_trigger2 = 0
	and I_UnitDistanceFromUnit General4 General1 < 750

	set_counter reinf_late 1
	set_counter distance_trigger2 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter distance_trigger3 = 0
	and I_UnitDistanceFromUnit General4 General1 < 500

	set_counter reinf_late 1
	set_counter distance_trigger3 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter distance_trigger4 = 0
	and I_UnitDistanceFromUnit General4 General1 < 300

	set_counter reinf_late 1
	set_counter distance_trigger4 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_CompareCounter distance_trigger5 = 0
	and I_UnitDistanceFromUnit General4 General1 < 200

	set_counter reinf_late 1
	set_counter distance_trigger5 1
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter army4_run = 1

	label_unit 0 1 0 General4
	label_unit 0 1 1 unit58
	label_unit 0 1 2 unit59
	label_unit 0 1 3 unit60
	label_unit 0 1 4 unit61
	label_unit 0 1 5 unit62
	label_unit 0 1 6 unit63
	label_unit 0 1 7 unit64
	label_unit 0 1 8 unit65
	label_unit 0 1 9 unit66
	label_unit 0 1 10 unit67
	label_unit 0 1 11 unit68
	label_unit 0 1 12 unit69
	label_unit 0 1 13 unit70
	label_unit 0 1 14 unit71
	label_unit 0 1 15 unit72
	label_unit 0 1 16 unit73
	label_unit 0 1 17 unit74
	label_unit 0 1 18 unit75
	label_unit 0 1 19 unit76
	
	unit_group_order_halt army4
	unit_group_move_to_missile_range_of_unit army4 General1 run
	set_counter army4_run 0
end_monitor
	
monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1	
	and I_UnitDistanceFromUnit General4 General1 < 150
	and I_UnitEnemyUnitInRadius General1 100

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_UnitDistanceFromUnit General4 General1 < 100

	set_counter label5_ready 0		
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1	
	and I_PercentageUnitKilled General4 > 60

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_UnitDistanceFromUnit General4 General2 < 200
	and I_UnitDistanceFromUnit General1 General2 < 200

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1	
	and I_PercentageUnitGroupKilled army4 > 50

	set_counter label5_ready 0		
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_UnitDistanceFromUnit General4 General1 < 250
	and I_UnitGroupInRangeOfUnit army4 General1

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_UnitDistanceFromUnit General1 General4 < 250
	and I_IsUnitIdle General4
		
	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_IsUnitRouting General1

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_PercentageUnitKilled General1 > 80

	set_counter label5_ready 0	
	unit_group_order_halt army4	
	ai_active_set on
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter label5_ready = 1
	and I_UnitDistanceFromUnit General1 General4 < 250
	and I_IsUnitUnderFire General4

	set_counter label5_ready 0
	unit_group_order_halt army4	
	ai_active_set on
end_monitor	

;################## Germanicu5 Integrated Stakes script v0.5 ###########################

monitor_conditions I_BattleStarted
	and I_CompareCounter label_ready = 1
	and I_BattlePlayerArmyIsAttacker
        and ! I_BattleAiAttacking
	and ! I_ConflictType SuccessfulAmbush
	and ! I_ConflictType Siege
	and ! I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
	and I_UnitEnemyUnitInRadius General2 115

	set_counter stakes_on 1
	set_counter label_ready 0
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter label_ready = 1
	and I_BattlePlayerArmyIsAttacker
        and ! I_BattleAiAttacking
	and I_BattleIsSallyOutBattle
	and I_BattleSettlementFortificationLevel < 3
	and I_IsBattleSettlementCastle
	and I_BattlePlayerAllianceOddsAgainst < 2.0
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines < 4
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
	and I_UnitEnemyUnitInRadius General2 115

	set_counter stakes_on 1
	set_counter label_ready 0
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter label_ready = 1
	and I_BattlePlayerArmyIsAttacker
        and ! I_BattleAiAttacking
	and I_BattleIsSallyOutBattle
	and I_BattleSettlementFortificationLevel > 2
	and I_IsBattleSettlementCastle
	and I_BattlePlayerAllianceOddsAgainst < 2.5
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines < 5
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
	and I_UnitEnemyUnitInRadius General2 115

	set_counter stakes_on 1
	set_counter label_ready 0
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter label_ready = 1
	and I_BattlePlayerArmyIsAttacker
        and ! I_BattleAiAttacking
	and I_BattleIsSallyOutBattle
	and I_BattleSettlementFortificationLevel < 3
	and ! I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines < 3
	and I_BattlePlayerAllianceOddsAgainst < 1.7
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
	and I_UnitEnemyUnitInRadius General2 115

	set_counter stakes_on 1
	set_counter label_ready 0
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter label_ready = 1
	and I_BattlePlayerArmyIsAttacker
        and ! I_BattleAiAttacking
	and I_BattleIsSallyOutBattle
	and I_BattleSettlementFortificationLevel > 2
	and ! I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines < 4
	and I_BattlePlayerAllianceOddsAgainst < 2.2
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
	and I_UnitEnemyUnitInRadius General2 115

	set_counter stakes_on 1
	set_counter label_ready 0
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter stakes_on = 1
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0

	ai_active_set off
 	
	unit_group_order_halt army2

	unit_deploy_stakes General2
	unit_deploy_stakes unit20
	unit_deploy_stakes unit21
	unit_deploy_stakes unit22
	unit_deploy_stakes unit23
	unit_deploy_stakes unit24
	unit_deploy_stakes unit25
	unit_deploy_stakes unit26
	unit_deploy_stakes unit27
	unit_deploy_stakes unit28
	unit_deploy_stakes unit29
	unit_deploy_stakes unit30
	unit_deploy_stakes unit31
	unit_deploy_stakes unit32
	unit_deploy_stakes unit33
	unit_deploy_stakes unit34
	unit_deploy_stakes unit35
	unit_deploy_stakes unit36
	unit_deploy_stakes unit37
	unit_deploy_stakes unit38
	
	ai_active_set on
	set_counter stakes_on 0
end_monitor

monitor_event BattleConflictPhaseCommenced FactionIsLocal
	and I_BattlePlayerArmyIsAttacker
	and I_ConflictType Siege
	and I_CompareCounter label_ready = 1 
	and I_BattlePlayerArmyNumberOfUnitCategory cavalry > 0
	and I_BattleEnemyArmyNumberOfUnitCategory cavalry = 0
	and I_BattleEnemyArmyNumberOfAttribute stakes > 0
		
	unit_deploy_stakes General2
	unit_deploy_stakes unit20
	unit_deploy_stakes unit21
	unit_deploy_stakes unit22
	unit_deploy_stakes unit23
	unit_deploy_stakes unit24
	unit_deploy_stakes unit25
	unit_deploy_stakes unit26
	unit_deploy_stakes unit27
	unit_deploy_stakes unit28
	unit_deploy_stakes unit29
	unit_deploy_stakes unit30
	unit_deploy_stakes unit31
	unit_deploy_stakes unit32
	unit_deploy_stakes unit33
	unit_deploy_stakes unit34
	unit_deploy_stakes unit35
	unit_deploy_stakes unit36
	unit_deploy_stakes unit37
	unit_deploy_stakes unit38
	
	ai_active_set on
	set_counter label_ready 0
end_monitor

;;;;;;;;HA fix;;;;;;;;;;;;

monitor_conditions I_InBattle
	and I_CompareCounter ha_fix = 1
	and ! I_ConflictType Siege
	and I_BattlePlayerArmyIsAttacker
	and ! I_BattleIsSallyOutBattle
   	and ! I_BattleAiAttacking
	and I_BattleEnemyArmyPercentageOfUnitCategory cavalry > 60
	and I_UnitEnemyUnitInRadius General2 250
	
	ai_gta_plan_set 1 ATTACK_ALL
	set_counter ha_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter ha_fix = 1
	and ! I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_BattleIsSallyOutBattle
	and ! I_BattleIsRiverBattle
   	and ! I_BattleAiAttacking
;	and I_BattleEnemyArmyPercentageOfUnitCategory cavalry > 60
	
	ai_gta_plan_set 0 ATTACK_ALL
	set_counter ha_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter ha_fix = 1
	and I_BattleIsRiverBattle
	and ! I_BattlePlayerArmyIsAttacker
   	and ! I_BattleAiAttacking
;	and I_BattleEnemyArmyPercentageOfUnitCategory cavalry >= 60
	
	ai_gta_add_objective 0 ASSAULT_CROSSING 999

	ai_active_set off


	if I_BattleEnemyArmyNumberOfUnits > 0
	ai_gta_add_unit_label 0 0 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	ai_gta_add_unit_label 0 0 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	ai_gta_add_unit_label 0 0 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	ai_gta_add_unit_label 0 0 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	ai_gta_add_unit_label 0 0 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	ai_gta_add_unit_label 0 0 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	ai_gta_add_unit_label 0 0 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	ai_gta_add_unit_label 0 0 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	ai_gta_add_unit_label 0 0 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	ai_gta_add_unit_label 0 0 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	ai_gta_add_unit_label 0 0 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	ai_gta_add_unit_label 0 0 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	ai_gta_add_unit_label 0 0 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	ai_gta_add_unit_label 0 0 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	ai_gta_add_unit_label 0 0 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	ai_gta_add_unit_label 0 0 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	ai_gta_add_unit_label 0 0 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	ai_gta_add_unit_label 0 0 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	ai_gta_add_unit_label 0 0 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_gta_add_unit_label 0 0 unit19
	end_if

	ai_active_set on

	set_counter ha_fix 0
end_monitor

;;;;;;;;Elephant;;;;;;;;;;;;

monitor_conditions I_InBattle
	and I_CompareCounter elephant_fix = 1
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
	and ! I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0

	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
	ai_active_set off

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General1 = horde
	ai_gta_add_unit_label 0 0 General1
;	remove_unit_from_group army1 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit1 = horde
	ai_gta_add_unit_label 0 0 unit1
;	remove_unit_from_group army1 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit2 = horde
	ai_gta_add_unit_label 0 0 unit2
;	remove_unit_from_group army1 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit3 = horde
	ai_gta_add_unit_label 0 0 unit3
;	remove_unit_from_group army1 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit4 = horde
	ai_gta_add_unit_label 0 0 unit4
;	remove_unit_from_group army1 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit5 = horde
	ai_gta_add_unit_label 0 0 unit5
;	remove_unit_from_group army1 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit6 = horde
	ai_gta_add_unit_label 0 0 unit6
;	remove_unit_from_group army1 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit7 = horde
	ai_gta_add_unit_label 0 0 unit7
;	remove_unit_from_group army1 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit8 = horde
	ai_gta_add_unit_label 0 0 unit8
;	remove_unit_from_group army1 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit9 = horde
	ai_gta_add_unit_label 0 0 unit9
;	remove_unit_from_group army1 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit10 = horde
	ai_gta_add_unit_label 0 0 unit10
;	remove_unit_from_group army1 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit11 = horde
	ai_gta_add_unit_label 0 0 unit11
;	remove_unit_from_group army1 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit12 = horde
	ai_gta_add_unit_label 0 0 unit12
;	remove_unit_from_group army1 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit13 = horde
	ai_gta_add_unit_label 0 0 unit13
;	remove_unit_from_group army1 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit14 = horde
	ai_gta_add_unit_label 0 0 unit14
;	remove_unit_from_group army1 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit15 = horde
	ai_gta_add_unit_label 0 0 unit15
;	remove_unit_from_group army1 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit16 = horde
	ai_gta_add_unit_label 0 0 unit16
;	remove_unit_from_group army1 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit17 = horde
	ai_gta_add_unit_label 0 0 unit17
;	remove_unit_from_group army1 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit18 = horde
	ai_gta_add_unit_label 0 0 unit18
;	remove_unit_from_group army1 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit19 = horde
	ai_gta_add_unit_label 0 0 unit19
;	remove_unit_from_group army1 unit19
	end_if

	ai_active_set on
	set_counter elephant_gate 1
	set_counter elephant_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter elephant_fix = 1
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0

	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
	ai_active_set off
	unit_group_order_halt army1

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General1 = horde
	ai_gta_add_unit_label 0 0 General1
;	remove_unit_from_group army1 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit1 = horde
	ai_gta_add_unit_label 0 0 unit1
;	remove_unit_from_group army1 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit2 = horde
	ai_gta_add_unit_label 0 0 unit2
;	remove_unit_from_group army1 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit3 = horde
	ai_gta_add_unit_label 0 0 unit3
;	remove_unit_from_group army1 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit4 = horde
	ai_gta_add_unit_label 0 0 unit4
;	remove_unit_from_group army1 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit5 = horde
	ai_gta_add_unit_label 0 0 unit5
;	remove_unit_from_group army1 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit6 = horde
	ai_gta_add_unit_label 0 0 unit6
;	remove_unit_from_group army1 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit7 = horde
	ai_gta_add_unit_label 0 0 unit7
;	remove_unit_from_group army1 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit8 = horde
	ai_gta_add_unit_label 0 0 unit8
;	remove_unit_from_group army1 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit9 = horde
	ai_gta_add_unit_label 0 0 unit9
;	remove_unit_from_group army1 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit10 = horde
	ai_gta_add_unit_label 0 0 unit10
;	remove_unit_from_group army1 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit11 = horde
	ai_gta_add_unit_label 0 0 unit11
;	remove_unit_from_group army1 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit12 = horde
	ai_gta_add_unit_label 0 0 unit12
;	remove_unit_from_group army1 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit13 = horde
	ai_gta_add_unit_label 0 0 unit13
;	remove_unit_from_group army1 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit14 = horde
	ai_gta_add_unit_label 0 0 unit14
;	remove_unit_from_group army1 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit15 = horde
	ai_gta_add_unit_label 0 0 unit15
;	remove_unit_from_group army1 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit16 = horde
	ai_gta_add_unit_label 0 0 unit16
;	remove_unit_from_group army1 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit17 = horde
	ai_gta_add_unit_label 0 0 unit17
;	remove_unit_from_group army1 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit18 = horde
	ai_gta_add_unit_label 0 0 unit18
;	remove_unit_from_group army1 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit19 = horde
	ai_gta_add_unit_label 0 0 unit19
;	remove_unit_from_group army1 unit19
	end_if

	unit_group_order_halt army1
	unit_group_order_change_group_formation army1 ai_wall_assault
	battle_wait 180

	ai_active_set on
	set_counter elephant_gate 1
	set_counter elephant_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter elephant_fix = 1
	and I_ConflictType Siege
	and I_BattleIsFortBattle
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0

	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
	ai_active_set off

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General1 = horde
	ai_gta_add_unit_label 0 0 General1
	remove_unit_from_group army1 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit1 = horde
	ai_gta_add_unit_label 0 0 unit1
	remove_unit_from_group army1 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit2 = horde
	ai_gta_add_unit_label 0 0 unit2
	remove_unit_from_group army1 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit3 = horde
	ai_gta_add_unit_label 0 0 unit3
	remove_unit_from_group army1 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit4 = horde
	ai_gta_add_unit_label 0 0 unit4
	remove_unit_from_group army1 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit5 = horde
	ai_gta_add_unit_label 0 0 unit5
	remove_unit_from_group army1 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit6 = horde
	ai_gta_add_unit_label 0 0 unit6
	remove_unit_from_group army1 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit7 = horde
	ai_gta_add_unit_label 0 0 unit7
	remove_unit_from_group army1 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit8 = horde
	ai_gta_add_unit_label 0 0 unit8
	remove_unit_from_group army1 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit9 = horde
	ai_gta_add_unit_label 0 0 unit9
	remove_unit_from_group army1 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit10 = horde
	ai_gta_add_unit_label 0 0 unit10
	remove_unit_from_group army1 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit11 = horde
	ai_gta_add_unit_label 0 0 unit11
	remove_unit_from_group army1 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit12 = horde
	ai_gta_add_unit_label 0 0 unit12
	remove_unit_from_group army1 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit13 = horde
	ai_gta_add_unit_label 0 0 unit13
	remove_unit_from_group army1 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit14 = horde
	ai_gta_add_unit_label 0 0 unit14
	remove_unit_from_group army1 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit15 = horde
	ai_gta_add_unit_label 0 0 unit15
	remove_unit_from_group army1 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit16 = horde
	ai_gta_add_unit_label 0 0 unit16
	remove_unit_from_group army1 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit17 = horde
	ai_gta_add_unit_label 0 0 unit17
	remove_unit_from_group army1 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit18 = horde
	ai_gta_add_unit_label 0 0 unit18
	remove_unit_from_group army1 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit19 = horde
	ai_gta_add_unit_label 0 0 unit19
	remove_unit_from_group army1 unit19
	end_if

	ai_active_set on
	set_counter elephant_gate 1
	set_counter elephant_fix 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter elephant_gate = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	set_counter elephant_gate 0
	set_counter rally_walls 1
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter elephant_gate = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	set_counter elephant_gate 0
	set_counter rally_walls 1
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter elephant_gate = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	ai_gta_del_objective 0

	set_counter elephant_gate 2
	set_counter rally_walls 0
end_monitor

monitor_event BattleEnemyUnitAttacksPlayerUnit BattleIsMeleeAttack
	and I_CompareCounter rally_walls = 1

	if I_CompareCounter elephant_gate != 2
	set_counter elephant_gate 0
	set_counter del_objective 1
	end_if
	battle_wait 180
	set_counter elephant_gate_tier2 1
	set_counter rally_walls 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter del_objective = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	battle_wait 15
	ai_gta_del_objective 0
	ai_active_set off
	battle_wait 1
	ai_active_set on
	set_counter del_objective 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter elephant_gate_tier2 = 1
	and ! I_BattleIsFortBattle
	and I_ConflictType Siege
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General1 = horde
	ai_gta_add_unit_label 0 0 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit1 = horde
	ai_gta_add_unit_label 0 0 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit2 = horde
	ai_gta_add_unit_label 0 0 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit3 = horde
	ai_gta_add_unit_label 0 0 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit4 = horde
	ai_gta_add_unit_label 0 0 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit5 = horde
	ai_gta_add_unit_label 0 0 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit6 = horde
	ai_gta_add_unit_label 0 0 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit7 = horde
	ai_gta_add_unit_label 0 0 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit8 = horde
	ai_gta_add_unit_label 0 0 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit9 = horde
	ai_gta_add_unit_label 0 0 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit10 = horde
	ai_gta_add_unit_label 0 0 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit11 = horde
	ai_gta_add_unit_label 0 0 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit12 = horde
	ai_gta_add_unit_label 0 0 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit13 = horde
	ai_gta_add_unit_label 0 0 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit14 = horde
	ai_gta_add_unit_label 0 0 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit15 = horde
	ai_gta_add_unit_label 0 0 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit16 = horde
	ai_gta_add_unit_label 0 0 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit17 = horde
	ai_gta_add_unit_label 0 0 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit18 = horde
	ai_gta_add_unit_label 0 0 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit19 = horde
	ai_gta_add_unit_label 0 0 unit19
	end_if

	ai_active_set on
	set_counter second_ring 1
	set_counter elephant_gate_tier2 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter second_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter second_ring 0
	set_counter rally_walls 2
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter second_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter second_ring 0
	set_counter rally_walls 2
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter second_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	ai_gta_del_objective 0

	set_counter second_ring 2
	set_counter rally_walls 2
end_monitor

monitor_event BattleEnemyUnitAttacksPlayerUnit BattleIsMeleeAttack
	and I_CompareCounter rally_walls = 2

	if I_CompareCounter second_ring != 2
	set_counter second_ring 0
	set_counter del_objective 1
	end_if
	battle_wait 180
	set_counter elephant_gate_tier3 1
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter elephant_gate_tier3 = 1
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General1 = horde
	ai_gta_add_unit_label 0 0 General1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit1 = horde
	ai_gta_add_unit_label 0 0 unit1
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit2 = horde
	ai_gta_add_unit_label 0 0 unit2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit3 = horde
	ai_gta_add_unit_label 0 0 unit3
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit4 = horde
	ai_gta_add_unit_label 0 0 unit4
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit5 = horde
	ai_gta_add_unit_label 0 0 unit5
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit6 = horde
	ai_gta_add_unit_label 0 0 unit6
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit7 = horde
	ai_gta_add_unit_label 0 0 unit7
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit8 = horde
	ai_gta_add_unit_label 0 0 unit8
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit9 = horde
	ai_gta_add_unit_label 0 0 unit9
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit10 = horde
	ai_gta_add_unit_label 0 0 unit10
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit11 = horde
	ai_gta_add_unit_label 0 0 unit11
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit12 = horde
	ai_gta_add_unit_label 0 0 unit12
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit13 = horde
	ai_gta_add_unit_label 0 0 unit13
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit14 = horde
	ai_gta_add_unit_label 0 0 unit14
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit15 = horde
	ai_gta_add_unit_label 0 0 unit15
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit16 = horde
	ai_gta_add_unit_label 0 0 unit16
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit17 = horde
	ai_gta_add_unit_label 0 0 unit17
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit18 = horde
	ai_gta_add_unit_label 0 0 unit18
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit19 = horde
	ai_gta_add_unit_label 0 0 unit19
	end_if

	ai_active_set on
	set_counter third_ring 1
	set_counter elephant_gate_tier3 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter third_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring 0
	set_counter del_objective 1
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter third_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring 0
	set_counter del_objective 1
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter third_ring = 1
	and I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring 0
	set_counter del_objective 1
end_monitor


;;;;;;;;Sally-Out Elephant;;;;;;;;;;;;

monitor_conditions I_InBattle
	and I_CompareCounter elephant_fix = 1
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0

	set_counter sally-out_fix 1
	ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General2 = horde
	ai_gta_add_unit_label 1 0 General2
;	remove_unit_from_group army2 General2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit20 = horde
	ai_gta_add_unit_label 1 0 unit20
;	remove_unit_from_group army2 unit20
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit21 = horde
	ai_gta_add_unit_label 1 0 unit21
;	remove_unit_from_group army2 unit21
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit22 = horde
	ai_gta_add_unit_label 1 0 unit22
;	remove_unit_from_group army2 unit22
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit23 = horde
	ai_gta_add_unit_label 1 0 unit23
;	remove_unit_from_group army2 unit23
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit24 = horde
	ai_gta_add_unit_label 1 0 unit24
;	remove_unit_from_group army2 unit24
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit25 = horde
	ai_gta_add_unit_label 1 0 unit25
;	remove_unit_from_group army2 unit25
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit26 = horde
	ai_gta_add_unit_label 1 0 unit26
;	remove_unit_from_group army2 unit26
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit27 = horde
	ai_gta_add_unit_label 1 0 unit27
;	remove_unit_from_group army2 unit27
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit28 = horde
	ai_gta_add_unit_label 1 0 unit28
;	remove_unit_from_group army2 unit28
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit29 = horde
	ai_gta_add_unit_label 1 0 unit29
;	remove_unit_from_group army2 unit29
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit30 = horde
	ai_gta_add_unit_label 1 0 unit30
;	remove_unit_from_group army2 unit30
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit31 = horde
	ai_gta_add_unit_label 1 0 unit31
;	remove_unit_from_group army2 unit31
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit32 = horde
	ai_gta_add_unit_label 1 0 unit32
;	remove_unit_from_group army2 unit32
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit33 = horde
	ai_gta_add_unit_label 1 0 unit33
;	remove_unit_from_group army2 unit33
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit34 = horde
	ai_gta_add_unit_label 1 0 unit34
;	remove_unit_from_group army2 unit34
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit35 = horde
	ai_gta_add_unit_label 1 0 unit35
;	remove_unit_from_group army2 unit35
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit36 = horde
	ai_gta_add_unit_label 1 0 unit36
;	remove_unit_from_group army2 unit36
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit37 = horde
	ai_gta_add_unit_label 1 0 unit37
;	remove_unit_from_group army2 unit37
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit38 = horde
	ai_gta_add_unit_label 1 0 unit38
;	remove_unit_from_group army2 unit38
	end_if

	ai_active_set on
	set_counter elephant_gate2 1
	set_counter elephant_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter elephant_fix = 1
	and I_BattleIsSallyOutBattle
	and I_BattleIsFortBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0

	set_counter sally-out_fix 1
	ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General2 = horde
	ai_gta_add_unit_label 1 0 General2
	remove_unit_from_group army2 General2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit20 = horde
	ai_gta_add_unit_label 1 0 unit20
	remove_unit_from_group army2 unit20
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit21 = horde
	ai_gta_add_unit_label 1 0 unit21
	remove_unit_from_group army2 unit21
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit22 = horde
	ai_gta_add_unit_label 1 0 unit22
	remove_unit_from_group army2 unit22
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit23 = horde
	ai_gta_add_unit_label 1 0 unit23
	remove_unit_from_group army2 unit23
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit24 = horde
	ai_gta_add_unit_label 1 0 unit24
	remove_unit_from_group army2 unit24
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit25 = horde
	ai_gta_add_unit_label 1 0 unit25
	remove_unit_from_group army2 unit25
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit26 = horde
	ai_gta_add_unit_label 1 0 unit26
	remove_unit_from_group army2 unit26
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit27 = horde
	ai_gta_add_unit_label 1 0 unit27
	remove_unit_from_group army2 unit27
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit28 = horde
	ai_gta_add_unit_label 1 0 unit28
	remove_unit_from_group army2 unit28
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit29 = horde
	ai_gta_add_unit_label 1 0 unit29
	remove_unit_from_group army2 unit29
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit30 = horde
	ai_gta_add_unit_label 1 0 unit30
	remove_unit_from_group army2 unit30
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit31 = horde
	ai_gta_add_unit_label 1 0 unit31
	remove_unit_from_group army2 unit31
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit32 = horde
	ai_gta_add_unit_label 1 0 unit32
	remove_unit_from_group army2 unit32
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit33 = horde
	ai_gta_add_unit_label 1 0 unit33
	remove_unit_from_group army2 unit33
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit34 = horde
	ai_gta_add_unit_label 1 0 unit34
	remove_unit_from_group army2 unit34
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit35 = horde
	ai_gta_add_unit_label 1 0 unit35
	remove_unit_from_group army2 unit35
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit36 = horde
	ai_gta_add_unit_label 1 0 unit36
	remove_unit_from_group army2 unit36
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit37 = horde
	ai_gta_add_unit_label 1 0 unit37
	remove_unit_from_group army2 unit37
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit38 = horde
	ai_gta_add_unit_label 1 0 unit38
	remove_unit_from_group army2 unit38
	end_if

	ai_active_set on
	set_counter elephant_gate2 1
	set_counter elephant_fix 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter elephant_gate2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	set_counter elephant_gate2 0
	set_counter rally_walls2 1
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter elephant_gate2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	set_counter elephant_gate2 0
	set_counter rally_walls2 1
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter elephant_gate2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	ai_gta_del_objective 1

	set_counter elephant_gate2 2
	set_counter rally_walls2 1
end_monitor

monitor_event BattleEnemyUnitAttacksPlayerUnit BattleIsMeleeAttack
	and I_CompareCounter rally_walls2 = 1

	if I_CompareCounter elephant_gate2 != 2
	set_counter elephant_gate2 0
	set_counter del_objective2 1
	end_if
	battle_wait 180
	set_counter elephant_gate_tier2s 1
	set_counter rally_walls2 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter del_objective2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	battle_wait 15
	ai_gta_del_objective 1
	ai_active_set off
	battle_wait 1
	ai_active_set on
	set_counter del_objective2 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter elephant_gate_tier2s = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General2 = horde
	ai_gta_add_unit_label 1 0 General2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit20 = horde
	ai_gta_add_unit_label 1 0 unit20
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit21 = horde
	ai_gta_add_unit_label 1 0 unit21
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit22 = horde
	ai_gta_add_unit_label 1 0 unit22
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit23 = horde
	ai_gta_add_unit_label 1 0 unit23
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit24 = horde
	ai_gta_add_unit_label 1 0 unit24
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit25 = horde
	ai_gta_add_unit_label 1 0 unit25
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit26 = horde
	ai_gta_add_unit_label 1 0 unit26
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit27 = horde
	ai_gta_add_unit_label 1 0 unit27
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit28 = horde
	ai_gta_add_unit_label 1 0 unit28
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit29 = horde
	ai_gta_add_unit_label 1 0 unit29
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit30 = horde
	ai_gta_add_unit_label 1 0 unit30
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit31 = horde
	ai_gta_add_unit_label 1 0 unit31
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit32 = horde
	ai_gta_add_unit_label 1 0 unit32
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit33 = horde
	ai_gta_add_unit_label 1 0 unit33
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit34 = horde
	ai_gta_add_unit_label 1 0 unit34
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit35 = horde
	ai_gta_add_unit_label 1 0 unit35
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit36 = horde
	ai_gta_add_unit_label 1 0 unit36
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit37 = horde
	ai_gta_add_unit_label 1 0 unit37
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit38 = horde
	ai_gta_add_unit_label 1 0 unit38
	end_if

	ai_active_set on
	set_counter second_ring2 1
	set_counter elephant_gate_tier2s 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter second_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter second_ring2 0
	set_counter rally_walls2 2
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter second_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter second_ring2 0
	set_counter rally_walls2 2
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter second_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0
	and I_BattleSettlementFortificationLevel > 2 

	ai_gta_del_objective 1

	set_counter second_ring2 2
	set_counter rally_walls2 2
end_monitor

monitor_event BattleEnemyUnitAttacksPlayerUnit BattleIsMeleeAttack
	and I_CompareCounter rally_walls2 = 2

	if I_CompareCounter second_ring2 != 2
	set_counter second_ring2 0
	set_counter del_objective2 1
	end_if
	battle_wait 180
	set_counter elephant_gate_tier3s 1
	set_counter rally_walls2 0
end_monitor

monitor_conditions I_InBattle 
	and I_CompareCounter elephant_gate_tier3s = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 

	ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation General2 = horde
	ai_gta_add_unit_label 1 0 General2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_UnitFormation unit20 = horde
	ai_gta_add_unit_label 1 0 unit20
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_UnitFormation unit21 = horde
	ai_gta_add_unit_label 1 0 unit21
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_UnitFormation unit22 = horde
	ai_gta_add_unit_label 1 0 unit22
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_UnitFormation unit23 = horde
	ai_gta_add_unit_label 1 0 unit23
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_UnitFormation unit24 = horde
	ai_gta_add_unit_label 1 0 unit24
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_UnitFormation unit25 = horde
	ai_gta_add_unit_label 1 0 unit25
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_UnitFormation unit26 = horde
	ai_gta_add_unit_label 1 0 unit26
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_UnitFormation unit27 = horde
	ai_gta_add_unit_label 1 0 unit27
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_UnitFormation unit28 = horde
	ai_gta_add_unit_label 1 0 unit28
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_UnitFormation unit29 = horde
	ai_gta_add_unit_label 1 0 unit29
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_UnitFormation unit30 = horde
	ai_gta_add_unit_label 1 0 unit30
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_UnitFormation unit31 = horde
	ai_gta_add_unit_label 1 0 unit31
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_UnitFormation unit32 = horde
	ai_gta_add_unit_label 1 0 unit32
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_UnitFormation unit33 = horde
	ai_gta_add_unit_label 1 0 unit33
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_UnitFormation unit34 = horde
	ai_gta_add_unit_label 1 0 unit34
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_UnitFormation unit35 = horde
	ai_gta_add_unit_label 1 0 unit35
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_UnitFormation unit36 = horde
	ai_gta_add_unit_label 1 0 unit36
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_UnitFormation unit37 = horde
	ai_gta_add_unit_label 1 0 unit37
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_UnitFormation unit38 = horde
	ai_gta_add_unit_label 1 0 unit38
	end_if
	ai_active_set on
	set_counter third_ring2 1
	set_counter elephant_gate_tier3s 0
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter third_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring2 0
	set_counter del_objective2 1
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter third_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring2 0
	set_counter del_objective2 1
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter third_ring2 = 1
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfMountClass elephant > 0 
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel > 2

	set_counter third_ring2 0
	set_counter del_objective2 1
end_monitor

;;;;;;;Sally Out
monitor_conditions I_InBattle
	and I_CompareCounter sally-out_fix = 1
	and ! I_BattleIsFortBattle
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleSettlementFortificationLevel < 3
	and I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines > 2
	and I_BattlePlayerAllianceOddsAgainst > 2.0

	ai_gta_plan_set 1 ATTACK_SETTLEMENT
	ai_active_set on
	set_counter army2_sally 1
	set_counter sally-out_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter sally-out_fix = 1
	and ! I_BattleIsFortBattle
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleSettlementFortificationLevel > 2
	and I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines > 3
	and I_BattlePlayerAllianceOddsAgainst > 2.5

	ai_active_set on
	ai_gta_plan_set 1 ATTACK_SETTLEMENT
	set_counter army2_sally 1
	set_counter sally-out_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter sally-out_fix = 1
	and ! I_BattleIsFortBattle
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleSettlementFortificationLevel < 3
	and ! I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines > 2
	and I_BattlePlayerAllianceOddsAgainst > 1.7

	ai_active_set on
	ai_gta_plan_set 1 ATTACK_SETTLEMENT
	set_counter army2_sally 1
	set_counter sally-out_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter sally-out_fix = 1
	and ! I_BattleIsFortBattle
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleSettlementFortificationLevel > 2
	and ! I_IsBattleSettlementCastle
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines > 3
	and I_BattlePlayerAllianceOddsAgainst > 2.2

	ai_active_set on
	ai_gta_plan_set 1 ATTACK_SETTLEMENT

	set_counter army2_sally 1
	set_counter sally-out_fix 0
end_monitor

monitor_conditions I_InBattle
	and I_CompareCounter sally-out_fix = 1
	and I_BattleIsFortBattle
	and I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfSpecialAbility drop_engines > 2
	and I_BattlePlayerAllianceOddsAgainst > 1.8

	ai_active_set on
	ai_gta_plan_set 1 ATTACK_SETTLEMENT
	set_counter army2_sally 1
	set_counter sally-out_fix 0
end_monitor

;################## Germanicu5 Integrated Protect General script v0.15 ###########################

monitor_event BattleConflictPhaseCommenced FactionIsLocal
	and I_BattleEnemyArmyNumberOfMountClass elephant = 0
	and I_BattleEnemyArmyNumberOfUnits > 4
	battle_wait 1

 	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfSpecialAbility rally > 0
 	set_counter protect_general 1
	end_if

 	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_BattleEnemyArmyNumberOfSpecialAbility rally > 0
 	set_counter protect_general 1
	end_if
end_monitor

monitor_event BattleBattleGatesDestroyedByEngine TrueCondition
	and I_CompareCounter protect_general = 1

	set_counter protect_general 0
 	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if

 	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if
end_monitor

monitor_event BattleWallsCaptured TrueCondition
	and I_CompareCounter protect_general = 1

	set_counter protect_general 0
 	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if

 	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if
end_monitor

monitor_event BattleWallsBreachedByEngine TrueCondition
	and I_CompareCounter protect_general = 1

	set_counter protect_general 0
 	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if

 	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	set_counter general_wait 1
	end_if
end_monitor

monitor_conditions I_BattleStarted
 	and I_ConflictType Siege
	and I_CompareCounter general_wait = 1
	and I_IsUnitMoveFastSet General1
	and I_BattleEnemyArmyNumberOfUnitCategory cavalry > 0

	wait 1
	ai_gta_add_objective 0 ATTACK_ENEMY_BATTLEGROUP 999
	ai_gta_add_unit_label 0 0 General1

	set_counter general_wait 0

	if I_BattleEnemyArmyNumberOfUnits < 7
	battle_wait 40
	end_if	
	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_BattleEnemyArmyNumberOfUnits < 12
	battle_wait 50
	end_if
	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_BattleEnemyArmyNumberOfUnits < 16
	battle_wait 60
	end_if
	if I_BattleEnemyArmyNumberOfUnits > 15
	battle_wait 70
	end_if

	ai_gta_del_objective 0
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_monitor

monitor_conditions I_BattleStarted
 	and I_BattleIsSallyOutBattle
	and I_CompareCounter general_wait = 1
	and I_IsUnitMoveFastSet General2
	and I_BattleEnemyArmyNumberOfUnitCategory cavalry > 0

	wait 1
	ai_gta_add_objective 1 ATTACK_ENEMY_BATTLEGROUP 999
	ai_gta_add_unit_label 1 0 General2

	set_counter general_wait 0

	if I_BattleEnemyArmyNumberOfUnits < 7
	battle_wait 40
	end_if	
	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_BattleEnemyArmyNumberOfUnits < 12
	battle_wait 50
	end_if
	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_BattleEnemyArmyNumberOfUnits < 16
	battle_wait 60
	end_if
	if I_BattleEnemyArmyNumberOfUnits > 15
	battle_wait 70
	end_if

	ai_gta_del_objective 1
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_monitor

;################## Germanicu5 Integrated Siege script v0.15 ###########################

monitor_conditions I_InBattle
	and ! I_BattleIsFortBattle
	and I_BattleEnemyArmyNumberOfMountClass elephant = 0
	and I_CompareCounter siege_fix = 1

	if I_ConflictType Siege
	label_location 0, -850, south_side
	label_location 0, 850, north_side
	label_location -850, 0, west_side
	label_location 850, 0, east_side
	end_if

	if I_BattleIsSallyOutBattle
	label_location 0, -850, south_side
	label_location 0, 850, north_side
	label_location -850, 0, west_side
	label_location 850, 0, east_side
	end_if

	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General1 west_side east_side > 200
	set_counter army_south 1
	end_if
	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General1 west_side east_side < -200
	set_counter army_north 1
	end_if
	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General1 south_side north_side > 200
	set_counter army_east 1
	end_if
	if I_ConflictType Siege
	and ! I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General1 south_side north_side < -200
	set_counter army_west 1
	end_if

	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General2 west_side east_side > 200
	set_counter army_south 1
	end_if
	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General2 west_side east_side < -200
	set_counter army_north 1
	end_if
	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General2 south_side north_side > 200
	set_counter army_east 1
	end_if
	if I_BattleIsSallyOutBattle
	and I_BattlePlayerArmyIsAttacker
	and I_UnitDistanceFromLine General2 south_side north_side < -200
	set_counter army_west 1
	end_if

	set_counter siege_fix 0

	if I_CompareCounter army_south = 1
	set_counter army_sieging 1
	end_if

	if I_CompareCounter army_north = 1
	set_counter army_sieging 1
	end_if

	if I_CompareCounter army_east = 1
	set_counter army_sieging 1
	end_if

	if I_CompareCounter army_west = 1
	set_counter army_sieging 1
	end_if

	if I_ConflictType Siege
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_south = 1
	set_counter wall_advance_south 1
	set_counter wall_advance 1
	end_if

	if I_ConflictType Siege
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_north = 1
	set_counter wall_advance_north 1
	set_counter wall_advance 1
	end_if

	if I_ConflictType Siege
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_west = 1
	set_counter wall_advance_west 1
	set_counter wall_advance 1
	end_if

	if I_ConflictType Siege
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_east = 1
	set_counter wall_advance_east 1
	set_counter wall_advance 1
	end_if

	if I_BattleIsSallyOutBattle
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_south = 1
	set_counter wall_advance_south 1
	set_counter wall_advance2 1
	end_if

	if I_BattleIsSallyOutBattle
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_north = 1
	set_counter wall_advance_north 1
	set_counter wall_advance2 1
	end_if

	if I_BattleIsSallyOutBattle
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_west = 1
	set_counter wall_advance_west 1
	set_counter wall_advance2 1
	end_if

	if I_BattleIsSallyOutBattle
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege = 0
 	and I_CompareCounter army_east = 1
	set_counter wall_advance_east 1
	set_counter wall_advance2 1
	end_if
end_monitor

;;;;;;;Huge City

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 4

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 65
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -65
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -65 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 65 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 85

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	set_counter move_forward 1
	end_if

	set_counter army_sieging 0
end_monitor

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 4

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 135
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -135
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -135 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 135 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 130

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
end_monitor

;;;;;;;Large City

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 60
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -60
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -60 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 60 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 80

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
end_monitor

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and ! I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 130
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -130
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -130 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 130 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 125 

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
end_monitor

;;;;;;;Castle, Citadel and Fortress

monitor_conditions I_InBattle
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and ! I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 100
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -100
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -100 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 100 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 115

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if 

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
end_monitor

monitor_conditions I_InBattle 
	and I_ConflictType Siege
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and ! I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army1
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army1 0 170
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army1 0 -170
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army1 -170 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army1 170 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 160
 
	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
end_monitor

;;;;;;;Wall Advance

monitor_conditions I_InBattle
 	and I_CompareCounter wall_advance = 1
	and I_ConflictType Siege

	unit_group_order_halt army1
	if I_CompareCounter wall_advance_south = 1
	unit_group_order_relative_move_formed army1 0 95
	end_if
	if I_CompareCounter wall_advance_north = 1
	unit_group_order_relative_move_formed army1 0 -95
	end_if
	if I_CompareCounter wall_advance_east = 1
	unit_group_order_relative_move_formed army1 -95 0
	end_if
	if I_CompareCounter wall_advance_west = 1
	unit_group_order_relative_move_formed army1 95 0
	end_if

	set_counter wall_advance 0
	set_counter emergency_stop 1
	battle_wait 80

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	
	set_counter emergency_stop 0
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter omfg_cannon_tower = 1

	battle_wait 5

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire General1
	and ! I_UnitInRangeOfUnitGroup General1 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit1
	and ! I_UnitInRangeOfUnitGroup unit1 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit2
	and ! I_UnitInRangeOfUnitGroup unit2 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit3
	and ! I_UnitInRangeOfUnitGroup unit3 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit4
	and ! I_UnitInRangeOfUnitGroup unit4 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit5
	and ! I_UnitInRangeOfUnitGroup unit5 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit6
	and ! I_UnitInRangeOfUnitGroup unit6 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit7
	and ! I_UnitInRangeOfUnitGroup unit7 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit8
	and ! I_UnitInRangeOfUnitGroup unit8 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit9
	and ! I_UnitInRangeOfUnitGroup unit9 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit10
	and ! I_UnitInRangeOfUnitGroup unit10 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit11
	and ! I_UnitInRangeOfUnitGroup unit11 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit12
	and ! I_UnitInRangeOfUnitGroup unit12 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit13
	and ! I_UnitInRangeOfUnitGroup unit13 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit14
	and ! I_UnitInRangeOfUnitGroup unit14 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit15
	and ! I_UnitInRangeOfUnitGroup unit15 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit16
	and ! I_UnitInRangeOfUnitGroup unit16 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit17
	and ! I_UnitInRangeOfUnitGroup unit17 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit18
	and ! I_UnitInRangeOfUnitGroup unit18 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit19
	and ! I_UnitInRangeOfUnitGroup unit19 army2
	set_counter emergency_stop 0
	unit_group_order_halt army1
	set_counter omfg_cannon_tower 2
	end_if

	wait 1

;;;;;;;South

while I_CompareCounter army_south = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	unit_order_move_relative unit15 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	unit_order_move_relative unit15 0 -40 run
	unit_order_move_relative unit16 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	unit_order_move_relative unit15 0 -40 run
	unit_order_move_relative unit16 0 -40 run
	unit_order_move_relative unit17 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	unit_order_move_relative unit15 0 -40 run
	unit_order_move_relative unit16 0 -40 run
	unit_order_move_relative unit17 0 -40 run
	unit_order_move_relative unit18 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General1 0 -40 run
	unit_order_move_relative unit1 0 -40 run
	unit_order_move_relative unit2 0 -40 run
	unit_order_move_relative unit3 0 -40 run
	unit_order_move_relative unit4 0 -40 run
	unit_order_move_relative unit5 0 -40 run
	unit_order_move_relative unit6 0 -40 run
	unit_order_move_relative unit7 0 -40 run
	unit_order_move_relative unit8 0 -40 run
	unit_order_move_relative unit9 0 -40 run
	unit_order_move_relative unit10 0 -40 run
	unit_order_move_relative unit11 0 -40 run
	unit_order_move_relative unit12 0 -40 run
	unit_order_move_relative unit13 0 -40 run
	unit_order_move_relative unit14 0 -40 run
	unit_order_move_relative unit15 0 -40 run
	unit_order_move_relative unit16 0 -40 run
	unit_order_move_relative unit17 0 -40 run
	unit_order_move_relative unit18 0 -40 run
	unit_order_move_relative unit19 0 -40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	unit_order_turn unit19 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;; North

while I_CompareCounter army_north = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	unit_order_move_relative unit15 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	unit_order_move_relative unit15 0 40 run
	unit_order_move_relative unit16 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	unit_order_move_relative unit15 0 40 run
	unit_order_move_relative unit16 0 40 run
	unit_order_move_relative unit17 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	unit_order_move_relative unit15 0 40 run
	unit_order_move_relative unit16 0 40 run
	unit_order_move_relative unit17 0 40 run
	unit_order_move_relative unit18 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General1 0 40 run
	unit_order_move_relative unit1 0 40 run
	unit_order_move_relative unit2 0 40 run
	unit_order_move_relative unit3 0 40 run
	unit_order_move_relative unit4 0 40 run
	unit_order_move_relative unit5 0 40 run
	unit_order_move_relative unit6 0 40 run
	unit_order_move_relative unit7 0 40 run
	unit_order_move_relative unit8 0 40 run
	unit_order_move_relative unit9 0 40 run
	unit_order_move_relative unit10 0 40 run
	unit_order_move_relative unit11 0 40 run
	unit_order_move_relative unit12 0 40 run
	unit_order_move_relative unit13 0 40 run
	unit_order_move_relative unit14 0 40 run
	unit_order_move_relative unit15 0 40 run
	unit_order_move_relative unit16 0 40 run
	unit_order_move_relative unit17 0 40 run
	unit_order_move_relative unit18 0 40 run
	unit_order_move_relative unit19 0 40 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	unit_order_turn unit19 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;;East

while I_CompareCounter army_east = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	unit_order_move_relative unit15 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	unit_order_move_relative unit15 -40 0 run
	unit_order_move_relative unit16 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	unit_order_move_relative unit15 -40 0 run
	unit_order_move_relative unit16 -40 0 run
	unit_order_move_relative unit17 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	unit_order_move_relative unit15 -40 0 run
	unit_order_move_relative unit16 -40 0 run
	unit_order_move_relative unit17 -40 0 run
	unit_order_move_relative unit18 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General1 -40 0 run
	unit_order_move_relative unit1 -40 0 run
	unit_order_move_relative unit2 -40 0 run
	unit_order_move_relative unit3 -40 0 run
	unit_order_move_relative unit4 -40 0 run
	unit_order_move_relative unit5 -40 0 run
	unit_order_move_relative unit6 -40 0 run
	unit_order_move_relative unit7 -40 0 run
	unit_order_move_relative unit8 -40 0 run
	unit_order_move_relative unit9 -40 0 run
	unit_order_move_relative unit10 -40 0 run
	unit_order_move_relative unit11 -40 0 run
	unit_order_move_relative unit12 -40 0 run
	unit_order_move_relative unit13 -40 0 run
	unit_order_move_relative unit14 -40 0 run
	unit_order_move_relative unit15 -40 0 run
	unit_order_move_relative unit16 -40 0 run
	unit_order_move_relative unit17 -40 0 run
	unit_order_move_relative unit18 -40 0 run
	unit_order_move_relative unit19 -40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	unit_order_turn unit19 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;; West

while I_CompareCounter army_west = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	unit_order_move_relative unit15 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	unit_order_move_relative unit15 40 0 run
	unit_order_move_relative unit16 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	unit_order_move_relative unit15 40 0 run
	unit_order_move_relative unit16 40 0 run
	unit_order_move_relative unit17 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	unit_order_move_relative unit15 40 0 run
	unit_order_move_relative unit16 40 0 run
	unit_order_move_relative unit17 40 0 run
	unit_order_move_relative unit18 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General1 40 0 run
	unit_order_move_relative unit1 40 0 run
	unit_order_move_relative unit2 40 0 run
	unit_order_move_relative unit3 40 0 run
	unit_order_move_relative unit4 40 0 run
	unit_order_move_relative unit5 40 0 run
	unit_order_move_relative unit6 40 0 run
	unit_order_move_relative unit7 40 0 run
	unit_order_move_relative unit8 40 0 run
	unit_order_move_relative unit9 40 0 run
	unit_order_move_relative unit10 40 0 run
	unit_order_move_relative unit11 40 0 run
	unit_order_move_relative unit12 40 0 run
	unit_order_move_relative unit13 40 0 run
	unit_order_move_relative unit14 40 0 run
	unit_order_move_relative unit15 40 0 run
	unit_order_move_relative unit16 40 0 run
	unit_order_move_relative unit17 40 0 run
	unit_order_move_relative unit18 40 0 run
	unit_order_move_relative unit19 40 0 run
	battle_wait 40
	unit_order_turn General1 -180 relative
	unit_order_turn unit1 -180 relative
	unit_order_turn unit2 -180 relative
	unit_order_turn unit3 -180 relative
	unit_order_turn unit4 -180 relative
	unit_order_turn unit5 -180 relative
	unit_order_turn unit6 -180 relative
	unit_order_turn unit7 -180 relative
	unit_order_turn unit8 -180 relative
	unit_order_turn unit9 -180 relative
	unit_order_turn unit10 -180 relative
	unit_order_turn unit11 -180 relative
	unit_order_turn unit12 -180 relative
	unit_order_turn unit13 -180 relative
	unit_order_turn unit14 -180 relative
	unit_order_turn unit15 -180 relative
	unit_order_turn unit16 -180 relative
	unit_order_turn unit17 -180 relative
	unit_order_turn unit18 -180 relative
	unit_order_turn unit19 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army1
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

end_monitor

;;;;;;;Sally Out
;;;;;;;Huge City

monitor_conditions I_InBattle
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 4

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 65
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -65
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -65 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 65 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 85

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	set_counter move_forward 1
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

monitor_conditions I_InBattle
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 4

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 135
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -135
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -135 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 135 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 130

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

;;;;;;;Large City

monitor_conditions I_InBattle
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 60
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -60
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -60 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 60 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 80

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

monitor_conditions I_InBattle
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and I_BattlePlayerArmyIsAttacker
	and ! I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 130
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -130
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -130 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 130 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 125 

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

;;;;;;;Castle, Citadel and Fortress

monitor_conditions I_InBattle
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range > 0
	and I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 100
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -100
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -100 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 100 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 115

	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if 

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

monitor_conditions I_InBattle 
	and I_BattleIsSallyOutBattle
	and ! I_BattleIsFortBattle
 	and I_CompareCounter army_sieging = 1
 	and I_CompareCounter army2_sally = 1
	and I_BattleEnemyArmyNumberOfClassAndCategory missile siege > 0
	and I_BattlePlayerArmyNumberOfAttribute extreme_range = 0
	and I_BattlePlayerArmyIsAttacker
	and I_IsBattleSettlementCastle
	and I_BattleSettlementFortificationLevel 3

	unit_group_order_halt army2
	if I_CompareCounter army_south = 1
	unit_group_order_relative_move_formed army2 0 170
	end_if
	if I_CompareCounter army_north = 1
	unit_group_order_relative_move_formed army2 0 -170
	end_if
	if I_CompareCounter army_east = 1
	unit_group_order_relative_move_formed army2 -170 0
	end_if
	if I_CompareCounter army_west = 1
	unit_group_order_relative_move_formed army2 170 0
	end_if
	set_counter emergency_stop 1
	set_counter omfg_cannon_tower 1
	battle_wait 160
 
	if I_InBattle
	and I_CompareCounter omfg_cannon_tower = 1
	set_counter omfg_cannon_tower 0
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if

	set_counter army_sieging 0
	set_counter army2_sally 0
end_monitor

;;;;;;;Wall Advance

monitor_conditions I_InBattle
 	and I_CompareCounter wall_advance2 = 1
	and I_BattleIsSallyOutBattle

	while I_BattleSettlementFortificationLevel < 3
 	and I_CompareCounter wall_advance2 = 1
	unit_group_order_halt army2
	if I_CompareCounter wall_advance_south = 1
	unit_group_order_relative_move_formed army2 0 95
	end_if
	if I_CompareCounter wall_advance_north = 1
	unit_group_order_relative_move_formed army2 0 -95
	end_if
	if I_CompareCounter wall_advance_east = 1
	unit_group_order_relative_move_formed army2 -95 0
	end_if
	if I_CompareCounter wall_advance_west = 1
	unit_group_order_relative_move_formed army2 95 0
	end_if
	set_counter wall_advance2 0
	end_while

	while I_BattleSettlementFortificationLevel > 2
 	and I_CompareCounter wall_advance2 = 1
	unit_group_order_halt army2
	if I_CompareCounter wall_advance_south = 1
	unit_group_order_relative_move_formed army2 0 200
	end_if
	if I_CompareCounter wall_advance_north = 1
	unit_group_order_relative_move_formed army2 0 -200
	end_if
	if I_CompareCounter wall_advance_east = 1
	unit_group_order_relative_move_formed army2 -200 0
	end_if
	if I_CompareCounter wall_advance_west = 1
	unit_group_order_relative_move_formed army2 200 0
	end_if
	set_counter wall_advance2 0
	end_while

	set_counter wall_advance2 0
	set_counter emergency_stop 1

	if I_BattleSettlementFortificationLevel < 3
	battle_wait 80
	end_if
	if I_BattleSettlementFortificationLevel > 2
	battle_wait 185
	end_if

	if I_InBattle
	and I_CompareCounter emergency_stop = 1
	
	set_counter emergency_stop 0
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if
end_monitor

monitor_conditions I_BattleStarted
	and I_CompareCounter omfg_cannon_tower = 1

	battle_wait 5

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire General2
	and ! I_UnitInRangeOfUnitGroup General2 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 1
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit20
	and ! I_UnitInRangeOfUnitGroup unit20 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 2
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit21
	and ! I_UnitInRangeOfUnitGroup unit21 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 3
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit22
	and ! I_UnitInRangeOfUnitGroup unit22 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 4
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit23
	and ! I_UnitInRangeOfUnitGroup unit23 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 5
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit24
	and ! I_UnitInRangeOfUnitGroup unit24 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 6
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit25
	and ! I_UnitInRangeOfUnitGroup unit25 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 7
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit26
	and ! I_UnitInRangeOfUnitGroup unit26 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 8
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit27
	and ! I_UnitInRangeOfUnitGroup unit27 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 9
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit28
	and ! I_UnitInRangeOfUnitGroup unit28 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 10
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit29
	and ! I_UnitInRangeOfUnitGroup unit29 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 11
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit30
	and ! I_UnitInRangeOfUnitGroup unit30 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 12
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit31
	and ! I_UnitInRangeOfUnitGroup unit31 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 13
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit32
	and ! I_UnitInRangeOfUnitGroup unit32 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 14
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit33
	and ! I_UnitInRangeOfUnitGroup unit33 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 15
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit34
	and ! I_UnitInRangeOfUnitGroup unit34 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 16
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit35
	and ! I_UnitInRangeOfUnitGroup unit35 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 17
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit36
	and ! I_UnitInRangeOfUnitGroup unit36 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits > 18
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit37
	and ! I_UnitInRangeOfUnitGroup unit37 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	and I_CompareCounter omfg_cannon_tower = 1
	and I_IsUnitUnderFire unit38
	and ! I_UnitInRangeOfUnitGroup unit38 army1
	set_counter emergency_stop 0
	unit_group_order_halt army2
	set_counter omfg_cannon_tower 2
	end_if

	wait 1

;;;;;;;South

while I_CompareCounter army_south = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	unit_order_move_relative unit34 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	unit_order_move_relative unit34 0 -40 run
	unit_order_move_relative unit35 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	unit_order_move_relative unit34 0 -40 run
	unit_order_move_relative unit35 0 -40 run
	unit_order_move_relative unit36 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	unit_order_move_relative unit34 0 -40 run
	unit_order_move_relative unit35 0 -40 run
	unit_order_move_relative unit36 0 -40 run
	unit_order_move_relative unit37 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General2 0 -40 run
	unit_order_move_relative unit20 0 -40 run
	unit_order_move_relative unit21 0 -40 run
	unit_order_move_relative unit22 0 -40 run
	unit_order_move_relative unit23 0 -40 run
	unit_order_move_relative unit24 0 -40 run
	unit_order_move_relative unit25 0 -40 run
	unit_order_move_relative unit26 0 -40 run
	unit_order_move_relative unit27 0 -40 run
	unit_order_move_relative unit28 0 -40 run
	unit_order_move_relative unit29 0 -40 run
	unit_order_move_relative unit30 0 -40 run
	unit_order_move_relative unit31 0 -40 run
	unit_order_move_relative unit32 0 -40 run
	unit_order_move_relative unit33 0 -40 run
	unit_order_move_relative unit34 0 -40 run
	unit_order_move_relative unit35 0 -40 run
	unit_order_move_relative unit36 0 -40 run
	unit_order_move_relative unit37 0 -40 run
	unit_order_move_relative unit38 0 -40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	unit_order_turn unit38 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;; North

while I_CompareCounter army_north = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	unit_order_move_relative unit34 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	unit_order_move_relative unit34 0 40 run
	unit_order_move_relative unit35 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	unit_order_move_relative unit34 0 40 run
	unit_order_move_relative unit35 0 40 run
	unit_order_move_relative unit36 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	unit_order_move_relative unit34 0 40 run
	unit_order_move_relative unit35 0 40 run
	unit_order_move_relative unit36 0 40 run
	unit_order_move_relative unit37 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General2 0 40 run
	unit_order_move_relative unit20 0 40 run
	unit_order_move_relative unit21 0 40 run
	unit_order_move_relative unit22 0 40 run
	unit_order_move_relative unit23 0 40 run
	unit_order_move_relative unit24 0 40 run
	unit_order_move_relative unit25 0 40 run
	unit_order_move_relative unit26 0 40 run
	unit_order_move_relative unit27 0 40 run
	unit_order_move_relative unit28 0 40 run
	unit_order_move_relative unit29 0 40 run
	unit_order_move_relative unit30 0 40 run
	unit_order_move_relative unit31 0 40 run
	unit_order_move_relative unit32 0 40 run
	unit_order_move_relative unit33 0 40 run
	unit_order_move_relative unit34 0 40 run
	unit_order_move_relative unit35 0 40 run
	unit_order_move_relative unit36 0 40 run
	unit_order_move_relative unit37 0 40 run
	unit_order_move_relative unit38 0 40 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	unit_order_turn unit38 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;;East

while I_CompareCounter army_east = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	unit_order_move_relative unit34 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	unit_order_move_relative unit34 -40 0 run
	unit_order_move_relative unit35 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	unit_order_move_relative unit34 -40 0 run
	unit_order_move_relative unit35 -40 0 run
	unit_order_move_relative unit36 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	unit_order_move_relative unit34 -40 0 run
	unit_order_move_relative unit35 -40 0 run
	unit_order_move_relative unit36 -40 0 run
	unit_order_move_relative unit37 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General2 -40 0 run
	unit_order_move_relative unit20 -40 0 run
	unit_order_move_relative unit21 -40 0 run
	unit_order_move_relative unit22 -40 0 run
	unit_order_move_relative unit23 -40 0 run
	unit_order_move_relative unit24 -40 0 run
	unit_order_move_relative unit25 -40 0 run
	unit_order_move_relative unit26 -40 0 run
	unit_order_move_relative unit27 -40 0 run
	unit_order_move_relative unit28 -40 0 run
	unit_order_move_relative unit29 -40 0 run
	unit_order_move_relative unit30 -40 0 run
	unit_order_move_relative unit31 -40 0 run
	unit_order_move_relative unit32 -40 0 run
	unit_order_move_relative unit33 -40 0 run
	unit_order_move_relative unit34 -40 0 run
	unit_order_move_relative unit35 -40 0 run
	unit_order_move_relative unit36 -40 0 run
	unit_order_move_relative unit37 -40 0 run
	unit_order_move_relative unit38 -40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	unit_order_turn unit38 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

;;;;;;; West

while I_CompareCounter army_west = 1
	and I_CompareCounter omfg_cannon_tower = 2

	if I_BattleEnemyArmyNumberOfUnits = 2
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 3
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 4
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 5
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 6
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 7
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 8
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 9
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 10
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 11
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 12
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 13
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 14
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 15
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 16
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	unit_order_move_relative unit34 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	battle_wait 1
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 17
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	unit_order_move_relative unit34 40 0 run
	unit_order_move_relative unit35 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 18
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	unit_order_move_relative unit34 40 0 run
	unit_order_move_relative unit35 40 0 run
	unit_order_move_relative unit36 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 19
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	unit_order_move_relative unit34 40 0 run
	unit_order_move_relative unit35 40 0 run
	unit_order_move_relative unit36 40 0 run
	unit_order_move_relative unit37 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	battle_wait 10
	end_if

	if I_BattleEnemyArmyNumberOfUnits = 20
	ai_active_set off
	unit_order_move_relative General2 40 0 run
	unit_order_move_relative unit20 40 0 run
	unit_order_move_relative unit21 40 0 run
	unit_order_move_relative unit22 40 0 run
	unit_order_move_relative unit23 40 0 run
	unit_order_move_relative unit24 40 0 run
	unit_order_move_relative unit25 40 0 run
	unit_order_move_relative unit26 40 0 run
	unit_order_move_relative unit27 40 0 run
	unit_order_move_relative unit28 40 0 run
	unit_order_move_relative unit29 40 0 run
	unit_order_move_relative unit30 40 0 run
	unit_order_move_relative unit31 40 0 run
	unit_order_move_relative unit32 40 0 run
	unit_order_move_relative unit33 40 0 run
	unit_order_move_relative unit34 40 0 run
	unit_order_move_relative unit35 40 0 run
	unit_order_move_relative unit36 40 0 run
	unit_order_move_relative unit37 40 0 run
	unit_order_move_relative unit38 40 0 run
	battle_wait 40
	unit_order_turn General2 -180 relative
	unit_order_turn unit20 -180 relative
	unit_order_turn unit21 -180 relative
	unit_order_turn unit22 -180 relative
	unit_order_turn unit23 -180 relative
	unit_order_turn unit24 -180 relative
	unit_order_turn unit25 -180 relative
	unit_order_turn unit26 -180 relative
	unit_order_turn unit27 -180 relative
	unit_order_turn unit28 -180 relative
	unit_order_turn unit29 -180 relative
	unit_order_turn unit30 -180 relative
	unit_order_turn unit31 -180 relative
	unit_order_turn unit32 -180 relative
	unit_order_turn unit33 -180 relative
	unit_order_turn unit34 -180 relative
	unit_order_turn unit35 -180 relative
	unit_order_turn unit36 -180 relative
	unit_order_turn unit37 -180 relative
	unit_order_turn unit38 -180 relative
	battle_wait 10
	end_if

	set_counter omfg_cannon_tower 0
	unit_group_order_halt army2
	wait 1
	ai_active_set off
	wait 1
	ai_active_set on
end_while

end_monitor

monitor_event BattlePlayerUnitAttacksEnemyUnit BattleIsMeleeAttack
	and I_CompareCounter emergency_stop = 1

	if I_ConflictType Siege
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	set_counter emergency_stop 0
	end_if
	if I_BattleIsSallyOutBattle
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	set_counter emergency_stop 0
	end_if
end_monitor

monitor_event BattleEnemySiegeEngineDestroyed BattleEnemyUnitSiegeEngineClass = ram

	if I_ConflictType Siege
	unit_group_order_halt army1
	battle_wait 1
	ai_active_set on
	end_if
	if I_BattleIsSallyOutBattle
	unit_group_order_halt army2
	battle_wait 1
	ai_active_set on
	end_if
end_monitor

;################## Cleaning up ##################

monitor_event ScrollOpened ScrollOpened post_battle_scroll

;;;;;;;Stakes
	set_counter label_ready 0
	set_counter stakes_on 0
	;;;;;;;Reinforcements
	set_counter label2_ready 0
	set_counter label4_ready 0
	set_counter label5_ready 0
	set_counter army_moving 0
	set_counter reinf_arrive 0
	set_counter reinf_arrive2 0
	set_counter reinf_late 0
	set_counter army3_run 0
	set_counter army3_run_siege 0
	set_counter army4_run 0
	set_counter distance_trigger1 0
	set_counter distance_trigger2 0
	set_counter distance_trigger3 0
	set_counter distance_trigger4 0
	set_counter distance_trigger5 0
	;;;;;;;HA Fix
	set_counter ha_fix 0
	;;;;;;;Elephant Fix
	set_counter elephant_fix 0
	set_counter elephant_gate 0
	set_counter elephant_gate2 0
	set_counter elephant_gate_tier2 0
	set_counter elephant_gate_tier3 0
	set_counter elephant_gate_tier2s 0
	set_counter elephant_gate_tier3s 0
	set_counter rally_walls 0
	set_counter rally_walls_s 0
	set_counter second_ring 0
	set_counter third_ring 0
	set_counter second_ring2 0
	set_counter third_ring2 0
	set_counter del_objective 0
	set_counter del_objective2 0
	;;;;;;;Sally-out
	set_counter sally-out_fix 0
	;;;;;;;Siege
	set_counter siege_fix 0
	set_counter kill_it 0
	set_counter army_sieging 0
	set_counter army_south 0
	set_counter army_north 0
	set_counter army_east 0
	set_counter army_west 0
	set_counter wall_advance 0
	set_counter wall_advance_south 0
	set_counter wall_advance_north 0
	set_counter wall_advance_west 0
	set_counter wall_advance_east 0
	set_counter emergency_stop 0
	set_counter omfg_cannon_tower 0
	set_counter omfg_cannon_tower2 0
	set_counter army2_sally 0
	set_counter wall_advance2 0
	;;;;;;;Protect General
	set_counter protect_general 0
	set_counter general_wait 0
	prepare_for_battle
	suspend_unscripted_advice false
end_monitor

wait_monitors
end_script