tiered_mobs.lua 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. --based on the fibonacci sequence
  2. local mobHeights={
  3. -23300, -14400, -8900, -5500,
  4. -3400, -2100, -1300, -800,
  5. -500, -300, -200, -100,
  6. 0
  7. }
  8. local function modify(ent,ix,ra)
  9. if ra==1 then
  10. ent.damage=ent.damage+0.4*ix
  11. ent.hp_min=ent.hp_min+2*ix
  12. ent.hp_max=ent.hp_max+2*ix
  13. ent.armor=ent.armor-3*ix
  14. else
  15. ent.damage=ent.damage+0.2*ix
  16. ent.hp_min=ent.hp_min+4*ix
  17. ent.hp_max=ent.hp_max+4*ix
  18. ent.armor=ent.armor-2*ix
  19. end
  20. end
  21. local function advance(obj,textureFu)
  22. local height=(obj:get_pos()).y
  23. local ra=Random:next(1,2)
  24. if height>mobHeights[13] then
  25. obj:set_properties({textures=textureFu(0,ra)})
  26. elseif height>mobHeights[12] then
  27. modify(obj:get_luaentity(),1,ra)
  28. obj:set_properties({textures=textureFu(-1,ra)})
  29. elseif height>mobHeights[11] then
  30. modify(obj:get_luaentity(),2,ra)
  31. obj:set_properties({textures=textureFu(-2,ra)})
  32. elseif height>mobHeights[10] then
  33. modify(obj:get_luaentity(),3,ra)
  34. obj:set_properties({textures=textureFu(-3,ra)})
  35. elseif height>mobHeights[9] then
  36. modify(obj:get_luaentity(),4,ra)
  37. obj:set_properties({textures=textureFu(-4,ra)})
  38. elseif height>mobHeights[8] then
  39. modify(obj:get_luaentity(),5,ra)
  40. obj:set_properties({textures=textureFu(-5,ra)})
  41. elseif height>mobHeights[7] then
  42. modify(obj:get_luaentity(),6,ra)
  43. obj:set_properties({textures=textureFu(-6,ra)})
  44. elseif height>mobHeights[6] then
  45. modify(obj:get_luaentity(),7,ra)
  46. obj:set_properties({textures=textureFu(-7,ra)})
  47. elseif height>mobHeights[5] then
  48. modify(obj:get_luaentity(),8,ra)
  49. obj:set_properties({textures=textureFu(-8,ra)})
  50. elseif height>mobHeights[4] then
  51. modify(obj:get_luaentity(),9,ra)
  52. obj:set_properties({textures=textureFu(-9,ra)})
  53. elseif height>mobHeights[3] then
  54. modify(obj:get_luaentity(),10,ra)
  55. obj:set_properties({textures=textureFu(-10,ra)})
  56. elseif height>mobHeights[2] then
  57. modify(obj:get_luaentity(),11,ra)
  58. obj:set_properties({textures=textureFu(-11,ra)})
  59. elseif height>mobHeights[1] then
  60. modify(obj:get_luaentity(),12,ra)
  61. obj:set_properties({textures=textureFu(-12,ra)})
  62. end
  63. end
  64. -------------------------------------------------------------------------------
  65. --Cubo
  66. local function cuboTextures(num,ra)
  67. if num==0 then
  68. return {"mobs_dungeon_cubo.png^mobs_dungeon_cubo_overlay0.png"}
  69. else
  70. return {"mobs_dungeon_cubo.png^mobs_dungeon_cubo_overlay"
  71. ..num.."_"..ra..".png"
  72. }
  73. end
  74. end
  75. mobs:register_mob(
  76. "mobs_dungeon:cubo",
  77. {
  78. type="monster",
  79. passive=false,
  80. damage=3,
  81. attack_type="shoot",
  82. shoot_interval=0.5,
  83. arrow="mobs_dungeon:cubo_arrow",
  84. shoot_offset=2,
  85. hp_min=10,
  86. hp_max=25,
  87. armor=100,
  88. collisionbox={-0.5, -1.5, -0.5, 0.5, 0.5, 0.5},
  89. visual="mesh",
  90. mesh="zmobs_mese_monster.x",
  91. textures={
  92. {"mobs_dungeon_cubo.png^mobs_dungeon_cubo_overlay0.png"},
  93. },
  94. makes_footstep_sound=false,
  95. sounds={
  96. random="mobs_dungeon_cubo_random",
  97. attack="mobs_dungeon_cubo_attack",
  98. shoot_attack="mobs_dungeon_cubo_attack",
  99. death="mobs_dungeon_cubo_death",
  100. damage="mobs_dungeon_cubo_damage",
  101. },
  102. view_range=10,
  103. walk_velocity=0.5,
  104. run_velocity=2,
  105. jump=true,
  106. jump_height=8,
  107. fall_damage=0,
  108. fall_speed=-6,
  109. stepheight=2.1,
  110. drops={},
  111. water_damage=1,
  112. lava_damage=1,
  113. light_damage=0,
  114. animation={
  115. speed_normal=15,
  116. speed_run=15,
  117. stand_start=0,
  118. stand_end=14,
  119. walk_start=15,
  120. walk_end=38,
  121. run_start=40,
  122. run_end=63,
  123. punch_start=40,
  124. punch_end=63,
  125. },
  126. on_spawn=function(self) advance(self.object,cuboTextures) end
  127. }
  128. )
  129. mobs:register_arrow(
  130. "mobs_dungeon:cubo_arrow",
  131. {
  132. visual="sprite",
  133. visual_size={x=0.5, y=0.5},
  134. textures={"mobs_dungeon_cubo_arrow.png"},
  135. velocity=6,
  136. hit_player=function(self, player)
  137. player:punch(
  138. self.object, 1.0,
  139. {full_punch_interval=1.0, damage_groups={fleshy=2}}, nil
  140. )
  141. end,
  142. hit_mob=function(self, player)
  143. player:punch(
  144. self.object, 1.0,
  145. {full_punch_interval=1.0,damage_groups={fleshy=2}}, nil
  146. )
  147. end,
  148. hit_node=function(self, pos, node)
  149. end
  150. }
  151. )
  152. mobs:spawn(
  153. {
  154. name="mobs_dungeon:cubo",
  155. nodes={"group:cracky"},
  156. chance=3000,
  157. active_object_count=2,
  158. }
  159. )
  160. mobs:register_egg("mobs_dungeon:cubo", "Cubo", "mobs_dungeon_cubo_egg.png", 1)
  161. -------------------------------------------------------------------------------
  162. --Animated Block
  163. local function createAnimatedBlockTextureFu(texture)
  164. local function animatedBlockTextures(num,ra)
  165. local out={
  166. texture,
  167. texture,
  168. texture,
  169. texture,
  170. texture,
  171. texture,
  172. }
  173. if num==0 then
  174. out[5]=out[5].."^mobs_dungeon_animated_block0.png"
  175. else
  176. out[5]=out[5].."^mobs_dungeon_animated_block"
  177. ..num.."_"..ra..".png"
  178. end
  179. return out
  180. end
  181. return animatedBlockTextures
  182. end
  183. mobs:register_mob(
  184. "mobs_dungeon:animated_block",
  185. {
  186. type="monster",
  187. passive=false,
  188. attack_type="dogfight",
  189. pathfinding=true,
  190. reach=2,
  191. damage=4,
  192. hp_min=40,
  193. hp_max=50,
  194. armor=40,
  195. collisionbox={-0.5, -0.5, -0.5, 0.5, 0.45, 0.5},
  196. visual_size={x=1,y=1,z=1},
  197. visual="cube",
  198. textures={
  199. "mobs_dungeon_animated_block0.png",
  200. "mobs_dungeon_animated_block0.png",
  201. "mobs_dungeon_animated_block0.png",
  202. "mobs_dungeon_animated_block0.png",
  203. "mobs_dungeon_animated_block0.png",
  204. "mobs_dungeon_animated_block0.png",
  205. },
  206. makes_footstep_sound=true,
  207. sounds={
  208. random="mobs_dungeon_animated_block_random",
  209. attack="mobs_dungeon_animated_block_attack",
  210. death="mobs_dungeon_animated_block_death"
  211. },
  212. walk_velocity=0.5,
  213. run_velocity=1,
  214. jump=true,
  215. jump_height=1,
  216. floats=1,
  217. view_range=10,
  218. drops={},
  219. water_damage=0,
  220. lava_damage=0,
  221. light_damage=0,
  222. on_spawn=function(self)
  223. local obj=self.object
  224. local tmp=minetest.find_node_near(obj:get_pos(),2,{"group:cracky"})
  225. if tmp then
  226. tmp=string.gsub(minetest.get_node(tmp).name,":","_")..".png"
  227. advance(obj,createAnimatedBlockTextureFu(tmp))
  228. end
  229. end
  230. }
  231. )
  232. mobs:spawn(
  233. {
  234. name="mobs_dungeon:animated_block",
  235. nodes={"group:cracky"},
  236. chance=3000,
  237. active_object_count=2,
  238. }
  239. )
  240. mobs:register_egg(
  241. "mobs_dungeon:animated_block", "Animated Block",
  242. "mobs_dungeon_animated_block_egg.png", 1
  243. )
  244. -------------------------------------------------------------------------------
  245. --Ooze
  246. local function oozeTextures(num,ra)
  247. if num==0 then
  248. return {"mobs_dungeon_ooze0.png"}
  249. else
  250. return {"mobs_dungeon_ooze"..num.."_"..ra..".png"}
  251. end
  252. end
  253. mobs:register_mob(
  254. "mobs_dungeon:ooze",
  255. {
  256. type="monster",
  257. passive=false,
  258. attack_type="dogfight",
  259. reach=2,
  260. damage=2,
  261. hp_min=30,
  262. hp_max=40,
  263. armor=80,
  264. collisionbox={-0.2, -0.01, -0.2, 0.2, 0.4, 0.2},
  265. visual_size={x=2, y=2},
  266. visual="mesh",
  267. mesh="slime_land.b3d",
  268. textures={
  269. {"mobs_dungeon_ooze0.png",}
  270. },
  271. makes_footstep_sound=false,
  272. sounds={
  273. random="mobs_dungeon_ooze_random",
  274. attack="mobs_dungeon_ooze_attack",
  275. death="mobs_dungeon_ooze_death"
  276. },
  277. view_range=10,
  278. walk_velocity=3,
  279. run_velocity=5,
  280. drops={},
  281. water_damage=0,
  282. lava_damage=1,
  283. light_damage=0,
  284. animation={
  285. idle_start=0,
  286. idle_end=20,
  287. move_start=21,
  288. move_end=41,
  289. fall_start=42,
  290. fall_end=62,
  291. jump_start=63,
  292. jump_end=83
  293. },
  294. do_custom=function(self)
  295. tmw_slimes.animate(self)
  296. end,
  297. on_spawn=function(self) advance(self.object,oozeTextures) end
  298. }
  299. )
  300. mobs:spawn(
  301. {
  302. name="mobs_dungeon:ooze",
  303. nodes={"group:cracky"},
  304. chance=3000,
  305. active_object_count=2,
  306. }
  307. )
  308. mobs:register_egg("mobs_dungeon:ooze", "Ooze", "mobs_dungeon_ooze0.png", 1)