What this does: When simulating battles some troops get advantages. Mounted troops get more bonus on the steppe, desert or plain ground, infantry gets an advantage in forests while archers get a penalty. I used this for the mod Avarice of the Exiled, where I also checked for items that gave certain units advantages in snow or desert.
How this works: When a battle is simulated (with either the "Order your troops to attack without you" or AI battles) the script_game_event_simulate_battle is called. Inside the script it uses script_party_calculate_strength to see which party is stronger. I added terrain to this, to give Khergits for example a bonus on steppe.
How to implent it: Search for the script party_calculate_strength. Add the lines in the spoiler right above:
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":party",":i_stack"),
(party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"),
(val_sub, ":stack_size", ":num_wounded"),
(val_mul, ":stack_strength", ":stack_size"),
(else_try),
(troop_is_wounded, ":stack_troop"), #hero...
(assign,":stack_strength",0),
(try_end),
(val_add,reg(0), ":stack_strength"),
(try_end),
(party_set_slot, ":party", slot_party_cached_strength, reg(0)),
]),
That should do it, if I forgot something or this doesn't work, tell me.
How this works: When a battle is simulated (with either the "Order your troops to attack without you" or AI battles) the script_game_event_simulate_battle is called. Inside the script it uses script_party_calculate_strength to see which party is stronger. I added terrain to this, to give Khergits for example a bonus on steppe.
How to implent it: Search for the script party_calculate_strength. Add the lines in the spoiler right above:
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":party",":i_stack"),
(party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"),
(val_sub, ":stack_size", ":num_wounded"),
(val_mul, ":stack_strength", ":stack_size"),
(else_try),
(troop_is_wounded, ":stack_troop"), #hero...
(assign,":stack_strength",0),
(try_end),
(val_add,reg(0), ":stack_strength"),
(try_end),
(party_set_slot, ":party", slot_party_cached_strength, reg(0)),
]),
##AotE terrain advantages
(party_get_current_terrain, ":terrain_type", ":party"),
(try_begin),
(eq, ":terrain_type", rt_steppe),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.5),
(else_try),
(eq, ":terrain_type", rt_plain),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.1),
(else_try),
(eq, ":terrain_type", rt_snow),
# (try_for_range,":items","itm_zrak_wildman_chest","itm_zrak_berserker_chest"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.4),
# (try_end),
# (try_for_range,":items","itm_vaegir_woodcutter_coat","itm_vaegir_woodcutter_helmet"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.5),
# (try_end),
(val_mul, ":stack_strength", 0.95),
(else_try),
(eq, ":terrain_type", rt_desert),
# (try_for_range,":items","itm_kabiel_villager_chest","itm_kabiel_villager_helmet"),
# (troop_is_guarantee_horse, ":stack_troop"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.8 ),
# (else_try),
# (troop_is_guarantee_horse, ":stack_troop"),
# (val_mul, ":stack_strength", 1.4),
# (try_end),
(val_mul, ":stack_strength", 0.95),
(else_try),
(eq, ":terrain_type", rt_steppe_forest),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(else_try),
(eq, ":terrain_type", rt_forest),
(neg|troop_is_guarantee_horse, ":stack_troop"),
(neg|troop_is_guarantee_ranged, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(else_try),
(eq, ":terrain_type", rt_snow_forest),
# (try_for_range,":items","itm_zrak_wildman_chest","itm_zrak_berserker_chest"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.2),
# (try_end),
# (try_for_range,":items","itm_vaegir_woodcutter_coat","itm_vaegir_woodcutter_helmet"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.2),
# (try_end),
(neg|troop_is_guarantee_horse, ":stack_troop"),
(neg|troop_is_guarantee_ranged, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(try_end),
##AotE terrain advantages
(party_get_current_terrain, ":terrain_type", ":party"),
(try_begin),
(eq, ":terrain_type", rt_steppe),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.5),
(else_try),
(eq, ":terrain_type", rt_plain),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.1),
(else_try),
(eq, ":terrain_type", rt_snow),
# (try_for_range,":items","itm_zrak_wildman_chest","itm_zrak_berserker_chest"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.4),
# (try_end),
# (try_for_range,":items","itm_vaegir_woodcutter_coat","itm_vaegir_woodcutter_helmet"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.5),
# (try_end),
(val_mul, ":stack_strength", 0.95),
(else_try),
(eq, ":terrain_type", rt_desert),
# (try_for_range,":items","itm_kabiel_villager_chest","itm_kabiel_villager_helmet"),
# (troop_is_guarantee_horse, ":stack_troop"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.8 ),
# (else_try),
# (troop_is_guarantee_horse, ":stack_troop"),
# (val_mul, ":stack_strength", 1.4),
# (try_end),
(val_mul, ":stack_strength", 0.95),
(else_try),
(eq, ":terrain_type", rt_steppe_forest),
(troop_is_guarantee_horse, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(else_try),
(eq, ":terrain_type", rt_forest),
(neg|troop_is_guarantee_horse, ":stack_troop"),
(neg|troop_is_guarantee_ranged, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(else_try),
(eq, ":terrain_type", rt_snow_forest),
# (try_for_range,":items","itm_zrak_wildman_chest","itm_zrak_berserker_chest"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.2),
# (try_end),
# (try_for_range,":items","itm_vaegir_woodcutter_coat","itm_vaegir_woodcutter_helmet"),
# (troop_has_item_equipped,":stack_troop",":items"),
# (val_mul, ":stack_strength", 1.2),
# (try_end),
(neg|troop_is_guarantee_horse, ":stack_troop"),
(neg|troop_is_guarantee_ranged, ":stack_troop"),
(val_mul, ":stack_strength", 1.2),
(try_end),
##AotE terrain advantages
That should do it, if I forgot something or this doesn't work, tell me.