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

Mirathei

Sergeant Knight
Best answers
0
There's been a whole lot of interest in my formations of late, so a put together a kit which would allow both the player and the ai (allied or enemy) to use multiple moveable formations of either line, box, or wedge shape for any type of there troops. In addition, battlefield morale is implemented (thank you Chel) and a side which is being thoroughly beaten will rout.

Controlls: use the default native controlls to select cavalry, infantry, or archers. Use j to order your troops to form ranks, k to order a wedge, u to bring them out of formation, or p to order them to form a line. Use the default native commands for movement (ie. hold, follow, charge, advance), including the tactical minimap.

To add it in, simply follow the instructions below:

Copy and past the following under the triggers section of the "lead_charge" mission template (or any other template in which you desire formations):
Code:
########Tactical triggers below##########

(ti_before_mission_start, 0, 0, [], 
   [(assign,"$rout",0),
    (assign,"$airout",0),
    (assign,"$formation",0),
    (assign,"$infantryformationtype",0),
    (assign,"$archerformationtype",0),
    (assign,"$cavalryformationtype",0),]),


     (0, 0, 0,
      [(key_clicked, key_2),       
       (assign,"$formation",grc_infantry),
        ], []),
     (0, 0, 0,
      [(key_clicked, key_3),        
       (assign,"$formation",grc_archers),
        ], []),
     (0, 0, 0,
      [(key_clicked, key_4),        
       (assign,"$formation",grc_cavalry),
        ], []),


     (0, 0, 0,
      [(key_clicked, key_j),        
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",1),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",1),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",1),
       (end_try),
       (display_message,"@Forming_ranks."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_p),        
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation_stagger"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",3),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",3),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",3),
       (end_try),
       (display_message,"@Forming_a_line."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_k),        
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_cf_formation_wedge"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",2),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",2),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",2),
       (end_try),
       (display_message,"@Forming_a_wedge."),
        ], []),

     (0, 0, 0,
      [(key_clicked, key_u),        
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,"$formation"),
       (call_script,"script_formation_end"),
       (call_script,"script_cf_formation"),
       (try_begin),
          (eq,"$formation",grc_infantry),
          (assign,"$infantryformationtype",0),
       (else_try),
          (eq,"$formation",grc_archers),
          (assign,"$archerformationtype",0),
       (else_try),
          (eq,"$formation",grc_cavalry),
          (assign,"$cavalryformationtype",0),
       (end_try),
       (display_message,"@Formation_disassembled."),
        ], []),

     (5.0, 0, 0,
      [(try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (eq,"$airout",0),
       (agent_get_team  ,reg0, ":enemy"),
       (assign,reg1,grc_cavalry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_infantry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_archers),
       (call_script,"script_formation_end"),], []),

     (5.0, 0, 0,
      [(assign,":enemy",-1),
       (assign,":infantry",0),
       (assign,":cavalry",0),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (agent_is_alive,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
         (agent_get_class ,":class", ":agent"),
         (try_begin),
            (eq,":class",grc_cavalry),
            (val_add,":cavalry",1),
         (else_try),
            (val_add,":infantry",1),
         (end_try),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (assign,":ratio",":infantry"),
       (val_div,":ratio",":cavalry"),
       (try_begin),
         (gt,":ratio",2),
         (lt,":cavalry",10),
         (team_give_order, reg0, grc_everyone, mordr_dismount),
       (else_try),
         (team_give_order, reg0, grc_everyone, mordr_mount),
       (end_try),], []),


     (5.0, 0, 0,
      [(eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (assign,reg1,grc_cavalry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_infantry),
       (call_script,"script_formation_end"),
       (assign,reg1,grc_archers),
       (call_script,"script_formation_end"),], []),

     (5.0, 0, 0,
      [(neq, "$battle_won", 1),
       (assign,":infantry",0),
       (assign,":cavalry",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (agent_is_alive,":agent"),
         (agent_get_team  ,":team", ":agent"),
         (eq,":team",reg0),
         (agent_get_class ,":class", ":agent"),
         (try_begin),
            (eq,":class",grc_cavalry),
            (val_add,":cavalry",1),
         (else_try),
            (val_add,":infantry",1),
         (end_try),
       (end_try),
       (assign,":ratio",":infantry"),
       (val_div,":ratio",":cavalry"),
       (try_begin),
         (gt,":ratio",2),
         (lt,":cavalry",10),
         (team_give_order, reg0, grc_everyone, mordr_dismount),
       (else_try),
         (team_give_order, reg0, grc_everyone, mordr_mount),
       (end_try),], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_infantry),
       (try_begin),
          (eq,"$infantryformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$infantryformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$infantryformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_archers),
       (try_begin),
          (eq,"$archerformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$archerformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$archerformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (assign,reg1,grc_cavalry),
       (try_begin),
          (eq,"$cavalryformationtype",1),
          (call_script,"script_cf_formation"),
       (else_try),
          (eq,"$cavalryformationtype",2),
          (call_script,"script_cf_formation_wedge"),
       (else_try),
          (eq,"$cavalryformationtype",3),
          (call_script,"script_cf_formation_stagger"),
       (else_try),
          (call_script,"script_formation_end"),
       (end_try),], []),

     (0.2, 0, 0,
      [(eq,"$airout",0),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_infantry),
       (call_script,"script_cf_formation"),
        ], []),

     (0.2, 0, 0,
      [(eq,"$airout",0),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_archers),
       (call_script,"script_cf_formation_stagger"),
        ], []),

     (0.2, 0, 0,
      [(eq,"$airout",0),
       (try_for_agents,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (assign,":enemy",":agent"),
       (end_try),
       (gt,":enemy",-1),
       (agent_get_team  ,reg0, ":enemy"),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_cavalry),
       (call_script,"script_cf_formation_wedge"),
        ], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (neq, "$battle_won", 1),
       (eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_infantry),
       (call_script,"script_cf_formation"),
        ], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (neq, "$battle_won", 1),
       (eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_archers),
       (call_script,"script_cf_formation_stagger"),
        ], []),

     (0.2, 0, 0,
      [(eq,"$rout",0),
       (neq, "$battle_won", 1),
       (eq,"$rout",0),
       (get_player_agent_no,":player"),
       (agent_get_team  ,reg0, ":player"),
       (val_add,reg0,2),
       (store_normalized_team_count,":num", reg0),  
       (gt,":num",5),
       (assign,reg1,grc_cavalry),
       (call_script,"script_cf_formation_wedge"),
        ], []),




     (1, 0, ti_once, [], [
        (get_player_agent_kill_count,"$base_kills",0),
        (assign,"$new_kills_a",0),
		(assign,"$new_kills",0),
         ]),

     (3, 0, 3, [], [
        (get_player_agent_kill_count,":more_kills",0),
        (val_sub,":more_kills","$base_kills"),
		(try_begin),
            (gt,":more_kills","$new_kills_a"),
            (assign,"$new_kills_a",":more_kills"),
			(assign,"$new_kills",":more_kills"),
			(val_div,"$new_kills",2),
            (assign,reg1,":more_kills"),
            (display_message,"@You have killed {reg1} enemies in this battle!",0x6495ed),         
            (display_message,"@Your bravery inspires your troops!",0x6495ed),
        (try_end),
         ]),


		 
     (0, 0, 2, [(key_clicked, key_t)], [
(call_script, "script_coherence"),    
(call_script, "script_healthbars"),       
         ]),

     (0, 0, ti_once, [(key_clicked, key_y)], [
#(play_sound,"snd_battle_cry_n"),
(display_message,"@You rally your men!",0x7ccd7c),
(call_script, "script_battle_cry"),
(call_script, "script_hero_exp_penalty"),       
         ]),
     (10, 0, 20, [ ], [
(call_script, "script_rally"),       
         ]),
     (0, 10, 100, [(key_clicked, key_v),(display_message,"@You call for reinforcements!",0x6495ed) ], [
(display_message,"@Reinforcements arrive!",0x6495ed), 
(add_reinforcements_to_entry,0,7),
(add_reinforcements_to_entry,3,7),
(call_script, "script_hero_exp_penalty"),       
         ]),      

      

