diff --git a/mods/mob/api/api_hook.lua b/mods/mob/api/api_hook.lua index c3634b6..4a79a89 100644 --- a/mods/mob/api/api_hook.lua +++ b/mods/mob/api/api_hook.lua @@ -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 diff --git a/mods/mob/api/interaction.lua b/mods/mob/api/interaction.lua index a5b6ffd..60179fd 100644 --- a/mods/mob/api/interaction.lua +++ b/mods/mob/api/interaction.lua @@ -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 diff --git a/mods/mob/api/movement.lua b/mods/mob/api/movement.lua index 52f9cce..ed06b55 100644 --- a/mods/mob/api/movement.lua +++ b/mods/mob/api/movement.lua @@ -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 diff --git a/mods/mob/api/timers.lua b/mods/mob/api/timers.lua index d9165e0..84ae2da 100644 --- a/mods/mob/api/timers.lua +++ b/mods/mob/api/timers.lua @@ -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 diff --git a/mods/mob/init.lua b/mods/mob/init.lua index afe0f9a..419bfae 100644 --- a/mods/mob/init.lua +++ b/mods/mob/init.lua @@ -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", diff --git a/mods/mob/sounds/creeper_hurt.1.ogg b/mods/mob/sounds/creeper_hurt.1.ogg index 76a7021..ccd697d 100644 Binary files a/mods/mob/sounds/creeper_hurt.1.ogg and b/mods/mob/sounds/creeper_hurt.1.ogg differ diff --git a/mods/mob/sounds/creeper_hurt.2.ogg b/mods/mob/sounds/creeper_hurt.2.ogg index 94f87e9..374e6d0 100644 Binary files a/mods/mob/sounds/creeper_hurt.2.ogg and b/mods/mob/sounds/creeper_hurt.2.ogg differ