forked from VoxeLibre/VoxeLibre
Implement lightning_bolt damage reason
This commit is contained in:
parent
ad3defdfb3
commit
49e7def70a
|
@ -139,22 +139,14 @@ lightning.strike = function(pos)
|
||||||
for o=1, #objs do
|
for o=1, #objs do
|
||||||
local obj = objs[o]
|
local obj = objs[o]
|
||||||
local lua = obj:get_luaentity()
|
local lua = obj:get_luaentity()
|
||||||
if obj:is_player() then
|
|
||||||
-- Player damage
|
|
||||||
if has_mcl_death_msg then
|
|
||||||
mcl_death_messages.player_damage(obj, S("@1 was struck by lightning.", obj:get_player_name()))
|
|
||||||
end
|
|
||||||
obj:set_hp(obj:get_hp()-5, { type = "punch", from = "mod" })
|
|
||||||
-- Mobs
|
|
||||||
elseif lua and lua._cmi_is_mob then
|
|
||||||
-- pig → zombie pigman (no damage)
|
-- pig → zombie pigman (no damage)
|
||||||
if lua.name == "mobs_mc:pig" then
|
if lua and lua.name == "mobs_mc:pig" then
|
||||||
local rot = obj:get_yaw()
|
local rot = obj:get_yaw()
|
||||||
obj:remove()
|
obj:remove()
|
||||||
obj = add_entity(pos2, "mobs_mc:pigman")
|
obj = add_entity(pos2, "mobs_mc:pigman")
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
-- mooshroom: toggle color red/brown (no damage)
|
-- mooshroom: toggle color red/brown (no damage)
|
||||||
elseif 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" }
|
||||||
else
|
else
|
||||||
|
@ -162,7 +154,7 @@ lightning.strike = function(pos)
|
||||||
end
|
end
|
||||||
obj:set_properties({textures = lua.base_texture})
|
obj:set_properties({textures = lua.base_texture})
|
||||||
-- villager → witch (no damage)
|
-- villager → witch (no damage)
|
||||||
elseif lua.name == "mobs_mc:villager" then
|
elseif lua and lua.name == "mobs_mc:villager" then
|
||||||
-- Witches are incomplete, this code is unused
|
-- Witches are incomplete, this code is unused
|
||||||
-- TODO: Enable this code when witches are working.
|
-- TODO: Enable this code when witches are working.
|
||||||
--[[
|
--[[
|
||||||
|
@ -172,15 +164,17 @@ lightning.strike = function(pos)
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
]]
|
]]
|
||||||
-- charged creeper
|
-- charged creeper
|
||||||
elseif lua.name == "mobs_mc:creeper" then
|
elseif lua and lua.name == "mobs_mc:creeper" then
|
||||||
local rot = obj:get_yaw()
|
local rot = obj:get_yaw()
|
||||||
obj:remove()
|
obj:remove()
|
||||||
obj = add_entity(pos2, "mobs_mc:creeper_charged")
|
obj = add_entity(pos2, "mobs_mc:creeper_charged")
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
-- Other mobs: Just damage
|
-- Other objects: Just damage
|
||||||
else
|
else
|
||||||
obj:set_hp(obj:get_hp()-5, { type = "punch", from = "mod" })
|
if obj:is_player() and has_mcl_death_msg then
|
||||||
|
mcl_death_messages.player_damage(obj, S("@1 was struck by lightning.", obj:get_player_name()))
|
||||||
end
|
end
|
||||||
|
mcl_util.deal_damage(obj, 5, {type = "lightning_bolt"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue