poisonous.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. mobs:register_mob("tmw_slimes:poisonous_slime", {
  2. group_attack = true,
  3. type = "monster",
  4. passive = false,
  5. attack_animals = true,
  6. attack_npcs = true,
  7. attack_monsters = false,
  8. attack_type = "dogfight",
  9. reach = 2,
  10. sounds = {random = "steps_in_the_mud_shorter",},
  11. damage = tmw_slimes.medium_dmg,
  12. hp_min = 20,
  13. hp_max = 40,
  14. armor = 180,
  15. collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.4, 0.2},
  16. visual_size = {x = 2, y = 2},
  17. visual = "mesh",
  18. mesh = "slime_land.b3d",
  19. blood_texture = "tmw_slime_goo.png^[colorize:"..tmw_slimes.colors["poisonous"],
  20. textures = {
  21. {"tmw_slime_goo_block.png^[colorize:"..tmw_slimes.colors["poisonous"],"tmw_slime_goo_block.png^[colorize:"..tmw_slimes.colors["poisonous"],"tmw_slime_goo_block.png^[colorize:"..tmw_slimes.colors["poisonous"]},
  22. },
  23. makes_footstep_sound = false,
  24. walk_velocity = 0.5,
  25. run_velocity = 1.8,
  26. jump_height = 7,
  27. jump = true,
  28. view_range = 15,
  29. drops = {
  30. {name = "tmw_slimes:poisonous_goo", chance = 1, min = 0, max = 2},
  31. },
  32. water_damage = 0,
  33. lava_damage = 8,
  34. light_damage = 0,
  35. animation = {
  36. idle_start = 0,
  37. idle_end = 20,
  38. move_start = 21,
  39. move_end = 41,
  40. fall_start = 42,
  41. fall_end = 62,
  42. jump_start = 63,
  43. jump_end = 83
  44. },
  45. do_custom = function(self)
  46. --tmw_slimes.animate(self)
  47. tmw_slimes.absorb_nearby_items(self)
  48. end,
  49. on_die = function(self, pos)
  50. tmw_slimes.drop_items(self, pos)
  51. end
  52. })
  53. minetest.override_item("tmw_slimes:poisonous_goo", {on_use = function(item, player, ...)
  54. minetest.item_eat(1)(item, player,...)
  55. tmw_slimes.poisoned_players[player:get_player_name()] = 6
  56. end})
  57. tmw_slimes.poisoned_players = {}
  58. minetest.register_on_punchplayer(function(player, hitter)
  59. if not hitter then return end
  60. local e = hitter:get_luaentity()
  61. if e and e.name == "tmw_slimes:poisonous_slime" and math.random() >= 0.67 then
  62. tmw_slimes.poisoned_players[player:get_player_name()] = math.random(3, 8)
  63. end
  64. end)
  65. minetest.register_globalstep(function(dt)
  66. for name, time in pairs(tmw_slimes.poisoned_players) do
  67. if time < dt then
  68. local player = minetest.get_player_by_name(name)
  69. if player then player:set_hp(0) end
  70. tmw_slimes.poisoned_players[name] = nil
  71. else
  72. tmw_slimes.poisoned_players[name] = time - dt
  73. end
  74. end
  75. end)
  76. minetest.register_on_leaveplayer(function(player)
  77. if tmw_slimes.poisoned_players[player:get_player_name()] then
  78. player:set_hp(0) -- You are NOT getting away.
  79. end
  80. tmw_slimes.poisoned_players[player:get_player_name()] = nil
  81. end)
  82. minetest.register_on_dieplayer(function(player)
  83. tmw_slimes.poisoned_players[player:get_player_name()] = nil
  84. end)
  85. local g = table.copy(minetest.registered_nodes["tmw_slimes:poisonous_goo_block"].groups)
  86. g.harmful_slime = tmw_slimes.medium_dmg
  87. minetest.override_item("tmw_slimes:poisonous_goo_block", {groups=table.copy(g)})
  88. mobs:spawn({
  89. name = "tmw_slimes:poisonous_slime",
  90. nodes = {
  91. "default:dirt_with_rainforest_litter",
  92. "ethereal:mesa_dirt",
  93. },
  94. min_light = 0,
  95. max_light = 16,
  96. chance = tmw_slimes.uncommon,
  97. active_object_count = tmw_slimes.uncommon_max,
  98. min_height = -31000,
  99. max_height = 31000,
  100. })