Add support for swim and panic animations
This commit is contained in:
parent
04807625ab
commit
15099e9b7f
@ -31,7 +31,7 @@ local function knockback(selfOrObject, dir, old_dir, strengh)
|
|||||||
end
|
end
|
||||||
object:set_properties({automatic_face_movement_dir = false})
|
object:set_properties({automatic_face_movement_dir = false})
|
||||||
object:setvelocity(vector.add(old_dir, {x = dir.x * strengh, y = 3.5, z = dir.z * strengh}))
|
object:setvelocity(vector.add(old_dir, {x = dir.x * strengh, y = 3.5, z = dir.z * strengh}))
|
||||||
old_dir.y = 0---10
|
old_dir.y = 0
|
||||||
core.after(0.4, function()
|
core.after(0.4, function()
|
||||||
object:set_properties({automatic_face_movement_dir = -90.0})
|
object:set_properties({automatic_face_movement_dir = -90.0})
|
||||||
object:setvelocity(old_dir)
|
object:setvelocity(old_dir)
|
||||||
@ -77,16 +77,9 @@ end
|
|||||||
|
|
||||||
local findTarget = creatures.findTarget
|
local findTarget = creatures.findTarget
|
||||||
|
|
||||||
local function update_animation(obj_ref, mode, anim_defs)
|
local function update_animation(obj_ref, mode, anim_def)
|
||||||
local anim = nil
|
if anim_def and obj_ref then
|
||||||
for mn,range in pairs(anim_defs) do
|
obj_ref:set_animation({x = anim_def.start, y = anim_def.stop}, anim_def.speed, 0, anim_def.loop)
|
||||||
if tostring(mn) == mode then
|
|
||||||
anim = range
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if anim and obj_ref then
|
|
||||||
obj_ref:set_animation({x = anim.start, y = anim.stop}, anim.speed, 0, anim.loop)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -560,7 +553,7 @@ creatures.on_step = function(self, dtime)
|
|||||||
if current_pos.y >= (modes["fly"].max_height or 50) and not self.target then
|
if current_pos.y >= (modes["fly"].max_height or 50) and not self.target then
|
||||||
self.dir.y = -0.5
|
self.dir.y = -0.5
|
||||||
else
|
else
|
||||||
self.dir.y = (rnd() - 0.5) --*0.1
|
self.dir.y = (rnd() - 0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -573,7 +566,11 @@ creatures.on_step = function(self, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
update_velocity(me, self.dir, moving_speed)
|
update_velocity(me, self.dir, moving_speed)
|
||||||
update_animation(me, current_mode, def.model.animations)
|
local anim_def = def.model.animations[current_mode]
|
||||||
|
if self.in_water and def.model.animations["swim"] then
|
||||||
|
anim_def = def.model.animations["swim"]
|
||||||
|
end
|
||||||
|
update_animation(me, current_mode, anim_def)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- update yaw
|
-- update yaw
|
||||||
|
@ -58,10 +58,16 @@ local function translate_def(def)
|
|||||||
new.chance = 0
|
new.chance = 0
|
||||||
new.duration = 3
|
new.duration = 3
|
||||||
new.moving_speed = new.moving_speed * 2
|
new.moving_speed = new.moving_speed * 2
|
||||||
|
if def.modes.panic and def.modes.panic.moving_speed then
|
||||||
|
new.moving_speed = def.modes.panic.moving_speed
|
||||||
|
end
|
||||||
new.update_yaw = 0.7
|
new.update_yaw = 0.7
|
||||||
new_def.modes["_run"] = new
|
new_def.modes["_run"] = new
|
||||||
local new_anim = table.copy(def.model.animations.walk)
|
local new_anim = def.model.animations.panic
|
||||||
new_anim.speed = new_anim.speed * 2 --= {start = 81, stop = 100, speed = 15},
|
if not new_anim then
|
||||||
|
new_anim = table.copy(def.model.animations.walk)
|
||||||
|
new_anim.speed = new_anim.speed * 2
|
||||||
|
end
|
||||||
new_def.model.animations._run = new_anim
|
new_def.model.animations._run = new_anim
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user