Overhaul mob collisionboxes and texture mod handling when hurt
This commit is contained in:
parent
e4da0a0c95
commit
96a37cf7d4
@ -101,6 +101,7 @@ mob_register.die_in_light = def.die_in_light
|
||||
mob_register.die_in_light_level = def.die_in_light_level
|
||||
|
||||
mob_register.current_animation = 0
|
||||
mob_register.hurt_color_timer = 0
|
||||
|
||||
mob_register.mob = true
|
||||
|
||||
@ -119,27 +120,19 @@ mob_register.on_step = function(self, dtime)
|
||||
self.custom_function_begin(self,dtime)
|
||||
end
|
||||
|
||||
--self.collision_detection(self)
|
||||
self.collision_detection(self)
|
||||
self.fall_damage(self)
|
||||
|
||||
if self.dead == false and self.death_animation_timer == 0 then
|
||||
--self.move(self,dtime)
|
||||
|
||||
if not self.yaw then self.yaw = 0 end
|
||||
self.yaw = self.yaw + dtime
|
||||
if self.yaw > math.pi then
|
||||
self.yaw = -math.pi
|
||||
end
|
||||
self.object:set_velocity(minetest.yaw_to_dir(self.yaw))
|
||||
self.move(self,dtime)
|
||||
|
||||
self.manage_hurt_color_timer(self,dtime)
|
||||
self.set_animation(self)
|
||||
|
||||
if self.look_around then
|
||||
self.look_around(self,dtime)
|
||||
end
|
||||
|
||||
--print(self.object:get_yaw()-(math.pi/2))
|
||||
|
||||
self.manage_punch_timer(self,dtime)
|
||||
--self.debug_nametag(self,dtime)
|
||||
else
|
||||
|
@ -107,6 +107,9 @@ mobs.create_interaction_functions = function(def,mob_register)
|
||||
|
||||
local hp = hp-hurt
|
||||
|
||||
self.object:set_texture_mod("^[colorize:red:130")
|
||||
self.hurt_color_timer = 0.25
|
||||
|
||||
if (self.punched_timer <= 0 and hp > 1) and not self.dead then
|
||||
if puncher ~= self.object then
|
||||
if self.attacked_hostile then
|
||||
@ -169,8 +172,6 @@ mobs.create_interaction_functions = function(def,mob_register)
|
||||
minetest.sound_play("critical", {object=self.object, gain = 0.1, max_hear_distance = 10,pitch = math.random(80,100)/100})
|
||||
end
|
||||
minetest.sound_play(self.die_sound, {object=self.object, gain = 1.0, max_hear_distance = 10,pitch = math.random(80,100)/100})
|
||||
|
||||
self.object:set_texture_mod("^[colorize:red:130")
|
||||
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
end
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ mobs.create_movement_functions = function(def,mob_register)
|
||||
end
|
||||
end
|
||||
|
||||
local get_group = minetest.get_node_group
|
||||
local get_group = minetest.get_item_group
|
||||
local get_node = minetest.get_node
|
||||
mob_register.hurt_inside = function(self,dtime)
|
||||
if self.hp > 0 and self.hurt_inside_timer <= 0 then
|
||||
|
@ -12,7 +12,7 @@ mobs.create_timer_functions = function(def,mob_register)
|
||||
end
|
||||
|
||||
--this controls the hostile state
|
||||
if def.hostile == false then
|
||||
if def.hostile == true or def.attacked_hostile == true then
|
||||
mob_register.manage_hostile_timer = function(self,dtime)
|
||||
if self.hostile_timer > 0 then
|
||||
self.hostile_timer = self.hostile_timer - dtime
|
||||
@ -23,15 +23,21 @@ mobs.create_timer_functions = function(def,mob_register)
|
||||
end
|
||||
end
|
||||
|
||||
mob_register.manage_hurt_color_timer = function(self,dtime)
|
||||
if self.hurt_color_timer > 0 then
|
||||
self.hurt_color_timer = self.hurt_color_timer - dtime
|
||||
if self.hurt_color_timer <= 0 then
|
||||
self.hurt_color_timer = 0
|
||||
self.object:set_texture_mod("")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mob_register.manage_explode_timer = function(self,dtime)
|
||||
self.tnt_timer = self.tnt_timer - dtime
|
||||
if self.tnt_timer <= 0 and not self.dead then
|
||||
|
||||
self.object:set_texture_mod("^[colorize:red:130")
|
||||
if self.child then
|
||||
self.child:set_texture_mod("^[colorize:red:130")
|
||||
end
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
--direction.y = direction.y + 1
|
||||
|
@ -17,7 +17,7 @@ mobs.register_mob(
|
||||
mobname = "pig",
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.37, 0, -0.37, 0.37, 0.5, 0.37},
|
||||
collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37},
|
||||
visual = "mesh",
|
||||
visual_size = {x = 3, y = 3},
|
||||
mesh = "pig.b3d",
|
||||
@ -79,7 +79,7 @@ mobs.register_mob(
|
||||
mobname = "phyg",
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.37, 0, -0.37, 0.37, 0.5, 0.37},
|
||||
collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37},
|
||||
visual = "mesh",
|
||||
visual_size = {x = 3, y = 3},
|
||||
mesh = "phyg.b3d",
|
||||
@ -354,7 +354,7 @@ mobs.register_mob(
|
||||
mobname = "creeper",
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.37,0, -0.37, 0.37, 0.5, 0.37},
|
||||
collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37},
|
||||
visual = "mesh",
|
||||
visual_size = {x = 3.2, y = 3.2},
|
||||
mesh = "creeper.b3d",
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user