igor.lua 3.6 KB

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