Namespacing pt. 3

This commit is contained in:
2022-11-24 00:51:57 -05:00
parent e5c3ae4ba0
commit 6bae4b3b6f
115 changed files with 175 additions and 1622 deletions

View File

@@ -768,7 +768,7 @@ end
function mob_class:item_drop()
-- no drops if disabled by setting or mob is child
if not mobs_drop_items or self.child then return end
local pos = self.object:get_pos()
@@ -780,27 +780,7 @@ function mob_class:item_drop()
return
end
-- was mob killed by player?
local death_by_player = self.cause_of_death
and self.cause_of_death.puncher
and self.cause_of_death.puncher:is_player()
-- check for tool 'looting_level' under tool_capabilities as default, or use
-- meta string 'looting_level' if found (max looting level is 3).
local looting = 0
if death_by_player then
local wield_stack = self.cause_of_death.puncher:get_wielded_item()
local wield_name = wield_stack:get_name()
local wield_stack_meta = wield_stack:get_meta()
local item_def = minetest.registered_items[wield_name]
local item_looting = item_def and item_def.tool_capabilities and
item_def.tool_capabilities.looting_level or 0
looting = tonumber(wield_stack_meta:get_string("looting_level")) or item_looting
looting = min(looting, 3)
end
--print("--- looting level", looting)
@@ -813,21 +793,11 @@ function mob_class:item_drop()
num = random(self.drops[n].min or 0, self.drops[n].max or 1)
item = self.drops[n].name
-- cook items on a hot death
if self.cause_of_death.hot then
local output = minetest.get_craft_result({
method = "cooking", width = 1, items = {item}})
if output and output.item and not output.item:is_empty() then
item = output.item:get_name()
end
end
-- only drop rare items (drops.min = 0) if killed by player
if death_by_player or self.drops[n].min ~= 0 then
obj = minetest.add_item(pos, ItemStack(item .. " " .. (num + looting)))
end
obj = minetest.add_item(pos, ItemStack(item .. " " .. (num)))
if obj and obj:get_luaentity() then
@@ -1198,7 +1168,7 @@ end
-- jump if facing a solid node (not fences or gates)
function mob_class:do_jump()
--[[
if not self.jump
or self.jump_height == 0
or self.fly
@@ -1235,14 +1205,18 @@ function mob_class:do_jump()
pos.y = pos.y + self.collisionbox[2]
-- what is in front of mob and above?
--This piece of code was causing random crashes
local nod = node_ok({x = pos.x + dir_x, y = pos.y + 0.5, z = pos.z + dir_z})
local nodt = node_ok({x = pos.x + dir_x, y = pos.y + 1.5, z = pos.z + dir_z})
[local nodt = node_ok({x = pos.x + dir_x, y = pos.y + 1.5, z = pos.z + dir_z})
local blocked = minetest.registered_nodes[nodt.name].walkable
-- are we facing a fence or wall
if nod.name:find("fence") or nod.name:find("gate") or nod.name:find("wall") then
self.facing_fence = true
end
]]
--[[
print("on: " .. self.standing_on
@@ -1252,7 +1226,7 @@ print("on: " .. self.standing_on
.. ", fence: " .. (self.facing_fence and "yes" or "no")
)
]]
--[[
-- if mob can leap then remove blockages and let them try
if self.can_leap == true then
blocked = false
@@ -1309,7 +1283,7 @@ print("on: " .. self.standing_on
end
end
return false
return false]]
end