Correct self-collision for lingering/splash potions

This commit is contained in:
teknomunk 2024-11-15 06:42:57 -06:00
parent 4731ae64f0
commit 74ce69e3f0
2 changed files with 14 additions and 6 deletions

View file

@ -151,9 +151,12 @@ function mcl_potions.register_lingering(name, descr, color, def)
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
local pos = placer:getpos(); local pos = placer:getpos();
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
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 = vl_projectile.create(id.."_flying",{
obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) pos = vector.offset(pos, dir.x, dir.y + 1.64, dir.z),
obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) owner = placer,
dir = dir,
velocity = velocity,
})
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
ent._thrower = placer:get_player_name() ent._thrower = placer:get_player_name()
ent._potency = item:get_meta():get_int("mcl_potions:potion_potent") ent._potency = item:get_meta():get_int("mcl_potions:potion_potent")
@ -212,6 +215,7 @@ function mcl_potions.register_lingering(name, descr, color, def)
vl_projectile.collides_with_entities, vl_projectile.collides_with_entities,
vl_projectile.collides_with_solids, vl_projectile.collides_with_solids,
}, },
grace_distance = 3.34, -- 1.5 active region + 1.64 height offset + 0.1 safety
on_collide_with_entity = on_collide, on_collide_with_entity = on_collide,
on_collide_with_solid = function(self, pos, node) on_collide_with_solid = function(self, pos, node)
if mod_target and node.name == "mcl_target:target_off" then if mod_target and node.name == "mcl_target:target_off" then

View file

@ -46,9 +46,12 @@ function mcl_potions.register_splash(name, descr, color, def)
local dir = placer:get_look_dir(); local dir = placer:get_look_dir();
local pos = placer:get_pos(); local pos = placer:get_pos();
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true) minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
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 = vl_projectile.create(id.."_flying",{
obj:set_velocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}) pos = vector.offset(pos, dir.x, dir.y + 1.64, dir.z),
obj:set_acceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3}) owner = placer,
dir = dir,
velocity = velocity,
})
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
ent._thrower = placer:get_player_name() ent._thrower = placer:get_player_name()
ent._potency = item:get_meta():get_int("mcl_potions:potion_potent") ent._potency = item:get_meta():get_int("mcl_potions:potion_potent")
@ -180,6 +183,7 @@ function mcl_potions.register_splash(name, descr, color, def)
vl_projectile.collides_with_entities, vl_projectile.collides_with_entities,
vl_projectile.collides_with_solids, vl_projectile.collides_with_solids,
}, },
grace_distance = 3.34, -- 1.5 active region + 1.64 height offset + 0.1 safety
on_collide_with_solid = function(self, pos, node) on_collide_with_solid = function(self, pos, node)
splash_effects(self, pos, def, 4) splash_effects(self, pos, def, 4)