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

Users who are viewing this thread

Yeah, the morale system sounds a bit flawed as-is.

EDIT:

I just emailed kikosha the triggers and script for formations without battle morale.
 
Well see that's a problem because that's exactly what I need done.  It won't compile for me either (if by compile you mean the function when you select "build module").
 
I did it
sending files to Kikosha
The downside is that you have to start a new game for this to work

Disclaimer
If this "mod" does something to your saves its not my fault nor intention.

I'm not saying it does but when i wanted to load a game with it on, a bunch of errors jumped out at me.
 
So, all my mission_types module stuff is numbers...  can I paste this safely into those text files or do I need to do it with some specific editor?  It's just, I've got all numbers in the "lead_charge" area...  and this is very clearly not numbers.  Will it still work as long as it's under the right section or is there something particular I need to do?

EDIT:  Nevermind, found the python tool.  Stupid question.  Half-asleep.  Totally awesome stuff here.
 
i know im going to get **** for this. please could anyone give me a quick bit of help getting this into a mod. which files do i copy the scripts into and where can i locate them. Thanks again.
 
be sure to download and study a little bit about the python and the module system. If you don't know what that is you should search it in the Forge.
 
It works great for me, took out the morale scripts not a huge fan of that but the formations work supurb!.....finally some brains on the battlefield I love it.  :mrgreen:
I implemented it into Wicked's Custom Settlements mod i've been playing, all is good.
 
Achilles_ said:
It works great for me, took out the morale scripts not a huge fan of that but the formations work supurb!.....finally some brains on the battlefield I love it.  :mrgreen:
I implemented it into Wicked's Custom Settlements mod i've been playing, all is good.

hi. i am having trouble find the right files to paste the code into. I am playing custom settlements 0.5 and would love to get formations working. I found the lead_charge trigger but i cannot find module_scripts.py.  If yuo could show me what im doing wrong, and the correct way to enter the code into the trigger lead charge etc I would grant you free ale in all my taverns, 20 prime cows and any slave girl of your choice, Plus my gratitude. Thanks if you read this.
 
fink said:
Achilles_ said:
It works great for me, took out the morale scripts not a huge fan of that but the formations work supurb!.....finally some brains on the battlefield I love it.  :mrgreen:
I implemented it into Wicked's Custom Settlements mod i've been playing, all is good.

hi. i am having trouble find the right files to paste the code into. I am playing custom settlements 0.5 and would love to get formations working. I found the lead_charge trigger but i cannot find module_scripts.py.  If yuo could show me what im doing wrong, and the correct way to enter the code into the trigger lead charge etc I would grant you free ale in all my taverns, 20 prime cows and any slave girl of your choice, Plus my gratitude. Thanks if you read this.

Tell you what, how about I just send you the module file for custom settlements 0.5 with the formation script already inside...then all you would have to do is compile it.  And I'm assuming you have python installed right? Just pm me your email and I'll send it to you.  And I will take the slave girl hands down, I like me a good slave girl now and then.
 
implemented those tihings in my "Kopie von Native" folder:

Formations/ set leader to the middle in front/ and the bugfix not to dismount!!!! Works all fine  :mrgreen: so thousand thanks

questions I still have:

is it and how possible to make an order key availible to abort "Choose_formation_leader"
e.g. press x leader fall back in line noones gonna lead rank so rank does not move??

this happend in the formation code used in 0.903 and I wonder how to readd that into the current script perhaps by change lines of the choose leader script.

advantages could be:

1. infantry rank would still do best against cav charge facing that withuot moving arround.

2. cav. skirmisher do not participate on cav formations so perhaps it would happen they could do "ranged charge" without the meele cav.

2 and. if there are more units defined not to be formationable they could do any order as long the formation is "freezed" (unleaded) as a seperate team!!!   
 
When putting this into the files you mentioned then pressing Build Module, nothing happens. I tried this with shield bash to the same results. It's giving me a syntax error on all but a few files (I haven't even edited most of the files that have syntax errors).

Has anyone else encountered this problem with the Module System?
 
Mirathei said:
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.



Next step: make the ai tactics in-battle more intelligent and fix any odd bugs that turn up.
It is for module system version 1.011?
 
Back
Top Bottom