Killer Regeneration (1.1):
I've seen a number of scripts that involve adding health regeneration to the game as well as arguments about how much of a cheat people consider it to be. A number of those scripts give a player, and sometimes only the player, health regeneration over time which I think rewards hiding. My goal here is to accomplish a middle ground that sets the playing field even for all troops on the field.
You are free to add this to or modify it for your mods as you wish. I'm welcome to any suggestions for improvement or refinement.
Features:
Additional Credits:
Modmerger Kit Download:
Killer Regeneration 1.1 - Modmerger Kit
Manual Installation:
[*]module_mission_templates.py - The following trigger needs to be added to every mission template you want it to be included in. If you're using a mod like the custom commander one with a "common triggers" definition you can likely just add it to that.
[*]variables.txt - The following global variables need to be added.
I've seen a number of scripts that involve adding health regeneration to the game as well as arguments about how much of a cheat people consider it to be. A number of those scripts give a player, and sometimes only the player, health regeneration over time which I think rewards hiding. My goal here is to accomplish a middle ground that sets the playing field even for all troops on the field.
You are free to add this to or modify it for your mods as you wish. I'm welcome to any suggestions for improvement or refinement.
Features:
- All units regain a percentage of health each time they kill a unit. This means enemies as well as allies which makes it a fairly level playing field. Different ranks of troop (regular, companion, lord, king) will receive differing percentages of health returned. As a player you will receive the lowest amount simply to balance the fact you should be the most active killer on the field.
- Strength provides a small boost to this percentage.
- Leadership provides a small boost to this percentage for units that are not the leader. You will not gain any benefit from this for yourself, but your troops will if you run with a decent leadership skill.
- Factors in difficulty setting to raise health regeneration of enemies and lower health regeneration of allies. I use in my game to keep things interesting, but this feature can be disabled in the constants.py file by changing the "wp_hr_factor_difficulty" constant to 0.
- (New in 1.1) Separate global variables have been added so that a player can control whether they and/or AI receive this benefit.
Additional Credits:
- Cdvader – For his initial health regeneration script that gave me inspiration to make one like this.
Modmerger Kit Download:
Killer Regeneration 1.1 - Modmerger Kit
Manual Installation:
- module_constants.py - You can add this section at the bottom of the associated file.
Code:
## KILLER REGENERATION (1.1) begin
# Rates listed below are per kill, not based on duration. They are also % of health, not exact values.
wp_hr_player_rate = 5
wp_hr_strength_factor = 4 # This is the value STR is divided by. So 4 = .25% per point of Strength.
wp_hr_leadership_factor = 2 # This is the value Leadership is divided by. Only non-heroes gain this.
wp_hr_lord_rate = 15
wp_hr_companion_rate = 10
wp_hr_king_rate = 20
wp_hr_common_rate = 5
wp_hr_elite_rate = 15 # Currently unused.
wp_hr_factor_difficulty = 0 # This turns ON (1) or OFF (0) any code changes based on difficulty.
wp_hr_diff_enemy_bonus = 4 # Amount the health regeneration of enemies is boosted by per difficulty rank.
wp_hr_diff_ally_penalty = -3 # Amount the health regeneration of allies is reduced by per difficulty rank.
wp_hr_debug = 0 # This turns ON (1) or OFF (0) all of the debug messages.
## KILLER REGENERATION end
Code:
## KILLER REGENERATION (1.1) Begin - Windyplains
(ti_on_agent_killed_or_wounded, 0, 0, [],
[
(store_trigger_param_1, ":agent_victim"),
(store_trigger_param_2, ":agent_killer"),
# Is this a valid kill worth gaining morale?
(agent_is_human, ":agent_victim"),
# Determine health amount to regenerate
(try_begin), # Is it the player?
(get_player_agent_no, ":agent_player"),
(eq, ":agent_killer", ":agent_player"),
(assign, ":health_regeneration", wp_hr_player_rate),
(else_try), # Is it a companion?
(is_between, ":agent_killer", companions_begin, companions_end),
(assign, ":health_regeneration", wp_hr_companion_rate),
(else_try), # Is it a lord?
(is_between, ":agent_killer", lords_begin, lords_end),
(assign, ":health_regeneration", wp_hr_lord_rate),
(else_try), # Is it a king?
(is_between, ":agent_killer", kings_begin, kings_end),
(assign, ":health_regeneration", wp_hr_king_rate),
(else_try), # This should catch all common soldiers, horses, etc.
# This section commented out because it is designed for use with "elite units" which most mods do not use.
# (try_begin),
# (agent_get_troop_id, ":troop_no", ":agent_killer"), # Is this an elite unit?
# (troop_slot_eq, ":troop_no", slot_troop_is_elite, 1),
# (assign, ":health_regeneration", wp_hr_elite_rate),
# (else_try),
# (assign, ":health_regeneration", wp_hr_common_rate),
# (try_end),
(assign, ":health_regeneration", wp_hr_common_rate),
# This adds a small bonus to all non-heroes based on the leadership of their owner.
(agent_get_team, ":team_killer", ":agent_killer"),
(team_get_leader, ":agent_leader", ":team_killer"),
(agent_get_troop_id, ":troop_leader", ":agent_leader"),
(store_skill_level, ":leadership", "skl_leadership", ":troop_leader"),
(assign, reg4, ":leadership"), # stored for debug display purposes.
(val_div, ":leadership", wp_hr_leadership_factor),
(val_add, ":health_regeneration", ":leadership"),
(try_end),
# Adds in Strength as a bonus or penalty. (STR - 10) / wp_hr_strength_factor
(agent_get_troop_id, ":troop_killer", ":agent_killer"),
(store_attribute_level, ":strength", ":troop_killer", ca_strength),
(val_sub, ":strength", 10),
(val_div, ":strength", wp_hr_strength_factor),
(val_add, ":health_regeneration", ":strength"),
# Changes health regeneration based on this factor.
(try_begin),
(eq, wp_hr_factor_difficulty, 1), # Is this difficulty script even being used.
(assign, ":bonus_difficulty", "$g_wp_difficulty"),
(try_begin),
(agent_is_ally, ":agent_killer"),
(val_mul, ":bonus_difficulty", wp_hr_diff_ally_penalty),
(else_try),
(val_mul, ":bonus_difficulty", wp_hr_diff_enemy_bonus),
(try_end),
(val_add, ":health_regeneration", ":bonus_difficulty"),
(try_end),
(val_max, ":health_regeneration", 0), # We don't want a negative health regeneration.
# Remove regeneration value if option not enabled for this unit type.
(try_begin), # Check if this is the player and regeneration is disabled.
(eq, ":agent_killer", ":agent_player"),
(eq, "$g_wp_player_hr_active", 0),
(assign, ":health_regeneration", 0),
(else_try), # If not player assume AI troop and check if AI regen is disabled.
(neq, ":agent_killer", ":agent_player"), # To prevent player enabled, AI disabled conflicts.
(eq, "$g_wp_ai_hr_active", 0),
(assign, ":health_regeneration", 0),
(try_end),
# Displays debug messages if turned on.
(try_begin),
(eq, wp_hr_debug, 1),
(str_store_troop_name, s1, ":troop_killer"),
(assign, reg0, ":health_regeneration"),
(assign, reg1, ":strength"),
(try_begin), (ge, ":leadership", 10), (assign, ":leadership", -1), (try_end), # If no leadership bonus exists put in a default value.
(assign, reg2, ":leadership"),
(display_message, "@DEBUG (Health Regen): Agent leadership skill is {reg4}."),
(try_begin), (eq, wp_hr_factor_difficulty, 1),(assign, reg3, ":bonus_difficulty"), (else_try), (assign, reg3, 0), (try_end), # Get difficulty bonus OR use 0.
(display_message, "@DEBUG (Health Regen): {s1} regains {reg0}% health. = +{reg1}% STR +{reg2}% Lead + {reg3}% Difficulty."),
(try_end),
# Regenerates the given health amount.
(ge, ":health_regeneration", 1),
(store_agent_hit_points, ":current_health", ":agent_killer", 0),
(val_add, ":current_health", ":health_regeneration"),
(agent_set_hit_points, ":agent_killer", ":current_health", 0),
])
Code:
g_wp_player_hr_active # Set to 0 to prevent player regeneration. 1 to activate.
g_wp_ai_hr_active # Set to 0 to prevent AI regeneration. 1 to activate.
g_wp_difficulty # Changes whether the regeneration is better or worse.