Merge branch 'wielditem' of https://git.minetest.land/epCode/MineClone2 into wielditem

This commit is contained in:
epCode 2020-12-18 16:44:32 -08:00
commit eee88adcd1
2 changed files with 43 additions and 39 deletions

View File

@ -67,7 +67,7 @@ local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false local mobs_drop_items = minetest.settings:get_bool("mobs_drop_items") ~= false
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false local spawn_protected = minetest.settings:get_bool("mobs_spawn_protected") ~= false
local remove_far = false local remove_far = true
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0 local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
local show_health = false local show_health = false
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 64) local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 64)
@ -2964,8 +2964,8 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
local die = false local die = false
-- only play hit sound and show blood effects if damage is 1 or over -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
if damage >= 1 then if damage >= 0.1 then
-- weapon sounds -- weapon sounds
if weapon:get_definition().sounds ~= nil then if weapon:get_definition().sounds ~= nil then
@ -2986,7 +2986,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
damage_effect(self, damage) damage_effect(self, damage)
-- do damage -- do damage
self.health = self.health - floor(damage) self.health = self.health - damage
-- skip future functions if dead, except alerting others -- skip future functions if dead, except alerting others
if check_for_death(self, "hit", {type = "punch", puncher = hitter}) then if check_for_death(self, "hit", {type = "punch", puncher = hitter}) then
@ -3113,6 +3113,7 @@ end
-- get entity staticdata -- get entity staticdata
local mob_staticdata = function(self) local mob_staticdata = function(self)
--[[
-- remove mob when out of range unless tamed -- remove mob when out of range unless tamed
if remove_far if remove_far
and self.can_despawn and self.can_despawn
@ -3125,7 +3126,7 @@ local mob_staticdata = function(self)
return ""-- nil return ""-- nil
end end
--]]
self.remove_ok = true self.remove_ok = true
self.attack = nil self.attack = nil
self.following = nil self.following = nil
@ -3334,37 +3335,6 @@ local mob_step = function(self, dtime)
update_tag(self) update_tag(self)
end end
-- Despawning: when lifetimer expires, remove mob
if remove_far
and self.can_despawn == true
and ((not self.nametag) or (self.nametag == "")) then
-- TODO: Finish up implementation of despawning rules
self.lifetimer = self.lifetimer - dtime
if self.lifetimer <= 0 then
-- only despawn away from player
local objs = minetest.get_objects_inside_radius(pos, 32)
for n = 1, #objs do
if objs[n]:is_player() then
self.lifetimer = 20
return
end
end
minetest.log("action", "Mob "..name.." despawns in mob_step at "..minetest.pos_to_string(pos))
self.object:remove()
return
end
end
if self.state == "die" then if self.state == "die" then
return return
end end
@ -3548,6 +3518,40 @@ local mob_step = function(self, dtime)
set_animation(self, "stand") set_animation(self, "stand")
end end
-- Despawning: when lifetimer expires, remove mob
if remove_far
and self.can_despawn == true
and ((not self.nametag) or (self.nametag == "")) then
self.lifetimer = self.lifetimer - dtime
if self.lifetimer <= 10 then
-- only despawn away from player
local far_objs = minetest.get_objects_inside_radius(pos, 48)
for n = 1, #far_objs do
if far_objs[n]:is_player() then
local close_objs = minetest.get_objects_inside_radius(pos, 16)
for n = 1, #close_objs do
if close_objs[n]:is_player() then
self.lifetimer = 20
else
if math.random(1,10) <= 3 then
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos))
self.object:remove()
return
end
end
end
else
minetest.log("action", "Mob "..self.name.." despawns in mob_step at "..minetest.pos_to_string(pos))
self.object:remove()
return
end
end
end
end
end end

View File

@ -185,7 +185,7 @@ local magma_cube_big = {
run_velocity = 4, run_velocity = 4,
damage = 6, damage = 6,
reach = 3, reach = 3,
armor = 40, armor = 53,
drops = { drops = {
{name = mobs_mc.items.magma_cream, {name = mobs_mc.items.magma_cream,
chance = 4, chance = 4,
@ -240,7 +240,7 @@ magma_cube_small.run_velocity = 2.6
magma_cube_small.jump_height = 6 magma_cube_small.jump_height = 6
magma_cube_small.damage = 4 magma_cube_small.damage = 4
magma_cube_small.reach = 2.75 magma_cube_small.reach = 2.75
magma_cube_small.armor = 70 magma_cube_small.armor = 66
magma_cube_small.spawn_small_alternative = "mobs_mc:magma_cube_tiny" magma_cube_small.spawn_small_alternative = "mobs_mc:magma_cube_tiny"
magma_cube_small.on_die = spawn_children_on_die("mobs_mc:magma_cube_tiny", 4, 0.6, 1.0) magma_cube_small.on_die = spawn_children_on_die("mobs_mc:magma_cube_tiny", 4, 0.6, 1.0)
mobs:register_mob("mobs_mc:magma_cube_small", magma_cube_small) mobs:register_mob("mobs_mc:magma_cube_small", magma_cube_small)
@ -260,7 +260,7 @@ magma_cube_tiny.run_velocity = 1.02
magma_cube_tiny.jump_height = 4 magma_cube_tiny.jump_height = 4
magma_cube_tiny.damage = 3 magma_cube_tiny.damage = 3
magma_cube_tiny.reach = 2.5 magma_cube_tiny.reach = 2.5
magma_cube_tiny.armor = 85 magma_cube_tiny.armor = 50
magma_cube_tiny.drops = {} magma_cube_tiny.drops = {}
magma_cube_tiny.spawn_small_alternative = nil magma_cube_tiny.spawn_small_alternative = nil
magma_cube_tiny.on_die = nil magma_cube_tiny.on_die = nil