animals.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. local function variance(min,max)
  2. local target = math.random(min,max) / 100
  3. --print(target)
  4. return target
  5. end
  6. local gob_name_parts = goblins.gob_name_parts
  7. local goblins_spawning = goblins.spawning
  8. goblins.gobdog_types = {
  9. gobdog = {
  10. owner_loyal = true,
  11. attack_npcs = false,
  12. attack_monsters = false,
  13. group_attack = true,
  14. attack_players = true,
  15. },
  16. gobdog_aggro = {
  17. description ="Dire Gobdog",
  18. lore = "Dire Gobdogs are sensitive to light and are very territorial",
  19. type = "monster",
  20. group_attack = true,
  21. owner_loyal = true,
  22. attack_npcs = false,
  23. attack_monsters = false,
  24. attack_players = true,
  25. spawning = goblins_spawning.gobdog_aggro
  26. },
  27. }
  28. -------------
  29. -- Gobdog Template
  30. ------------
  31. goblins.gobdog_template = {
  32. description ="Gobdog",
  33. lore = "Gobdogs are not canids but goblins that have mutated somehow, fortunately they do not share the hunger and size of the mythical werewolf.",
  34. type = "npc",
  35. attack_type = "dogfight",
  36. group_attack = true,
  37. reach = 2,
  38. damage = 1,
  39. hp_min = 2,
  40. hp_max = 5,
  41. armor = 100,
  42. stepheight = 1.2,
  43. walk_velocity = 2,
  44. run_velocity = 4,
  45. jump = true,
  46. jump_height = 6,
  47. pushable = true,
  48. knock_back = true,
  49. view_range = 15,
  50. water_damage = 0,
  51. lava_damage = 5,
  52. light_damage = 0,
  53. fear_height = 4,
  54. floats = 1,
  55. --glow = 1,
  56. pathfinding = 1,
  57. stay_near = {
  58. "group:water", 20,
  59. "group:sand", 20,
  60. "group:soil", 20,
  61. "default:mossycobble", 10,
  62. "group:meat" ,2,
  63. "goblins:goblins_goblin_bone_meaty"},
  64. collisionbox = {-0.45, -0.01, -0.45, 0.45, 0.85, 0.45},
  65. visual = "mesh",
  66. mesh = "goblins_goblin_dog.b3d",
  67. textures = {
  68. {"goblins_goblin_dog.png"},
  69. },
  70. makes_footstep_sound = true,
  71. sounds = {
  72. random = "goblins_goblin_dog_ambient_cave",
  73. war_cry = "goblins_goblin_dog_war_cry_cave",
  74. attack = "goblins_goblin_dog_attack_cave",
  75. damage = "goblins_goblin_dog_damage_cave",
  76. death = "goblins_goblin_dog_death_cave",
  77. replace = "goblins_goblin_dog_replace_cave",gain = 0.8,
  78. },
  79. follow = {
  80. "goblins:goblins_goblin_bone","goblins:goblins_goblin_bone_meaty","group:meat"
  81. },
  82. drops = {
  83. {name = "goblins:goblins_goblin_bone", chance = 1, min = 1, max = 3},
  84. },
  85. animation = {
  86. speed_normal = 60,
  87. stand_start = 0,
  88. stand_end = 60,
  89. walk_start = 70,
  90. walk_end = 90,
  91. run_start = 130,
  92. run_end = 140,
  93. run_speed =30,
  94. jump_start = 160,
  95. jump_end = 190,
  96. jump_loop = true,
  97. jump_speed = 30,
  98. punch_start = 130,
  99. punch_end = 140,
  100. punch_speed = 30,
  101. die_start = 140,
  102. die_stop = 145,
  103. die_speed = 30,
  104. die_loop = false,
  105. },
  106. on_spawn = function(self)
  107. minetest.sound_play("goblins_goblin_dog_war_cry_cave", {
  108. object = self.object,
  109. gain = .5,
  110. max_hear_distance =30
  111. })
  112. self.groups = {"gobdog", "goblin"}
  113. self.groups_defend = {"goblin","gobdog","gobdog_friend"}
  114. if not self.secret_name then
  115. local name_rules = {"list_a", "list_opt"}
  116. self.secret_name = goblins.generate_name(gob_name_parts, name_rules)
  117. end
  118. --print (dump(self.secret_name))
  119. local pos = vector.round(self.object:get_pos())
  120. if not pos then return end
  121. if not self.secret_territory then
  122. local territory = {goblins.territory(pos)}
  123. self.secret_territory = {name = territory[1], vol = territory[2]}
  124. --print(dump(self.secret_territory.name).." secret_territory assigned")
  125. else
  126. --print(dump(self.secret_territory.name).." secret_territory already assigned")
  127. end
  128. local color_var = "#"..math.random(10,50)..math.random(10,50)..math.random(10,50)
  129. --print("COLOR_VAR: "..color_var)
  130. self.object:set_texture_mod("^[colorize:"..color_var..":80")
  131. if not self.size then
  132. local s_mod = variance(1,20)
  133. self.size = {x = (variance(90,100) - s_mod), y = (variance(80,110) - s_mod), z = (variance(90,100) - s_mod)}
  134. end
  135. local self_properties = self.object:get_properties()
  136. self_properties.visual_size = self.size
  137. self.object:set_properties(self_properties)
  138. goblins.announce_spawn(self)
  139. end,
  140. on_rightclick = function(self, clicker)
  141. if mobs:feed_tame(self, clicker, 4, true, true) then return end
  142. if mobs:protect(self, clicker) then return end
  143. if mobs:capture_mob(self, clicker, 0, 5, 50, false, nil) then return end
  144. end,
  145. ---dog behaviors or not...
  146. do_custom = function(self)
  147. goblins.goblin_dog_behaviors(self)
  148. end,
  149. do_punch = function(self,hitter)
  150. local pname = hitter:get_player_name()
  151. local relations = goblins.relations(self, pname)
  152. if not relations.aggro then
  153. goblins.relations(self, pname, {aggro = 0})
  154. relations = goblins.relations(self, pname)
  155. end
  156. --print(self.secret_name.." relations on click:\n"..dump(self.relations).."\n")
  157. if self.relations[pname].aggro then
  158. local adj = (self.relations[pname].aggro + 1) * 1.5
  159. self.relations[pname].aggro = math.floor(adj)
  160. goblins.relations(self, pname, {aggro = self.relations[pname].aggro} )
  161. end
  162. end,
  163. spawning = goblins_spawning.gobdog
  164. }
  165. mobs:alias_mob("goblins:goblins_goblin_dog", "goblins:goblin_gobdog")
  166. mobs:alias_mob("goblins:goblin_goblin_dog", "goblins:goblin_gobdog")
  167. mobs:alias_mob("goblins:goblins_goblin_dog_aggro", "goblins:goblin_gobdog_aggro")
  168. mobs:alias_mob("goblins:goblin_goblin_dog_aggro", "goblins:goblin_gobdog_aggro")