Author Topic: Battle Morale code and instructions  (Read 2824 times)

0 Members and 1 Guest are viewing this topic.

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Battle Morale code and instructions
« on: June 04, 2008, 06:04:59 AM »
This is the code and instructions for the battle morale system that I developed. I post it here to make it easier for anyone who might like to use it.
Currently a fifth version of the system is implemented in my mod and I find it adds a lot of variety to the battles as well as new tactical gameplay content.

You can read about how it works (and watch a video) here: http://forums.taleworlds.net/index.php/topic,36364.0.html



Paste this into module_scripts.py
Code: [Select]
############# BATTLE MORALE


  #script_healthbars
    ("healthbars",
    [
(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_position,pos2,":agent"),
(position_move_z,pos2,204,0),
(try_begin),
(ge,":hitpoints",70),
                                 (particle_system_burst, "psys_troop_fresh", pos2,1),
                (else_try),
(ge,":hitpoints",30),
                                (particle_system_burst, "psys_troop_med", pos2,1),
                (else_try),
# (ge,":hitpoints",1),
                                (particle_system_burst, "psys_troop_low", pos2,2),
                (try_end),
(end_try),
(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"),
               (try_end),

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

  #script_rout_check_castle
    ("rout_check_castle",
    [
(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",60),
                  (display_message,"@Your enemies flee in terror!",0x7ccd7c), 
                  (call_script, "script_rout_enemies"),
               (try_end),

                (try_begin),
                   (le,":ally",-60),
                  (display_message,"@Your troops flee in terror!",0xff4040), 
                  (call_script, "script_rout_allies"),
               (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),
                         (particle_system_burst, "psys_troop_flee", pos2,20),
               (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),
                         (particle_system_burst, "psys_troop_flee", pos2,20),
               (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),
                         (particle_system_burst, "psys_troop_flee", pos2,20),
               (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),
                         (particle_system_burst, "psys_troop_flee", pos2,20),
               (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"),
     ]), 

######################## end morale

  #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 paste these triggers into mission_templates.py, into battle missions like field battle, castle siege, village raid.

For castle missions, use
(call_script, "(call_script, "script_rout_check"),
instead of
(call_script, "script_rout_check"),
Because the castle scenes are different, troops might not have a good place to retreat, so "script_rout_check" makes it harder to cause a rout of either side in a siege. This part needs some further refinement, but for now it basically means sieges are not affected by morale very much

Code: [Select]
### BATTLE MORALE

     (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_u),(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"),       
         ]),

     

################### BATTLE MORALE END


The code isn't very commented, but most of it is pretty self-explanatory.

Any questions?    :D

« Last Edit: June 04, 2008, 06:09:47 AM by Chel »

Dindi

  • Sergeant Knight
  • *
  • Losing is Fun
    • View Profile
  • Faction: Bandit
Re: Battle Morale code and instructions
« Reply #1 on: June 04, 2008, 12:30:16 PM »
All hail Chel lord of Code!!!!

Quote
Any questions?

do you plan on any other coding projects in the future?
Most of the major mod authors are indeed dead, and I intend to get around to the rest once my Visa gets approved.

Pagan

  • Sergeant Knight at Arms
  • *
  • HA! The other hand feeds me.
    • View Profile
  • Faction: Bandit
Re: Battle Morale code and instructions
« Reply #2 on: June 04, 2008, 03:19:46 PM »
sheeeet! do you, like, sit there and just type all that out off the top of your head like a mathematical equation or something. crazy...

my hats off to ya chel. i always said EG2 was a stunning mod, but now when i consider how much of THAT is actually behind it.... the mind boggles.

do you know if amry has looked at this code. seems like a dead ringer to be added into native. 

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #3 on: June 04, 2008, 04:39:08 PM »
do you plan on any other coding projects in the future?

I have idea for global tracking of Calradian population, so that deaths of soldiers in battle mean less soldiers for the next campaign until more recruits train up and birth rate produces new recruits.

sheeeet! do you, like, sit there and just type all that out off the top of your head like a mathematical equation or something. crazy...

once I had the concept in my head, yeah pretty much..

the hardest thing to get was right was the timing of display of health blobs, because the module system commands for particle bursts are a bit strange in their effects. So that took a lot of trial and error.
And also the calcuation of random positions in 1/4th of the field -- because apparently the random number generator is limited to numbers up to 100,000 and position coordinates are sometimes in hundreds, sometimes in thousands -- I don't know why.

I've messaged armagan to take a look at it a couple days ago, before I posted this code.


A couple things I should add,
to make battles better, make the size of battlefield larger (in module_scenes.py), at least up to 300,300 (I use 340,340 because horses are faster in my mod). That way retreating troops have more room to retreat, and there's more room for maneuvers.

and one thing I also did is raise the limit on number of automatic reinforcement waves from 3 (or 2?) to 10. and make them come sooner, when there are less than 12 remaining troops on one side instead of 6 as in Native. For old battlesize of 40 it was better with 6 troops, now with 72 (or more), 12 is better.

ealabor

  • Grandmaster Knight
  • *
  • Faction: Carthage
    • View Profile
    • Hegemony 268 B.C.
  • Faction: Neutral
  • WB
Re: Battle Morale code and instructions
« Reply #4 on: June 04, 2008, 06:01:46 PM »

and one thing I also did is raise the limit on number of automatic reinforcement waves from 3 (or 2?) to 10. and make them come sooner, when there are less than 12 remaining troops on one side instead of 6 as in Native. For old battlesize of 40 it was better with 6 troops, now with 72 (or more), 12 is better.

thats something I didnt think of.

I think it would be much better for consistent action between larger armies to have such, rather than 1 side getting boxed into difficult situations where theres 4 or 5 guys left scattered about the battlefield

im curious how does the remaining troops threshold work when in less than situations

for example you have yours set to spawn in at 12 remaining. What happens when as a result of enemy tactics or ratio factors, you initially spawn with less than 12 men. would your reinforcements trickle in on a 1 man per 1 loss basis then?

Zaro

  • italiano stallion-o
  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #5 on: June 04, 2008, 10:58:46 PM »
Quote
I have idea for global tracking of Calradian population, so that deaths of soldiers in battle mean less soldiers for the next campaign until more recruits train up and birth rate produces new recruits.

Is this just a global value, or will it be specific for each settlement? If so, it could be used, along with prosperity, to come up with the rental income rather than just using a static value (I think it was 500 or so last module system). Would mean recruitment of your villagers and putting them at risk would hurt your fief income.

Dindi

  • Sergeant Knight
  • *
  • Losing is Fun
    • View Profile
  • Faction: Bandit
Re: Battle Morale code and instructions
« Reply #6 on: June 05, 2008, 03:31:27 PM »
Quote
have idea for global tracking of Calradian population, so that deaths of soldiers in battle mean less soldiers for the next campaign until more recruits train up and birth rate produces new recruits.

sounds great :)
Most of the major mod authors are indeed dead, and I intend to get around to the rest once my Visa gets approved.

pentagathus

  • Sergeant Knight at Arms
  • *
  • Lord of Team Alpha Beta Supercool Wolf Squadron
    • View Profile
  • Faction: Vaegir
Re: Battle Morale code and instructions
« Reply #7 on: June 05, 2008, 08:17:02 PM »
I have a question. Is it possible to change this so that troops with a certain flag wil never run? (ie the undead thingymabobs that go running round)
Hit me at 40 and there's an 80% chance I'll die.
Hit me at 30 and there's an 80% chance I'll live.
Hit me at 80 and it's clear I shouldn't play on the motorway.

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #8 on: June 05, 2008, 08:34:46 PM »
I have a question. Is it possible to change this so that troops with a certain flag wil never run? (ie the undead thingymabobs that go running round)

yep. one easy way is to set troops above a certain level, or those wearing a particular item to not be affected by morale. for the fallen in EGII, their helms can be that 'flag'.

Killerflood

  • Sergeant
  • *
  • A teen looking for a purpose.
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #9 on: June 05, 2008, 08:49:24 PM »
where is the file that i need to paste this into? i have .954
"For every thing said that is stupid, somebody actually makes sense of it."

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #10 on: June 07, 2008, 12:20:27 AM »
where is the file that i need to paste this into? i have .954

to implement this you need the module system. it has not yet been released by armagan for 0.95x version.

cfnz

  • Regular
  • *
    • View Profile
Re: Battle Morale code and instructions
« Reply #11 on: June 07, 2008, 02:58:06 AM »
I was messing around with this for my own interest and ran into a couple of things.

1. Copying and pasting the code directly into the module files results in a number of unexpected indent errors, namely around sections in the code like this.

Code: [Select]
  #script_morale_check
    ("morale_check",  <---- unexpected indent on this line
    [

It's easy enough to fix even will my limited knowledge but perhaps something to be aware of.

2. This line throws up a syntax error: (call_script, "(call_script, "script_rout_check"), should it be (call_script, (call_script, "script_rout_check"), (i.e. minus the first ")?

Nice work though, I appreciate you releasing the code.

Chel

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #12 on: June 07, 2008, 03:51:33 AM »
should be just
(call_script, "script_rout_check"),

thanks for pointing this out, I'll fix it. must have gotten messed up a little in copy-pasting.

grailknighthero

  • Knight at Arms
  • *
  • www.games-workshop.com
    • View Profile
  • Faction: Neutral
  • M&B
Re: Battle Morale code and instructions
« Reply #13 on: June 10, 2008, 09:56:12 PM »
Awesome Chel. 

You should work on formations and maybe try to get it so your allies and enemies have multiple formations.  Although it might get difficult with moral thrown into it, but it is definitely possible, it will just take a ton of work.

Quote
I have idea for global tracking of Calradian population, so that deaths of soldiers in battle mean less soldiers for the next campaign until more recruits train up and birth rate produces new recruits.

Is this just a global value, or will it be specific for each settlement? If so, it could be used, along with prosperity, to come up with the rental income rather than just using a static value (I think it was 500 or so last module system). Would mean recruitment of your villagers and putting them at risk would hurt your fief income.

This is what I have in mind for my mod, but if Chel does awesome and it will save me time and he is a better coder than me anyway.
« Last Edit: June 10, 2008, 09:58:30 PM by grailknighthero »
The Peasants' Rebellion: Warhammer Battles - a custom battle mod featuring TW/Warhammer style formations/battles for M&B - currently in development.

Shadow0

  • Sergeant
  • *
    • View Profile
    • ShadowWolves
  • Faction: Neutral
Re: Battle Morale code and instructions
« Reply #14 on: June 25, 2008, 05:41:48 AM »
great work Chel :D cant wait to see what future mods are like because of you!
ShadowWolves - Move as one, fight as one, win as one.