1
0
Fork 0

Update potions for mob effects. Healing harms zombies, harming heals zombies.

This commit is contained in:
Brandon 2020-06-18 16:56:19 -04:00
parent 9f5bce29cb
commit 4b23c2a15c
5 changed files with 19 additions and 6 deletions

View File

@ -31,7 +31,19 @@ function mcl_potions._use_potion(item)
minetest.sound_play("mcl_potions_drinking") minetest.sound_play("mcl_potions_drinking")
end 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) function mcl_potions.swiftness_func(player, factor, duration)
playerphysics.add_physics_factor(player, "speed", "swiftness", factor) playerphysics.add_physics_factor(player, "speed", "swiftness", factor)

View File

@ -7,7 +7,7 @@ dofile(modpath .. "/splash.lua")
dofile(modpath .. "/lingering.lua") dofile(modpath .. "/lingering.lua")
dofile(modpath .. "/potions.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", { minetest.register_craftitem("mcl_potions:fermented_spider_eye", {
description = S("Fermented Spider Eye"), description = S("Fermented Spider Eye"),

View File

@ -60,7 +60,7 @@ local function register_lingering(name, descr, color, def)
self.object:remove() self.object:remove()
for i, obj in ipairs(minetest.get_objects_inside_radius(pos, 4)) do 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() 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)) local rad = math.floor(math.sqrt((pos2.x-pos.x)^2 + (pos2.y-pos.y)^2 + (pos2.z-pos.z)^2))

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator("mcl_potions") local S = minetest.get_translator("mcl_potions")
local brewhelp = S("Try different combinations to create potions.")
local potion_image = function(colorstring, opacity) local potion_image = function(colorstring, opacity)
if not opacity then if not opacity then

View File

@ -60,7 +60,7 @@ local function register_splash(name, descr, color, def)
self.object:remove() self.object:remove()
for i, obj in ipairs(minetest.get_objects_inside_radius(pos, 4)) do 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() 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)) 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", { 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", { 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", { register_splash("harming", "Splash Harming", "#660099", {