forked from LizzyFleckenstein03/Memeclone
use mcl_util.replace_mob function to simplify lightning code
This commit is contained in:
parent
e4af02ea52
commit
463fe2af5f
|
@ -128,8 +128,6 @@ function lightning.strike(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lightning.register_on_strike(function(pos, pos2, objects)
|
lightning.register_on_strike(function(pos, pos2, objects)
|
||||||
local particle_pos = vector.offset(pos2, 0, (lightning.size / 2) + 0.5, 0)
|
local particle_pos = vector.offset(pos2, 0, (lightning.size / 2) + 0.5, 0)
|
||||||
local particle_size = lightning.size * 10
|
local particle_size = lightning.size * 10
|
||||||
|
@ -158,13 +156,8 @@ lightning.register_on_strike(function(pos, pos2, objects)
|
||||||
-- damage nearby objects, transform mobs
|
-- damage nearby objects, transform mobs
|
||||||
for _, obj in pairs(objects) do
|
for _, obj in pairs(objects) do
|
||||||
local lua = obj:get_luaentity()
|
local lua = obj:get_luaentity()
|
||||||
-- pig → zombie pigman (no damage)
|
|
||||||
if lua and lua.name == "mobs_mc:pig" then
|
if lua and lua.name == "mobs_mc:pig" then
|
||||||
local rot = obj:get_yaw()
|
mcl_util.replace_mob(obj, "mobs_mc:pigman")
|
||||||
obj:remove()
|
|
||||||
obj = add_entity(pos2, "mobs_mc:pigman")
|
|
||||||
obj:set_yaw(rot)
|
|
||||||
-- mooshroom: toggle color red/brown (no damage)
|
|
||||||
elseif lua and lua.name == "mobs_mc:mooshroom" then
|
elseif lua and lua.name == "mobs_mc:mooshroom" then
|
||||||
if lua.base_texture[1] == "mobs_mc_mooshroom.png" then
|
if lua.base_texture[1] == "mobs_mc_mooshroom.png" then
|
||||||
lua.base_texture = { "mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" }
|
lua.base_texture = { "mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" }
|
||||||
|
@ -172,23 +165,10 @@ lightning.register_on_strike(function(pos, pos2, objects)
|
||||||
lua.base_texture = { "mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png" }
|
lua.base_texture = { "mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png" }
|
||||||
end
|
end
|
||||||
obj:set_properties({ textures = lua.base_texture })
|
obj:set_properties({ textures = lua.base_texture })
|
||||||
-- villager → witch (no damage)
|
elseif lua and lua.name == "mobs_mc:villager" then
|
||||||
-- elseif lua and lua.name == "mobs_mc:villager" then
|
mcl_util.replace_mob(obj, "mobs_mc:witch")
|
||||||
-- Witches are incomplete, this code is unused
|
|
||||||
-- TODO: Enable this code when witches are working.
|
|
||||||
--[[
|
|
||||||
local rot = obj:get_yaw()
|
|
||||||
obj:remove()
|
|
||||||
obj = minetest.add_entity(pos2, "mobs_mc:witch")
|
|
||||||
obj:set_yaw(rot)
|
|
||||||
]]
|
|
||||||
-- charged creeper
|
|
||||||
elseif lua and lua.name == "mobs_mc:creeper" then
|
elseif lua and lua.name == "mobs_mc:creeper" then
|
||||||
local rot = obj:get_yaw()
|
mcl_util.replace_mob(obj, "mobs_mc:creeper_charged")
|
||||||
obj:remove()
|
|
||||||
obj = add_entity(pos2, "mobs_mc:creeper_charged")
|
|
||||||
obj:set_yaw(rot)
|
|
||||||
-- Other objects: Just damage
|
|
||||||
else
|
else
|
||||||
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
|
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue