ostrich.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. mobs:register_mob("desert_life:ostrich", {
  2. type = "animal",
  3. passive = false,
  4. attack_type = "dogfight",
  5. group_attack = true,
  6. reach = 2,
  7. damage = 2,
  8. damage_max = 8,
  9. damage_chance = 80,
  10. hp_min = 5,
  11. hp_max = 10,
  12. armor = 200,
  13. collisionbox = {-0.4, -0.575, -0.4, 0.4, 0.75, 0.4},
  14. visual = "mesh",
  15. mesh = "dl_ostrich.b3d",
  16. textures = {
  17. {'dl_ostrich.png'},
  18. },
  19. visual_size = {x=11, y=11},
  20. makes_footstep_sound = true,
  21. walk_velocity = 1,
  22. run_velocity = 3,
  23. jump = true,
  24. drops = {
  25. {name = "mobs:chicken_raw", chance = 1, min = 2, max = 6},
  26. },
  27. water_damage = 1,
  28. lava_damage = 5,
  29. light_damage = 0,
  30. fall_damage = 0,
  31. fall_speed = -8,
  32. fear_height = 5,
  33. animation = {
  34. speed_normal = 15,
  35. speed_run = 30,
  36. stand_start = 0,
  37. stand_end = 60,
  38. walk_start = 180,
  39. walk_end = 229,
  40. run_start = 180,
  41. run_end = 229,
  42. punch_start = 65,
  43. punch_end = 90,
  44. punch2_start = 95,
  45. punch2_end = 125,
  46. },
  47. follow = {"farming:seed_wheat", "farming:seed_cotton"},
  48. view_range = 5,
  49. replace_what = {'group:flora', 'group:plant'},
  50. replace_with = 'air',
  51. replace_rate = 1,
  52. do_custom = function(self, dtime)
  53. -- set needed values if not already present
  54. if not self.v2 then
  55. self.v2 = 0
  56. self.max_speed_forward = 6
  57. self.max_speed_reverse = 2
  58. self.accel = 6
  59. self.terrain_type = 3
  60. self.driver_attach_at = {x = 0, y = .5, z = -0.25}
  61. self.driver_eye_offset = {x = 0, y = 3, z = 0}
  62. self.driver_scale = {x = .09, y = .09}
  63. end
  64. -- if driver present allow control of ostrich
  65. if self.driver then
  66. mobs.drive(self, "walk", "stand", false, dtime)
  67. return false -- skip rest of mob functions
  68. end
  69. return true
  70. end,
  71. on_die = function(self, pos)
  72. -- drop saddle when ostrich is killed while riding
  73. -- also detach from ostrich properly
  74. if self.driver then
  75. minetest.add_item(pos, "mobs:saddle")
  76. mobs.detach(self.driver, {x = 1, y = 0, z = 1})
  77. self.saddle = nil
  78. end
  79. -- drop any ostrichshoes added
  80. if self.shoed then
  81. minetest.add_item(pos, self.shoed)
  82. end
  83. end,
  84. on_rightclick = function(self, clicker)
  85. -- make sure player is clicking
  86. if not clicker or not clicker:is_player() then
  87. return
  88. end
  89. -- feed, tame or heal ostrich
  90. if mobs:feed_tame(self, clicker, 10, true, true) then
  91. return
  92. end
  93. -- applying protection rune
  94. if mobs:protect(self, clicker) then
  95. return
  96. end
  97. -- make sure tamed ostrich is being clicked by owner only
  98. if self.tamed and self.owner == clicker:get_player_name() then
  99. local inv = clicker:get_inventory()
  100. local tool = clicker:get_wielded_item()
  101. local item = tool:get_name()
  102. -- detatch player already riding ostrich
  103. if self.driver and clicker == self.driver then
  104. mobs.detach(clicker, {x = 1, y = 0, z = 1})
  105. -- add saddle back to inventory
  106. if inv:room_for_item("main", "mobs:saddle") then
  107. inv:add_item("main", "mobs:saddle")
  108. else
  109. minetest.add_item(clicker:get_pos(), "mobs:saddle")
  110. end
  111. self.saddle = nil
  112. -- attach player to ostrich
  113. elseif (not self.driver and not self.child
  114. and clicker:get_wielded_item():get_name() == "mobs:saddle")
  115. or self.saddle then
  116. --self.object:set_properties()
  117. --print(self.object)
  118. mobs.attach(self, clicker)
  119. -- take saddle from inventory
  120. if not self.saddle then
  121. inv:remove_item("main", "mobs:saddle")
  122. end
  123. self.saddle = true
  124. end
  125. end
  126. -- used to capture ostrich with magic lasso
  127. mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
  128. end
  129. })
  130. mobs:spawn({
  131. name = 'desert_life:ostrich',
  132. nodes = {'default:desert_sand', 'default:desert_stone'},
  133. min_height = 0,
  134. max_height = 150,
  135. interval = 60,
  136. chance = 10000,
  137. active_object_count = 5,
  138. })
  139. mobs:register_egg("desert_life:ostrich", "Ostrich", "wool.png^[multiply:#40230f", 1)