mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
Update potions for mob effects. Healing harms zombies, harming heals zombies.
This commit is contained in:
parent
9f5bce29cb
commit
4b23c2a15c
5 changed files with 19 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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", {
|
||||
|
|
Loading…
Reference in a new issue