changed API to recognise sitting order, added animations for sitting and idle, dog will no longer walk around while in sit mode

This commit is contained in:
Sumyjkl 2022-07-20 18:09:15 +10:00 committed by cora
parent c60002b18d
commit 3852c0297f
3 changed files with 21 additions and 8 deletions

View File

@ -248,7 +248,7 @@ local set_velocity = function(self, v)
end
-- halt mob if it has been ordered to stay
if self.order == "stand" then
if self.order == "stand" or self.order == "sit" then
self.object:set_velocity({x = 0, y = 0, z = 0})
return
end
@ -2392,9 +2392,13 @@ local do_states = function(self, dtime)
yaw = set_yaw(self, yaw, 8)
end
set_velocity(self, 0)
set_animation(self, "stand")
if self.order == "sit" then
set_animation(self, "sit")
set_velocity(self, 0)
else
set_animation(self, "stand")
set_velocity(self, 0)
end
-- npc's ordered to stand stay standing
if self.type ~= "npc"

View File

@ -66,6 +66,9 @@ local wolf = {
ent = dog:get_luaentity()
ent.owner = clicker:get_player_name()
ent.tamed = true
mcl_mobs:set_animation(ent, "sit")
ent.walk_chance = 0
ent.jump = false
-- cornfirm taming
minetest.sound_play("mobs_mc_wolf_bark", {object=dog, max_hear_distance=16}, true)
-- Replace wolf
@ -75,9 +78,10 @@ local wolf = {
end,
animation = {
speed_normal = 50, speed_run = 100,
stand_start = 40, stand_end = 45,
walk_start = 0, walk_end = 40,
run_start = 0, run_end = 40,
stand_start = 0, stand_end = 40,
walk_start = 40, walk_end = 80,
run_start = 80, run_end = 120,
sit_start = 121, sit_end = 140,
},
jump = true,
attacks_monsters = true,
@ -128,7 +132,8 @@ dog.hp_max = 20
dog.textures = get_dog_textures("unicolor_red")
dog.owner = ""
-- TODO: Start sitting by default
dog.order = "roam"
dog.order = "sit"
dog.state = "stand"
dog.owner_loyal = true
dog.follow_velocity = 3.2
-- Automatically teleport dog to owner
@ -190,14 +195,18 @@ dog.on_rightclick = function(self, clicker)
if not self.order or self.order == "" or self.order == "sit" then
particle = "mobs_mc_wolf_icon_roam.png"
self.order = "roam"
self.state = "stand"
self.walk_chance = default_walk_chance
self.jump = true
mcl_mobs:set_animation(self, "stand")
-- TODO: Add sitting model
else
particle = "mobs_mc_wolf_icon_sit.png"
self.order = "sit"
self.state = "stand"
self.walk_chance = 0
self.jump = false
mcl_mobs:set_animation(self, "sit")
end
-- Display icon to show current order (sit or roam)
minetest.add_particle({