init.lua 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. dofile(minetest.get_modpath("mobs").."/api.lua")
  2. mobs:register_mob("mobs:dirt_monster", {
  3. type = "monster",
  4. hp_max = 5,
  5. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  6. visual = "mesh",
  7. mesh = "mobs_stone_monster.x",
  8. textures = {"mobs_dirt_monster.png"},
  9. visual_size = {x=3, y=2.6},
  10. makes_footstep_sound = true,
  11. view_range = 15,
  12. walk_velocity = 1,
  13. run_velocity = 3,
  14. damage = 2,
  15. drops = {
  16. {name = "default:dirt",
  17. chance = 1,
  18. min = 3,
  19. max = 5,},
  20. },
  21. armor = 100,
  22. drawtype = "front",
  23. water_damage = 1,
  24. lava_damage = 5,
  25. light_damage = 2,
  26. on_rightclick = nil,
  27. attack_type = "dogfight",
  28. animation = {
  29. speed_normal = 15,
  30. speed_run = 15,
  31. stand_start = 0,
  32. stand_end = 14,
  33. walk_start = 15,
  34. walk_end = 38,
  35. run_start = 40,
  36. run_end = 63,
  37. punch_start = 40,
  38. punch_end = 63,
  39. }
  40. })
  41. mobs:register_spawn("mobs:dirt_monster", {"default:dirt_with_grass"}, 3, -1, 7000, 3, 31000)
  42. mobs:register_mob("mobs:stone_monster", {
  43. type = "monster",
  44. hp_max = 10,
  45. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  46. visual = "mesh",
  47. mesh = "mobs_stone_monster.x",
  48. textures = {"mobs_stone_monster.png"},
  49. visual_size = {x=3, y=2.6},
  50. makes_footstep_sound = true,
  51. view_range = 10,
  52. walk_velocity = 0.5,
  53. run_velocity = 2,
  54. damage = 3,
  55. drops = {
  56. {name = "default:mossycobble",
  57. chance = 1,
  58. min = 3,
  59. max = 5,},
  60. },
  61. light_resistant = true,
  62. armor = 80,
  63. drawtype = "front",
  64. water_damage = 0,
  65. lava_damage = 0,
  66. light_damage = 0,
  67. attack_type = "dogfight",
  68. animation = {
  69. speed_normal = 15,
  70. speed_run = 15,
  71. stand_start = 0,
  72. stand_end = 14,
  73. walk_start = 15,
  74. walk_end = 38,
  75. run_start = 40,
  76. run_end = 63,
  77. punch_start = 40,
  78. punch_end = 63,
  79. }
  80. })
  81. mobs:register_spawn("mobs:stone_monster", {"default:stone"}, 3, -1, 7000, 3, 0)
  82. mobs:register_mob("mobs:sand_monster", {
  83. type = "monster",
  84. hp_max = 3,
  85. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  86. visual = "mesh",
  87. mesh = "mobs_sand_monster.x",
  88. textures = {"mobs_sand_monster.png"},
  89. visual_size = {x=8,y=8},
  90. makes_footstep_sound = true,
  91. view_range = 15,
  92. walk_velocity = 1.5,
  93. run_velocity = 4,
  94. damage = 1,
  95. drops = {
  96. {name = "default:sand",
  97. chance = 1,
  98. min = 3,
  99. max = 5,},
  100. },
  101. light_resistant = true,
  102. armor = 100,
  103. drawtype = "front",
  104. water_damage = 3,
  105. lava_damage = 1,
  106. light_damage = 0,
  107. attack_type = "dogfight",
  108. animation = {
  109. speed_normal = 15,
  110. speed_run = 15,
  111. stand_start = 0,
  112. stand_end = 39,
  113. walk_start = 41,
  114. walk_end = 72,
  115. run_start = 74,
  116. run_end = 105,
  117. punch_start = 74,
  118. punch_end = 105,
  119. },
  120. })
  121. mobs:register_spawn("mobs:sand_monster", {"default:desert_sand"}, 20, -1, 7000, 3, 31000)
  122. mobs:register_mob("mobs:tree_monster", {
  123. type = "monster",
  124. hp_max = 5,
  125. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  126. visual = "mesh",
  127. mesh = "mobs_tree_monster.x",
  128. textures = {"mobs_tree_monster.png"},
  129. visual_size = {x=4.5,y=4.5},
  130. makes_footstep_sound = true,
  131. view_range = 15,
  132. walk_velocity = 1,
  133. run_velocity = 3,
  134. damage = 2,
  135. drops = {
  136. {name = "default:sapling",
  137. chance = 3,
  138. min = 1,
  139. max = 2,},
  140. {name = "default:junglesapling",
  141. chance = 3,
  142. min = 1,
  143. max = 2,},
  144. },
  145. light_resistant = true,
  146. armor = 100,
  147. drawtype = "front",
  148. water_damage = 1,
  149. lava_damage = 5,
  150. light_damage = 2,
  151. disable_fall_damage = true,
  152. attack_type = "dogfight",
  153. animation = {
  154. speed_normal = 15,
  155. speed_run = 15,
  156. stand_start = 0,
  157. stand_end = 24,
  158. walk_start = 25,
  159. walk_end = 47,
  160. run_start = 48,
  161. run_end = 62,
  162. punch_start = 48,
  163. punch_end = 62,
  164. },
  165. })
  166. mobs:register_spawn("mobs:tree_monster", {"default:leaves", "default:jungleleaves"}, 3, -1, 7000, 3, 31000)
  167. mobs:register_mob("mobs:sheep", {
  168. type = "animal",
  169. hp_max = 5,
  170. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1, 0.4},
  171. textures = {"mobs_sheep.png"},
  172. visual = "mesh",
  173. mesh = "mobs_sheep.x",
  174. makes_footstep_sound = true,
  175. walk_velocity = 1,
  176. armor = 200,
  177. drops = {
  178. {name = "mobs:meat_raw",
  179. chance = 1,
  180. min = 2,
  181. max = 3,},
  182. },
  183. drawtype = "front",
  184. water_damage = 1,
  185. lava_damage = 5,
  186. light_damage = 0,
  187. sounds = {
  188. random = "mobs_sheep",
  189. },
  190. animation = {
  191. speed_normal = 15,
  192. stand_start = 0,
  193. stand_end = 80,
  194. walk_start = 81,
  195. walk_end = 100,
  196. },
  197. follow = "farming:wheat",
  198. view_range = 5,
  199. on_rightclick = function(self, clicker)
  200. local item = clicker:get_wielded_item()
  201. if item:get_name() == "farming:wheat" then
  202. if not self.tamed then
  203. if not minetest.setting_getbool("creative_mode") then
  204. item:take_item()
  205. clicker:set_wielded_item(item)
  206. end
  207. self.tamed = true
  208. elseif self.naked then
  209. if not minetest.setting_getbool("creative_mode") then
  210. item:take_item()
  211. clicker:set_wielded_item(item)
  212. end
  213. self.food = (self.food or 0) + 1
  214. if self.food >= 8 then
  215. self.food = 0
  216. self.naked = false
  217. self.object:set_properties({
  218. textures = {"mobs_sheep.png"},
  219. mesh = "mobs_sheep.x",
  220. })
  221. end
  222. end
  223. return
  224. end
  225. if clicker:get_inventory() and not self.naked then
  226. self.naked = true
  227. if minetest.registered_items["wool:white"] then
  228. clicker:get_inventory():add_item("main", ItemStack("wool:white "..math.random(1,3)))
  229. end
  230. self.object:set_properties({
  231. textures = {"mobs_sheep_shaved.png"},
  232. mesh = "mobs_sheep_shaved.x",
  233. })
  234. end
  235. end,
  236. })
  237. mobs:register_spawn("mobs:sheep", {"default:dirt_with_grass"}, 20, 8, 9000, 1, 31000)
  238. minetest.register_craftitem("mobs:meat_raw", {
  239. description = "Raw Meat",
  240. inventory_image = "mobs_meat_raw.png",
  241. })
  242. minetest.register_craftitem("mobs:meat", {
  243. description = "Meat",
  244. inventory_image = "mobs_meat.png",
  245. on_use = minetest.item_eat(8),
  246. })
  247. minetest.register_craft({
  248. type = "cooking",
  249. output = "mobs:meat",
  250. recipe = "mobs:meat_raw",
  251. cooktime = 5,
  252. })
  253. mobs:register_mob("mobs:rat", {
  254. type = "animal",
  255. hp_max = 1,
  256. collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.2, 0.2},
  257. visual = "mesh",
  258. mesh = "mobs_rat.x",
  259. textures = {"mobs_rat.png"},
  260. makes_footstep_sound = false,
  261. walk_velocity = 1,
  262. armor = 200,
  263. drops = {},
  264. drawtype = "front",
  265. water_damage = 0,
  266. lava_damage = 1,
  267. light_damage = 0,
  268. on_rightclick = function(self, clicker)
  269. if clicker:is_player() and clicker:get_inventory() then
  270. clicker:get_inventory():add_item("main", "mobs:rat")
  271. self.object:remove()
  272. end
  273. end,
  274. })
  275. mobs:register_spawn("mobs:rat", {"default:dirt_with_grass", "default:stone"}, 20, -1, 7000, 1, 31000)
  276. minetest.register_craftitem("mobs:rat", {
  277. description = "Rat",
  278. inventory_image = "mobs_rat_inventory.png",
  279. on_place = function(itemstack, placer, pointed_thing)
  280. if pointed_thing.above then
  281. minetest.env:add_entity(pointed_thing.above, "mobs:rat")
  282. itemstack:take_item()
  283. end
  284. return itemstack
  285. end,
  286. })
  287. minetest.register_craftitem("mobs:rat_cooked", {
  288. description = "Cooked Rat",
  289. inventory_image = "mobs_cooked_rat.png",
  290. on_use = minetest.item_eat(3),
  291. })
  292. minetest.register_craft({
  293. type = "cooking",
  294. output = "mobs:rat_cooked",
  295. recipe = "mobs:rat",
  296. cooktime = 5,
  297. })
  298. mobs:register_mob("mobs:oerkki", {
  299. type = "monster",
  300. hp_max = 8,
  301. collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.9, 0.4},
  302. visual = "mesh",
  303. mesh = "mobs_oerkki.x",
  304. textures = {"mobs_oerkki.png"},
  305. visual_size = {x=5, y=5},
  306. makes_footstep_sound = false,
  307. view_range = 15,
  308. walk_velocity = 1,
  309. run_velocity = 3,
  310. damage = 4,
  311. drops = {},
  312. armor = 100,
  313. drawtype = "front",
  314. light_resistant = true,
  315. water_damage = 1,
  316. lava_damage = 1,
  317. light_damage = 0,
  318. attack_type = "dogfight",
  319. animation = {
  320. stand_start = 0,
  321. stand_end = 23,
  322. walk_start = 24,
  323. walk_end = 36,
  324. run_start = 37,
  325. run_end = 49,
  326. punch_start = 37,
  327. punch_end = 49,
  328. speed_normal = 15,
  329. speed_run = 15,
  330. },
  331. })
  332. mobs:register_spawn("mobs:oerkki", {"default:stone"}, 2, -1, 7000, 3, -10)
  333. mobs:register_mob("mobs:dungeon_master", {
  334. type = "monster",
  335. hp_max = 10,
  336. collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.6, 0.7},
  337. visual = "mesh",
  338. mesh = "mobs_dungeon_master.x",
  339. textures = {"mobs_dungeon_master.png"},
  340. visual_size = {x=8, y=8},
  341. makes_footstep_sound = true,
  342. view_range = 15,
  343. walk_velocity = 1,
  344. run_velocity = 3,
  345. damage = 4,
  346. drops = {
  347. {name = "default:mese",
  348. chance = 100,
  349. min = 1,
  350. max = 2,},
  351. },
  352. armor = 60,
  353. drawtype = "front",
  354. water_damage = 1,
  355. lava_damage = 1,
  356. light_damage = 0,
  357. on_rightclick = nil,
  358. attack_type = "shoot",
  359. arrow = "mobs:fireball",
  360. shoot_interval = 2.5,
  361. sounds = {
  362. attack = "mobs_fireball",
  363. },
  364. animation = {
  365. stand_start = 0,
  366. stand_end = 19,
  367. walk_start = 20,
  368. walk_end = 35,
  369. punch_start = 36,
  370. punch_end = 48,
  371. speed_normal = 15,
  372. speed_run = 15,
  373. },
  374. })
  375. mobs:register_spawn("mobs:dungeon_master", {"default:stone"}, 2, -1, 7000, 1, -50)
  376. mobs:register_arrow("mobs:fireball", {
  377. visual = "sprite",
  378. visual_size = {x=1, y=1},
  379. --textures = {{name="mobs_fireball.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.5}}}, FIXME
  380. textures = {"mobs_fireball.png"},
  381. velocity = 5,
  382. hit_player = function(self, player)
  383. local s = self.object:getpos()
  384. local p = player:getpos()
  385. local vec = {x=s.x-p.x, y=s.y-p.y, z=s.z-p.z}
  386. player:punch(self.object, 1.0, {
  387. full_punch_interval=1.0,
  388. damage_groups = {fleshy=4},
  389. }, vec)
  390. local pos = self.object:getpos()
  391. for dx=-1,1 do
  392. for dy=-1,1 do
  393. for dz=-1,1 do
  394. local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  395. local n = minetest.env:get_node(pos).name
  396. if minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30 then
  397. minetest.env:set_node(p, {name="fire:basic_flame"})
  398. else
  399. minetest.env:remove_node(p)
  400. end
  401. end
  402. end
  403. end
  404. end,
  405. hit_node = function(self, pos, node)
  406. for dx=-1,1 do
  407. for dy=-2,1 do
  408. for dz=-1,1 do
  409. local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  410. local n = minetest.env:get_node(pos).name
  411. if minetest.registered_nodes[n].groups.flammable or math.random(1, 100) <= 30 then
  412. minetest.env:set_node(p, {name="fire:basic_flame"})
  413. else
  414. minetest.env:remove_node(p)
  415. end
  416. end
  417. end
  418. end
  419. end
  420. })
  421. if minetest.setting_get("log_mods") then
  422. minetest.log("action", "mobs loaded")
  423. end