Quieter Cats, More polished movement

This commit is contained in:
ElCeejo 2021-08-22 01:41:36 -07:00
parent 66f9b36b75
commit 72d66f7f64
11 changed files with 45 additions and 25 deletions

View File

@ -1,12 +1,14 @@
------------- -------------
---- API ---- ---- API ----
------------- -------------
-- Ver 0.1 -- -- Ver 0.2 --
local hitbox = mob_core.get_hitbox local hitbox = mob_core.get_hitbox
local find_string = mob_core.find_val local find_string = mob_core.find_val
local creative = minetest.settings:get_bool("creative_mode")
---------- ----------
-- Math -- -- Math --
---------- ----------
@ -23,13 +25,13 @@ end
local function round(x) -- Round to nearest multiple of 0.5 local function round(x) -- Round to nearest multiple of 0.5
return x + 0.5 - (x + 0.5) % 1 return x + 0.5 - (x + 0.5) % 1
end end
local function clamp(num, min, max) local function clamp(num, min, max)
if num < min then if num < min then
num = min num = min
elseif num > max then elseif num > max then
num = max num = max
end end
return num return num
end end
@ -86,6 +88,10 @@ end
local is_movable = mob_core.is_moveable local is_movable = mob_core.is_moveable
local function walkable(pos)
return minetest.registered_nodes[minetest.get_node(pos).name].walkable
end
------------------- -------------------
-- API Functions -- -- API Functions --
------------------- -------------------
@ -199,7 +205,7 @@ function animalia.feed_tame(self, clicker, feed_count, tame, breed)
local pos = self.object:get_pos() local pos = self.object:get_pos()
local mob_name = mob_core.get_name_proper(self.name) local mob_name = mob_core.get_name_proper(self.name)
if mob_core.follow_holding(self, clicker) then if mob_core.follow_holding(self, clicker) then
if creative == false then if not creative then
item:take_item() item:take_item()
clicker:set_wielded_item(item) clicker:set_wielded_item(item)
end end
@ -582,8 +588,7 @@ end
local function is_under_solid(pos) local function is_under_solid(pos)
local pos2 = vector.new(pos.x, pos.y + 1, pos.z) local pos2 = vector.new(pos.x, pos.y + 1, pos.z)
local def = minetest.registered_nodes[minetest.get_node(pos2).name] return (walkable(pos2) or ((mobkit.get_node_height(pos2) or 0) < 1.5))
return (def.walkable or ((mobkit.get_node_height(pos2) or 0) < 1.5))
end end
local function vec_center(vec) local function vec_center(vec)
@ -598,21 +603,28 @@ local function do_step(self, moveresult)
local width = hitbox(self)[4] - 0.1 local width = hitbox(self)[4] - 0.1
if not self._step then if not self._step then
for _, data in ipairs(moveresult.collisions) do for _, data in ipairs(moveresult.collisions) do
if data.type == "node" if data.type == "node" then
and data.node_pos.y + 0.5 > pos.y local step_pos = data.node_pos
and not is_under_solid(data.node_pos) local halfway = vector.add(pos, vector.multiply(vector.direction(pos, step_pos), 0.5))
and not vector.equals(vec_center(pos), vec_center(data.node_pos)) then if step_pos.y + 0.5 > pos.y
local vel_yaw = self.object:get_yaw() and is_movable({x = halfway.x, y = data.node_pos.y + 1, z = halfway.z}, width, self.height)
local dir_yaw = minetest.dir_to_yaw(vector.direction(pos, data.node_pos)) and not is_under_solid(data.node_pos)
if diff(vel_yaw, dir_yaw) < 1.6 then and walkable({x = pos.x, y = pos.y - 1, z = pos.z})
self._step = data.node_pos and not vector.equals(vec_center(pos), vec_center(data.node_pos)) then
break local vel_yaw = self.object:get_yaw()
local dir_yaw = minetest.dir_to_yaw(vector.direction(pos, data.node_pos))
if diff(vel_yaw, dir_yaw) < width * 2 then
self._step = data.node_pos
break
end
else
self._step = nil
end end
end end
end end
else else
local vel = self.object:get_velocity() local vel = self.object:get_velocity()
self.object:set_velocity(vector.new(vel.x, 4, vel.z)) self.object:set_velocity(vector.new(vel.x, 7, vel.z))
if self._step.y < pos.y - 0.5 then if self._step.y < pos.y - 0.5 then
self.object:set_velocity(vector.new(vel.x, 0.5, vel.z)) self.object:set_velocity(vector.new(vel.x, 0.5, vel.z))
self._step = nil self._step = nil
@ -1304,8 +1316,12 @@ function animalia.hq_mount_logic(self, prty)
if self.isinliquid then if self.isinliquid then
tvel = tvel * 0.4 tvel = tvel * 0.4
vel.y = vel.y * 0.4 vel.y = vel.y * 0.4
elseif jumping then else
tvel = tvel * 0.4 if jumping then
tvel = tvel * 0.4
else
tvel = tvel * 0.6
end
end end
end end
if tvel > 0 then if tvel > 0 then

