read_mobs_config.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. local S=minerdream.intllib
  2. local has_value = basic_functions.has_value
  3. local mob_cols={
  4. col_num={"reach","damage","hp_min",
  5. "hp_max","armor","walk_velocity","run_velocity","walk_chance",
  6. "fall_speed","jump_chance","jump_height","stepheight","floats",
  7. "view_range","water_damage","lava_damage","light_damage","slimeball",
  8. "egg","slimering","maxlight","chance","max_height","collisionbox"},
  9. -- as_numeric=1,
  10. }
  11. local mob_definition = basic_functions.import_csv(minerdream.path.."/mobs.txt",mob_cols)
  12. local mob_default = {
  13. type = "monster",
  14. passive = false,
  15. attack_type = "dogfight",
  16. reach = 2,
  17. damage = 1,
  18. hp_min = 5,
  19. hp_max = 5,
  20. armor = 100,
  21. collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.3, 0.3},
  22. visual = "wielditem",
  23. makes_footstep_sound = true,
  24. walk_velocity = 2,
  25. run_velocity = 2,
  26. walk_chance = 0,
  27. fall_speed = -50,
  28. jump_chance = 30,
  29. jump_height = 6,
  30. stepheight = 1.1,
  31. floats = 0,
  32. view_range = 16,
  33. water_damage = 0,
  34. lava_damage = 8,
  35. light_damage = 0,
  36. animation = {
  37. speed_normal = 15,
  38. speed_run = 15,
  39. stand_start = 0,
  40. stand_end = 14,
  41. walk_start = 15,
  42. walk_end = 38,
  43. run_start = 40,
  44. run_end = 63,
  45. punch_start = 40,
  46. punch_end = 63,
  47. },
  48. }
  49. if mob_definition["default"] ~= nil then
  50. tmobd=table.copy(mob_definition["default"])
  51. for _,column in pairs({"attack_type","reach","damage","hp_min",
  52. "hp_max","armor","walk_velocity","run_velocity","walk_chance",
  53. "fall_speed","jump_chance","jump_height","stepheight","floats",
  54. "view_range","water_damage","lava_damage","light_damage","slimeball",
  55. "egg","slimering","maxlight","chance","max_height"}) do
  56. if tmobd[column] ~= nil then
  57. mob_default[column]=tmobd[column]
  58. end
  59. end
  60. if tmobd["collisionbox"] ~= nil then
  61. local cb=tmobd["collisionbox"]
  62. mob_default["collisionbox"] = {-1*cb, -1*cb, -1*cb, cb, cb, cb}
  63. end
  64. end
  65. for i,tdef in pairs(mob_definition) do
  66. if (i ~= "default") then
  67. local mdef=table.copy(mob_default)
  68. for _,column in pairs({"attack_type","reach","damage","hp_min",
  69. "hp_max","armor","walk_velocity","run_velocity","walk_chance",
  70. "fall_speed","jump_chance","jump_height","stepheight","floats",
  71. "view_range","water_damage","lava_damage","light_damage","slimeball",
  72. "egg","slimering","maxlight","chance","max_height"}) do
  73. if tdef[column] ~= nil then
  74. mdef[column]=tdef[column]
  75. end
  76. end
  77. if tdef["collisionbox"] ~= nil then
  78. local cb=tdef["collisionbox"]
  79. mdef["collisionbox"] = {-1*cb, -1*cb, -1*cb, cb, cb, cb}
  80. end
  81. mdef.textures = {
  82. {"minerdream:slime_"..i},
  83. }
  84. mdef.blood_texture = "minerdream_slimeball_"..i..".png"
  85. mdef.drops = {
  86. {name = "minerdream:slimeball_"..i, chance = mdef.slimeball, min = 1, max = 3},
  87. {name = "minerdream:slime_"..i.."_egg", chance = mdef.egg, min = 1, max = 1},
  88. {name = "minerdream:accessory_slimering", chance = mdef.slimering, min = 1, max = 1},
  89. }
  90. mobs:register_mob("minerdream:slime_"..i, mdef)
  91. mobs:spawn({
  92. name = "minerdream:slime_"..i,
  93. nodes = {"default:stone"},
  94. max_light = mdef.maxlight,
  95. chance = mdef.chance,
  96. max_height = mdef.max_height,
  97. })
  98. minetest.register_craftitem("minerdream:slime_"..i.."_egg", {
  99. description = S(i).." "..S("slime spawnegg"),
  100. inventory_image = "minerdream_egg_"..i.."slime.png",
  101. on_place = function(itemstack, placer, pointed_thing)
  102. if pointed_thing.above then
  103. minetest.env:add_entity(pointed_thing.above, "minerdream:slime_"..i)
  104. itemstack:take_item()
  105. end
  106. return itemstack
  107. end,
  108. })
  109. minetest.register_node("minerdream:slime_"..i, {
  110. tiles = {
  111. "minerdream_slime_"..i.."_top.png",
  112. "minerdream_slime_"..i.."_top.png",
  113. "minerdream_slime_"..i.."_side.png",
  114. "minerdream_slime_"..i.."_side.png",
  115. "minerdream_slime_"..i.."_side.png",
  116. "minerdream_slime_"..i.."_side.png"
  117. },
  118. drawtype = "nodebox",
  119. wield_scale = {x=0.4,y=0.4,z=0.4},
  120. paramtype = "light",
  121. node_box = {
  122. type = "fixed",
  123. fixed = {
  124. {-0.3125, -0.5, -0.3125, 0.3125, 0.3125, 0.3125}, -- NodeBox1
  125. {-0.375, -0.5, -0.3125, 0.375, 0.25, 0.3125}, -- NodeBox2
  126. {-0.3125, -0.5, -0.375, 0.3125, 0.25, 0.375}, -- NodeBox3
  127. {-0.3125, -0.4375, -0.4375, 0.3125, 0.125, 0.4375}, -- NodeBox4
  128. {-0.375, -0.4375, -0.375, 0.375, 0.125, 0.375}, -- NodeBox5
  129. {-0.4375, -0.4375, -0.3125, 0.4375, 0.125, 0.3125}, -- NodeBox6
  130. {-0.25, -0.375, -0.5, 0.25, 0, 0.5}, -- NodeBox7
  131. {-0.5, -0.375, -0.25, 0.5, 0, 0.25}, -- NodeBox8
  132. }
  133. }
  134. })
  135. end
  136. end