OSP Kit Combat Battlefield Tactics kit. Multiple formations per team+command revamp!

Users who are viewing this thread

Repost code, 1st post cut, too long for opera mini so I split into 2 posts now
Code:
# script_team_give_order_from_order_panel
# Input: arg1 = leader_agent_no, arg2 = class_no
# Output: none
("team_give_order_from_order_panel",
 [(store_script_param_1, ":leader_agent_no"),
  (store_script_param_2, ":order"),
  (agent_get_team, ":team_no", ":leader_agent_no"),
  (set_show_messages, 0),
  ##########################################################
  # motomataru's formation
     (try_begin),
        (eq, ":order", mordr_charge),
        (try_begin),
           (eq, "$g_formation_infantry_selected", 1),
           (gt, "$infantry_formation_move_order", -1),
           (call_script, "script_formation_end", ":team_no", grc_infantry),
           (display_message, "@Infantry formation disassembled."),
           (assign, "$infantry_formation_move_order", -1),
        (try_end),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (call_script, "script_formation_end", ":team_no", grc_cavalry),
           (display_message, "@Cavalry starting column disassembled."),
           (assign, "$cavalry_formation_move_order", -1),
        (try_end),
        (try_begin),
           (eq, "$g_formation_archers_selected", 1),
           (gt, "$archer_formation_move_order", -1),
           (call_script, "script_formation_end", ":team_no", grc_archers),
           (display_message, "@Archer starting line disassembled. Use HOLD to reform."),
           (assign, "$archer_formation_move_order", -1),
        (try_end),
     (else_try),
        (eq, ":order", mordr_hold),
        (try_begin),
           (eq, "$g_formation_infantry_selected", 1),
           (gt, "$infantry_formation_move_order", -1),
           (call_script, "script_cf_formation", ":team_no", grc_infantry, "$infantry_space"),
           (assign, "$infantry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (call_script, "script_cf_formation", ":team_no", grc_cavalry, "$infantry_space"),
           (assign, "$cavalry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_archers_selected", 1),
           (gt, "$archer_formation_move_order", -1),
           (call_script, "script_cf_formation", ":team_no", grc_archers, "$infantry_space"),
           (assign, "$archer_formation_move_order", ":order"),    
        (try_end),
     (else_try),
        (eq, ":order", mordr_follow),
        (try_begin),
           (eq, "$g_formation_infantry_selected", 1),
           (gt, "$infantry_formation_move_order", -1),
           (assign, "$infantry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (assign, "$cavalry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_archers_selected", 1),
           (gt, "$archer_formation_move_order", -1),
           (assign, "$archer_formation_move_order", ":order"),    
        (try_end),
     (else_try),
        (this_or_next|eq, ":order", mordr_advance),
        (eq, ":order", mordr_fall_back),
        (assign, ":one", 1),
        (try_begin),
           (eq, ":order", mordr_fall_back),
           (val_mul, ":one", -1),
        (try_end), 
        (try_begin),
           (eq, "$g_formation_infantry_selected", 1),
           (gt, "$infantry_formation_move_order", -1),
           (call_script, "script_formation_move_position", ":team_no", grc_infantry, ":leader_agent_no", ":one"),
           (call_script, "script_form_infantry", ":team_no", grc_infantry, ":leader_agent_no", "$infantry_space"),
           (assign, "$infantry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (call_script, "script_formation_move_position", ":team_no", grc_cavalry, ":leader_agent_no", ":one"),
           (call_script, "script_form_cavalry", ":team_no", grc_cavalry, ":leader_agent_no", "$infantry_space"),
           (assign, "$cavalry_formation_move_order", ":order"),  
        (try_end),
        (try_begin),
           (eq, "$g_formation_archers_selected", 1),
           (gt, "$archer_formation_move_order", -1),
           (call_script, "script_formation_move_position", ":team_no", grc_archers, ":leader_agent_no", ":one"),
           (call_script, "script_form_archers", ":team_no", grc_archers, ":leader_agent_no", "$infantry_space"),  
           (assign, "$archer_formation_move_order", ":order"),    
        (try_end),
 
2nd part:
Code:
     (else_try),
        (this_or_next|eq, ":order", mordr_spread_out),
        (eq, ":order", mordr_stand_closer),
        (try_begin),
           (eq, ":order", mordr_stand_closer),
           (val_mul, ":one", -1),
        (try_end), 
        (try_begin),
           (eq, "$g_formation_infantry_selected", 1),
           (gt, "$infantry_formation_move_order", -1),
           (val_add, "$infantry_space", ":one"),
           (val_max, "$infantry_space", 0), 
           (call_script, "script_get_formation_position", ":team_no", grc_infantry, ":leader_agent_no"),
           (call_script, "script_form_infantry", ":team_no", grc_infantry, ":leader_agent_no", "$infantry_space"),
        (try_end),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (val_add, "$cavalry_space", ":one"),
           (val_max, "$cavalry_space", 0), 
           (call_script, "script_get_formation_position", ":team_no", grc_cavalry, ":leader_agent_no"),
           (call_script, "script_form_cavalry", ":team_no", grc_cavalry, ":leader_agent_no", "$infantry_space"),
        (try_end),
        (try_begin),
           (eq, "$g_formation_archers_selected", 1),
           (gt, "$archer_formation_move_order", -1),
           (val_add, "$archer_space", ":one"),
           (val_max, "$archer_space", 0), 
           (call_script, "script_get_formation_position", ":team_no", grc_archers, ":leader_agent_no"),
           (call_script, "script_form_archers", ":team_no", grc_archers, ":leader_agent_no", "$infantry_space"),
        (try_end),
     (else_try),
        (eq, ":order", mordr_dismount),
        (try_begin),
           (eq, "$g_formation_cavalry_selected", 1),
           (gt, "$cavalry_formation_move_order", -1),
           (call_script, "script_formation_end", ":team_no", grc_cavalry),
           (display_message, "@Cavalry starting column disassembled."),
           (assign, "$cavalry_formation_move_order", -1),
        (try_end), 
     (try_end),
  ############################################################################33
  # Default
  (try_begin),
     (eq, "$g_formation_infantry_selected", 1),
     (team_give_order, ":team_no", grc_infantry, ":order"),
  (try_end),
  (try_begin),
     (eq, "$g_formation_archers_selected", 1),
     (team_give_order, ":team_no", grc_archers, ":order"),
  (try_end),
  (try_begin),
     (eq, "$g_formation_cavalry_selected", 1),
     (team_give_order, ":team_no", grc_cavalry, ":order"),
  (try_end),
   # Hold
  (try_begin),
     (eq, ":order", mordr_hold),
     (agent_get_position, pos1, ":leader_agent_no"),
     (try_begin),
        (eq, "$g_formation_infantry_selected", 1),
        (team_set_order_position, ":team_no", grc_infantry, pos1),
     (try_end),
     (try_begin),
        (eq, "$g_formation_archers_selected", 1),
        (team_set_order_position, ":team_no", grc_archers, pos1),
     (try_end),
     (try_begin),
        (eq, "$g_formation_cavalry_selected", 1),
        (team_set_order_position, ":team_no", grc_cavalry, pos1),
     (try_end),
  (try_end),
  (set_show_messages, 1), ]), 
 
Currently the formation for player infantry will always be the 'default_formation' no matter what faction he/she joined.  I added a few lines to fix this problem (if this needed a fix).


Find this piece of code in the 'script_form_infantry' section in module_scripts.py

Code:
   (else_try),
      (agent_get_troop_id, ":fleader_troop", ":fleader"),
      (store_troop_faction, ":ffaction", ":fleader_troop"),
   (end_try),

and insert this snippet just below it

Code:
   (try_begin),
    (eq, ":ffaction", "fac_player_faction"),
    (gt, "$players_kingdom", 0),
    (neq, "$players_kingdom", "fac_player_supporters_faction"),
    (neq, "$players_kingdom", "fac_player_faction"),
    (assign, ":ffaction", "$players_kingdom"),
   (try_end),
 
I've finished the implementation of formations that I posted four months ago. Major changes include:

  • I've gone back to allowing the player to pick any formation for his/her infantry, mapping each formation to a key like in Mirathei's original code. However, the keys are: j - for regular ranks, k - for shieldwall/phalanx, l - for wedge, and semi-colon for square. The key u is for undoing formations. Oh, and I included othr's fix for determining player team faction.
  • By popular demand, I've restored the wedge formation for cavalry. Although the formation still disperses on "charge," one can approximate a charge to the average position of the enemy through "multiple" advances (see video at http://www.youtube.com/watch?v=wzpcsTf-6MM ).
  • I learned how to implement rotation from the forum and spent a LOT of time refining the behavior of advancing formations. Now, when a formation is close to the average position of the enemy, it will NOT rotate wildly upon advance. See in particular my practical implementation of arcsine -- script_point_y_toward_position.

I still need to double check how it affect's dunde's application to the order map, but first I need to address pressing issues with idibil's port to Warband.

I've included here the simple application of formations to native AI. My intention for the not-too-distant future is to integrate formations with my version of AI http://mbx.streetofeyes.com/index.php/topic,2143.0.html .

Modified 6/14/2010:
-- Use gk_clicked* instead of gk_is_down* and remove lags for rapid-use triggers
-- Add globals for player agent and team

Modified 6/20/2010:
-- Lengthen delay for spawning to complete

Modified 6/24/2010:
-- Set player team global before initial formation scripts are called

In module_constants, add the follow to the end
Code:
#Formation modes
formation_none	= 0
formation_default	= 1
formation_ranks	= 2
formation_shield	= 3
formation_wedge	= 4
formation_square	= 5

In module_mission_templates, add the following before the mission templates list (i.e., before where it says "mission_templates = [").

Code:
# Formations triggers v2 by motomataru
# Global variables	*_formation_type holds type of formation: see "Formation modes" in module_constants
#					*_formation_move_order hold the current move order for the formation
#					*_space hold the multiplier of extra space ordered into formation by the player

formations_triggers = [
	(ti_before_mission_start, 0, 0, [], [
		(assign, "$infantry_formation_type", formation_default),	#type set by first call; depends on faction
		(assign, "$archer_formation_type", formation_default),
		(assign, "$cavalry_formation_type", formation_wedge),
		(assign, "$infantry_space", 2),	#give a little extra space for ease of forming up
		(assign, "$archer_space", 2),
		(assign, "$cavalry_space", 0),
		(assign, "$min_troops_for_formation", 5),
		(assign, "$fclock", 1)
	]),

# Start troops in formation
	(0, .4, ti_once, [], [	#delay to allow spawning to finish
		(display_message, "@Forming ranks."),
		(get_player_agent_no, "$fplayer_agent_no"),
		(agent_get_team, "$fplayer_team_no", "$fplayer_agent_no"),
		(call_script, "script_player_attempt_formation", grc_infantry, formation_default),
		(call_script, "script_player_attempt_formation", grc_cavalry, formation_wedge),
		(call_script, "script_player_attempt_formation", grc_archers, formation_default),
		#init troops for when formation ends
		(set_show_messages, 0),
		(try_for_range, ":dummy", 0, "$infantry_space"),
			(team_give_order, "$fplayer_team_no", grc_infantry, mordr_spread_out),
		(try_end),
		(try_for_range, ":dummy", 0, "$archer_space"),
			(team_give_order, "$fplayer_team_no", grc_archers, mordr_spread_out),
		(try_end),
		(try_for_range, ":dummy", 0, "$cavalry_space"),
			(team_give_order, "$fplayer_team_no", grc_cavalry, mordr_spread_out),
		(try_end),
		(set_show_messages, 1),
		(try_begin),
			(gt, ":dummy", 0),	#suppress compile warning
		(try_end),
	]),

#form ranks command
	(0, 0, 1, [(key_clicked, key_j)], [
		(str_store_string, s1, "@ranks"),
		(call_script, "script_player_attempt_formation", grc_infantry, formation_ranks)
	]),

#form shield wall command
	(0, 0, 1, [(key_clicked, key_k)], [
		(str_store_string, s1, "@shield wall"),
		(call_script, "script_player_attempt_formation", grc_infantry, formation_shield)
	]),

#form wedge command
	(0, 0, 1, [(key_clicked, key_l)], [
		(str_store_string, s1, "@wedge"),
		(call_script, "script_player_attempt_formation", grc_infantry, formation_wedge),
		(call_script, "script_player_attempt_formation", grc_cavalry, formation_wedge)
	]),

#form square command
	(0, 0, 1, [(key_clicked, key_semicolon)], [
		(str_store_string, s1, "@square"),
		(call_script, "script_player_attempt_formation", grc_infantry, formation_square)
	]),

#end formation command
	(0, 0, 1, [(key_clicked, key_u)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_infantry),
			(display_message, "@Infantry formation disassembled."),
			(assign, "$infantry_formation_type", formation_none),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_cavalry),
			(display_message, "@Cavalry formation disassembled."),
			(assign, "$cavalry_formation_type", formation_none),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_archers),
			(display_message, "@Archer starting line disassembled. Use HOLD to reform."),
			(assign, "$archer_formation_type", formation_none),
		(try_end),
	]),

#charge ends formation
	(0, 0, 1, [(game_key_clicked, gk_order_charge)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_infantry),
			(display_message, "@Infantry formation disassembled."),
			(assign, "$infantry_formation_type", formation_none),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_cavalry),
			(display_message, "@Cavalry formation disassembled."),
			(assign, "$cavalry_formation_type", formation_none),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(call_script, "script_formation_end", "$fplayer_team_no", grc_archers),
			(display_message, "@Archer starting line disassembled. Use HOLD to reform."),
			(assign, "$archer_formation_type", formation_none),
		(try_end),
	]),

