1
0
Fork 0

Merge pull request 'Make mobs walk up stairs/slabs properly, yet not glitch out when jumping over solid nodes' (#1650) from jordan4ibanez/MineClone2:mineclone5 into mineclone5

Reviewed-on: MineClone2/MineClone2#1650
This commit is contained in:
jordan4ibanez 2021-04-25 08:04:39 +00:00
commit b4ead73e22
4 changed files with 36 additions and 5 deletions

View File

@ -200,6 +200,7 @@ function mobs:register_mob(name, def)
use_texture_alpha = def.use_texture_alpha, use_texture_alpha = def.use_texture_alpha,
stepheight = def.stepheight or 0.6, stepheight = def.stepheight or 0.6,
stepheight_backup = def.stepheight or 0.6,
name = name, name = name,
type = def.type, type = def.type,
attack_type = def.attack_type, attack_type = def.attack_type,

View File

@ -822,7 +822,7 @@ mobs.mob_step = function(self, dtime)
--DEBUG TIME! --DEBUG TIME!
mobs.do_head_logic(self) --mobs.do_head_logic(self,dtime)
@ -844,6 +844,9 @@ mobs.mob_step = function(self, dtime)
end end
end end
--make it so mobs do not glitch out when walking around/jumping
mobs.swap_auto_step_height_adjust(self)
--color modifier which coincides with the pause_timer --color modifier which coincides with the pause_timer
if self.old_health and self.health < self.old_health then if self.old_health and self.health < self.old_health then
self.object:set_texture_mod("^[colorize:red:120") self.object:set_texture_mod("^[colorize:red:120")

View File

@ -1,8 +1,23 @@
mobs.do_head_logic = function(self) local vector_new = vector.new
local yaw = self.object:get_yaw()
mobs.do_head_logic = function(self,dtime)
--local yaw = self.object:get_yaw()
--local bone_pos = vector_new(0,5,0)
--print(yaw)
--local _, bone_rot = self.object:get_bone_position("head")
--bone_rot.x = bone_rot.x + (dtime * 10)
--bone_rot.z = bone_rot.z + (dtime * 10)
--self.object:set_bone_position("head", bone_pos, bone_rot)
--set_bone_position([bone, position, rotation])
end end

View File

@ -376,4 +376,16 @@ mobs.jump_move = function(self, velocity)
if vector_length(new_velocity_addition) >= 0.0001 then if vector_length(new_velocity_addition) >= 0.0001 then
self.object:add_velocity(new_velocity_addition) self.object:add_velocity(new_velocity_addition)
end end
end
--make it so mobs do not glitch out and freak out
--when moving around over nodes
mobs.swap_auto_step_height_adjust = function(self)
local y_vel = self.object:get_velocity().y
if y_vel == 0 and self.stepheight ~= self.stepheight_backup then
self.stepheight = self.stepheight_backup
elseif y_vel ~= 0 and self.stepheight ~= 0 then
self.stepheight = 0
end
end end