mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-09 17:30:21 +01:00
tidy api
This commit is contained in:
parent
6f8b6fe3f5
commit
168014b86f
49
api.lua
49
api.lua
@ -28,7 +28,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20220501",
|
version = "20220514",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -546,6 +546,7 @@ local new_line_of_sight = function(self, pos1, pos2, stepsize)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- check line of sight using raycasting (thanks Astrobe)
|
-- check line of sight using raycasting (thanks Astrobe)
|
||||||
local ray_line_of_sight = function(self, pos1, pos2)
|
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
|
self.health = self.hp_max
|
||||||
end
|
end
|
||||||
|
|
||||||
-- backup nametag so we can show health stats
|
self:update_tag()
|
||||||
-- 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
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -1098,14 +1088,7 @@ function mob_class:do_env_damage()
|
|||||||
self.htimer = self.htimer - 1
|
self.htimer = self.htimer - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- reset nametag after showing health stats
|
self:update_tag()
|
||||||
-- if self.htimer < 1 and self.nametag2 then
|
|
||||||
|
|
||||||
-- self.nametag = self.nametag2
|
|
||||||
-- self.nametag2 = nil
|
|
||||||
|
|
||||||
self:update_tag()
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos() ; if not pos then return end
|
local pos = self.object:get_pos() ; if not pos then return end
|
||||||
|
|
||||||
@ -1704,6 +1687,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local pathfinder_mod = minetest.get_modpath("pathfinder")
|
local pathfinder_mod = minetest.get_modpath("pathfinder")
|
||||||
|
|
||||||
-- path finding and smart mob routine by rnd,
|
-- path finding and smart mob routine by rnd,
|
||||||
-- line_of_sight and other edits by Elkien3
|
-- line_of_sight and other edits by Elkien3
|
||||||
function mob_class:smart_mobs(s, p, dist, dtime)
|
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
|
if self:check_for_death({type = "punch", puncher = hitter, hot = hot}) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end -- END if damage
|
end
|
||||||
|
|
||||||
-- knock back effect (only on full punch)
|
-- knock back effect (only on full punch)
|
||||||
if self.knock_back and tflp >= punch_interval then
|
if self.knock_back and tflp >= punch_interval then
|
||||||
@ -3167,8 +3151,6 @@ function mob_class:mob_staticdata()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--print('===== '..self.name..'\n'.. dump(tmp)..'\n=====\n')
|
|
||||||
|
|
||||||
return minetest.serialize(tmp)
|
return minetest.serialize(tmp)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3379,8 +3361,7 @@ function mob_class:mob_expire(pos, dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- minetest.log("action",
|
-- minetest.log("action", S("lifetimer expired, removed @1", self.name))
|
||||||
-- S("lifetimer expired, removed @1", self.name))
|
|
||||||
|
|
||||||
effect(pos, 15, "tnt_smoke.png", 2, 4, 2, 0)
|
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
|
-- early warning check, if no yaw then no entity, skip rest of function
|
||||||
if not yaw then return end
|
if not yaw then return end
|
||||||
|
|
||||||
-- get node at foot level every quarter second
|
|
||||||
self.node_timer = (self.node_timer or 0) + dtime
|
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
|
if self.node_timer > 0.25 then
|
||||||
|
|
||||||
self.node_timer = 0
|
self.node_timer = 0
|
||||||
@ -3707,7 +3688,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
|
|
||||||
get_staticdata = function(self)
|
get_staticdata = function(self)
|
||||||
return self:mob_staticdata(self)
|
return self:mob_staticdata(self)
|
||||||
end,
|
end
|
||||||
|
|
||||||
}, mob_class_meta))
|
}, mob_class_meta))
|
||||||
|
|
||||||
@ -4509,7 +4490,7 @@ end
|
|||||||
function mobs:capture_mob(self, clicker, chance_hand, chance_net,
|
function mobs:capture_mob(self, clicker, chance_hand, chance_net,
|
||||||
chance_lasso, force_take, replacewith)
|
chance_lasso, force_take, replacewith)
|
||||||
|
|
||||||
if not self --self.child
|
if not self
|
||||||
or not clicker:is_player()
|
or not clicker:is_player()
|
||||||
or not clicker:get_inventory() then
|
or not clicker:get_inventory() then
|
||||||
return false
|
return false
|
||||||
@ -4713,15 +4694,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
if self.health >= self.hp_max then
|
if self.health >= self.hp_max then
|
||||||
|
|
||||||
self.health = self.hp_max
|
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
|
end
|
||||||
|
|
||||||
self.object:set_hp(self.health)
|
self.object:set_hp(self.health)
|
||||||
@ -4729,7 +4701,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
-- make children grow quicker
|
-- make children grow quicker
|
||||||
if self.child == true then
|
if self.child == true then
|
||||||
|
|
||||||
-- self.hornytimer = self.hornytimer + 20
|
|
||||||
-- deduct 10% of the time to adulthood
|
-- deduct 10% of the time to adulthood
|
||||||
self.hornytimer = math.floor(self.hornytimer + (
|
self.hornytimer = math.floor(self.hornytimer + (
|
||||||
(CHILD_GROW_TIME - self.hornytimer) * 0.1))
|
(CHILD_GROW_TIME - self.hornytimer) * 0.1))
|
||||||
|
Loading…
Reference in New Issue
Block a user