unggoy.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. defense.mobs.register_mob("defense:unggoy", {
  2. hp_max = 11,
  3. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.3, 0.4},
  4. mesh = "defense_unggoy.b3d",
  5. textures = {"defense_unggoy.png"},
  6. makes_footstep_sound = true,
  7. animation = {
  8. idle = {a=0, b=39, rate=30},
  9. jump = {a=40, b=49, rate=15},
  10. fall = {a=50, b=64, rate=20},
  11. attack = {a=65, b=72, rate=15},
  12. move = {a=75, b=99, rate=40},
  13. move_attack = {a=100, b=113, rate=20},
  14. },
  15. smart_path = true,
  16. smart_path_for = 0, --initializing to 0 >= 0 means it's going to switch on and off
  17. mass = 4,
  18. move_speed = 5,
  19. jump_height = 2,
  20. armor = 0,
  21. attack_damage = 1,
  22. attack_range = 1.5,
  23. attack_interval = 0.6,
  24. wander = false,
  25. on_activate = function(self, staticdata)
  26. defense.mobs.default_prototype.on_activate(self, staticdata)
  27. -- Some monkeys can jump higher
  28. if math.random() < 0.1 then
  29. self.jump_height = self.jump_height + math.random() * 2
  30. end
  31. end,
  32. on_step = function(self, dtime)
  33. defense.mobs.default_prototype.on_step(self, dtime)
  34. if self.wander
  35. then
  36. local g = vector.add(
  37. self.object:get_pos(),
  38. {x = math.random(-12, 12) + 4, y = 0, z = math.random(-12, 12) + 4}
  39. )
  40. local node = minetest.get_node_or_nil(g)
  41. node = minetest.registered_nodes[node] or {walkable = true}
  42. if not node.walkable
  43. then
  44. self.destination = g
  45. end
  46. self.wander = false
  47. elseif math.random() < 0.006
  48. then
  49. self.wander = true
  50. end
  51. self:hunt()
  52. end,
  53. is_standing = function(self)
  54. -- Able to stand on top of others
  55. if defense.mobs.default_prototype.is_standing(self) then
  56. return true
  57. else
  58. local vel = self.object:getvelocity()
  59. if math.abs(vel.y) > 0.2 then
  60. return false
  61. end
  62. local pos = self.object:get_pos()
  63. pos.y = pos.y - 1
  64. for _,o in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
  65. if o ~= self.object then
  66. local e = o:get_luaentity()
  67. if e and e.name == self.name then
  68. return true
  69. end
  70. end
  71. end
  72. return false
  73. end
  74. end,
  75. })