1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-11-13 05:50:17 +01:00
This commit is contained in:
tenplus1 2022-05-14 11:21:36 +01:00
parent 6f8b6fe3f5
commit 168014b86f

49
api.lua
View File

@ -28,7 +28,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20220501",
version = "20220514",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -546,6 +546,7 @@ local new_line_of_sight = function(self, pos1, pos2, stepsize)
return false
end
-- check line of sight using raycasting (thanks Astrobe)
local ray_line_of_sight = function(self, pos1, pos2)
@ -914,18 +915,7 @@ function mob_class:check_for_death(cmi_cause)
self.health = self.hp_max
end
-- backup nametag so we can show health stats
-- if not self.nametag2 then
-- self.nametag2 = self.nametag or ""
-- end
-- if show_health
-- and (cmi_cause and cmi_cause.type == "punch") then
-- self.htimer = 2
-- self.nametag = "♥ " .. self.health .. " / " .. self.hp_max
self:update_tag()
-- end
self:update_tag()
return false
end
@ -1098,14 +1088,7 @@ function mob_class:do_env_damage()
self.htimer = self.htimer - 1
end
-- reset nametag after showing health stats
-- if self.htimer < 1 and self.nametag2 then
-- self.nametag = self.nametag2
-- self.nametag2 = nil
self:update_tag()
-- end
self:update_tag()
local pos = self.object:get_pos() ; if not pos then return end
@ -1704,6 +1687,7 @@ end
local pathfinder_mod = minetest.get_modpath("pathfinder")
-- path finding and smart mob routine by rnd,
-- line_of_sight and other edits by Elkien3
function mob_class:smart_mobs(s, p, dist, dtime)
@ -3024,7 +3008,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
if self:check_for_death({type = "punch", puncher = hitter, hot = hot}) then
return true
end
end -- END if damage
end
-- knock back effect (only on full punch)
if self.knock_back and tflp >= punch_interval then
@ -3167,8 +3151,6 @@ function mob_class:mob_staticdata()
end
end
--print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
return minetest.serialize(tmp)
end
@ -3379,8 +3361,7 @@ function mob_class:mob_expire(pos, dtime)
end
end
-- minetest.log("action",
-- S("lifetimer expired, removed @1", self.name))
-- minetest.log("action", S("lifetimer expired, removed @1", self.name))
effect(pos, 15, "tnt_smoke.png", 2, 4, 2, 0)
@ -3407,9 +3388,9 @@ function mob_class:on_step(dtime, moveresult)
-- early warning check, if no yaw then no entity, skip rest of function
if not yaw then return end
-- get node at foot level every quarter second
self.node_timer = (self.node_timer or 0) + dtime
-- get nodes above and below foot level every 1/4 second
if self.node_timer > 0.25 then
self.node_timer = 0
@ -3707,7 +3688,7 @@ minetest.register_entity(name, setmetatable({
get_staticdata = function(self)
return self:mob_staticdata(self)
end,
end
}, mob_class_meta))
@ -4509,7 +4490,7 @@ end
function mobs:capture_mob(self, clicker, chance_hand, chance_net,
chance_lasso, force_take, replacewith)
if not self --self.child
if not self
or not clicker:is_player()
or not clicker:get_inventory() then
return false
@ -4713,15 +4694,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
if self.health >= self.hp_max then
self.health = self.hp_max
-- if self.htimer < 1 then
-- minetest.chat_send_player(clicker:get_player_name(),
-- S("@1 at full health (@2)",
-- self.name:split(":")[2], tostring(self.health)))
-- self.htimer = 5
-- end
end
self.object:set_hp(self.health)
@ -4729,7 +4701,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
-- make children grow quicker
if self.child == true then
-- self.hornytimer = self.hornytimer + 20
-- deduct 10% of the time to adulthood
self.hornytimer = math.floor(self.hornytimer + (
(CHILD_GROW_TIME - self.hornytimer) * 0.1))