(1, 0, ti_once, [ ], [
(call_script, "script_coherence"),    
         ]),						


      
(15, 0, 10, [ ], [
(call_script, "script_coherence"),    
(call_script, "script_morale_check"),    
         ]),
(5, 0, 3, [ ], [
(call_script, "script_coherence"),    
(call_script, "script_rout_check"),       
         ]),



##########Tactical triggers above#########
Copy and past the following into the bottom of module_scripts.py:
Code:
  ("cf_formation",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
       (assign,":leader",":teamleader"),
    (else_try),
       (call_script,"script_choose_formation_leader"),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try),  
    (gt,":leader",-1),  
    (agent_get_position,1,":leader"),
    (position_move_x,1,100),
    (assign,":collumn",1),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),                                   
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,100),
       (try_begin),
          (eq,":collumn",12),
          (position_move_x,1,-12*100),
          (position_move_y,1,-200),
          (assign,":collumn",1),
       (else_try),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

  ("cf_formation_stagger",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
       (assign,":leader",":teamleader"),
    (else_try),
       (call_script,"script_choose_formation_leader"),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try),  
    (gt,":leader",-1), 
    (agent_get_position,1,":leader"),
    (position_move_x,1,100),
    (assign,":move_y",-100),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),                                   
       (agent_set_scripted_destination,reg(5),1),
       (position_move_x,1,100),
       (position_move_y,1,":move_y"),
       (val_mul,":move_y",-1),
    (end_try)]),

  ("cf_formation_wedge",
   [(team_get_leader, ":teamleader", reg0),
    (gt,":teamleader",-1),
    (assign,":leader",-1),
    (agent_get_class,":class",":teamleader"),
    (try_begin),
       (eq,":class",reg1),
       (get_player_agent_no,":player"),
       (neq,":teamleader",":player"),
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,":teamleader",":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0),
       (assign,":leader",":teamleader"),
    (else_try),
       (assign,reg2,-1),
       (assign,":max_xp",0),
       (try_for_agents,":agent"),
          (agent_is_alive,":agent"),
          (agent_is_human,":agent"),
          (agent_get_team,":team",":agent"),
          (eq,":team",reg0),
          (agent_get_class,":class",":agent"),
          (eq,":class",reg1),
          (get_player_agent_no,":player"),
          (neq,":player",":agent"),
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,":agent",":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0),
          (agent_get_troop_id,":troop", ":agent"),
          (troop_get_xp, ":xp", ":troop"),
          (gt,":xp",":max_xp"),
          (assign,":max_xp",":xp"),
          (assign,reg2,":agent"),
       (end_try),
       (gt,reg2,-1),
       (assign,":leader",reg2),
    (end_try),  
    (gt,":leader",-1), 
    (agent_get_position,1,":leader"),
    (assign,":collumn",1),
    (assign,":nc",3),
    (position_move_x,1,-150),
    (try_for_agents,reg(5)),
       (neq,reg5,":leader"),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1), 
          (assign,":fail",0),
          (try_for_range,":ranged_item","itm_jarid","itm_flintlock_pistol"),
             (agent_has_item_equipped,reg5,":ranged_item"),
             (assign,":fail",1),
          (end_try),
          (eq,":fail",0), 
       (agent_set_scripted_destination,reg(5),1),
       (try_begin),
          (eq,":collumn",":nc"),
          (val_mul,":nc",-150),
          (position_move_x,1,":nc"),
          (position_move_y,1,-300),
          (assign,":collumn",1),
          (val_div,":nc",-150),
          (val_add,":nc",2),
       (else_try),
          (position_move_x,1,150),
          (val_add,":collumn",1),
       (end_try),
    (end_try)]),

  ("formation_end",
   [(try_for_agents,reg(5)),
       (agent_is_alive,reg(5)),
       (agent_is_human,reg(5)),
       (agent_get_team  ,":team", reg5),
       (eq,":team",reg0),
       (agent_get_class ,":class", reg5),
       (eq,":class",reg1),  
       (agent_clear_scripted_mode,reg5),
     (try_end),]),

  ("choose_formation_leader",
   [(assign,reg2,-1),
    (assign,":max_xp",0),
    (try_for_agents,":agent"),
        (agent_is_alive,":agent"),
        (agent_is_human,":agent"),
        (agent_get_team,":team",":agent"),
        (eq,":team",reg0),
        (agent_get_class,":class",":agent"),
        (eq,":class",reg1),
        (get_player_agent_no,":player"),
        (neq,":player",":agent"),
        (agent_get_troop_id,":troop", ":agent"),
        (troop_get_xp, ":xp", ":troop"),
        (gt,":xp",":max_xp"),
        (assign,":max_xp",":xp"),
        (assign,reg2,":agent"),
    (end_try),]),
    



  #script_healthbars
    ("healthbars",
    [
(assign,reg1,"$allies_coh_base"),
(assign,reg2,"$enemies_coh"),
(assign,reg3,"$new_kills"),
(display_message,"@Your troops are at {reg1}% cohesion (+{reg3}% bonus), the enemy at {reg2}%!",0x6495ed),
     ]),

  #script_morale_check
    ("morale_check",
    [
            (try_begin),
              (lt,"$allies_coh",80),
              (store_random_in_range,":routed",1,101),
              (assign,":chance_ply",85),
              (val_sub,":chance_ply","$allies_coh"),
                (try_begin),            
                  (le,":routed",":chance_ply"),             
                  (display_message,"@Morale of your troops wavers!",0xff4040),            
                  (call_script, "script_flee_allies"),
                (try_end),
            (try_end),

            (try_begin),
              (lt,"$enemies_coh",80),
              (store_random_in_range,":routed",1,101),
              (assign,":chance_ply",85),
              (val_sub,":chance_ply","$enemies_coh"),
                (try_begin),  
                  (le,":routed",":chance_ply"),             
                  (display_message,"@Morale of your enemies wavers!",0x7ccd7c),            
                  (call_script, "script_flee_enemies"),
                (try_end),            
            (try_end),
     ]),

  #script_battle_cry
    ("battle_cry",
    [

(store_skill_level,":leader","skl_leadership","trp_player"),
(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
				(try_begin),
                   (le,":hitpoints",80),
				   (val_add,":hitpoints",":leader"),
				   (val_add,":hitpoints",10),
                   (agent_set_hit_points,":agent",":hitpoints"), 
               (try_end),
(end_try),	
(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
         (val_sub,":hitpoints",10),
         (store_random_in_range,":routed",1,101),
              (try_begin),
                   (le,":routed",":hitpoints"),
                         (agent_clear_scripted_mode,":agent"),
               (try_end),
(end_try),	
     ]),

    ("rally",
    [
#(display_message,"@Your enemies rally to rejoin the battle!",0xff4040),
(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
         #(val_sub,":hitpoints",10),
         (store_random_in_range,":routed",1,101),
              (try_begin),
                   (le,":routed",":hitpoints"),
                         (agent_clear_scripted_mode,":agent"),
               (try_end),
(end_try),	
     ]),


  #script_rout_check
    ("rout_check",
    [
(assign,":ally","$allies_coh"),
#(assign,reg2,"$allies_coh"),
#(display_message,"@allies {reg2}% cohesion!"),
(assign,":enemy","$enemies_coh"),
#(assign,reg2,"$enemies_coh"),
#(display_message,"@enemies {reg2}% cohesion!"),
(val_sub,":ally",":enemy"),
#(assign,reg2,":ally"),
#(display_message,"@difference {reg2}."),

                (try_begin),
                   (ge,":ally",40),
                  (display_message,"@Your enemies flee in terror!",0x7ccd7c),  
                  (call_script, "script_rout_enemies"),
                  (assign,"$airout",1),
               (try_end),

                (try_begin),
                   (le,":ally",-40),
                  (display_message,"@Your troops flee in terror!",0xff4040),  
                  (call_script, "script_rout_allies"),
                  (assign,"$rout",1),
               (try_end),
     ]),

	 
	 
## script_flee
    ("flee_allies",
    [
(get_scene_boundaries, pos3, pos4),

(position_get_x,":xmin",pos3),
(position_get_y,":ymin",pos3),
(position_get_x,":xmax",pos4),
(position_get_y,":ymax",pos4),
	   
	   (val_div,":xmin",100),
	   (val_div,":xmax",100),
	   
(store_random_in_range,":xrout_point3",":xmin",":xmax"),
    (val_mul,":xrout_point3",100),
(store_random_in_range,":yrout_point3",":xmin",":xmax"),
	(val_mul,":yrout_point3",100),
(store_random_in_range,":xrout_point4",":xmin",":xmax"),
	(val_mul,":xrout_point4",100),
(store_random_in_range,":yrout_point4",":xmin",":xmax"),
	(val_mul,":yrout_point4",100),

	   (val_mul,":xmin",100),
	   (val_mul,":xmax",100),

(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_div,":xrout_point3",4),
(position_set_x,pos3,":xrout_point3"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_div,":yrout_point3",4),
(position_set_y,pos3,":yrout_point3"),

(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_div,":xrout_point4",4),
(position_set_x,pos4,":xrout_point4"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_div,":yrout_point4",4),
(position_set_y,pos4,":yrout_point4"),

		 
(store_skill_level,":leader","skl_leadership","trp_player"),
(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
		 (val_div,":troop_level",10),
		 (val_add,":hitpoints",":troop_level"),		 
         (assign,":chance_ply",100),
         (val_sub,":chance_ply",":hitpoints"),
         (val_sub,":chance_ply",":leader"),
         (val_div,":chance_ply",2),
         (store_random_in_range,":routed",1,101),
              (try_begin),
                   (le,":routed",":chance_ply"),
#                  (display_message,"@One ally runs!"),  
                	 (agent_get_position,pos2,":agent"),
		 (position_move_z,pos2,200,0),
                         (agent_clear_scripted_mode,":agent"),
                         (agent_set_scripted_destination,":agent",pos4,1),
               (try_end),
(end_try),	
     ]),

    ("flee_enemies",
    [
(get_scene_boundaries, pos3, pos4),

(position_get_x,":xmin",pos3),
(position_get_y,":ymin",pos3),
(position_get_x,":xmax",pos4),
(position_get_y,":ymax",pos4),
	   
	   (val_div,":xmin",100),
	   (val_div,":xmax",100),
	   
(store_random_in_range,":xrout_point3",":xmin",":xmax"),
    (val_mul,":xrout_point3",100),
(store_random_in_range,":yrout_point3",":xmin",":xmax"),
	(val_mul,":yrout_point3",100),
(store_random_in_range,":xrout_point4",":xmin",":xmax"),
	(val_mul,":xrout_point4",100),
(store_random_in_range,":yrout_point4",":xmin",":xmax"),
	(val_mul,":yrout_point4",100),

	   (val_mul,":xmin",100),
	   (val_mul,":xmax",100),

(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_div,":xrout_point3",4),
(position_set_x,pos3,":xrout_point3"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_div,":yrout_point3",4),
(position_set_y,pos3,":yrout_point3"),

(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_div,":xrout_point4",4),
(position_set_x,pos4,":xrout_point4"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_div,":yrout_point4",4),
(position_set_y,pos4,":yrout_point4"),


(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
		 (val_div,":troop_level",10),
		 (val_add,":hitpoints",":troop_level"),		 
         (assign,":chance_ply",100),
         (val_sub,":chance_ply",":hitpoints"),
         (val_sub,":chance_ply",4),
         (val_div,":chance_ply",2),
         (store_random_in_range,":routed",1,101),
	 (try_begin),
                   (le,":routed",":chance_ply"),
#                  (display_message,"@One enemy runs!"),  
                	 (agent_get_position,pos2,":agent"),
		 (position_move_z,pos2,200,0),
                         (agent_clear_scripted_mode,":agent"),
                         (agent_set_scripted_destination,":agent",pos3,1),
               (try_end),
(end_try),	
     ]),

## script_rout
    ("rout_allies",
    [
(get_scene_boundaries, pos3, pos4),	

(position_get_x,":xmin",pos3),
(position_get_y,":ymin",pos3),
(position_get_x,":xmax",pos4),
(position_get_y,":ymax",pos4),
	   
	   (val_div,":xmin",100),
	   (val_div,":xmax",100),
	   
(store_random_in_range,":xrout_point3",":xmin",":xmax"),
    (val_mul,":xrout_point3",100),
(store_random_in_range,":yrout_point3",":xmin",":xmax"),
	(val_mul,":yrout_point3",100),
(store_random_in_range,":xrout_point4",":xmin",":xmax"),
	(val_mul,":xrout_point4",100),
(store_random_in_range,":yrout_point4",":xmin",":xmax"),
	(val_mul,":yrout_point4",100),

	   (val_mul,":xmin",100),
	   (val_mul,":xmax",100),

(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_div,":xrout_point3",4),
(position_set_x,pos3,":xrout_point3"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_div,":yrout_point3",4),
(position_set_y,pos3,":yrout_point3"),

(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_div,":xrout_point4",4),
(position_set_x,pos4,":xrout_point4"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_div,":yrout_point4",4),
(position_set_y,pos4,":yrout_point4"),


	 
(store_skill_level,":leader","skl_leadership","trp_player"),
(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
		 (val_div,":troop_level",10),
         (val_div,":hitpoints",3),
         (assign,":chance_ply",100),
         (val_sub,":chance_ply",":hitpoints"),
         (val_sub,":chance_ply",":leader"),
         (val_sub,":chance_ply",":troop_level"),
         (store_random_in_range,":routed",1,101),
              (try_begin),
                   (le,":routed",":chance_ply"),
#                  (display_message,"@One ally runs!"),  
                	 (agent_get_position,pos2,":agent"),
		 (position_move_z,pos2,200,0),
                         (agent_clear_scripted_mode,":agent"),
                         (agent_set_scripted_destination,":agent",pos4,1),
               (try_end),
(end_try),	
     ]),

    ("rout_enemies",
    [
(get_scene_boundaries, pos3, pos4),

(position_get_x,":xmin",pos3),
(position_get_y,":ymin",pos3),
(position_get_x,":xmax",pos4),
(position_get_y,":ymax",pos4),
	   
	   (val_div,":xmin",100),
	   (val_div,":xmax",100),
	   
(store_random_in_range,":xrout_point3",":xmin",":xmax"),
    (val_mul,":xrout_point3",100),
(store_random_in_range,":yrout_point3",":xmin",":xmax"),
	(val_mul,":yrout_point3",100),
(store_random_in_range,":xrout_point4",":xmin",":xmax"),
	(val_mul,":xrout_point4",100),
(store_random_in_range,":yrout_point4",":xmin",":xmax"),
	(val_mul,":yrout_point4",100),

	   (val_mul,":xmin",100),
	   (val_mul,":xmax",100),

(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_add,":xrout_point3",":xmin"),
(val_div,":xrout_point3",4),
(position_set_x,pos3,":xrout_point3"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_add,":yrout_point3",":ymin"),
(val_div,":yrout_point3",4),
(position_set_y,pos3,":yrout_point3"),

(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_add,":xrout_point4",":xmax"),
(val_div,":xrout_point4",4),
(position_set_x,pos4,":xrout_point4"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_add,":yrout_point4",":ymax"),
(val_div,":yrout_point4",4),
(position_set_y,pos4,":yrout_point4"),


(try_for_agents,":agent"),
         (agent_is_alive,":agent"),
         (agent_is_human,":agent"),
         (neg|agent_is_ally,":agent"),
         (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
		 (val_div,":troop_level",10),
         (val_div,":hitpoints",3),
         (assign,":chance_ply",100),
         (val_sub,":chance_ply",":hitpoints"),
         (val_sub,":chance_ply",3), ## AI's Leadership bonus
         (val_sub,":chance_ply",":troop_level"),
         (store_random_in_range,":routed",1,101),
	 (try_begin),
                   (le,":routed",":chance_ply"),
#                  (display_message,"@One enemy runs!"),  
                	 (agent_get_position,pos2,":agent"),
		 (position_move_z,pos2,200,0),
                         (agent_clear_scripted_mode,":agent"),
                         (agent_set_scripted_destination,":agent",pos3,1),
               (try_end),
(end_try),
    ]),  

  

  #script_coherence
    ("coherence",
    [
(get_scene_boundaries, pos3, pos4),		 
(assign,":num_allies",0),
(assign,":coh_allies",0),
(assign,":num_enemies",0),
(assign,":coh_enemies",0),
     (try_for_agents,":agent"),
         (agent_is_ally,":agent"),
         (agent_is_human,":agent"),
		 (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
#		 (val_div,":troop_level",10),
		 (val_mul,":hitpoints",":troop_level"),
		 (val_add,":num_allies",":troop_level"),
         (val_add,":coh_allies",":hitpoints"),
      (else_try),
         (agent_is_human,":agent"),
		 (store_agent_hit_points,":hitpoints",":agent",0),
		 (agent_get_troop_id,":troop_type", ":agent"),
		 (store_character_level, ":troop_level", ":troop_type"),
#		 (val_div,":troop_level",10),
		 (val_mul,":hitpoints",":troop_level"),
		 (val_add,":num_enemies",":troop_level"),
         (val_add,":coh_enemies",":hitpoints"),
      (end_try),
(val_div,":coh_allies",":num_allies"),
(assign,"$allies_coh_base",":coh_allies"),
(assign,"$allies_coh","$allies_coh_base"),
(val_add,"$allies_coh","$new_kills"),
(val_div,":coh_enemies",":num_enemies"),
(assign,"$enemies_coh",":coh_enemies"),
     ]),  


  #script_hero_exp_penalty
    ("hero_exp_penalty",
    [(store_character_level,":level","trp_player"),
     (val_mul,":level",-20),
     (add_xp_to_troop,":level","trp_player"),
     (assign,reg1,":level"),
       (display_message, "@You lost {reg1} experience points.",0x8fbc8f),     
     ]),
And that's it!  :razz: If you need help modifying some of the above or implementing it, or have any suggestions, please let me know.


Alternately, you could do the same thing but without the morale scripts:

http://forums.taleworlds.com/index.php/topic,34685.msg1044622.html#msg1044622


And a screenie, just for fun.


Next step: make the ai tactics in-battle more intelligent and fix any odd bugs that turn up.
 

italiano

Grandmaster Knight
Best answers
0
Excellent. I tried implementing it a while ago for different troop types but failed. Trying them out now :smile:.
 

Shik

Baron
M&BWBWF&S
Best answers
0
Excellent, good work. I didn't think that people could do moving formations, or formations with cavalry last time I checked.
 

italiano

Grandmaster Knight
Best answers
0
After a few battles:

1. Raiders combined missile troops and infantry into one formation. This may have been because the game considered them infantry equipped with missile weapons rather than the other way around.

2. I only had about 30 infantry, but it seemed that the formation will be too deep. Is it possible to divide the ranked formation into rows instead of columns? If we were to have 100 troops, we wouldn't want them 10x10 but more like 20x5 or 17x6.

3. Archers as expected don't need a formation as they work best in single line.

I'm wondering if the system can be made more user-friendly, why not map most of the effects to the current commands? You use I, B and H for troop types, why not just use the standard keys for the troop types? You have a key for dissemble formation, why not have the attack and hold keys include the dissemble effect? Why have the M command instead of just using the "hold" or "follow me" commands? This would remove the need for the M and U commands, and as far as I can tell the I, B and H are just covering commands that already exist. What do you think?
 

grailknighthero

Sergeant Knight
M&BWBNW
Best answers
0
This is going to be nice when I get this into my Bretonnian mod.  My knights will have the lance formation!  Thanks for posting this.

I got a question.  I am probably going to edit the wedge formation so only knights will form up (I know how to do that).  Will I be able to give commands to other cavalry and still have those in the formation follow me?  Id test it out but I have class tomorrow.  Ill get it implemented and tested out sometime within tomorrow and Saturday.

Zaro said:
After a few battles:
1. Raiders combined missile troops and infantry into one formation. This may have been because the game considered them infantry equipped with missile weapons rather than the other way around.
I believe the game defines archers as a troop that has the tf_guarantee_ranged flag.  Is that right?  So if sea raiders don't have the tf_guarantee_ranged then they wouldn't be archers.  Am I correct or wrong?
 

Mirathei

Sergeant Knight
Best answers
0
Zaro said:
1. Raiders combined missile troops and infantry into one formation. This may have been because the game considered them infantry equipped with missile weapons rather than the other way around.
The formation processes troops the same way as an m+b command. If they are forming with infantry, the game counts them as infantry.


2. I only had about 30 infantry, but it seemed that the formation will be too deep. Is it possible to divide the ranked formation into rows instead of columns? If we were to have 100 troops, we wouldn't want them 10x10 but more like 20x5 or 17x6.
This is why I kept it seperate from the ordinary hold and follow commands. The game's version works better for large numbers and archers. However, I may give that a try. It could just call a different formation if there were more than so many men.

Zaro said:
3. Archers as expected don't need a formation as they work best in single line.
True. The only reason I gave them the ability is so that ai archers would stick together and behave like infantry if they were the only ones left. I may try a unique archer formation.

I'm wondering if the system can be made more user-friendly, why not map most of the effects to the current commands? You use I, B and H for troop types, why not just use the standard keys for the troop types? You have a key for dissemble formation, why not have the attack and hold keys include the dissemble effect? Why have the M command instead of just using the "hold" or "follow me" commands? This would remove the need for the M and U commands, and as far as I can tell the I, B and H are just covering commands that already exist. What do you think?
I agree that it is too difficult to use, but I like the added versatility of having both the default m+b commands plus these. I'll see if I can't find a middle ground.
 

TRC

Regular
Best answers
0
This is simply awesome, we can finally ride through the enemy infantry and stay together for more than one charge!

"Lances forward, men!"
 

Markus II

Knight
Best answers
0
Firstly Mirathei, might I say... ****ing well done:grin:

Absolutely superb.

I actually like the interface as it stands, a little complex perhaps, but then placement of troops and troop formations is a complex matter. :wink:

Some screenies from your code implemented in my mod 867 A.D.:



Only problem that I've found with it so far is what happens when you combine the hold, follow and charge commands with your new formations commands during a battle. During the battle it's fine, but at the end I get this:



It doesn't stop the game from progressing, it just looks yuck...

Aside from that,...

...I want to have your love child.  :lol:
 

Druss

Recruit
Best answers
0
For some reason i cant copy any of that in to my files comp is F####D up, so there a chance of it coming out in next release?
 

DarkAnd

Sergeant Knight at Arms
Best answers
0
demize2010 said:
Mirathei I love you  :smile:
Sigged.
EDIT: Anyway mirathei, the moving formation made the game crash, and I don't know why, maybe a m&b bug.
 

grailknighthero

Sergeant Knight
M&BWBNW
Best answers
0
It works for me, although I get the same stuff that Marcus gets at the end when I have my guys in formation.  I think I have a fix for it though, I just have to try it out.

Edit:  I got most of the script errors to go away by adding in checks on the formation processing to make sure it wasnt the end of the battle.  All but two went away.  The error messages have to do with agents.  Thats all I know right now cause I got to go.  My next step will be to add the check to the scripts and see what happens.
 

Mirathei

Sergeant Knight
Best answers
0
Updated it, with a unique archer formation, an improved footman formation, and with the red-text bug removed. I kept the interface the same since it tended to interfere with the ordinary m+b tactics otherwise. I also made it so that in an enemy force with far more infantry than cavalry and with too little cavalry to be effective, cavalry will dismount.
 

Ben Hussey

Sergeant Knight
Best answers
0
Does this cause the enemy to adopt line formation too? (Just looking at Markus II's piccies)


Mirathei said:
Updated it, with a unique archer formation, an improved footman formation, and with the red-text bug removed. I kept the interface the same since it tended to interfere with the ordinary m+b tactics otherwise. I also made it so that in an enemy force with far more infantry than cavalry and with too little cavalry to be effective, cavalry will dismount.

Mirathei, if you have any spare time could you give a vague discription of what is possible with your script, and how it is operated (commands and suchlike), I'm not well up on the module system since .808, let alone the battlefield commands.
 

grailknighthero

Sergeant Knight
M&BWBNW
Best answers
0
Hey Mirathei, lets say I wanted to restrict certain agents from using the formation, do I need to put these checks in both the mission triggers and the scripts or just the scripts?

@Ealdormann Hussey
Edit: I guess I was right the first time, only the units with the same class as the leader form up, although I swear Ive seen infantry form up into a formation when the leader is cav and already has a formation.
 

Ben Hussey

Sergeant Knight
Best answers
0
Beg pardon? So if the leader is an infantryman, all infantry enemy infantry will form into a line?


NB.
What module file are the command lines that appear on the screen in (so i.e. Advance 10 paces, blunt weapons only, move closer etc etc)
 

Markus II

Knight
Best answers
0
Mirathei,

I've just tested the update script. I'm still getting the red text. Perhaps I've entered it in the wrong place? Here's the code extract from module_mission_templates:

(
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
    (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
    (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
    (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
    ],


    [

######Formation triggers below##########

(ti_before_mission_start, 0, 0, [], [(assign,"$formation",0),(assign,"$formationtype",0),(assign,"$aiformation",0),(assign,"$aiformationtype",0),(assign,"$formationmode",0),]),


    (0, 0, 0,
      [(key_clicked, key_i),        #F for footmen
      (assign,"$formation",grc_infantry),
      (display_message,"@FOOTMEN!"),
        ], []),
    (0, 0, 0,
      [(key_clicked, key_b),        #B for bowmen
      (assign,"$formation",grc_archers),
      (display_message,"@BOWMEN!"),
        ], []),
    (0, 0, 0,
      [(key_clicked, key_h),        #H for horsemen
      (assign,"$formation",grc_cavalry),
      (display_message,"@HORSEMEN!"),
        ], []),

    (0, 0, 0,
      [(key_clicked, key_m),        #M for movement
      (try_begin),
        (eq,"$formationmode",0),
        (assign,"$formationmode",1),
        (display_message,"@FOLLOW_ME_YOU_DOGS!"),
      (else_try),
        (eq,"$formationmode",1),
        (assign,"$formationmode",0),
        (display_message,"@HOLD_YOUR_GROUND!"),
      (end_try),
        ], []),

    (0, 0, 0,
      [(key_clicked, key_j),       
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (assign,reg1,"$formation"),
      (call_script,"script_formation"),
      (assign,"$formationtype",1),
      (display_message,"@SHIELDWALL!_SHIELDWALL!_HOLD_THE_BASTARDS!"),
        ], []),

    (0, 0, 0,
      [(key_clicked, key_p),       
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (assign,reg1,"$formation"),
      (call_script,"script_formation"),
      (assign,"$formationtype",3),
      (display_message,"@MAKE_A_LINE!"),
        ], []),

    (0, 0, 0,
      [(key_clicked, key_k),       
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (assign,reg1,"$formation"),
      (call_script,"script_formation_wedge"),
      (assign,"$formationtype",2),
      (display_message,"@FORM_THE_SWINES_HEAD!"),
        ], []),

    (0, 0, 0,
      [(key_clicked, key_u),       
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (assign,reg1,"$formation"),
      (call_script,"script_formation_end"),
      (assign,"$formationtype",0),
      (display_message,"@BREAK_RANKS!_BREAK_RANKS_AND_KILL_THEM_ALL!"),
        ], []),

    (5.0, 0, 0,
      [(neq, "$battle_won", 1),
      (try_for_agents,":agent"),
        (agent_is_human,":agent"),
        (agent_is_alive,":agent"),
        (neg|agent_is_ally,":agent"),
        (assign,":enemy",":agent"),
      (end_try),
      (agent_get_team  ,reg0, ":enemy"),
      (team_get_leader, ":leader", reg0),
      (agent_get_class ,":class", ":leader"),
      (try_begin),
        (eq,":class",grc_infantry),
        (assign,"$aiformation",grc_infantry),
        (assign,"$aiformationtype",1),
      (else_try),
        (eq,":class",grc_archers),
        (assign,"$aiformation",grc_archers),
        (assign,"$aiformationtype",3),
      (else_try),
        (eq,":class",grc_cavalry),
        (assign,"$aiformation",grc_cavalry),
        (assign,"$aiformationtype",2),
      (end_try),
      (assign,reg1,grc_cavalry),
      (call_script,"script_formation_end"),
      (assign,reg1,grc_infantry),
      (call_script,"script_formation_end"),
      (assign,reg1,grc_archers),
      (call_script,"script_formation_end"),], []),

    (5.0, 0, 0,
      [(neq, "$battle_won", 1),
      (assign,":infantry",0),
      (assign,":cavalry",0),
      (try_for_agents,":agent"),
        (agent_is_human,":agent"),
        (agent_is_alive,":agent"),
        (neg|agent_is_ally,":agent"),
        (assign,":enemy",":agent"),
        (agent_get_class ,":class", ":agent"),
        (try_begin),
            (eq,":class",grc_cavalry),
            (val_add,":cavalry",1),
        (else_try),
            (val_add,":infantry",1),
        (end_try),
      (end_try),
      (agent_get_team  ,reg0, ":enemy"),
      (assign,":ratio",":infantry"),
      (val_div,":ratio",":cavalry"),
      (try_begin),
        (gt,":ratio",2),
        (lt,":cavalry",15),
        (team_give_order, reg0, grc_everyone, mordr_dismount),
      (else_try),
        (team_give_order, reg0, grc_everyone, mordr_mount),
      (end_try),], []),

    (0.2, 0, 0,
      [(neq, "$battle_won", 1),
      (eq,"$formationmode",1),
      (neq,"$formationtype",0),
      (get_player_agent_no,":player"),
      (agent_get_team  ,reg0, ":player"),
      (assign,reg1,"$formation"),
      (try_begin),
          (eq,"$formationtype",1),
          (call_script,"script_formation"),
      (else_try),
          (eq,"$formationtype",2),
          (call_script,"script_formation_wedge"),
      (else_try),
          (call_script,"script_formation_stagger"),
      (end_try),
        ], []),

    (0.2, 0, 0,
      [(neq, "$battle_won", 1),
      (neq,"$aiformationtype",0),
      (try_for_agents,":agent"),
        (agent_is_human,":agent"),
        (agent_is_alive,":agent"),
        (neg|agent_is_ally,":agent"),
        (assign,":enemy",":agent"),
      (end_try),
      (agent_get_team  ,reg0, ":enemy"),
      (assign,reg1,"$aiformation"),
      (try_begin),
          (eq,"$aiformationtype",1),
          (call_script,"script_formation"),
      (else_try),
          (eq,"$aiformationtype",2),
          (call_script,"script_formation_wedge"),
      (else_try),
          (call_script,"script_formation_stagger"),
      (end_try),
        ], []),

##########Formation triggers above###########

       
      (ti_tab_pressed, 0, 0, [],
      [
          (try_begin),
            (eq, "$battle_won", 1),
            (call_script, "script_count_mission_casualties_from_agents"),
            (finish_mission,0),
          (else_try),
            (call_script, "script_cf_check_enemies_nearby"),
            (question_box,"str_do_you_want_to_retreat"),
          (else_try),
            (display_message,"str_can_not_retreat"),
          (try_end),
        ]),
      (ti_question_answered, 0, 0, [],
      [(store_trigger_param_1,":answer"),
        (eq,":answer",0),
        (assign, "$pin_player_fallen", 0),
        (call_script, "script_simulate_retreat", 10, 20),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission,0),]),

      (ti_before_mission_start, 0, 0, [],
      [
          (team_set_relation, 0, 2, 1),
        ]),
     
      (0, 0, ti_once, [], [(assign,"$battle_won",0),
                          (assign,"$defender_reinforcement_stage",0),
                          (assign,"$attacker_reinforcement_stage",0),
                          (assign,"$g_presentation_battle_active", 0),
                          ]),
Any thoughts?
 

grailknighthero

Sergeant Knight
M&BWBNW
Best answers
0
I added in a (neq, "$battle_end", 1), to where he has "$battle_won" and I had "$battle_end" be assigned whenever the battle ended (so one assignment when the player wins, one assignment if the player retreats, and one assignment if the player is knocked out) and I no longer have an error messages.
 

Ashes42

Sergeant
Best answers
0
This looks like some really good stuff.  I was planning on trying to hack my way though some of this in Bandit King, you may have saved me some trouble ; ).  You missed a couple of things that I'm going for, and I'm curious if they are planned at all.  Firstly, this may already be in there, I haven't tested it yet to be honest, does this interface well with the current battle-field overlay?  (the other thing is I'd like a better battlefield overlay in general, a topographical map I could have reveal and not reveal based on scouts and LOS, but thats way too much.)  The second, and more important of the two though, is re-defining those groups and adding more of them.  For example, I want to have a unit of pikemen and one of swordsmen.  Or two different units of swordsmen, ideal would be the ability to set these up on a per battle basis, and to change them on the fly, but thats more difficult.

Looks like some really good work though, keep it up ; )  Some excellent stuff.  After we get the player the ability to use these formations, maybe we can make the AI use them too and have actual battles.