poisonous.lua 2.9 KB

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