Quieter Cats, More polished movement
This commit is contained in:
parent
66f9b36b75
commit
72d66f7f64
50
api/api.lua
50
api/api.lua
@ -1,12 +1,14 @@
|
||||
-------------
|
||||
---- API ----
|
||||
-------------
|
||||
-- Ver 0.1 --
|
||||
-- Ver 0.2 --
|
||||
|
||||
local hitbox = mob_core.get_hitbox
|
||||
|
||||
local find_string = mob_core.find_val
|
||||
|
||||
local creative = minetest.settings:get_bool("creative_mode")
|
||||
|
||||
----------
|
||||
-- Math --
|
||||
----------
|
||||
@ -23,13 +25,13 @@ end
|
||||
local function round(x) -- Round to nearest multiple of 0.5
|
||||
return x + 0.5 - (x + 0.5) % 1
|
||||
end
|
||||
|
||||
local function clamp(num, min, max)
|
||||
if num < min then
|
||||
num = min
|
||||
elseif num > max then
|
||||
num = max
|
||||
end
|
||||
|
||||
return num
|
||||
end
|
||||
|
||||
@ -86,6 +88,10 @@ end
|
||||
|
||||
local is_movable = mob_core.is_moveable
|
||||
|
||||
local function walkable(pos)
|
||||
return minetest.registered_nodes[minetest.get_node(pos).name].walkable
|
||||
end
|
||||
|
||||
-------------------
|
||||
-- API Functions --
|
||||
-------------------
|
||||
@ -199,7 +205,7 @@ function animalia.feed_tame(self, clicker, feed_count, tame, breed)
|
||||
local pos = self.object:get_pos()
|
||||
local mob_name = mob_core.get_name_proper(self.name)
|
||||
if mob_core.follow_holding(self, clicker) then
|
||||
if creative == false then
|
||||
if not creative then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
@ -582,8 +588,7 @@ end
|
||||
|
||||
local function is_under_solid(pos)
|
||||
local pos2 = vector.new(pos.x, pos.y + 1, pos.z)
|
||||
local def = minetest.registered_nodes[minetest.get_node(pos2).name]
|
||||
return (def.walkable or ((mobkit.get_node_height(pos2) or 0) < 1.5))
|
||||
return (walkable(pos2) or ((mobkit.get_node_height(pos2) or 0) < 1.5))
|
||||
end
|
||||
|
||||
local function vec_center(vec)
|
||||
@ -598,21 +603,28 @@ local function do_step(self, moveresult)
|
||||
local width = hitbox(self)[4] - 0.1
|
||||
if not self._step then
|
||||
for _, data in ipairs(moveresult.collisions) do
|
||||
if data.type == "node"
|
||||
and data.node_pos.y + 0.5 > pos.y
|
||||
and not is_under_solid(data.node_pos)
|
||||
and not vector.equals(vec_center(pos), vec_center(data.node_pos)) then
|
||||
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) < 1.6 then
|
||||
self._step = data.node_pos
|
||||
break
|
||||
if data.type == "node" then
|
||||
local step_pos = data.node_pos
|
||||
local halfway = vector.add(pos, vector.multiply(vector.direction(pos, step_pos), 0.5))
|
||||
if step_pos.y + 0.5 > pos.y
|
||||
and is_movable({x = halfway.x, y = data.node_pos.y + 1, z = halfway.z}, width, self.height)
|
||||
and not is_under_solid(data.node_pos)
|
||||
and walkable({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
and not vector.equals(vec_center(pos), vec_center(data.node_pos)) then
|
||||
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
|
||||
else
|
||||
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
|
||||
self.object:set_velocity(vector.new(vel.x, 0.5, vel.z))
|
||||
self._step = nil
|
||||
@ -1304,8 +1316,12 @@ function animalia.hq_mount_logic(self, prty)
|
||||
if self.isinliquid then
|
||||
tvel = tvel * 0.4
|
||||
vel.y = vel.y * 0.4
|
||||
elseif jumping then
|
||||
tvel = tvel * 0.4
|
||||
else
|
||||
if jumping then
|
||||
tvel = tvel * 0.4
|
||||
else
|
||||
tvel = tvel * 0.6
|
||||
end
|
||||
end
|
||||
end
|
||||
if tvel > 0 then
|
||||
|
@ -165,14 +165,14 @@ minetest.register_craftitem("animalia:poultry_raw", {
|
||||
description = "Raw Poultry",
|
||||
inventory_image = "animalia_poultry_raw.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("animalia:poultry_cooked", {
|
||||
description = "Cooked Poultry",
|
||||
inventory_image = "animalia_poultry_cooked.png",
|
||||
on_use = minetest.item_eat(6),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -227,14 +227,14 @@ minetest.register_craftitem("animalia:beef_raw", {
|
||||
description = "Raw Beef",
|
||||
inventory_image = "animalia_beef_raw.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("animalia:beef_cooked", {
|
||||
description = "Steak",
|
||||
inventory_image = "animalia_beef_cooked.png",
|
||||
on_use = minetest.item_eat(8),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -245,6 +245,10 @@ animalia.register_mob("horse", {
|
||||
self.object:set_properties({
|
||||
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,
|
||||
on_rightclick = function(self, clicker)
|
||||
|
@ -145,14 +145,14 @@ minetest.register_craftitem("animalia:porkchop_raw", {
|
||||
description = "Raw Porkchop",
|
||||
inventory_image = "animalia_porkchop_raw.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("animalia:porkchop_cooked", {
|
||||
description = "Cooked Porkchop",
|
||||
inventory_image = "animalia_porkchop_cooked.png",
|
||||
on_use = minetest.item_eat(7),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -265,14 +265,14 @@ minetest.register_craftitem("animalia:mutton_raw", {
|
||||
description = "Raw Mutton",
|
||||
inventory_image = "animalia_mutton_raw.png",
|
||||
on_use = minetest.item_eat(1),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("animalia:mutton_cooked", {
|
||||
description = "Cooked Mutton",
|
||||
inventory_image = "animalia_mutton_cooked.png",
|
||||
on_use = minetest.item_eat(6),
|
||||
groups = {flammable = 2},
|
||||
groups = {flammable = 2, meat = 1},
|
||||
})
|
||||
|
||||
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 |
Loading…
x
Reference in New Issue
Block a user