Fix hungry sheep and hyrdophobic passive mobs

This commit is contained in:
ancientmarinerdev 2023-02-11 00:37:16 +00:00
parent 6a34a30941
commit 2fd7f8c69f
4 changed files with 53 additions and 66 deletions

View file

@ -317,7 +317,7 @@ local function update_timers (self, dtime)
return true return true
end end
-- attack timer -- attack timer. Not anymore, it seems. Used for also occassionally processing mob step too!
self.timer = self.timer + dtime self.timer = self.timer + dtime
if self.state ~= "attack" and self.state ~= PATHFINDING then if self.state ~= "attack" and self.state ~= PATHFINDING then
@ -392,7 +392,6 @@ function mob_class:on_step(dtime)
self:check_water_flow() self:check_water_flow()
self:env_danger_movement_checks (dtime) self:env_danger_movement_checks (dtime)
self:follow_flop() -- Mob following code. self:follow_flop() -- Mob following code.
self:set_animation_speed() -- set animation speed relative to velocity self:set_animation_speed() -- set animation speed relative to velocity
@ -408,29 +407,37 @@ function mob_class:on_step(dtime)
self:npc_attack() self:npc_attack()
self:check_aggro(dtime) self:check_aggro(dtime)
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 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) -- In certain circumstances, we abandon processing of certain functionality
local skip_processing = false
if self:env_damage (dtime, pos) then return end if update_timers(self, dtime) then
if self:do_states(dtime) then return end skip_processing = true
if self.opinion_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
end
-- mob plays random sound at times. Should be 120. Zombie and mob farms are ridiculous
if math.random(1, 70) == 1 then
self:mob_sound("random", true)
end end
if self:do_states(dtime) then return end
if not skip_processing then
self:check_breeding()
self:check_item_pickup()
self:set_armor_texture()
self:check_particlespawners(dtime)
if self.opinion_sound_cooloff > 0 then
self.opinion_sound_cooloff = self.opinion_sound_cooloff - dtime
end
-- mob plays random sound at times. Should be 120. Zombie and mob farms are ridiculous
if math.random(1, 70) == 1 then
self:mob_sound("random", true)
end
if self:do_states(dtime) then return end
end
if mobs_debug then self:update_tag() end if mobs_debug then self:update_tag() end

View file

@ -1,9 +1,9 @@
local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs local math, vector, minetest, mcl_mobs = math, vector, minetest, mcl_mobs
local mob_class = mcl_mobs.mob_class local mob_class = mcl_mobs.mob_class
local HORNY_TIME = 30*20 local HORNY_TIME = 30
local HORNY_AGAIN_TIME = 30*20 -- was 300 or 15*20 local HORNY_AGAIN_TIME = 30 -- was 300 or 15*20
local CHILD_GROW_TIME = 60*20 local CHILD_GROW_TIME = 60
local LOGGING_ON = minetest.settings:get_bool("mcl_logging_mobs_villager",false) local LOGGING_ON = minetest.settings:get_bool("mcl_logging_mobs_villager",false)

View file

@ -460,7 +460,7 @@ end
-- find and replace what mob is looking for (grass, wheat etc.) -- find and replace what mob is looking for (grass, wheat etc.)
function mob_class:replace(pos) function mob_class:replace_node(pos)
if not self.replace_rate if not self.replace_rate
or not self.replace_what or not self.replace_what

View file

