sand_monster.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. local S = mobs.intllib
  2. -- custom particle effects
  3. local effect = function(pos, amount, texture, min_size, max_size, radius, gravity, glow)
  4. radius = radius or 2
  5. min_size = min_size or 0.5
  6. max_size = max_size or 1
  7. gravity = gravity or -10
  8. glow = glow or 0
  9. minetest.add_particlespawner({
  10. amount = amount,
  11. time = 0.25,
  12. minpos = pos,
  13. maxpos = pos,
  14. minvel = {x = -radius, y = -radius, z = -radius},
  15. maxvel = {x = radius, y = radius, z = radius},
  16. minacc = {x = 0, y = gravity, z = 0},
  17. maxacc = {x = -20, y = gravity, z = 15},
  18. minexptime = 0.1,
  19. maxexptime = 1,
  20. minsize = min_size,
  21. maxsize = max_size,
  22. texture = texture,
  23. glow = glow,
  24. })
  25. end
  26. -- Sand Monster by PilzAdam
  27. mobs:register_mob("mobs_monster:sand_monster", {
  28. type = "monster",
  29. passive = false,
  30. attack_type = "dogfight",
  31. pathfinding = true,
  32. --specific_attack = {"player", "mobs_npc:npc"},
  33. reach = 2,
  34. damage = 1,
  35. hp_min = 4,
  36. hp_max = 20,
  37. armor = 100,
  38. collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
  39. visual = "mesh",
  40. mesh = "mobs_sand_monster.b3d",
  41. textures = {
  42. {"mobs_sand_monster.png"},
  43. },
  44. blood_texture = "default_desert_sand.png",
  45. makes_footstep_sound = true,
  46. sounds = {
  47. random = "mobs_sandmonster",
  48. },
  49. walk_velocity = 1.5,
  50. run_velocity = 4,
  51. view_range = 8, --15
  52. jump = true,
  53. floats = 0,
  54. drops = {
  55. {name = "default:desert_sand", chance = 1, min = 3, max = 5},
  56. },
  57. water_damage = 3,
  58. lava_damage = 4,
  59. light_damage = 0,
  60. fear_height = 4,
  61. animation = {
  62. speed_normal = 15,
  63. speed_run = 15,
  64. stand_start = 0,
  65. stand_end = 39,
  66. walk_start = 41,
  67. walk_end = 72,
  68. run_start = 74,
  69. run_end = 105,
  70. punch_start = 74,
  71. punch_end = 105,
  72. },
  73. immune_to = {
  74. {"default:shovel_wood", 3}, -- shovels deal more damage to sand monster
  75. {"default:shovel_stone", 3},
  76. {"default:shovel_bronze", 4},
  77. {"default:shovel_steel", 4},
  78. {"default:shovel_mese", 5},
  79. {"default:shovel_diamond", 7},
  80. },
  81. --[[
  82. custom_attack = function(self, p)
  83. local pos = self.object:get_pos()
  84. minetest.add_item(pos, "default:sand")
  85. end,
  86. ]]
  87. on_die = function(self, pos)
  88. pos.y = pos.y + 0.5
  89. effect(pos, 30, "mobs_sand_particles.png", 0.1, 2, 3, 5)
  90. pos.y = pos.y + 0.25
  91. effect(pos, 30, "mobs_sand_particles.png", 0.1, 2, 3, 5)
  92. end,
  93. --[[
  94. on_rightclick = function(self, clicker)
  95. local tool = clicker:get_wielded_item()
  96. local name = clicker:get_player_name()
  97. if tool:get_name() == "default:sand" then
  98. self.owner = name
  99. self.type = "npc"
  100. mobs:force_capture(self, clicker)
  101. end
  102. end,
  103. ]]
  104. })
  105. mobs:spawn({
  106. name = "mobs_monster:sand_monster",
  107. nodes = {"default:desert_sand"},
  108. chance = 7000,
  109. active_object_count = 2,
  110. min_height = 0,
  111. })
  112. mobs:register_egg("mobs_monster:sand_monster", S("Sand Monster"), "default_desert_sand.png", 1)
  113. mobs:alias_mob("mobs:sand_monster", "mobs_monster:sand_monster") -- compatibility