paniki.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. defense_mob_api.register_mob("mob_paniki:paniki", {
  2. hp_max = 7,
  3. collisionbox = {-0.4,-0.4,-0.4, 0.4,0.4,0.4},
  4. mesh = "mob_paniki_paniki.b3d",
  5. textures = {"mob_paniki_paniki.png"},
  6. makes_footstep_sound = false,
  7. animation = {
  8. idle = {a=0, b=29, rate=50},
  9. attack = {a=60, b=89, rate=50},
  10. move = {a=30, b=59, rate=75},
  11. move_attack = {a=60, b=89, rate=75},
  12. },
  13. mass = 1,
  14. movement = "air",
  15. move_speed = 16,
  16. attack_damage = 1,
  17. attack_range = 1.1,
  18. attack_interval = 1.2,
  19. last_hp = 3,
  20. flee_timer = 0,
  21. flee_timer = 0,
  22. on_step = function(self, dtime)
  23. defense_mob_api.default_prototype.on_step(self, dtime)
  24. if self.flee_timer > 0
  25. then
  26. local nearest = self:find_target()
  27. local pos = self.object:get_pos()
  28. local delta = vector.subtract(pos, nearest.player:get_pos())
  29. local x = delta.x
  30. delta.x = delta.x - delta.z * 0.4
  31. delta.z = delta.z + x * 0.4
  32. self.destination = vector.add(pos, delta)
  33. if self.flee_timer > 0 and self.last_attack_time + 0.25 < self.timer
  34. then
  35. self.flee_timer = self.flee_timer - dtime
  36. end
  37. else
  38. self:hunt()
  39. if self.object:get_hp() < self.last_hp
  40. then
  41. self.flee_timer = 0.5 + math.random() / (self.object:get_hp() + 1)
  42. end
  43. self.last_hp = self.object:get_hp()
  44. end
  45. end,
  46. attack = function(self, obj, dir)
  47. defense_mob_api.default_prototype.attack(self, obj)
  48. self.flee_timer = math.random() * 0.5
  49. end,
  50. })
  51. minetest.register_alias("paniki", "mob_paniki:paniki")