Add immortal and fall_damage_add_percent armor groups (#3)

This change adds special handling for these armor groups, ensuring that their default values will remain as they are while also allowing mods to manage these groups via Armor Monoid.
Beware that the value range does not exactly correspond to the Luanti-provided API.
This commit is contained in:
EmptyStar
2025-04-16 12:24:11 -05:00
committed by GitHub
parent c5c43514f4
commit 96b12b9dea
2 changed files with 64 additions and 2 deletions

View File

@ -1,7 +1,11 @@
armor_monoid = {}
local armor_groups = { fleshy = 100 }
local armor_groups = {
fleshy = 100,
fall_damage_add_percent = 100,
immortal = 1,
}
armor_monoid.registered_groups = armor_groups
@ -71,6 +75,15 @@ armor_monoid.monoid = player_monoids.make_monoid({
end
end
-- fall_damage_add_percent is a special armor group that has an inherent
-- value of 0 rather than 100, so its final value is offset by -100 here
final.fall_damage_add_percent = final.fall_damage_add_percent - 100
-- immortal is a special armor group that must be either 0 or 1 to indicate
-- mortality or immortality, respectively, so its final value is constrained
-- here
final.immortal = final.immortal > 1 and 1 or 0
join_handled[player:get_player_name()] = true
player:set_armor_groups(final)