View File

@ -165,14 +165,14 @@ minetest.register_craftitem("animalia:poultry_raw", {
description = "Raw Poultry", description = "Raw Poultry",
inventory_image = "animalia_poultry_raw.png", inventory_image = "animalia_poultry_raw.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craftitem("animalia:poultry_cooked", { minetest.register_craftitem("animalia:poultry_cooked", {
description = "Cooked Poultry", description = "Cooked Poultry",
inventory_image = "animalia_poultry_cooked.png", inventory_image = "animalia_poultry_cooked.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -227,14 +227,14 @@ minetest.register_craftitem("animalia:beef_raw", {
description = "Raw Beef", description = "Raw Beef",
inventory_image = "animalia_beef_raw.png", inventory_image = "animalia_beef_raw.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craftitem("animalia:beef_cooked", { minetest.register_craftitem("animalia:beef_cooked", {
description = "Steak", description = "Steak",
inventory_image = "animalia_beef_cooked.png", inventory_image = "animalia_beef_cooked.png",
on_use = minetest.item_eat(8), on_use = minetest.item_eat(8),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -245,6 +245,10 @@ animalia.register_mob("horse", {
self.object:set_properties({ self.object:set_properties({
textures = {texture .. "^animalia_horse_saddle.png"} textures = {texture .. "^animalia_horse_saddle.png"}
}) })
self.drops = {
{name = "animalia:leather", chance = 2, min = 1, max = 4},
{name = "animalia:saddle", chance = 1, min = 1, max = 1}
}
end end
end, end,
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)

View File

@ -145,14 +145,14 @@ minetest.register_craftitem("animalia:porkchop_raw", {
description = "Raw Porkchop", description = "Raw Porkchop",
inventory_image = "animalia_porkchop_raw.png", inventory_image = "animalia_porkchop_raw.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craftitem("animalia:porkchop_cooked", { minetest.register_craftitem("animalia:porkchop_cooked", {
description = "Cooked Porkchop", description = "Cooked Porkchop",
inventory_image = "animalia_porkchop_cooked.png", inventory_image = "animalia_porkchop_cooked.png",
on_use = minetest.item_eat(7), on_use = minetest.item_eat(7),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -265,14 +265,14 @@ minetest.register_craftitem("animalia:mutton_raw", {
description = "Raw Mutton", description = "Raw Mutton",
inventory_image = "animalia_mutton_raw.png", inventory_image = "animalia_mutton_raw.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craftitem("animalia:mutton_cooked", { minetest.register_craftitem("animalia:mutton_cooked", {
description = "Cooked Mutton", description = "Cooked Mutton",
inventory_image = "animalia_mutton_cooked.png", inventory_image = "animalia_mutton_cooked.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = {flammable = 2}, groups = {flammable = 2, meat = 1},
}) })
minetest.register_craft({ minetest.register_craft({

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB