From 7dc36368b0992e0b67cc96e96164f2fe5c1cabc6 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 18 Jun 2020 20:08:00 -0400 Subject: [PATCH] Add poison. Update times/potency. --- mods/ITEMS/mcl_potions/functions.lua | 30 ++++++++++++++-------------- mods/ITEMS/mcl_potions/lingering.lua | 12 +++++------ mods/ITEMS/mcl_potions/splash.lua | 12 +++++------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 282e53e841..06a75d1752 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -65,25 +65,25 @@ function mcl_potions.weakness_func(player, factor, duration) minetest.after(duration, function() player:set_attribute("weakness", tostring(0)) end ) end + function mcl_potions.poison_func(player, factor, duration) - player:set_attribute("poison", tostring(factor)) - print(player:get_player_name().." ".."poison = "..player:get_attribute("poison")) - minetest.after(duration, function() player:set_attribute("poison", tostring(0)) end ) -end - -function mcl_potions.regeneration_func(player, factor, duration) - if minetest.is_player(player) then - - for i=1,math.floor(duration/factor) do - minetest.after(i*factor, function() - if player:get_hp() < 20 then - player:set_hp(player:get_hp() + 1) - end - end ) - end + for i=1,math.floor(duration/factor) do + minetest.after(i*factor, function() player:set_hp(player:get_hp() - 1) end) end end + +function mcl_potions.regeneration_func(player, factor, duration) + for i=1,math.floor(duration/factor) do + minetest.after(i*factor, function() + if player:get_hp() < 20 then + player:set_hp(player:get_hp() + 1) + end + end ) + end +end + + function mcl_potions.invisiblility_func(player, duration) mcl_potions.invisible(player, true) minetest.after(duration, function() mcl_potions.invisible(player, false) end ) diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 383f6e22e6..158e7a34db 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -143,27 +143,27 @@ register_lingering("slowness_plus", "Lingering Slowness +", "#000066", { }) register_lingering("poison", "Lingering Poison", "#335544", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 2.5, 45*redx) end }) register_lingering("poison_2", "Lingering Poison II", "#446655", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 1.2, 21*redx) end }) register_lingering("poison_plus", "Lingering Poison +", "#557766", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 2.5, 90*redx) end }) register_lingering("regeneration", "Lingering Regeneration", "#A52BB2", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 2.5, 45*redx) end }) register_lingering("regeneration_2", "Lingering Regeneration II", "#B52CC2", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 1.2, 21*redx) end }) register_lingering("regeneration_plus", "Lingering Regeneration +", "#C53DD3", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 300*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 2.5, 90*redx) end }) register_lingering("invisibility", "Lingering Invisibility", "#B0B0B0", { diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index ce39e795eb..886f2b0200 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -143,27 +143,27 @@ register_splash("slowness_plus", "Splash Slowness +", "#000066", { }) register_splash("poison", "Splash Poison", "#335544", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 2.5, 45*redx) end }) register_splash("poison_2", "Splash Poison II", "#446655", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 1.2, 21*redx) end }) register_splash("poison_plus", "Splash Poison +", "#557766", { - potion_fun = function(player, redx) mcl_potions.poison_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.poison_func(player, 2.5, 90*redx) end }) register_splash("regeneration", "Splash Regeneration", "#A52BB2", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 2.5, 45*redx) end }) register_splash("regeneration_2", "Splash Regeneration II", "#B52CC2", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 180*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 1.2, 21*redx) end }) register_splash("regeneration_plus", "Splash Regeneration +", "#C53DD3", { - potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 0.85, 300*redx) end + potion_fun = function(player, redx) mcl_potions.regeneration_func(player, 2.5, 90*redx) end }) register_splash("invisibility", "Splash Invisibility", "#B0B0B0", {