mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-27 19:57:31 +01:00
Merge pull request 'Mobs fix crash and not drop XP when dying by fire from sunlight' (#3398) from mob_death_xp_drop into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3398
This commit is contained in:
commit
30bb1ab075
@ -365,6 +365,8 @@ function mob_class:on_step(dtime)
|
||||
if self:check_despawn(pos, dtime) then return true end
|
||||
if self:outside_limits() then return end
|
||||
|
||||
-- Start: Death/damage processing
|
||||
-- All damage needs to be undertaken at the start. We need to exit processing if the mob dies.
|
||||
if self:check_death_and_slow_mob() then
|
||||
--minetest.log("action", "Mob is dying: ".. tostring(self.name))
|
||||
-- Do we abandon out of here now?
|
||||
@ -375,47 +377,50 @@ function mob_class:on_step(dtime)
|
||||
|
||||
if not self.fire_resistant then
|
||||
mcl_burning.tick(self.object, dtime, self)
|
||||
-- mcl_burning.tick may remove object immediately
|
||||
if not self.object:get_pos() then return end
|
||||
if not self.object:get_pos() then return end -- mcl_burning.tick may remove object immediately
|
||||
|
||||
if self:check_for_death("fire", {type = "fire"}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if self:env_damage (dtime, pos) then return end
|
||||
|
||||
if self.state == "die" then return end
|
||||
-- End: Death/damage processing
|
||||
|
||||
self:check_water_flow()
|
||||
self:env_danger_movement_checks (dtime)
|
||||
|
||||
if mobs_debug then self:update_tag() end
|
||||
|
||||
self:follow_flop() -- Mob following code.
|
||||
|
||||
self:set_animation_speed() -- set animation speed relitive to velocity
|
||||
self:set_animation_speed() -- set animation speed relative to velocity
|
||||
|
||||
self:check_smooth_rotation(dtime)
|
||||
self:check_head_swivel(dtime)
|
||||
|
||||
if self.jump_sound_cooloff > 0 then
|
||||
self.jump_sound_cooloff = self.jump_sound_cooloff - dtime
|
||||
end
|
||||
if self.jump_sound_cooloff > 0 then self.jump_sound_cooloff = self.jump_sound_cooloff - dtime end
|
||||
self:do_jump()
|
||||
|
||||
self:set_armor_texture()
|
||||
self:check_runaway_from()
|
||||
|
||||
self:monster_attack()
|
||||
self:npc_attack()
|
||||
self:check_breeding()
|
||||
self:check_aggro(dtime)
|
||||
|
||||
-- run custom function (defined in mob lua file)
|
||||
if self.do_custom then
|
||||
if self.do_custom(self, dtime) == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
self:check_breeding()
|
||||
|
||||
self:check_item_pickup()
|
||||
self:set_armor_texture()
|
||||
|
||||
if self.do_custom and self.do_custom(self, dtime) == false then return end
|
||||
|
||||
if update_timers(self, dtime) then return end
|
||||
|
||||
self:check_particlespawners(dtime)
|
||||
self:check_item_pickup()
|
||||
|
||||
if self:env_damage (dtime, pos) then return end
|
||||
if self:do_states(dtime) then return end
|
||||
|
||||
if self.opinion_sound_cooloff > 0 then
|
||||
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
|
||||
@ -425,9 +430,10 @@ function mob_class:on_step(dtime)
|
||||
self:mob_sound("random", true)
|
||||
end
|
||||
|
||||
if self:env_damage (dtime, pos) then return end
|
||||
if self:do_states(dtime) then return end
|
||||
|
||||
if mobs_debug then self:update_tag() end
|
||||
|
||||
if not self.object:get_luaentity() then
|
||||
return false
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
|
||||
local math, tonumber, vector, minetest, mcl_mobs = math, tonumber, vector, minetest, mcl_mobs
|
||||
local mob_class = mcl_mobs.mob_class
|
||||
local active_particlespawners = {}
|
||||
local disable_blood = minetest.settings:get_bool("mobs_disable_blood")
|
||||
@ -8,6 +8,15 @@ local player_transfer_distance = tonumber(minetest.settings:get("player_transfer
|
||||
if player_transfer_distance == 0 then player_transfer_distance = math.huge end
|
||||
|
||||
|
||||
local function validate_vector (vect)
|
||||
if vect then
|
||||
if tonumber(vect.x) and tonumber(vect.y) and tonumber(vect.z) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- custom particle effects
|
||||
function mcl_mobs.effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, go_down)
|
||||
|
||||
@ -385,6 +394,8 @@ function mob_class:check_head_swivel(dtime)
|
||||
mcl_util.set_bone_position(self.object,self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), final_rotation)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function mob_class:set_animation_speed()
|
||||
local v = self.object:get_velocity()
|
||||
if v then
|
||||
@ -400,7 +411,7 @@ function mob_class:set_animation_speed()
|
||||
end
|
||||
end
|
||||
--set_speed
|
||||
if self.acc then
|
||||
if validate_vector(self.acc) then
|
||||
self.object:add_velocity(self.acc)
|
||||
end
|
||||
end
|
||||
|
@ -239,9 +239,15 @@ function mob_class:is_at_water_danger()
|
||||
return false
|
||||
end
|
||||
local yaw = self.object:get_yaw()
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
if not yaw or not pos then
|
||||
return
|
||||
end
|
||||
|
||||
local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)
|
||||
local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
local ypos = pos.y + self.collisionbox[2] -- just above floor
|
||||
|
||||
local free_fall, blocker = minetest.line_of_sight(
|
||||
|
@ -311,6 +311,8 @@ end
|
||||
function mob_class:set_yaw(yaw, delay, dtime)
|
||||
if self.noyaw then return end
|
||||
|
||||
if not self.object:get_yaw() or not self.object:get_pos() then return end
|
||||
|
||||
if self.state ~= PATHFINDING then
|
||||
self._turn_to = yaw
|
||||
end
|
||||
@ -462,6 +464,14 @@ function mob_class:check_for_death(cause, cmi_cause)
|
||||
self:mob_sound("death")
|
||||
|
||||
local function death_handle(self)
|
||||
if cmi_cause and cmi_cause["type"] then
|
||||
--minetest.log("cmi_cause: " .. tostring(cmi_cause["type"]))
|
||||
end
|
||||
--minetest.log("cause: " .. tostring(cause))
|
||||
|
||||
-- TODO other env damage shouldn't drop xp
|
||||
-- "rain", "water", "drowning", "suffocation"
|
||||
|
||||
-- dropped cooked item if mob died in fire or lava
|
||||
if cause == "lava" or cause == "fire" then
|
||||
self:item_drop(true, 0)
|
||||
@ -800,7 +810,7 @@ function mob_class:do_env_damage()
|
||||
self.suffocation_timer = 0
|
||||
end
|
||||
|
||||
return self:check_for_death("", {type = "unknown"})
|
||||
return self:check_for_death("unknown", {type = "unknown"})
|
||||
end
|
||||
|
||||
function mob_class:env_damage (dtime, pos)
|
||||
|
Loading…
Reference in New Issue
Block a user