@ -659,7 +659,6 @@ function mob_class:do_env_damage()
-- rain -- rain
if self.rain_damage > 0 then if self.rain_damage > 0 then
if mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then if mcl_weather.rain.raining and mcl_weather.is_outdoor(pos) then
self.health = self.health - self.rain_damage self.health = self.health - self.rain_damage
if self:check_for_death("rain", {type = "environment", if self:check_for_death("rain", {type = "environment",
@ -672,13 +671,9 @@ function mob_class:do_env_damage()
pos.y = pos.y + 1 -- for particle effect position pos.y = pos.y + 1 -- for particle effect position
-- water damage -- water damage
if self.water_damage > 0 if self.water_damage > 0 and nodef.groups.water then
and nodef.groups.water then
if self.water_damage ~= 0 then if self.water_damage ~= 0 then
self.health = self.health - self.water_damage self.health = self.health - self.water_damage
mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil) mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png", nil, nil, 1, nil)
if self:check_for_death("water", {type = "environment", if self:check_for_death("water", {type = "environment",
@ -686,27 +681,10 @@ function mob_class:do_env_damage()
return true return true
end end
end end
-- magma damage elseif self.lava_damage > 0 and (nodef.groups.lava) then
elseif self.fire_damage > 0 -- lava damage
and (nodef2.groups.fire) then
if self.fire_damage ~= 0 then
self.health = self.health - self.fire_damage
if self:check_for_death("fire", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end
-- lava damage
elseif self.lava_damage > 0
and (nodef.groups.lava) then
if self.lava_damage ~= 0 then if self.lava_damage ~= 0 then
self.health = self.health - self.lava_damage self.health = self.health - self.lava_damage
mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil)
mcl_burning.set_on_fire(self.object, 10) mcl_burning.set_on_fire(self.object, 10)
@ -715,15 +693,20 @@ function mob_class:do_env_damage()
return true return true
end end
end end
elseif self.fire_damage > 0 and (nodef2.groups.fire) then
-- fire damage -- magma damage
elseif self.fire_damage > 0
and (nodef.groups.fire) then
if self.fire_damage ~= 0 then if self.fire_damage ~= 0 then
self.health = self.health - self.fire_damage self.health = self.health - self.fire_damage
if self:check_for_death("fire", {type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end
elseif self.fire_damage > 0 and (nodef.groups.fire) then
-- fire damage
if self.fire_damage ~= 0 then
self.health = self.health - self.fire_damage
mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil) mcl_mobs.effect(pos, 5, "fire_basic_flame.png", nil, nil, 1, nil)
mcl_burning.set_on_fire(self.object, 5) mcl_burning.set_on_fire(self.object, 5)
@ -732,12 +715,9 @@ function mob_class:do_env_damage()
return true return true
end end
end end
-- damage_per_second node check
elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then elseif nodef.damage_per_second ~= 0 and not nodef.groups.lava and not nodef.groups.fire then
-- damage_per_second node check
self.health = self.health - nodef.damage_per_second self.health = self.health - nodef.damage_per_second
mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png") mcl_mobs.effect(pos, 5, "mcl_particles_smoke.png")
if self:check_for_death("dps", {type = "environment", if self:check_for_death("dps", {type = "environment",
@ -749,6 +729,7 @@ function mob_class:do_env_damage()
-- Drowning damage -- Drowning damage
if self.breath_max ~= -1 then if self.breath_max ~= -1 then
local drowning = false local drowning = false
if self.breathes_in_water then if self.breathes_in_water then
if minetest.get_item_group(self.standing_in, "water") == 0 then if minetest.get_item_group(self.standing_in, "water") == 0 then
drowning = true drowning = true
@ -756,10 +737,9 @@ function mob_class:do_env_damage()
elseif nodef.drowning > 0 then elseif nodef.drowning > 0 then
drowning = true drowning = true
end end
if drowning then if drowning then
self.breath = math.max(0, self.breath - 1) self.breath = math.max(0, self.breath - 1)
mcl_mobs.effect(pos, 2, "bubble.png", nil, nil, 1, nil) mcl_mobs.effect(pos, 2, "bubble.png", nil, nil, 1, nil)
if self.breath <= 0 then if self.breath <= 0 then
local dmg local dmg
@ -817,18 +797,18 @@ function mob_class:env_damage (dtime, pos)
-- environmental damage timer (every 1 second) -- environmental damage timer (every 1 second)
self.env_damage_timer = self.env_damage_timer + dtime self.env_damage_timer = self.env_damage_timer + dtime
if (self.state == "attack" and self.env_damage_timer > 1)
or self.state ~= "attack" then if self.env_damage_timer > 1 then
self:check_entity_cramming()
self.env_damage_timer = 0 self.env_damage_timer = 0
self:check_entity_cramming()
-- check for environmental damage (water, fire, lava etc.) -- check for environmental damage (water, fire, lava etc.)
if self:do_env_damage() then if self:do_env_damage() then
return true return true
end end
-- node replace check (cow eats grass etc.) self:replace_node(pos) -- (sheep eats grass etc.)
self:replace(pos)
end end
end end