Example usage of the new functionality in a script for X-PirateZ. Requires OXCE 6.4.3+.
# OXCE Requirement: 6.4.3+
#
# ***************************************************
# *** End of Battle Hit Point Regeneration Script ***
# ***************************************************
#
# Use for units that regenerate hit points every turn in combat.
# So at end of combat, they don't go to sick bay.
#
# Soldier Type Tag:
# MISSION_END_FULL_SOLDIER_REGEN - How many HP recovered per unit of mana (freshness/readiness)
#
# Armor Tag:
# MISSION_END_FULL_REGENERATION - How many HP recovered per unit of mana (freshness/readiness)
#
# Set either tag value to hitpoints regenerated / mana (freshness/readiness) lost
# A value of 5 means 5 hp recovered for every 1 mana (freshness/readiness).
# If Freshness tanks to 0, full HP recovery completes anyway. Freshness stays at 0 then.
# So mana_missing becomes equal to mana_max, but does not go over that value.
#
# Armors take priority over soldiers.
# Soldier regen is baseline. Armor value overwrites it.
# Tag value of 0 disables regeneration.
# This means you can have non-regenerating soldiers with regenerating armors.
# You could also have regenerating soldiers with non-regenerating armor, meaning their regen is disabled.
soldiers:
- type: STR_SOLDIER_SYNTH
tags:
MISSION_END_FULL_SOLDIER_REGEN: 3
armors:
- type: STR_BIO_SUIT_ADV_UC
tags:
MISSION_END_FULL_REGENERATION: 2
- type: STR_BIO_SUIT_ADV_SEA_UC
tags:
MISSION_END_FULL_REGENERATION: 2
- type: STR_BIO_SUIT_NECRO_UC
tags:
MISSION_END_FULL_REGENERATION: 3
- type: STR_BIO_SUIT_NECRO_SEA_UC
tags:
MISSION_END_FULL_REGENERATION: 3
extended:
tags:
RuleSoldier:
MISSION_END_FULL_SOLDIER_REGEN: int
RuleArmor:
MISSION_END_FULL_REGENERATION: int
scripts:
returnFromMissionUnit:
- offset: 10
code: |
var ptr RuleArmor soldierArmor;
var ptr RuleSoldier soldierRuleset;
var int regenSoldier;
var int regenArmor;
var int recoveryCost;
var int hpNow;
var int hpMax;
var int hpMissing;
var int manaNow;
var int manaMax;
var int manaMissing;
unit.getHealth hpNow;
unit.getHealthMax hpMax;
set hpMissing hpMax;
sub hpMissing hpNow;
unit.getMana manaNow;
unit.getManaMax manaMax;
unit.getRuleSoldier soldierRuleset;
soldierRuleset.getTag regenSoldier Tag.MISSION_END_FULL_SOLDIER_REGEN;
unit.getRuleArmor soldierArmor;
soldierArmor.getTag regenArmor Tag.MISSION_END_FULL_REGENERATION;
if gt regenSoldier 0;
set recoveryCost regenSoldier;
end;
if gt regenArmor 0;
set recoveryCost regenArmor;
end;
if gt recoveryCost 0;
div hpMissing recoveryCost;
sub manaNow hpMissing;
limit manaNow 0 manaMax;
set manaMissing manaMax;
sub manaMissing manaNow;
unit.setMana manaNow;
unit.setHealth hpMax;
set recovery_time 0;
# OXCE 6.4.3+ functions, without which script does not work.
set final_health_loss 0;
set final_mana_loss manaMissing;
return;
end;
return;