mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-11-13 05:50:17 +01:00
alternative to using on_punch for hearing ability, remove food xp desc
This commit is contained in:
parent
b1da38456d
commit
1f6867bf25
16
api.lua
16
api.lua
|
@ -2823,16 +2823,6 @@ local tr = minetest.get_modpath("toolranks")
|
|||
-- deal damage and effects when mob punched
|
||||
function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
||||
|
||||
-- is punch from sound detection
|
||||
if hitter and hitter.type == "sound" then
|
||||
|
||||
if self.on_sound then
|
||||
self.on_sound(self, hitter) -- pass sound table to custom function
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- mob health check
|
||||
if self.health <= 0 then
|
||||
return true
|
||||
|
@ -5109,14 +5099,14 @@ minetest.sound_play = function(spec, param, eph)
|
|||
|
||||
local ent = obj:get_luaentity()
|
||||
|
||||
if ent and ent._cmi_is_mob then
|
||||
if ent and ent._cmi_is_mob and ent.on_sound then
|
||||
|
||||
-- calculate loudness of sound to mob
|
||||
op_params.distance = get_distance(op_params.pos, obj:get_pos())
|
||||
op_params.loudness = op_params.gain / op_params.distance
|
||||
|
||||
-- run custom mob on_punch with sound information table
|
||||
ent:on_punch(op_params)
|
||||
-- run custom on_sound function
|
||||
ent.on_sound(ent, op_params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
crafts.lua
10
crafts.lua
|
@ -4,8 +4,6 @@ local FS = function(...) return minetest.formspec_escape(S(...)) end
|
|||
local mc2 = minetest.get_modpath("mcl_core")
|
||||
|
||||
-- helper function to add {eatable} group to food items
|
||||
local mod_tt_base = minetest.get_modpath("tt_base") -- mod does similar to infotext
|
||||
|
||||
function mobs.add_eatable(item, hp)
|
||||
|
||||
local def = minetest.registered_items[item]
|
||||
|
@ -13,16 +11,10 @@ function mobs.add_eatable(item, hp)
|
|||
if def then
|
||||
|
||||
local groups = table.copy(def.groups) or {}
|
||||
local txt = " (" ; if hp > 0 then txt = txt .. "+" end
|
||||
txt = txt .. hp .. " HP)"
|
||||
|
||||
groups.eatable = hp ; groups.flammable = 2
|
||||
|
||||
if mod_tt_base == nil then
|
||||
def.description = def.description .. txt
|
||||
end
|
||||
|
||||
minetest.override_item(item, {description = def.description, groups = groups})
|
||||
minetest.override_item(item, {groups = groups})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user