local velocity = vector.multiply(dir,1.1)
- vel1 = vector.multiply(velocity, -1)
- vel2 = velocity
+ local vel1 = vector.multiply(velocity, -1)
+ local vel2 = velocity
self.object:add_velocity(vel1)
if object:is_player() then
end
local hp = hp-hurt
-
- if (self.punched_timer <= 0 and hp > 1) then
+
+ if (self.punched_timer <= 0 and hp > 1) and not self.dead then
+ self.object:set_texture_mod("^[colorize:red:130")
+ self.hurt_color_timer = 0.25
if puncher ~= self.object then
- self.hostile = true
+ self.punched_timer = 0.8
+ if self.attacked_hostile then
+ self.hostile = true
+ self.hostile_timer = 20
+ if self.group_attack == true then
+ for _,object in ipairs(minetest.get_objects_inside_radius(pos, self.view_distance)) do
+ if not object:is_player() and object:get_luaentity() and object:get_luaentity().mobname == self.mobname then
+ object:get_luaentity().hostile = true
+ object:get_luaentity().hostile_timer = 20
+ end
+ end
+ end
+ end
end
- self.hostile_timer = 20
- self.punched_timer = 0.8
--critical effect
if critical == true then
self.object:add_velocity(dir)
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
elseif (self.punched_timer <= 0 and self.death_animation_timer == 0) then
+ self.object:set_texture_mod("^[colorize:red:130")
+ self.hurt_color_timer = 0.25
+ if puncher ~= self.object then
+ self.punched_timer = 0.8
+ if self.attacked_hostile then
+ self.hostile = true
+ self.hostile_timer = 20
+ if self.group_attack == true then
+ for _,object in ipairs(minetest.get_objects_inside_radius(pos, self.view_distance)) do
+ if not object:is_player() and object:get_luaentity() and object:get_luaentity().mobname == self.mobname then
+ object:get_luaentity().hostile = true
+ object:get_luaentity().hostile_timer = 20
+ end
+ end
+ end
+ end
+ end
self.death_animation_timer = 1
self.dead = true
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")
- if self.child then
- self.child:set_texture_mod("^[colorize:red:130")
- end
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
end
end
--this is what happens when a mob dies
mob_register.on_death = function(self, killer)
- local pos = self.object:getpos()
+ local pos = self.object:get_pos()
--pos.y = pos.y + 0.4
minetest.sound_play("mob_die", {pos = pos, gain = 1.0})
minetest.add_particlespawner({
global_mob_amount = global_mob_amount - 1
print("Mobs Died. Current Mobs: "..global_mob_amount)
- if self.child and self.child:get_luaentity() then
- self.child:get_luaentity().parent = nil
- end
self.object:remove()
end
local pos2 = object:get_pos()
pos2.y = pos2.y + 1.625
- player_found = true
+ player_found = false
if self.head_bone then
- self.move_head(self,pos2,dtime)
+ player_found = self.move_head(self,pos2,dtime)
end
if self.hostile == true then
-
- self.direction = vector.direction(pos,pos2)
- local distance = vector.distance(pos,pos2)-2
- if distance < 0 then
- distance = 0
- end
+ local distance = vector.distance(pos,pos2)
--punch the player
if self.attack_type == "punch" then
- if distance < 1 and self.punch_timer <= 0 and object:get_hp() > 0 then
+ if distance < 2.5 and self.punch_timer <= 0 and object:get_hp() > 0 then
local line_of_sight = minetest.line_of_sight(pos, pos2)
if line_of_sight == true then
self.punch_timer = 1
if not self.tnt_timer then
minetest.sound_play("tnt_ignite", {object = self.object, gain = 1.0,})
self.tnt_timer = self.explosion_time
+ self.tnt_tick_timer = 0.2
+ self.tnt_mod_state = 1
self.object:set_texture_mod("^[colorize:white:130")
end
end
end
end
end
- self.speed = distance * 4
- if self.speed > self.max_speed then
- self.speed = self.max_speed
- end
+ self.direction = vector.direction(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z))
+ self.speed = self.max_speed
self.following = true
end
--only look at one player