Convert lingering potion to vl_projectile
This commit is contained in:
parent
1a6f7d3c15
commit
ad087805ea
|
@ -1,5 +1,6 @@
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
|
||||||
|
local PARTICLE_DENSITY = 4
|
||||||
local mod_target = minetest.get_modpath("mcl_target")
|
local mod_target = minetest.get_modpath("mcl_target")
|
||||||
|
|
||||||
local function lingering_image(colorstring, opacity)
|
local function lingering_image(colorstring, opacity)
|
||||||
|
@ -53,7 +54,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
else
|
else
|
||||||
texture = "mcl_particles_effect.png"
|
texture = "mcl_particles_effect.png"
|
||||||
end
|
end
|
||||||
linger_particles(pos, d, texture, vals.color)
|
linger_particles(pos, PARTICLE_DENSITY, texture, vals.color)
|
||||||
|
|
||||||
-- -- Extinguish fire if water bottle
|
-- -- Extinguish fire if water bottle
|
||||||
-- if vals.is_water then
|
-- if vals.is_water then
|
||||||
|
@ -181,40 +182,47 @@ function mcl_potions.register_lingering(name, descr, color, def)
|
||||||
|
|
||||||
local w = 0.7
|
local w = 0.7
|
||||||
|
|
||||||
minetest.register_entity(id.."_flying",{
|
local particle_texture
|
||||||
|
if name == "water" then
|
||||||
|
particle_texture = "mcl_particles_droplet_bottle.png"
|
||||||
|
else
|
||||||
|
if def.instant then
|
||||||
|
particle_texture = "mcl_particles_instant_effect.png"
|
||||||
|
else
|
||||||
|
particle_texture = "mcl_particles_effect.png"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_collide(self, pos)
|
||||||
|
local potency = self._potency or 0
|
||||||
|
local plus = self._plus or 0
|
||||||
|
add_lingering_effect(pos, color, def, name == "water", potency, plus)
|
||||||
|
linger_particles(pos, PARTICLE_DENSITY, particle_texture, color)
|
||||||
|
if def.on_splash then def.on_splash(pos, potency+1) end
|
||||||
|
end
|
||||||
|
vl_projectile.register(id.."_flying",{
|
||||||
textures = {lingering_image(color)},
|
textures = {lingering_image(color)},
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
visual_size = {x=w/2,y=w/2},
|
visual_size = {x=w/2,y=w/2},
|
||||||
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
||||||
pointable = false,
|
pointable = false,
|
||||||
on_step = function(self, dtime)
|
_vl_projectile = {
|
||||||
local pos = self.object:get_pos()
|
behaviors = {
|
||||||
local node = minetest.get_node(pos)
|
vl_projectile.collides_with_entities,
|
||||||
local n = node.name
|
vl_projectile.collides_with_solids,
|
||||||
local g = minetest.get_item_group(n, "liquid")
|
},
|
||||||
local d = 4
|
collides_with = {"group:liquid"},
|
||||||
if mod_target and n == "mcl_target:target_off" then
|
on_collide_with_entity = on_collide,
|
||||||
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
|
on_collide_with_solid = function(self, pos, node)
|
||||||
end
|
if mod_target and n == "mcl_target:target_off" then
|
||||||
if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then
|
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
|
||||||
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
|
|
||||||
local potency = self._potency or 0
|
|
||||||
local plus = self._plus or 0
|
|
||||||
add_lingering_effect(pos, color, def, name == "water", potency, plus)
|
|
||||||
local texture
|
|
||||||
if name == "water" then
|
|
||||||
texture = "mcl_particles_droplet_bottle.png"
|
|
||||||
else
|
|
||||||
if def.instant then
|
|
||||||
texture = "mcl_particles_instant_effect.png"
|
|
||||||
else
|
|
||||||
texture = "mcl_particles_effect.png"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
linger_particles(pos, d, texture, color)
|
|
||||||
if def.on_splash then def.on_splash(pos, potency+1) end
|
on_collide(self, pos)
|
||||||
self.object:remove()
|
end,
|
||||||
end
|
sounds = {
|
||||||
end,
|
{"mcl_potions_breaking_glass", {max_hear_distance = 16, gain = 1}},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue