From 25d092a95e6034637bd92a27f35078c96834f7da Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 12 Jul 2020 08:50:48 -0400 Subject: [PATCH] Update potions to not hit player feet when thrown. --- mods/ITEMS/mcl_potions/lingering.lua | 2 +- mods/ITEMS/mcl_potions/potions.lua | 37 +++++++++++++++++++--------- mods/ITEMS/mcl_potions/splash.lua | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 2affead99..574364993 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -78,7 +78,7 @@ function mcl_potions.register_lingering(name, descr, color, def) local velocity = 10 local dir = placer:get_look_dir(); local pos = placer:getpos(); - local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") + local obj = minetest.add_entity({x=pos.x+(dir.x*2),y=pos.y+2+(dir.y*3),z=pos.z+(dir.z*2)}, id.."_flying") obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) if not minetest.is_creative_enabled(placer:get_player_name()) then diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 16977ea6a..fc033fbb9 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -150,18 +150,33 @@ local function register_potion(def) local splash_dur_2 = dur_2 * mcl_potions.SPLASH_FACTOR local ling_dur_2 = dur_2 * mcl_potions.LINGERING_FACTOR - if def.name == "healing" then effect_II = 7 end - local splash_def_2 = { - tt = get_tt(def._tt_2, effect_II, splash_dur_2), - potion_fun = get_splash_fun(effect_II, splash_dur_2), - } - if def.name == "healing" or def.name == "harming" then - effect_II = def.effect*mcl_potions.II_FACTOR*mcl_potions.LINGERING_FACTOR + local splash_def_2 + if def.name == "healing" then + splash_def_2 = { + tt = get_tt(def._tt_2, 7, splash_dur_2), + potion_fun = get_splash_fun(7, splash_dur_2), + } + else + splash_def_2 = { + tt = get_tt(def._tt_2, effect_II, splash_dur_2), + potion_fun = get_splash_fun(effect_II, splash_dur_2), + } end - local ling_def_2 = { - tt = get_tt(def._tt_2, effect_II, ling_dur_2), - potion_fun = get_lingering_fun(effect_II, ling_dur_2), - } + + + local ling_def_2 + if def.name == "healing" or def.name == "harming" then + ling_def_2 = { + tt = get_tt(def._tt_2, effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), + potion_fun = get_lingering_fun(effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), + } + else + ling_def_2 = { + tt = get_tt(def._tt_2, effect_II, ling_dur_2), + potion_fun = get_lingering_fun(effect_II, ling_dur_2), + } + end + if def.color then mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2) mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2) diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index f9f81ae1f..9b8d004f2 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -20,7 +20,7 @@ function mcl_potions.register_splash(name, descr, color, def) local velocity = 10 local dir = placer:get_look_dir(); local pos = placer:get_pos(); - local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying") + local obj = minetest.add_entity({x=pos.x+(dir.x*2),y=pos.y+2+(dir.y*3),z=pos.z+(dir.z*2)}, id.."_flying") obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) if not minetest.is_creative_enabled(placer:get_player_name()) then