From 87858643f9772ad4184e96e5d5a20972c8c0021a Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Aug 2021 00:59:14 +0200 Subject: [PATCH] possibility of no damage if enable_damage or in protected areas --- petz/api/api_on_punch.lua | 11 ++++++++++- petz/petz.conf | 7 +++++++ petz/settings.lua | 11 +++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/petz/api/api_on_punch.lua b/petz/api/api_on_punch.lua index 5c1752e..611edc1 100644 --- a/petz/api/api_on_punch.lua +++ b/petz/api/api_on_punch.lua @@ -47,13 +47,22 @@ end function petz.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir) local pos = self.object:get_pos() --pos of the petz - if not mobkit.is_alive(self) then --is petz alive + if not(mobkit.is_alive(self)) then --is petz is died return end --Do not punch when you are mounted on it!!!--> if self.is_mountable and puncher == self.driver then return end + --Check the setting 'check_enable_damage' + if petz.settings.check_enable_damage and + not(minetest.setting_getbool("enable_damage")) then + return + end + --Check area protection + if petz.settings.no_damage_in_protected and minetest.is_protected(pos, puncher:get_player_name()) then + return + end --Check Dreamcatcher Protection local puncher_is_player = petz.puncher_is_player(puncher) if puncher_is_player then --player diff --git a/petz/petz.conf b/petz/petz.conf index 50101f3..963de89 100644 --- a/petz/petz.conf +++ b/petz/petz.conf @@ -179,6 +179,13 @@ lycanthropy = true lycanthropy_infection_chance_by_wolf = 200 lycanthropy_infection_chance_by_werewolf = 10 +##Damage Engine +#If this setting is 'true', checks the "enable_damage" setting of the game +#and if 'enable_damage=false', disables the damage for pets too. +check_enable_damage = false +#Petz are not damaged in protected areas +no_damage_in_protected = true + ##Enviromental Damage air_damage = 1 #Lava & Fire diff --git a/petz/settings.lua b/petz/settings.lua index 202e97b..4cdafd9 100644 --- a/petz/settings.lua +++ b/petz/settings.lua @@ -79,6 +79,17 @@ local settings_def = { split = true, default = "", }, + --Damage Engine + { + name = "check_enable_damage", + type = "boolean", + default = false, + }, + { + name = "no_damage_in_protected", + type = "boolean", + default = false, + }, --Enviromental Damage { name = "air_damage",