#dismount ends formation
	(0, 0, 1, [(game_key_clicked, gk_order_dismount), (neq, "$cavalry_formation_type", formation_none)], [
		(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
		(call_script, "script_formation_end", "$fplayer_team_no", grc_cavalry),
		(display_message, "@Cavalry formation disassembled."),
		(assign, "$cavalry_formation_type", formation_none),
	]),
		
#On hold, any formations reform in new location		
	(0, 0, 1, [(game_key_clicked, gk_order_halt)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(call_script, "script_player_attempt_formation", grc_infantry, "$infantry_formation_type"),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(call_script, "script_player_attempt_formation", grc_cavalry, "$cavalry_formation_type"),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(call_script, "script_player_attempt_formation", grc_archers, "$archer_formation_type"),
		(try_end)
	]),
		
#Follow is hold	repeated frequently
	(0, 0, 1, [(game_key_clicked, gk_order_follow)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(assign, "$infantry_formation_move_order", mordr_follow),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(assign, "$cavalry_formation_move_order", mordr_follow),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(assign, "$archer_formation_move_order", mordr_follow),
		(try_end),
	]),

	(1, 0, 0, [	#attempt to avoid simultaneous formations function calls
		(neg|key_clicked, key_j),
		(neg|key_clicked, key_k),
		(neg|key_clicked, key_l),
		(neg|key_clicked, key_semicolon),
		(neg|key_clicked, key_u),
		(neg|game_key_clicked, gk_order_charge),
		(neg|game_key_clicked, gk_order_dismount),
		(neg|game_key_clicked, gk_order_halt),
		(neg|game_key_clicked, gk_order_follow),
		(neg|game_key_clicked, gk_order_advance),
		(neg|game_key_clicked, gk_order_fall_back),
		(neg|game_key_clicked, gk_order_spread_out),
		(neg|game_key_clicked, gk_order_stand_closer)
	  ], [
		(store_mod, ":fifth_second", "$fclock", 5),
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(try_begin),
				(eq, "$infantry_formation_move_order", mordr_follow),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_infantry, "$infantry_space", "$infantry_formation_type"),
			(else_try),	#periodically reform
				(eq, ":fifth_second", 0),
#				(team_get_order_position, pos1, "$fplayer_team_no", grc_infantry),
				(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_infantry),
				(call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
			(try_end),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(try_begin),
				(eq, "$cavalry_formation_move_order", mordr_follow),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_cavalry, "$cavalry_space", "$cavalry_formation_type"),
			(else_try),	#periodically reform
				(eq, ":fifth_second", 0),
#				(team_get_order_position, pos1, "$fplayer_team_no", grc_cavalry),
				(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_cavalry),
				(call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
			(try_end),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(try_begin),
				(eq, "$archer_formation_move_order", mordr_follow),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_archers, "$archer_space", "$archer_formation_type"),
			(else_try),	#periodically reform
				(eq, ":fifth_second", 0),
#				(team_get_order_position, pos1, "$fplayer_team_no", grc_archers),
				(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_archers),
				(call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space"),
			(try_end),
		(try_end),
		(val_add, "$fclock", 1),
	]),
		
	(0, 0, 0, [(game_key_clicked, gk_order_advance)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_infantry, "$fplayer_agent_no", "$infantry_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$infantry_formation_move_order", mordr_advance),
				# (team_set_order_position, "$fplayer_team_no", grc_infantry, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_infantry, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_infantry, pos63, 1),			
			(call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
			(assign, "$infantry_formation_move_order", mordr_advance),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_cavalry, "$fplayer_agent_no", "$cavalry_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$cavalry_formation_move_order", mordr_advance),
				# (team_set_order_position, "$fplayer_team_no", grc_cavalry, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_cavalry, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_cavalry, pos63, 1),
			(call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
			(assign, "$cavalry_formation_move_order", mordr_advance),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_archers, "$fplayer_agent_no", "$archer_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$archer_formation_move_order", mordr_advance),
				# (team_set_order_position, "$fplayer_team_no", grc_archers, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_archers, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_archers, pos63, 1),
			(call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space"),
			(assign, "$archer_formation_move_order", mordr_advance),
		(try_end),
	]),
		
	(0, 0, 0, [(game_key_clicked, gk_order_fall_back)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_infantry, "$fplayer_agent_no", "$infantry_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$infantry_formation_move_order", mordr_fall_back),
				# (team_set_order_position, "$fplayer_team_no", grc_infantry, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_infantry, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_infantry, pos63, -1),
			(call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
			(assign, "$infantry_formation_move_order", mordr_fall_back),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_cavalry, "$fplayer_agent_no", "$cavalry_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$cavalry_formation_move_order", mordr_fall_back),
				# (team_set_order_position, "$fplayer_team_no", grc_cavalry, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_cavalry, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_cavalry, pos63, -1),
			(call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
			(assign, "$cavalry_formation_move_order", mordr_fall_back),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(call_script, "script_formation_current_position", pos63, "$fplayer_team_no", grc_archers, "$fplayer_agent_no", "$archer_formation_type"),
			(try_begin),	#on change of orders cancel order position
				(neq, "$archer_formation_move_order", mordr_fall_back),
				# (team_set_order_position, "$fplayer_team_no", grc_archers, pos63),
				(call_script, "script_set_formation_position", "$fplayer_team_no", grc_archers, pos63),
			(try_end),
			(call_script, "script_formation_move_position", "$fplayer_team_no", grc_archers, pos63, -1),
			(call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space"),
			(assign, "$archer_formation_move_order", mordr_fall_back),
		(try_end),
	]),
		
	(0, 0, 0, [(game_key_clicked, gk_order_spread_out)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(val_add, "$infantry_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_infantry),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_infantry),
			(call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(val_add, "$cavalry_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(val_add, "$archer_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_archers),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_archers),
			(call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space"),
		(try_end),
	]),
		
	(0, 0, 0, [(game_key_clicked, gk_order_stand_closer)], [
		(try_begin),
			(neq, "$infantry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_infantry),
			(gt, "$infantry_space", 0),
			(val_sub, "$infantry_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_infantry),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_infantry),
			(call_script, "script_form_infantry", "$fplayer_team_no", "$fplayer_agent_no", "$infantry_space", "$infantry_formation_type"),
		(try_end),
		(try_begin),
			(neq, "$cavalry_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_cavalry),
			(gt, "$cavalry_space", 0),
			(val_sub, "$cavalry_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_cavalry),
			(call_script, "script_form_cavalry", "$fplayer_team_no", "$fplayer_agent_no", "$cavalry_space"),
		(try_end),
		(try_begin),
			(neq, "$archer_formation_type", formation_none),
			(class_is_listening_order, "$fplayer_team_no", grc_archers),
			(gt, "$archer_space", 0),
			(val_sub, "$archer_space", 1),
#			(team_get_order_position, pos1, "$fplayer_team_no", grc_archers),
			(call_script, "script_get_formation_position", pos1, "$fplayer_team_no", grc_archers),
			(call_script, "script_form_archers", "$fplayer_team_no", "$fplayer_agent_no", "$archer_space"),
		(try_end),
	]),

]
#end formations triggers

To use in a PARTICULAR mission template, add "+ formations_triggers" to the end of the triggers list, as in:
Code:
    ] + formations_triggers
  ),

 
For module_scripts. Simply add this to the end of module_scripts.

Modified: 6/14/2010
--add check to avoid div by 0 at end of battle for team_get_average_position_of_enemies_augmented
--use new globals for player agent and team

Modified: 6/20/2010
--set fixed point multiplier in get_ and set_formation_position to avoid accidents

Code:
# #Formations Scripts	  
  # script_cf_formation v2 by motomataru
  # Input: team, troop class, spacing, formation type
  # Output: reg0 number of troops in formation, pos61 formation position
  # Formation(s) form near team leader (player)
  ("cf_formation", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fclass", 2),
	(store_script_param, ":formation_extra_spacing", 3),
	(store_script_param, ":fformation", 4),
	(team_get_leader, ":fleader", ":fteam"),
	(gt, ":fleader", -1),	#any team members left?
	(agent_get_position, pos1, ":fleader"),
	(try_begin),
		(eq, ":fclass", grc_cavalry),
		(position_move_x, pos1, -500),		#cavalry set up 5m LEFT of leader
		(copy_position, pos61, pos1),
		(call_script, "script_form_cavalry", ":fteam", ":fleader", ":formation_extra_spacing"),
	(else_try),
		(eq, ":fclass", grc_infantry),
		(position_move_x, pos1, 500),		#infantry set up 5m RIGHT of leader
		(copy_position, pos61, pos1),
		(call_script, "script_form_infantry", ":fteam", ":fleader", ":formation_extra_spacing", ":fformation"),
	(else_try),
		(position_move_y, pos1, 1000),		#archers set up 10m FRONT of leader
		#preadjust in order to use sequential algorithm
		(store_mul, ":extra_space", ":formation_extra_spacing", 50),
		(store_add, ":distance", 75, ":extra_space"),		#minimum distance between troops
		(assign, ":num_troops", 0),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_archers, ":fleader", ":agent"),
			(val_add, ":num_troops", 1),
		(end_try),	
		(store_mul, ":offset", ":num_troops", ":distance"),
		(val_div, ":offset", -2),
		(position_move_x, pos1, ":offset", 0),
	
		(copy_position, pos61, pos1),
		(call_script, "script_form_archers", ":fteam", ":fleader", ":formation_extra_spacing"),
	(try_end),
#	(team_set_order_position, ":fteam", ":fclass", pos61),
	(call_script, "script_set_formation_position", ":fteam", ":fclass", pos61),
	(ge, reg0, "$min_troops_for_formation"),
  ]),
   
  # script_form_cavalry v2 by motomataru
  # Input: team, agent number of team leader, spacing
  # Output: reg0 troop count
  # Form in wedge, (now not) excluding horse archers
  # Creates formation starting at pos1
  ("form_cavalry", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fleader", 2),
	(store_script_param, ":formation_extra_spacing", 3),
	(store_mul, ":extra_space", ":formation_extra_spacing", 50),
	(store_add, ":x_distance", 150, ":extra_space"),
	(store_add, ":y_distance", 250, ":extra_space"),		#larger y minimum distance to accommodate mounts
	(assign, ":max_level", 0),
	(try_for_agents, ":agent"),
		(call_script, "script_cf_valid_formation_member", ":fteam", grc_cavalry, ":fleader", ":agent"),
		(agent_get_troop_id, ":troop_id", ":agent"),
		(store_character_level, ":troop_level", ":troop_id"),
		(gt, ":troop_level", ":max_level"),
		(assign, ":max_level", ":troop_level"),
	(end_try),
	(assign, ":column", 1),
	(assign, ":rank_dimension", 1),
	(store_mul, ":neg_y_distance", ":y_distance", -1),
	(store_mul, ":neg_x_distance", ":x_distance", -1),
	(store_mul, ":move_back_x", ":rank_dimension", ":neg_x_distance"),
	(store_div, ":wedge_adj", ":neg_x_distance", 2),
	(assign, ":troop_count", 0),
	(val_add, ":max_level", 1),
	(try_for_range_backwards, ":rank_level", 0, ":max_level"),	#put troops with highest exp in front
		(try_for_agents, ":agent"),
			(agent_get_troop_id, ":troop_id", ":agent"),
			(store_character_level, ":troop_level", ":troop_id"),
			(eq, ":troop_level", ":rank_level"),				
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_cavalry, ":fleader", ":agent"),
			
			# (agent_get_wielded_item, ":agent_weapon", ":agent", 0),	#exclude ranged horsemen
			# (gt, ":agent_weapon", -1),
			# (item_get_type, ":agent_weapon_type", ":agent_weapon"),
			# (this_or_next|eq, ":agent_weapon_type", itp_type_one_handed_wpn),
			# (this_or_next|eq, ":agent_weapon_type", itp_type_two_handed_wpn),
			# (eq, ":agent_weapon_type", itp_type_polearm),
			
			(val_add, ":troop_count", 1),
			(agent_set_scripted_destination, ":agent", pos1, 1),
			(position_move_x, pos1, ":x_distance", 0),
			(val_add, ":column", 1),
			(gt, ":column", ":rank_dimension"),
			(position_move_x, pos1, ":move_back_x", 0),
			(position_move_x, pos1, ":wedge_adj", 0),
			(position_move_y, pos1, ":neg_y_distance", 0),
			(assign, ":column", 1),
			(val_add, ":rank_dimension", 1),
			(store_mul, ":move_back_x", ":rank_dimension", ":neg_x_distance"),
		(end_try),
	(end_try),
	(assign, reg0, ":troop_count")
  ]),
	   
  # script_form_archers v2 by motomataru
  # Input: team, agent number of team leader, spacing
  # Output: reg0 troop count
  # Form in staggered line both directions
  # Creates formation starting at pos1
  ("form_archers", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fleader", 2),
	(store_script_param, ":formation_extra_spacing", 3),
	(store_mul, ":extra_space", ":formation_extra_spacing", 50),
	(store_add, ":distance", 75, ":extra_space"),		#minimum distance between troops
	(assign, ":troop_count", 0),
#	(assign, ":total_move_y", 0),	#staggering variable	
	(try_for_agents, ":agent"),
		(call_script, "script_cf_valid_formation_member", ":fteam", grc_archers, ":fleader", ":agent"),
		(agent_set_scripted_destination, ":agent", pos1, 1),
		(position_move_x, pos1, ":distance", 0),
		# (val_add, ":total_move_y", 75),
		# (try_begin),
			# (le, ":total_move_y", 150),
			# (position_move_y, pos1, 75, 0),
		# (else_try),
			# (position_move_y, pos1, -150, 0),
			# (assign, ":total_move_y", 0),
		# (try_end),
		(val_add, ":troop_count", 1),
	(try_end),
	(assign, reg0, ":troop_count")
  ]),
	   
  # script_form_infantry v2 by motomataru
  # Input: (pos1), team, agent number of team leader, spacing, formation
  # Output: reg0 troop count
  # If input "formation" is formation_default, will select a formation based on faction
  # Creates formation starting at pos1
  ("form_infantry", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fleader", 2),
	(store_script_param, ":formation_extra_spacing", 3),
	(store_script_param, ":infantry_formation", 4),
	(store_mul, ":extra_space", ":formation_extra_spacing", 50),
	(store_add, ":distance", 75, ":extra_space"),		#minimum distance between troops	
	(assign, ":num_troops", 0),
    (try_for_agents, ":agent"),
		(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
		(val_add, ":num_troops", 1),
	(end_try),
	(assign, ":troop_count", ":num_troops"),
	
	(try_begin),
		(eq, ":infantry_formation", formation_default),
		#find "team faction"
		(agent_get_troop_id, ":fleader_troop", ":fleader"),
		(store_troop_faction, ":ffaction", ":fleader_troop"),
		(try_begin),
			(eq, ":ffaction", fac_player_supporters_faction),
			(assign, ":ffaction", fac_player_faction),
		(try_end),
		(try_begin),
			(eq, ":ffaction", fac_player_faction),
			(gt, "$players_kingdom", 0),
			(neq, "$players_kingdom", fac_player_supporters_faction),
			(assign, ":ffaction", "$players_kingdom"),
		(try_end),

		#assign default formation
		(try_begin),
			(eq, ":ffaction", fac_kingdom_1),	#Swadians
			(assign, ":infantry_formation", formation_shield),
		(else_try),
			(eq, ":ffaction", fac_kingdom_2),	#Vaegirs
			(assign, ":infantry_formation", formation_ranks),
		(else_try),
			(eq, ":ffaction", fac_kingdom_3),	#Khergit
			(assign, ":infantry_formation", formation_none),	#Khergit have underdeveloped infantry
		(else_try),
			(eq, ":ffaction", fac_kingdom_4),	#Nords
			(assign, ":infantry_formation", formation_shield),
		(else_try),
			(eq, ":ffaction", fac_kingdom_5),	#Rhodoks
			(assign, ":infantry_formation", formation_shield),
		(else_try),
			(eq, ":ffaction", fac_player_faction),	#independent player
			(assign, ":infantry_formation", formation_ranks),
		(else_try),
			(assign, ":infantry_formation", formation_none),	#riffraff don't use formations
		(try_end),
	(try_end),

	(try_begin),
		(eq, ":infantry_formation", formation_square),
		(convert_to_fixed_point, ":num_troops"),
		(store_sqrt, ":square_dimension", ":num_troops"),
		(convert_from_fixed_point, ":square_dimension"),
		(val_add, ":square_dimension", 1),
		(assign, ":column", 1),
		(store_mul, ":neg_distance", ":distance", -1),
		(store_mul, ":move_back_x", ":square_dimension", ":neg_distance"),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(agent_set_scripted_destination, ":agent", pos1, 1),
			(position_move_x, pos1, ":distance", 0),
			(val_add, ":column", 1),
			(gt, ":column", ":square_dimension"),
			(position_move_x, pos1, ":move_back_x", 0),
			(position_move_y, pos1, ":neg_distance", 0),
			(assign, ":column", 1),		
		(end_try),
		
	(else_try),
		(eq, ":infantry_formation", formation_wedge),
		(assign, ":max_level", 0),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(agent_get_troop_id, ":troop_id", ":agent"),
			(store_character_level, ":troop_level", ":troop_id"),
			(gt, ":troop_level", ":max_level"),
			(assign, ":max_level", ":troop_level"),
		(end_try),
		(assign, ":column", 1),
		(assign, ":rank_dimension", 1),
		(store_mul, ":neg_distance", ":distance", -1),
		(store_mul, ":move_back_x", ":rank_dimension", ":neg_distance"),
		(store_div, ":wedge_adj", ":neg_distance", 2),
		(val_add, ":max_level", 1),
		(try_for_range_backwards, ":rank_level", 0, ":max_level"),	#put troops with highest exp in front
			(try_for_agents, ":agent"),
				(agent_get_troop_id, ":troop_id", ":agent"),
				(store_character_level, ":troop_level", ":troop_id"),
				(eq, ":troop_level", ":rank_level"),				
				(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
				(agent_set_scripted_destination, ":agent", pos1, 1),
				(position_move_x, pos1, ":distance", 0),
				(val_add, ":column", 1),
				(gt, ":column", ":rank_dimension"),
				(position_move_x, pos1, ":move_back_x", 0),
				(position_move_x, pos1, ":wedge_adj", 0),
				(position_move_y, pos1, ":neg_distance", 0),
				(assign, ":column", 1),
				(val_add, ":rank_dimension", 1),
				(store_mul, ":move_back_x", ":rank_dimension", ":neg_distance"),
			(end_try),
		(end_try),
		
	(else_try),
		(eq, ":infantry_formation", formation_ranks),
		(store_div, ":rank_dimension", ":num_troops", 3),		#basic three ranks
		(val_add, ":rank_dimension", 1),		
		(assign, ":max_level", 0),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(agent_get_troop_id, ":troop_id", ":agent"),
			(store_character_level, ":troop_level", ":troop_id"),
			(gt, ":troop_level", ":max_level"),
			(assign, ":max_level", ":troop_level"),
		(end_try),

		(assign, ":column", 1),
		(store_mul, ":neg_distance", ":distance", -1),
		(store_mul, ":move_back_x", ":rank_dimension", ":neg_distance"),
		(val_add, ":max_level", 1),
		(try_for_range_backwards, ":rank_level", 0, ":max_level"),	#put troops with highest exp in front
			(try_for_agents, ":agent"),
				(agent_get_troop_id, ":troop_id", ":agent"),
				(store_character_level, ":troop_level", ":troop_id"),
				(eq, ":troop_level", ":rank_level"),				
				(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
				(agent_set_scripted_destination, ":agent", pos1, 1),
				(position_move_x, pos1, ":distance", 0),
				(val_add, ":column", 1),
				(gt, ":column", ":rank_dimension"),
				(position_move_x, pos1, ":move_back_x", 0),
				(position_move_y, pos1, ":neg_distance", 0),
				(assign, ":column", 1),
			(end_try),
		(end_try),
		
	(else_try),
		(eq, ":infantry_formation", formation_shield),
		(store_div, ":rank_dimension", ":num_troops", 3),		#basic three ranks
		(val_add, ":rank_dimension", 1),
		(assign, ":column", 1),
		(store_mul, ":neg_distance", ":distance", -1),
		(store_mul, ":move_back_x", ":rank_dimension", ":neg_distance"),
	#shields
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 1),
			(gt, ":agent_weapon", -1),
			(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(eq, ":agent_weapon_type", itp_type_shield),
			(agent_set_scripted_destination, ":agent", pos1, 1),
			(position_move_x, pos1, ":distance", 0),
			(val_add, ":column", 1),
			(gt, ":column", ":rank_dimension"),
			(position_move_x, pos1, ":move_back_x", 0),
			(position_move_y, pos1, ":neg_distance", 0),
			(assign, ":column", 1),
		(try_end),
	#short weapons
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(assign, ":agent_weapon_type", 0),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 0),
			(try_begin),
				(gt, ":agent_weapon", -1),
				(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(try_end),
			(neq, ":agent_weapon_type", itp_type_polearm),
			(assign, ":agent_weapon_type", 0),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 1),
			(try_begin),
				(gt, ":agent_weapon", -1),
				(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(try_end),
			(neq, ":agent_weapon_type", itp_type_shield),
			(agent_set_scripted_destination, ":agent", pos1, 1),
			(position_move_x, pos1, ":distance", 0),
			(val_add, ":column", 1),
			(gt, ":column", ":rank_dimension"),
			(position_move_x, pos1, ":move_back_x", 0),
			(position_move_y, pos1, ":neg_distance", 0),
			(assign, ":column", 1),
		(try_end),
	#pole weapons
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", grc_infantry, ":fleader", ":agent"),
			(assign, ":agent_weapon_type", 0),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 1),
			(try_begin),
				(gt, ":agent_weapon", -1),
				(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(try_end),
			(neq, ":agent_weapon_type", itp_type_shield),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 0),
			(gt, ":agent_weapon", -1),
			(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(eq, ":agent_weapon_type", itp_type_polearm),
			(agent_set_scripted_destination, ":agent", pos1, 1),
			(position_move_x, pos1, ":distance", 0),
			(val_add, ":column", 1),
			(gt, ":column", ":rank_dimension"),
			(position_move_x, pos1, ":move_back_x", 0),
			(position_move_y, pos1, ":neg_distance", 0),
			(assign, ":column", 1),
		(try_end),
	(try_end),
	(assign, reg0, ":troop_count")
  ]),


  # script_formation_current_position by motomataru
  # Input: destination position, team, troop class, team leader, formation type
  # Output: in destination position
  ("formation_current_position", [
	(store_script_param, ":fposition", 1),
	(store_script_param, ":fteam", 2),
	(store_script_param, ":fclass", 3),
	(store_script_param, ":fleader", 4),
	(store_script_param, ":fformation", 5),
	(assign, ":first_agent_in_formation", -1),
	(try_begin),
		(eq, ":fformation", formation_square),
		(try_for_agents, ":agent"),
			(eq, ":first_agent_in_formation", -1),
			(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
			(assign, ":first_agent_in_formation", ":agent"),
		(try_end),
	(else_try),
		(eq, ":fformation", formation_shield),
		(try_for_agents, ":agent"),
			(eq, ":first_agent_in_formation", -1),
			(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 1),
			(gt, ":agent_weapon", -1),
			(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(eq, ":agent_weapon_type", itp_type_shield),
			(assign, ":first_agent_in_formation", ":agent"),
		(try_end),
		(try_for_agents, ":agent"),
			(eq, ":first_agent_in_formation", -1),
			(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
			(assign, ":agent_weapon_type", 0),
			(agent_get_wielded_item, ":agent_weapon", ":agent", 0),
			(try_begin),
				(gt, ":agent_weapon", -1),
				(item_get_type, ":agent_weapon_type", ":agent_weapon"),
			(try_end),
			(neq, ":agent_weapon_type", itp_type_polearm),
			(assign, ":first_agent_in_formation", ":agent"),
		(try_end),
		(try_for_agents, ":agent"),
			(eq, ":first_agent_in_formation", -1),
			(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
			(assign, ":first_agent_in_formation", ":agent"),	#must have polearm w/o shields...
		(try_end),
	(else_try),	#must be a level sort
		(assign, ":rank_level", 0),
		(try_for_agents, ":agent"),
			(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
			(agent_get_troop_id, ":troop_id", ":agent"),
			(store_character_level, ":troop_level", ":troop_id"),
			(gt, ":troop_level", ":rank_level"),
			(assign, ":rank_level", ":troop_level"),
			(assign, ":first_agent_in_formation", ":agent"),
		(try_end),
	(try_end),
	(call_script, "script_get_formation_position", pos0, ":fteam", ":fclass"),
	(try_begin),
		(eq, ":first_agent_in_formation", -1),
		(copy_position, ":fposition", pos0),
	(else_try),
		(agent_get_position, ":fposition", ":first_agent_in_formation"),
# (position_get_x, reg0, ":fposition"),
# (position_get_y, reg1, ":fposition"),
# (display_message, "@Inf leader at {reg0},{reg1}"),
		(position_copy_rotation, ":fposition", pos0),
	(try_end),
  ]),

  
# script_formation_end
# Input: team, troop class
# Output: none
  ("formation_end",
   [(store_script_param, ":fteam", 1),
    (store_script_param, ":fclass", 2),
	(try_for_agents, ":agent"),
       (agent_is_alive, ":agent"),
       (agent_is_human, ":agent"),
       (agent_get_team, ":team", ":agent"),
       (eq, ":team", ":fteam"),
       (agent_get_class, ":class", ":agent"),
       (this_or_next|eq, ":class", ":fclass"), 
       (eq, ":fclass", grc_everyone), 
       (agent_clear_scripted_mode, ":agent"),
     (try_end),]),


  # script_formation_move_position v2 by motomataru
  # Input: team, troop class, formation type, formation current position, (1 to advance or -1 to withdraw or 0 to redirect)
  # Output: pos1
  ("formation_move_position", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fclass", 2),
	(store_script_param, ":fcurrentpos", 3),
	(store_script_param, ":direction", 4),
	(copy_position, pos1, ":fcurrentpos"),
	(call_script, "script_team_get_average_position_of_enemies_augmented", pos60, ":fteam", grc_everyone),
	(try_begin),
		(neq, reg0, 0),	#more than 0 enemies still alive?
		(call_script, "script_cf_team_get_average_position_of_agents_with_type_to_pos1", ":fteam", ":fclass"),
		(call_script, "script_point_y_toward_position", pos60, pos1),	#record angle from center to enemy
		(store_mul, ":distance_to_enemy", reg0, 100),
		(copy_position, pos1, ":fcurrentpos"),	#restore current formation "position"
		(position_copy_rotation, pos1, pos60),	#copy angle from center of angle (to center approach)
		(position_rotate_z, pos1, 180),
#		(team_get_order_position, pos61, ":fteam", ":fclass"),
		(call_script, "script_get_formation_position", pos61, ":fteam", ":fclass"),
		(get_distance_between_positions, ":move_amount", pos1, pos61),	#distance already moving from previous orders
		(val_add, ":move_amount", 1000),
		(try_begin),
			(gt, ":direction", 0),	#moving forward?
			(gt, ":move_amount", ":distance_to_enemy"),
			(assign, ":move_amount", ":distance_to_enemy"),
		(try_end),
		(val_mul, ":move_amount", ":direction"),
		(position_move_y, pos1, ":move_amount", 0),
		(try_begin),
			(lt, ":distance_to_enemy", 1000),	#less than a move away?
			(position_copy_rotation, pos1, pos61),	#avoid rotating formation
		(try_end),
#		(team_set_order_position, ":fteam", ":fclass", pos1),
		(call_script, "script_set_formation_position", ":fteam", ":fclass", pos1),
	(try_end),
  ]),


  # script_set_formation_position by motomataru
  # Input: team, troop class, position
  # Kluge around buggy *_order_position functions for teams 0-3
  ("set_formation_position", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fclass", 2),
	(store_script_param, ":fposition", 3),
	(set_fixed_point_multiplier, 1),
	(try_begin),
		(eq, ":fteam", 0),
		(try_begin),
			(eq, ":fclass", 0),
			(position_get_x, "$formation_00_x", ":fposition"),
			(position_get_y, "$formation_00_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_00_rot", ":fposition"),
# (assign, reg0, "$formation_00_x"),
# (assign, reg1, "$formation_00_y"),
# (display_message, "@Team 0 inf to {reg0},{reg1}"),
		(else_try),
			(eq, ":fclass", 1),
			(position_get_x, "$formation_01_x", ":fposition"),
			(position_get_y, "$formation_01_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_01_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 2),
			(position_get_x, "$formation_02_x", ":fposition"),
			(position_get_y, "$formation_02_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_02_rot", ":fposition"),
		(end_try),
	(else_try),
		(eq, ":fteam", 1),
		(try_begin),
			(eq, ":fclass", 0),
			(position_get_x, "$formation_10_x", ":fposition"),
			(position_get_y, "$formation_10_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_10_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 1),
			(position_get_x, "$formation_11_x", ":fposition"),
			(position_get_y, "$formation_11_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_11_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 2),
			(position_get_x, "$formation_12_x", ":fposition"),
			(position_get_y, "$formation_12_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_12_rot", ":fposition"),
		(end_try),
	(else_try),
		(eq, ":fteam", 2),
		(try_begin),
			(eq, ":fclass", 0),
			(position_get_x, "$formation_20_x", ":fposition"),
			(position_get_y, "$formation_20_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_20_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 1),
			(position_get_x, "$formation_21_x", ":fposition"),
			(position_get_y, "$formation_21_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_21_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 2),
			(position_get_x, "$formation_22_x", ":fposition"),
			(position_get_y, "$formation_22_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_22_rot", ":fposition"),
		(end_try),
	(else_try),
		(eq, ":fteam", 3),
		(try_begin),
			(eq, ":fclass", 0),
			(position_get_x, "$formation_30_x", ":fposition"),
			(position_get_y, "$formation_30_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_30_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 1),
			(position_get_x, "$formation_31_x", ":fposition"),
			(position_get_y, "$formation_31_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_31_rot", ":fposition"),
		(else_try),
			(eq, ":fclass", 2),
			(position_get_x, "$formation_32_x", ":fposition"),
			(position_get_y, "$formation_32_y", ":fposition"),
			(position_get_rotation_around_z, "$formation_32_rot", ":fposition"),
		(end_try),	
	(end_try),
	(team_set_order_position, ":fteam", ":fclass", ":fposition"),
  ]),	


  # script_get_formation_position by motomataru
  # Input: position, team, troop class
  # Output: input position (pos0 used)
  # Kluge around buggy *_order_position functions for teams 0-3
  ("get_formation_position", [
	(store_script_param, ":fposition", 1),
	(store_script_param, ":fteam", 2),
	(store_script_param, ":fclass", 3),
	(init_position, ":fposition"),
	(set_fixed_point_multiplier, 1),
	(try_begin),
		(eq, ":fteam", 0),
		(try_begin),
			(eq, ":fclass", 0),
			(position_set_x, ":fposition", "$formation_00_x"),
			(position_set_y, ":fposition", "$formation_00_y"),
			(position_rotate_z, ":fposition", "$formation_00_rot"),
		(else_try),
			(eq, ":fclass", 1),
			(position_set_x, ":fposition", "$formation_01_x"),
			(position_set_y, ":fposition", "$formation_01_y"),
			(position_rotate_z, ":fposition", "$formation_01_rot"),
		(else_try),
			(eq, ":fclass", 2),
			(position_set_x, ":fposition", "$formation_02_x"),
			(position_set_y, ":fposition", "$formation_02_y"),
			(position_rotate_z, ":fposition", "$formation_02_rot"),
		(try_end),
	(else_try),
		(eq, ":fteam", 1),
		(try_begin),
			(eq, ":fclass", 0),
			(position_set_x, ":fposition", "$formation_10_x"),
			(position_set_y, ":fposition", "$formation_10_y"),
			(position_rotate_z, ":fposition", "$formation_10_rot"),
		(else_try),
			(eq, ":fclass", 1),
			(position_set_x, ":fposition", "$formation_11_x"),
			(position_set_y, ":fposition", "$formation_11_y"),
			(position_rotate_z, ":fposition", "$formation_11_rot"),
		(else_try),
			(eq, ":fclass", 2),
			(position_set_x, ":fposition", "$formation_12_x"),
			(position_set_y, ":fposition", "$formation_12_y"),
			(position_rotate_z, ":fposition", "$formation_12_rot"),
		(try_end),
	(else_try),
		(eq, ":fteam", 2),
		(try_begin),
			(eq, ":fclass", 0),
			(position_set_x, ":fposition", "$formation_20_x"),
			(position_set_y, ":fposition", "$formation_20_y"),
			(position_rotate_z, ":fposition", "$formation_20_rot"),
		(else_try),
			(eq, ":fclass", 1),
			(position_set_x, ":fposition", "$formation_21_x"),
			(position_set_y, ":fposition", "$formation_21_y"),
			(position_rotate_z, ":fposition", "$formation_21_rot"),
		(else_try),
			(eq, ":fclass", 2),
			(position_set_x, ":fposition", "$formation_22_x"),
			(position_set_y, ":fposition", "$formation_22_y"),
			(position_rotate_z, ":fposition", "$formation_22_rot"),
		(try_end),
	(else_try),
		(eq, ":fteam", 3),
		(try_begin),
			(eq, ":fclass", 0),
			(position_set_x, ":fposition", "$formation_30_x"),
			(position_set_y, ":fposition", "$formation_30_y"),
			(position_rotate_z, ":fposition", "$formation_30_rot"),
		(else_try),
			(eq, ":fclass", 1),
			(position_set_x, ":fposition", "$formation_31_x"),
			(position_set_y, ":fposition", "$formation_31_y"),
			(position_rotate_z, ":fposition", "$formation_31_rot"),
		(else_try),
			(eq, ":fclass", 2),
			(position_set_x, ":fposition", "$formation_32_x"),
			(position_set_y, ":fposition", "$formation_32_y"),
			(position_rotate_z, ":fposition", "$formation_32_rot"),
		(try_end),	
	(else_try),
		(call_script, "script_choose_formation_leader", ":fteam", ":fclass"),
		(try_begin),	  # "launder" team_get_order_position shutting down position_move_x
			(gt, reg2, -1),
			(team_get_order_position, ":fposition", ":fteam", ":fclass"),
			(agent_get_position, pos0, reg2),
			(agent_set_position, reg2, ":fposition"),
			(agent_get_position, ":fposition", reg2),
			(agent_set_position, reg2, pos0),
		(try_end),
	(try_end),
	(position_set_z_to_ground_level, ":fposition"),
  ]),	

	
  # script_choose_formation_leader
  # Input: team, troop class
  # Output: reg2 leader agent number or -1
  # Just pick first member of formation
  ("choose_formation_leader",
   [(store_script_param, ":fteam", 1),
    (store_script_param, ":fclass", 2),
	(team_get_leader, ":fleader", ":fteam"),
	(assign, reg2, -1),
    (try_for_agents, ":agent"),
		(call_script, "script_cf_valid_formation_member", ":fteam", ":fclass", ":fleader", ":agent"),
        (eq, reg2, -1),
        (assign, reg2, ":agent"),
    (end_try),]),

	
  # script_cf_valid_formation_member by motomataru
  # Input: team, troop class, agent number of team leader, test agent
  # Output: failure indicates agent is not member of formation
  ("cf_valid_formation_member", [
	(store_script_param, ":fteam", 1),
	(store_script_param, ":fclass", 2),
	(store_script_param, ":fleader", 3),
	(store_script_param, ":agent", 4),
	(agent_get_class, ":class", ":agent"),
	(eq, ":class", ":fclass"),
	(agent_get_team, ":team", ":agent"),
	(eq, ":team", ":fteam"),
	(agent_is_alive, ":agent"),
	(agent_is_human, ":agent"),
	(neq, ":fleader", ":agent"),
  ]),

	
# #Player team formations functions

  # script_player_attempt_formation
  # Inputs:	arg1: troop class (grc_*)
  #			arg2: formation identifier (formation_*)
  # Output: none
  ("player_attempt_formation", [
	(store_script_param, ":fclass", 1),
	(store_script_param, ":fformation", 2),
	(try_begin),
		(class_is_listening_order, "$fplayer_team_no", ":fclass"),
		(try_begin),
			(eq, ":fclass", grc_infantry),
			(try_begin),
				(neq, "$infantry_formation_type", ":fformation"),
				(assign, "$infantry_formation_type", ":fformation"),
				(display_message, "@Infantry forming {s1}."),
				(lt, "$infantry_space", 2),
				(assign, "$infantry_space", 2),	#spread out for ease of forming up
			(try_end),
			(try_begin),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_infantry, "$infantry_space", "$infantry_formation_type"),
				(assign, "$infantry_formation_move_order", mordr_hold),
			(else_try),
				(call_script, "script_formation_end", "$fplayer_team_no", grc_infantry),
				(display_message, "@Not enough infantry to make formations."),
				(assign, "$infantry_formation_type", formation_none),
			(try_end),
			(set_show_messages, 0),
			(team_give_order, "$fplayer_team_no", grc_infantry, mordr_hold),
			(set_show_messages, 1),
		(else_try),
			(eq, ":fclass", grc_cavalry),
			(try_begin),
				(neq, "$cavalry_formation_type", ":fformation"),
				(assign, "$cavalry_formation_type", ":fformation"),
				(display_message, "@Cavalry forming {s1}."),
				(lt, "$cavalry_space", 0),
				(assign, "$cavalry_space", 0),	#spread out for ease of forming up
			(try_end),
			(try_begin),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_cavalry, "$cavalry_space", "$cavalry_formation_type"),
				(assign, "$cavalry_formation_move_order", mordr_hold),
			(else_try),
				(call_script, "script_formation_end", "$fplayer_team_no", grc_cavalry),
				(display_message, "@Not enough cavalry to make formations."),
				(assign, "$cavalry_formation_type", formation_none),
			(try_end),
			(set_show_messages, 0),
			(team_give_order, "$fplayer_team_no", grc_cavalry, mordr_hold),
			(set_show_messages, 1),
		(else_try),	#must be archers
			(try_begin),
				(neq, "$archer_formation_type", ":fformation"),
				(assign, "$archer_formation_type", ":fformation"),
				(display_message, "@Archers forming {s1}."),
				(lt, "$archer_space", 2),
				(assign, "$archer_space", 2),	#spread out for ease of forming up
			(try_end),
			(try_begin),
				(call_script, "script_cf_formation", "$fplayer_team_no", grc_archers, "$archer_space", "$archer_formation_type"),
				(assign, "$archer_formation_move_order", mordr_hold),
			(else_try),
				(call_script, "script_formation_end", "$fplayer_team_no", grc_archers),
				(display_message, "@Not enough archers to make formations."),
				(assign, "$archer_formation_type", formation_none),
			(try_end),
			(set_show_messages, 0),
			(team_give_order, "$fplayer_team_no", grc_archers, mordr_hold),
			(set_show_messages, 1),
		(try_end),
	(try_end)
  ]),

  
# #Utilities used by formations
  # script_point_y_toward_position by motomataru
  # Input: from position, to position
  # Output: pos62 normalized vector, reg0 distance
  ("point_y_toward_position", [
	(store_script_param, ":from_position", 1),
	(store_script_param, ":to_position", 2),
	(position_transform_position_to_local, pos62, ":from_position", ":to_position"),
	(position_normalize_origin, ":distance_between", pos62),
	(convert_from_fixed_point, ":distance_between"),
	(position_get_x, ":dir_x", pos62),
	(position_get_y, ":dir_y", pos62),
	(try_begin),
		(lt, ":dir_x", 0),
		(assign, ":bound_a", 90),
		(assign, ":bound_b", 270),
		(assign, ":theta", 180),
	(else_try),
		(assign, ":bound_a", 90),
		(assign, ":bound_b", -90),
		(assign, ":theta", 0),
	(try_end),
	(assign, ":sine_theta", 0),	#avoid error on compile
	(convert_to_fixed_point, ":theta"),
	(convert_to_fixed_point, ":bound_a"),
	(convert_to_fixed_point, ":bound_b"),
	(try_for_range, ":angle_splits", 0, 6),	#precision 90/2exp6 (around 2 degrees)
		(store_sin, ":sine_theta", ":theta"),
		(try_begin),
			(gt, ":sine_theta", ":dir_y"),
			(assign, ":bound_a", ":theta"),
		(else_try),
			(lt, ":sine_theta", ":dir_y"),
			(assign, ":bound_b", ":theta"),
		(try_end),
		(store_add, ":angle_sum", ":bound_b", ":bound_a"),
		(store_div, ":theta", ":angle_sum", 2),
	(try_end),
	(try_begin),
		(ge, ":angle_splits", 0),	#suppress warning on compile
	(try_end),
	(convert_from_fixed_point, ":theta"),
	(val_sub, ":theta", 90),	#point y-axis at destination
	(position_rotate_z, ":from_position", ":theta"),
	(assign, reg0, ":distance_between"),
  ]),


  # script_team_get_average_position_of_enemies_augmented
  # Inputs:	arg1: destination position number
  #			arg2: team_no
  #			arg3: troop class (grc_*)
  # Output: destination position: average position if reg0 > 0
  #			reg0: number of enemies
  # Used: pos62
  ("team_get_average_position_of_enemies_augmented", [
	(store_script_param, ":position_no", 1),
	(store_script_param, ":team_no", 2),
	(store_script_param, ":troop_type", 3),
	(init_position, ":position_no"),
	(assign, ":num_enemies", 0),
	(assign, ":accum_x", 0),
	(assign, ":accum_y", 0),
	(assign, ":accum_z", 0),
	(try_for_agents, ":enemy_agent"),
		(agent_is_alive, ":enemy_agent"),
		(agent_is_human, ":enemy_agent"),
		(agent_get_team, ":enemy_team", ":enemy_agent"),
		(teams_are_enemies, ":team_no", ":enemy_team"),
		(agent_get_class, ":class", ":enemy_agent"),
		(this_or_next|eq, ":troop_type", ":class"),
		(eq, ":troop_type", grc_everyone),

		(agent_get_position, pos62, ":enemy_agent"),
		(position_get_x, ":x", pos62),
		(position_get_y, ":y", pos62),
		(position_get_z, ":z", pos62),
		(val_add, ":accum_x", ":x"),
		(val_add, ":accum_y", ":y"),
		(val_add, ":accum_z", ":z"),
		(val_add, ":num_enemies", 1),
	(try_end),
	(try_begin),
		(gt, ":num_enemies", 0),
		(store_div, ":average_x", ":accum_x", ":num_enemies"),
		(store_div, ":average_y", ":accum_y", ":num_enemies"),
		(store_div, ":average_z", ":accum_z", ":num_enemies"),
		(position_set_x, ":position_no", ":average_x"),
		(position_set_y, ":position_no", ":average_y"),
		(position_set_z, ":position_no", ":average_z"),
	(try_end),
	(assign, reg0, ":num_enemies"),
  ]),
 
And finally the modified AI functions in module_scripts. Replace these functions in module_scripts.

Code:
# # M&B Standard AI with changes for formations
  # script_battle_tactic_init_aux
  # Input: team_no, battle_tactic
  # Output: none
  ("battle_tactic_init_aux",
    [
      (store_script_param, ":team_no", 1),
      (store_script_param, ":battle_tactic", 2),
      (team_get_leader, ":ai_leader", ":team_no"),
      (try_begin),
        (eq, ":battle_tactic", btactic_hold),
        (agent_get_position, pos1, ":ai_leader"),
        (call_script, "script_find_high_ground_around_pos1", ":team_no", 30),
        (copy_position, pos1, pos52),
        (call_script, "script_find_high_ground_around_pos1", ":team_no", 30), # call again just in case we are not at peak point.
        (copy_position, pos1, pos52),
        (call_script, "script_find_high_ground_around_pos1", ":team_no", 30), # call again just in case we are not at peak point.
        (team_give_order, ":team_no", grc_everyone, mordr_hold),
        (team_set_order_position, ":team_no", grc_everyone, pos52),
        (team_give_order, ":team_no", grc_archers, mordr_advance),
        (team_give_order, ":team_no", grc_archers, mordr_advance),
		(call_script, "script_cf_formation", ":team_no", grc_infantry, 0, formation_default),
		(call_script, "script_cf_formation", ":team_no", grc_cavalry, 0, formation_wedge),
		(call_script, "script_cf_formation", ":team_no", grc_archers, 0, formation_default),
        (team_give_order, ":team_no", grc_archers, mordr_spread_out),
        (team_give_order, ":team_no", grc_archers, mordr_spread_out),
      (else_try),
        (eq, ":battle_tactic", btactic_follow_leader),
        (team_get_leader, ":ai_leader", ":team_no"),
        (agent_set_speed_limit, ":ai_leader", 8),
        (agent_get_position, pos60, ":ai_leader"),
        (team_give_order, ":team_no", grc_everyone, mordr_hold),
        (team_set_order_position, ":team_no", grc_everyone, pos60),
		(call_script, "script_cf_formation", ":team_no", grc_infantry, 0, formation_default),
		(call_script, "script_cf_formation", ":team_no", grc_cavalry, 0, formation_wedge),
		(call_script, "script_cf_formation", ":team_no", grc_archers, 0, formation_default),
        (team_give_order, ":team_no", grc_archers, mordr_spread_out),
        (team_give_order, ":team_no", grc_archers, mordr_spread_out),
      (try_end),
  ]),
  
  # script_battle_tactic_apply_aux
  # Input: team_no, battle_tactic
  # Output: battle_tactic
  ("battle_tactic_apply_aux",
    [
      (store_script_param, ":team_no", 1),
      (store_script_param, ":battle_tactic", 2),
      (store_mission_timer_a, ":mission_time"),
      (try_begin),
        (eq, ":battle_tactic", btactic_hold),
        (copy_position, pos1, pos52),
        (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team_no", 1),
        (assign, ":avg_dist", reg0),
        (assign, ":min_dist", reg1),
        (try_begin),
          (this_or_next|lt, ":min_dist", 1000),
          (lt, ":avg_dist", 4000),
          (assign, ":battle_tactic", 0),
		  (call_script, "script_formation_end", ":team_no", grc_everyone),
          (team_give_order, ":team_no", grc_everyone, mordr_charge),
        (try_end),
      (else_try),
        (eq, ":battle_tactic", btactic_follow_leader),
        (team_get_leader, ":ai_leader", ":team_no"),
        (agent_set_speed_limit, ":ai_leader", 9),
        (call_script, "script_team_get_average_position_of_enemies", ":team_no"),
        (copy_position, pos60, pos0),
        (agent_get_position, pos61, ":ai_leader"),
        (position_transform_position_to_local, pos62, pos61, pos60), #pos62 = vector to enemy w.r.t leader
        (position_normalize_origin, ":distance_to_enemy", pos62),
        (convert_from_fixed_point, ":distance_to_enemy"),
        (assign, reg17, ":distance_to_enemy"),
        (position_get_x, ":dir_x", pos62),
        (position_get_y, ":dir_y", pos62),
        (val_mul, ":dir_x", 23),
        (val_mul, ":dir_y", 23), #move 23 meters
        (position_set_x, pos62, ":dir_x"),
        (position_set_y, pos62, ":dir_y"),
      
        (position_transform_position_to_parent, pos63, pos61, pos62), #pos63 is 23m away from leader in the direction of the enemy.
        (position_set_z_to_ground_level, pos63),
      
        (team_give_order, ":team_no", grc_everyone, mordr_hold),
        (team_set_order_position, ":team_no", grc_everyone, pos63),
		(call_script, "script_cf_formation", ":team_no", grc_infantry, 0, formation_default),
		(call_script, "script_cf_formation", ":team_no", grc_cavalry, 0, formation_wedge),
		(call_script, "script_cf_formation", ":team_no", grc_archers, 0, formation_default),
#        (team_give_order, ":team_no", grc_everyone, mordr_follow),
        (agent_get_position, pos1, ":ai_leader"),
#        (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team_no"),
#        (assign, ":avg_dist", reg0),
#        (assign, ":min_dist", reg1),
        (try_begin),
          (lt, ":distance_to_enemy", 50),
          (ge, ":mission_time", 30),
          (assign, ":battle_tactic", 0),
		  (call_script, "script_formation_end", ":team_no", grc_everyone),
          (team_give_order, ":team_no", grc_everyone, mordr_charge),
          (agent_set_speed_limit, ":ai_leader", 60),
        (try_end),
      (try_end),
      
      (try_begin), # charge everyone after a while
        (neq, ":battle_tactic", 0),
        (ge, ":mission_time", 300),
        (assign, ":battle_tactic", 0),
		(call_script, "script_formation_end", ":team_no", grc_everyone),
        (team_give_order, ":team_no", grc_everyone, mordr_charge),
        (team_get_leader, ":ai_leader", ":team_no"),
        (agent_set_speed_limit, ":ai_leader", 60),
      (try_end),
      (assign, reg0, ":battle_tactic"),
  ]),
 
Excellent, glad you're still working on this.  I will attempt to implement it in my mod!
 
Okay i'm just revising my whole post.
It seems to be working great! I just started a new build for AoCII

but I'm getting this with your scripts.
And more up top something about a name being undefined, i think for an infantry.
Am i missing something?
WARNING: Usage of unassigned global variable: $cavalry_formation_type
WARNING: Usage of unassigned global variable: $cavalry_space
WARNING: Usage of unassigned global variable: $cavalry_space
WARNING: Usage of unassigned global variable: $cavalry_space
WARNING: Usage of unassigned global variable: $cavalry_formation_type
WARNING: Usage of unassigned global variable: $cavalry_formation_move_order
WARNING: Usage of unassigned global variable: $cavalry_formation_type
WARNING: Usage of unassigned global variable: $archer_formation_type
WARNING: Usage of unassigned global variable: $archer_formation_type
WARNING: Usage of unassigned global variable: $archer_space
WARNING: Usage of unassigned global variable: $archer_space
WARNING: Usage of unassigned global variable: $archer_space
WARNING: Usage of unassigned global variable: $archer_formation_type
WARNING: Usage of unassigned global variable: $archer_formation_move_order
WARNING: Usage of unassigned global variable: $archer_formation_type
Exporting mission_template data...
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
WARNING: Usage of unassigned global variable: $g_horses_are_avaliable
Exporting game menus data...
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $demanded_castle
WARNING: Usage of unassigned global variable: $demanded_castle
WARNING: Usage of unassigned global variable: $demanded_castle
WARNING: Usage of unassigned global variable: $demanded_castle
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_chamberlain
WARNING: Usage of unassigned global variable: $g_player_constable
WARNING: Usage of unassigned global variable: $g_constable_training_center
WARNING: Usage of unassigned global variable: $g_player_constable
WARNING: Usage of unassigned global variable: $g_player_constable
WARNING: Usage of unassigned global variable: $g_constable_training_center
WARNING: Usage of unassigned global variable: $g_player_chancellor
WARNING: Usage of unassigned global variable: $g_player_chancellor
WARNING: Usage of unassigned global variable: $g_player_chancellor
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
WARNING: Usage of unassigned global variable: $diplomacy_var
exporting simple triggers...
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_days_as_marshal
WARNING: Usage of unassigned global variable: $g_player_chancellor
WARNING: Usage of unassigned global variable: $g_player_chancellor
WARNING: Usage of unassigned global variable: $g_player_constable
WARNING: Usage of unassigned global variable: $g_constable_training_center
WARNING: Usage of unassigned global variable: $g_constable_training_center
WARNING: Usage of unassigned global variable: $g_constable_training_center
Traceback (most recent call last):
  File "process_dialogs.py", line 5, in <module>
    from module_triggers import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
Copy - Copy\module_triggers.py", line 1709, in <module>
    (call_script, "script_cf_formation", ":fteam", grc_infantry, "$infantry_spac
e"),
NameError: name 'grc_infantry' is not defined
Checking global variable usages...
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_presentation_obj_bugdet_report_container

WARNING: Global variable never used: $g_presentation_obj_bugdet_report_container

WARNING: Global variable never used: $g_presentation_obj_bugdet_report_container

WARNING: Global variable never used: $g_presentation_obj_bugdet_report_container

WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_game_before_quit_state
WARNING: Global variable never used: $g_game_before_quit_state
WARNING: Global variable never used: $g_game_before_quit_state
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_multiplayer_max_num_bots
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_player_culture
WARNING: Global variable never used: $g_player_culture
WARNING: Global variable never used: $g_player_culture
WARNING: Global variable never used: $g_player_culture
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $min_troops_for_formation
WARNING: Global variable never used: $formation_00_x
WARNING: Global variable never used: $formation_00_y
WARNING: Global variable never used: $formation_00_rot
WARNING: Global variable never used: $formation_01_x
WARNING: Global variable never used: $formation_01_y
WARNING: Global variable never used: $formation_01_rot
WARNING: Global variable never used: $formation_02_x
WARNING: Global variable never used: $formation_02_y
WARNING: Global variable never used: $formation_02_rot
WARNING: Global variable never used: $formation_10_x
WARNING: Global variable never used: $formation_10_y
WARNING: Global variable never used: $formation_10_rot
WARNING: Global variable never used: $formation_11_x
WARNING: Global variable never used: $formation_11_y
WARNING: Global variable never used: $formation_11_rot
WARNING: Global variable never used: $formation_12_x
WARNING: Global variable never used: $formation_12_y
WARNING: Global variable never used: $formation_12_rot
WARNING: Global variable never used: $formation_20_x
WARNING: Global variable never used: $formation_20_y
WARNING: Global variable never used: $formation_20_rot
WARNING: Global variable never used: $formation_21_x
WARNING: Global variable never used: $formation_21_y
WARNING: Global variable never used: $formation_21_rot
WARNING: Global variable never used: $formation_22_x
WARNING: Global variable never used: $formation_22_y
WARNING: Global variable never used: $formation_22_rot
WARNING: Global variable never used: $formation_30_x
WARNING: Global variable never used: $formation_30_y
WARNING: Global variable never used: $formation_30_rot
WARNING: Global variable never used: $formation_31_x
WARNING: Global variable never used: $formation_31_y
WARNING: Global variable never used: $formation_31_rot
WARNING: Global variable never used: $formation_32_x
WARNING: Global variable never used: $formation_32_y
WARNING: Global variable never used: $formation_32_rot
WARNING: Global variable never used: $formation_00_x
WARNING: Global variable never used: $formation_00_y
WARNING: Global variable never used: $formation_00_rot
WARNING: Global variable never used: $formation_01_x
WARNING: Global variable never used: $formation_01_y
WARNING: Global variable never used: $formation_01_rot
WARNING: Global variable never used: $formation_02_x
WARNING: Global variable never used: $formation_02_y
WARNING: Global variable never used: $formation_02_rot
WARNING: Global variable never used: $formation_10_x
WARNING: Global variable never used: $formation_10_y
WARNING: Global variable never used: $formation_10_rot
WARNING: Global variable never used: $formation_11_x
WARNING: Global variable never used: $formation_11_y
WARNING: Global variable never used: $formation_11_rot
WARNING: Global variable never used: $formation_12_x
WARNING: Global variable never used: $formation_12_y
WARNING: Global variable never used: $formation_12_rot
WARNING: Global variable never used: $formation_20_x
WARNING: Global variable never used: $formation_20_y
WARNING: Global variable never used: $formation_20_rot
WARNING: Global variable never used: $formation_21_x
WARNING: Global variable never used: $formation_21_y
WARNING: Global variable never used: $formation_21_rot
WARNING: Global variable never used: $formation_22_x
WARNING: Global variable never used: $formation_22_y
WARNING: Global variable never used: $formation_22_rot
WARNING: Global variable never used: $formation_30_x
WARNING: Global variable never used: $formation_30_y
WARNING: Global variable never used: $formation_30_rot
WARNING: Global variable never used: $formation_31_x
WARNING: Global variable never used: $formation_31_y
WARNING: Global variable never used: $formation_31_rot
WARNING: Global variable never used: $formation_32_x
WARNING: Global variable never used: $formation_32_y
WARNING: Global variable never used: $formation_32_rot
WARNING: Global variable never used: $infantry_formation_type
WARNING: Global variable never used: $infantry_formation_type
WARNING: Global variable never used: $infantry_space
WARNING: Global variable never used: $infantry_space
WARNING: Global variable never used: $infantry_space
WARNING: Global variable never used: $infantry_formation_type
WARNING: Global variable never used: $infantry_formation_move_order
WARNING: Global variable never used: $infantry_formation_type
WARNING: Global variable never used: $cavalry_formation_type
WARNING: Global variable never used: $cavalry_formation_type
WARNING: Global variable never used: $cavalry_space
WARNING: Global variable never used: $cavalry_space
WARNING: Global variable never used: $cavalry_space
WARNING: Global variable never used: $cavalry_formation_type
WARNING: Global variable never used: $cavalry_formation_move_order
WARNING: Global variable never used: $cavalry_formation_type
WARNING: Global variable never used: $archer_formation_type
WARNING: Global variable never used: $archer_formation_type
WARNING: Global variable never used: $archer_space
WARNING: Global variable never used: $archer_space
WARNING: Global variable never used: $archer_space
WARNING: Global variable never used: $archer_formation_type
WARNING: Global variable never used: $archer_formation_move_order
WARNING: Global variable never used: $archer_formation_type
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_horses_are_avaliable
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $demanded_castle
WARNING: Global variable never used: $demanded_castle
WARNING: Global variable never used: $demanded_castle
WARNING: Global variable never used: $demanded_castle
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_chamberlain
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $diplomacy_var
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_days_as_marshal
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_chancellor
WARNING: Global variable never used: $g_player_constable
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_constable_training_center
WARNING: Global variable never used: $g_constable_training_center
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
 
I think I am just confused on the installation.

Just module_constant Module_mission_template and Module_scripts get any code right?

And then i have to disable the code native Ai code?
 
No, Motomataru Formations add code only.

Mount&Blade -
You need put code in Mision_templates.py, down:

pilgrim_disguise = [itm_pilgrim_hood,itm_pilgrim_disguise,itm_practice_staff, itm_stones]
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian

Then, you copy: formations_triggers , and you put it end AI Triggers (down:      common_battle_order_panel,
common_battle_order_panel_tick,)


]+formations_triggers,

In Module_script, principal code must go to end. AI Code, you should find script and add lines that Motomataru said.

Constans.py is easy, only need add it end.



 
How did you get around the gk_order... vs gk_order_charge key problem Idbil?  I got it to work but it'd be best if I could get it to trigger when the right keys are pressed.
 
(Modified)

othr said:
How did you get around the gk_order... vs gk_order_charge key problem Idbil?  I got it to work but it'd be best if I could get it to trigger when the right keys are pressed.

Like this:

Code:
	(ti_before_mission_start, 0, 0, [], [
		(assign, "$gk_order", 0),
	]),

	(0, .2, .2, [(game_key_is_down, gk_order_1)], [
		(try_begin),
			(eq, "$gk_order", 0),
			(assign, "$gk_order", gk_order_1),
		(else_try),
			(try_begin),
				(eq, "$gk_order", gk_order_1),
				(call_script, "script_cf_check_order", ":fteam", mordr_hold),
				etc...
				(assign, "$gk_order", 0),
				
			(else_try),
				(eq, "$gk_order", gk_order_2),
				(call_script, "script_cf_check_order", ":fteam", mordr_advance),
				etc...
				(assign, "$gk_order", 0),
			
			(else_try),
				(eq, "$gk_order", gk_order_3),
				(call_script, "script_cf_check_order", ":fteam", mordr_hold_fire),
				(assign, "$gk_order", 0),
			(try_end),
		(try_end),
	]),

And so on for the other commands. Orders 4-6 slightly different because they don't initiate submenus and/or are missing from some submenus.

Problem is that we're second-guessing what WB is sensing. Initially I didn't have the check_order, but then my code was picking up player commands that WB was missing. Apparently WB does not interrupt its time-consuming menu display processing when the player does not wait for the menu to form before pressing a menu selection.

So then I added a script to check orders (meaning I had to delay .2 seconds because that's how long it takes on my computer for WB to process a command), but now it turns out that get_team_movement_order ONLY retrieves, well, movement orders. Plus it takes more than .2 seconds for WB to process a command when the LAST command was CHARGE. Plus I now have to figure out a way of capturing the "HOLD OVER THERE" command.

This also means that whatever I figure out won't work on slower computers where WB command processing will take even longer. Perhaps single-threading might help for them.

This would be a lot simpler and accurate if they had made game_key_is_down to register the compound key strokes as virtual keystrokes gk_order_charge, gk_order_hold, gk_order_hold_over_there, etc.
 
Ok so here is what I did: (and thanks for the help in advance)
I added formation_trggers to the module_mission_template file
just after
common_battle_order_panel = (
0, 0, 0, [],
  [
  (game_key_clicked, gk_view_orders),
    (neg|is_presentation_active, "prsnt_battle"),
    (start_presentation, "prsnt_battle"),
    ])

common_battle_order_panel_tick = (
  0.1, 0, 0, [],
  [
    (is_presentation_active, "prsnt_battle"),
    (call_script, "script_update_order_panel_statistics_and_map"),
    ])

Then i added the scripts to the module_Script file at the end, and the constant code.

Then i added ]+formations_triggers, at the very end of mission_templates.

This is what i get
]Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting scene data...
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting troops data
Exporting particle data...
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting party_template data...
Traceback (most recent call last):
  File "process_parties.py", line 6, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
  File "process_scripts.py", line 7, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_mission_tmps.py", line 5, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_game_menus.py", line 8, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Traceback (most recent call last):
  File "process_global_variables_unused.py", line 3, in <module>
    from process_operations import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\process_operations.py", line 21, in <module>
    from module_mission_templates import *
  File "C:\Download\warband modding\mb_warband_module_system_1113\modulesystem -
clean install - Works good - Copy\module_mission_templates.py", line 1051, in <
module>
    (0, 0, 1, [(game_key_is_down, gk_order_charge)], [
NameError: name 'gk_order_charge' is not defined
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
 
Back
Top Bottom