From 4b23c2a15c95cfe4147b713518409d0609092af0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 18 Jun 2020 16:56:19 -0400 Subject: [PATCH] Update potions for mob effects. Healing harms zombies, harming heals zombies. --- mods/ITEMS/mcl_potions/functions.lua | 14 +++++++++++++- mods/ITEMS/mcl_potions/init.lua | 2 +- mods/ITEMS/mcl_potions/lingering.lua | 2 +- mods/ITEMS/mcl_potions/potions.lua | 1 + mods/ITEMS/mcl_potions/splash.lua | 6 +++--- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 886502cfbd..410717d086 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -31,7 +31,19 @@ function mcl_potions._use_potion(item) minetest.sound_play("mcl_potions_drinking") end -function mcl_potions.healing_func(player, hp) player:set_hp(player:get_hp() + hp) end +local is_zombie = {} + +for i, zombie in ipairs({"husk","zombie","pigman"}) do + is_zombie["mobs_mc:"..zombie] = true + is_zombie["mobs_mc:baby_"..zombie] = true +end + +function mcl_potions.healing_func(player, hp) + + if is_zombie[player:get_entity_name()] then hp = -hp end + player:set_hp(player:get_hp() + hp) + +end function mcl_potions.swiftness_func(player, factor, duration) playerphysics.add_physics_factor(player, "speed", "swiftness", factor) diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index e782b43e86..2e31316c65 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -7,7 +7,7 @@ dofile(modpath .. "/splash.lua") dofile(modpath .. "/lingering.lua") dofile(modpath .. "/potions.lua") -local brewhelp = S("Put this item in an item frame for decoration. It's useless otherwise.") +local brewhelp = S("Try different combinations to create potions.") minetest.register_craftitem("mcl_potions:fermented_spider_eye", { description = S("Fermented Spider Eye"), diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 053601d41d..383f6e22e6 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -60,7 +60,7 @@ local function register_lingering(name, descr, color, def) self.object:remove() for i, obj in ipairs(minetest.get_objects_inside_radius(pos, 4)) do - if minetest.is_player(obj) then + if minetest.is_player(obj) or obj:get_entity_name() then pos2 = obj:get_pos() local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2)) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 32ddb37807..bdae4326cb 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("mcl_potions") +local brewhelp = S("Try different combinations to create potions.") local potion_image = function(colorstring, opacity) if not opacity then diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index e4576f0bcb..4543386f93 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -60,7 +60,7 @@ local function register_splash(name, descr, color, def) self.object:remove() for i, obj in ipairs(minetest.get_objects_inside_radius(pos, 4)) do - if minetest.is_player(obj) then + if minetest.is_player(obj) or obj:get_entity_name() then pos2 = obj:get_pos() local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2)) @@ -95,11 +95,11 @@ register_splash("thick", "Splash Thick Potion", "#0000FF", { }) register_splash("healing", "Splash Healing", "#AA0000", { - potion_fun = function(player, redx) player:set_hp(player:get_hp() + 3*redx) end, + potion_fun = function(player, redx) mcl_potions.healing_func(player, 3*redx) end, }) register_splash("healing_2", "Splash Healing II", "#DD0000", { - potion_fun = function(player, redx) player:set_hp(player:get_hp() + 6*redx) end, + potion_fun = function(player, redx) mcl_potions.healing_func(player, 6*redx) end, }) register_splash("harming", "Splash Harming", "#660099", {