igor.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. local S = mobs.intllib
  2. -- Igor by TenPlus1
  3. mobs.igor_drops = {
  4. "vessels:glass_bottle", "mobs:meat_raw", "default:sword_steel",
  5. "farming:bread", "bucket:bucket_water"
  6. }
  7. mobs:register_mob("mobs_npc:igor", {
  8. type = "npc",
  9. passive = false,
  10. damage = 5,
  11. attack_type = "dogfight",
  12. owner_loyal = true,
  13. pathfinding = true,
  14. reach = 2,
  15. attacks_monsters = true,
  16. hp_min = 20,
  17. hp_max = 30,
  18. armor = 100,
  19. collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
  20. visual = "mesh",
  21. mesh = "mobs_character.b3d",
  22. textures = {
  23. {"mobs_igor.png"}, -- skin by ruby32199
  24. {"mobs_igor2.png"},
  25. {"mobs_igor3.png"},
  26. {"mobs_igor4.png"},
  27. {"mobs_igor5.png"},
  28. {"mobs_igor6.png"},
  29. {"mobs_igor7.png"},
  30. {"mobs_igor8.png"},
  31. },
  32. makes_footstep_sound = true,
  33. sounds = {},
  34. walk_velocity = 1,
  35. run_velocity = 2,
  36. stepheight = 1.1,
  37. fear_height = 2,
  38. jump = true,
  39. drops = {
  40. {name = "mobs:meat_raw", chance = 1, min = 1, max = 2},
  41. {name = "default:gold_lump", chance = 3, min = 1, max = 1},
  42. },
  43. water_damage = 1,
  44. lava_damage = 3,
  45. light_damage = 0,
  46. follow = {"mobs:meat_raw", "default:diamond"},
  47. view_range = 15,
  48. owner = "",
  49. order = "follow",
  50. -- model animation
  51. animation = {
  52. speed_normal = 30,
  53. speed_run = 30,
  54. stand_start = 0,
  55. stand_end = 79,
  56. walk_start = 168,
  57. walk_end = 187,
  58. run_start = 168,
  59. run_end = 187,
  60. punch_start = 200,
  61. punch_end = 219,
  62. },
  63. -- right clicking with raw meat will give Igor more health
  64. on_rightclick = function(self, clicker)
  65. -- feed to heal npc
  66. if mobs:feed_tame(self, clicker, 8, false, true) then return end
  67. if mobs:protect(self, clicker) then return end
  68. if mobs:capture_mob(self, clicker, nil, 5, 80, false, nil) then return end
  69. local item = clicker:get_wielded_item()
  70. local name = clicker:get_player_name()
  71. -- right clicking with gold lump drops random item from mobs.npc_drops
  72. if item:get_name() == "default:gold_lump" then
  73. if not mobs.is_creative(name) then
  74. item:take_item()
  75. clicker:set_wielded_item(item)
  76. end
  77. local pos = self.object:get_pos()
  78. pos.y = pos.y + 0.5
  79. local drops = self.igor_drops or mobs.igor_drops
  80. minetest.add_item(pos, {
  81. name = drops[math.random(1, #drops)]
  82. })
  83. minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))
  84. return
  85. end
  86. -- if owner switch between follow and stand
  87. if self.owner and self.owner == name then
  88. if self.order == "follow" then
  89. self.attack = nil
  90. self.order = "stand"
  91. self.state = "stand"
  92. self:set_animation("stand")
  93. self:set_velocity(0)
  94. minetest.chat_send_player(name, S("NPC stands still."))
  95. else
  96. self.order = "follow"
  97. minetest.chat_send_player(name, S("NPC will follow you."))
  98. end
  99. end
  100. end,
  101. })
  102. -- register spawn egg
  103. mobs:register_egg("mobs_npc:igor", S("Igor"), "mobs_meat_raw.png", 1)
  104. -- compatibility
  105. mobs:alias_mob("mobs:igor", "mobs_npc:igor")