uber.lua 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. mobs:register_mob("tmw_slimes:uber_slime", {
  2. type = "npc",
  3. passive = false,
  4. attack_animals = false,
  5. attack_npcs = false,
  6. attack_monsters = true,
  7. attack_type = "dogfight",
  8. reach = 4,
  9. damage = 10,
  10. hp_min = 60,
  11. hp_max = 60,
  12. armor = 50,
  13. collisionbox = {-1.25, -0.01, -1.25, 1.25, 4.25, 1.25},
  14. visual_size = {x = 4, y = 4},
  15. stepheight = 1.5,
  16. visual = "mesh",
  17. mesh = "slime_uber.b3d",
  18. blood_texture = "tmw_slime_goo.png^[colorize:"..tmw_slimes.colors["uber"],
  19. textures = {
  20. {"tmw_slime_goo_block.png^[colorize:"..tmw_slimes.colors["uber"].."^[colorize:#FFF:96","tmw_slime_goo_block.png^[colorize:"..tmw_slimes.colors["uber"]},
  21. },
  22. makes_footstep_sound = false,
  23. walk_velocity = 0.5,
  24. run_velocity = 1.25,
  25. jump_height = 15,
  26. jump = true,
  27. view_range = 24,
  28. drops = {
  29. {name = "tmw_slimes:algae_goo", chance = 1, min = 0, max = 1},
  30. {name = "tmw_slimes:alien_goo", chance = 1, min = 0, max = 1},
  31. {name = "tmw_slimes:cloud_goo", chance = 1, min = 0, max = 1},
  32. {name = "tmw_slimes:dark_goo", chance = 1, min = 0, max = 1},
  33. {name = "tmw_slimes:icy_goo", chance = 1, min = 0, max = 1},
  34. {name = "tmw_slimes:jungle_goo", chance = 1, min = 0, max = 1},
  35. {name = "tmw_slimes:lava_goo", chance = 1, min = 0, max = 1},
  36. {name = "tmw_slimes:mineral_goo", chance = 1, min = 0, max = 1},
  37. {name = "tmw_slimes:ocean_goo", chance = 1, min = 0, max = 1},
  38. {name = "tmw_slimes:poisonous_goo", chance = 1, min = 0, max = 1},
  39. {name = "tmw_slimes:savannah_goo", chance = 1, min = 0, max = 1},
  40. {name = "tmw_slimes:live_nucleus", chance = 1, min = 0, max = 1},
  41. },
  42. fall_damage = 0,
  43. water_damage = 0,
  44. lava_damage = 0,
  45. light_damage = 0,
  46. animation = {
  47. idle_start = 0,
  48. idle_end = 20,
  49. move_start = 21,
  50. move_end = 41,
  51. fall_start = 63,
  52. fall_end = 83,
  53. jump_start = 42,
  54. jump_end = 62
  55. },
  56. do_custom = function(self, dtime)
  57. if not self.particle_spawner_dt or self.particle_spawner_dt > 4 then
  58. minetest.add_particlespawner({
  59. amount = 12,
  60. time = 4,
  61. minpos = {x=-1.5, y=0, z=-1.5},
  62. maxpos = {x=1.5, y=5, z=1.5},
  63. minvel = {x=0, y=0, z=0},
  64. maxvel = {x=0, y=0.1, z=0},
  65. minacc = {x=0, y=0, z=0},
  66. maxacc = {x=0, y=0, z=0},
  67. minexptime = 2,
  68. maxexptime = 2,
  69. minsize = 1,
  70. maxsize = 1.5,
  71. collisiondetection = false,
  72. collisionremoval = false,
  73. attached = self.object,
  74. texture = "uber_slime_particle.png^[colorize:"..tmw_slimes.colors["uber"].."^[colorize:#FFF:96"
  75. })
  76. self.particle_spawner_dt = 0
  77. self.health = math.min(self.object:get_hp()+math.random(1,6),60) -- Regenerate health
  78. end
  79. self.particle_spawner_dt = self.particle_spawner_dt + dtime
  80. --tmw_slimes.uber_slime_anim(self)
  81. if self.driver then
  82. local player = self.driver
  83. if player:is_player() and player:get_attach("parent") == self.object and
  84. not (
  85. player:get_player_control().RMB and
  86. (math.pi/4) < player:get_look_vertical())
  87. then
  88. self.blast_dt = self.blast_dt or 1.1
  89. if self.blast_dt > 1 and player:get_player_control().aux1 then
  90. tmw_slimes.uber_slime_blast(self)
  91. self.blast_dt = 0
  92. end
  93. self.blast_dt = self.blast_dt + dtime
  94. mobs.drive(self, "", "", false, dtime)
  95. return false
  96. else
  97. mobs.detach(player, {x = 1, y = 0, z = 1})
  98. end
  99. end
  100. return true
  101. end,
  102. on_die = function(self, pos)
  103. if self.driver then
  104. mobs.detach(self.driver, {x = 0, y = 0, z = 0})
  105. end
  106. end,
  107. after_activate = function(self)
  108. self.health = 60
  109. self.v = 0
  110. self.max_speed_forward = 7
  111. self.max_speed_reverse = 7
  112. self.accel = 3
  113. self.driver_attach_at = {x = 0, y = 11, z = -0.5}
  114. self.driver_eye_offset = {x = 0, y = 40, z = 0}
  115. self.driver_scale = {y=0.25,x=0.25}
  116. end,
  117. on_rightclick = function(self, clicker)
  118. if self.owner == clicker:get_player_name() then
  119. if self.driver and clicker == self.driver then
  120. mobs.detach(clicker, {x = 1, y = 0, z = 1})
  121. return
  122. elseif not (self.driver or clicker:get_player_control().sneak) then
  123. mobs.attach(self, clicker)
  124. return
  125. end
  126. end
  127. mobs:capture_mob(self, clicker, 100, 100, 100, false, nil)
  128. end
  129. })
  130. minetest.register_entity("tmw_slimes:blast", {
  131. textures = {"default_wood.png^[colorize:#0000:255"},
  132. hp_max = 1,
  133. collisionbox = {-0.33, -0.33, -0.33, 0.33, 0.33, 0.33},
  134. static_save = false,
  135. physical = true,
  136. on_activate = function(self)
  137. self.dt = 0
  138. self.hits = 8
  139. end,
  140. on_step = function(self, dtime)
  141. self.dt = self.dt + dtime
  142. if self.dt < 0.5 then
  143. return
  144. end
  145. self.hits = self.hits - 1
  146. self.dt = 0
  147. local player = minetest.get_player_by_name(self.player)
  148. if not player then return end
  149. local pos = self.object:get_pos()
  150. for _,ent in pairs(minetest.get_objects_inside_radius(pos, 4)) do
  151. if ent:is_player() and ent ~= player then
  152. ent:punch(player, nil, {damage_groups={fleshy=4}}, nil)
  153. else
  154. local luaent = ent:get_luaentity()
  155. if luaent and
  156. luaent._cmi_is_mob and
  157. luaent.name ~= "tmw_slimes:uber_slime"
  158. then
  159. ent:punch(player, nil, {damage_groups={fleshy=4}}, nil)
  160. end
  161. end
  162. end
  163. if self.hits <= 0 then
  164. self.object:remove()
  165. end
  166. end
  167. })
  168. tmw_slimes.uber_slime_blast = function(ent)
  169. local yaw = ent.object:get_yaw()
  170. local epos = ent.object:get_pos()
  171. local pos = {x=epos.x+2*math.sin(-yaw),y=epos.y+3,z=epos.z+2*math.cos(-yaw)}
  172. local ent_vel = ent.object:get_velocity()
  173. local vel = {x=ent_vel.x+9*math.sin(-yaw),y=ent_vel.y,z=ent_vel.z+9*math.cos(-yaw)}
  174. local blast = minetest.add_entity(pos, "tmw_slimes:blast")
  175. blast:set_velocity(vel)
  176. blast:get_luaentity().player = ent.driver and ent.driver:get_player_name() or ""
  177. minetest.sound_play("item_slurp", {pos = pos, max_hear_distance = 10, gain = 0.7})
  178. minetest.add_particlespawner({
  179. amount = 64,
  180. time = 4,
  181. minpos = {x=0,y=0,z=0},
  182. maxpos = {x=0,y=0,z=0},
  183. minvel = {x=-1.3, y=-1.3, z=-1.3},
  184. maxvel = {x=1.3, y=1.3, z=1.3},
  185. minacc = {x=0, y=0, z=0},
  186. maxacc = {x=0, y=0, z=0},
  187. minexptime = 2,
  188. maxexptime = 2,
  189. minsize = 1,
  190. maxsize = 2,
  191. collisiondetection = false,
  192. collisionremoval = false,
  193. texture = "tmw_slime_goo.png^[colorize:"..tmw_slimes.colors["uber"],
  194. attached = blast,
  195. glow = 5
  196. })
  197. end
  198. tmw_slimes.uber_slime_anim = function(ent)
  199. if not (ent and minetest.registered_entities[ent.name] and ent.object) then return end
  200. local pos = ent.object:get_pos()
  201. local velocity = ent.object:get_velocity()
  202. local is_liquid_below = ((minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-0.5,z=pos.z}).name] or {liquidtype = "none"}).liquidtype == "none")
  203. if velocity.y ~= 0 then
  204. if is_liquid_below and (math.abs(velocity.x) > math.abs(velocity.y) or math.abs(velocity.z) > math.abs(velocity.y)) then
  205. mobs.set_animation(ent, "move")
  206. return
  207. end
  208. if velocity.y > 0 then
  209. mobs:set_animation(ent, "jump")
  210. return
  211. else
  212. mobs:set_animation(ent, "fall")
  213. return
  214. end
  215. end
  216. if velocity.x ~= 0 or velocity.z ~= 0 then
  217. mobs:set_animation(ent, "move")
  218. return
  219. end
  220. mobs:set_animation(ent, "idle")
  221. end
  222. mobs:register_egg("tmw_slimes:uber_slime", "Über-Slime", "uber_slime.png^[colorize:"..tmw_slimes.colors["uber"], 0)
  223. minetest.register_craft({
  224. output = "tmw_slimes:uber_slime",
  225. type = "shapeless",
  226. recipe = {
  227. "tmw_slimes:algae_goo_block",
  228. (minetest.get_modpath("other_worlds") and "tmw_slimes:alien_goo_block" or "default:mese_crystal"),
  229. "tmw_slimes:cloud_goo_block",
  230. "tmw_slimes:poisonous_goo_block",
  231. "tmw_slimes:live_nucleus",
  232. "tmw_slimes:icy_goo_block",
  233. "tmw_slimes:jungle_goo_block",
  234. "tmw_slimes:dark_goo_block",
  235. "tmw_slimes:savannah_goo_block",
  236. }
  237. })