diff --git a/init.lua b/init.lua index 0ff031a..d0c8e7e 100644 --- a/init.lua +++ b/init.lua @@ -68,7 +68,25 @@ dofile(path .. "/utilities.lua") dofile(path .. "/ui.lua") dofile(path .. "/items.lua") dofile(path .. "/nodes.lua") -dofile(path .. "/sheep.lua") + +-- This gets the list of possible sheep that an enemy can be turned into +if minetest.get_modpath("animalia") then + witches.sheep = {"animalia:sheep"} +elseif minetest.get_modpath("mobs_animal") then + witches.sheep = {} + for key, value in pairs(minetest.registered_entities) do + if string.sub(key, 1, #("mobs_animal:sheep_")) == "mobs_animal:sheep_" then + witches.sheep[#witches.sheep + 1] = key + end + end +else + dofile(path .. "/sheep.lua") + witches.sheep = {} + for _, col in ipairs(witches.sheep_colors) do + witches.sheep[#witches.sheep + 1] = "witches:sheep_" .. col[1] + end +end + dofile(path .. "/magic.lua") dofile(path .. "/cottages.lua") diff --git a/magic.lua b/magic.lua index 4b94d87..8ee1ec4 100644 --- a/magic.lua +++ b/magic.lua @@ -1,5 +1,4 @@ witches.magic = {} -local wsc = witches.sheep_colors local magic_texture = "bubble.png" local magic_animation = nil @@ -136,20 +135,13 @@ end function witches.magic.polymorph(self, target, mob, duration) duration = duration or 0 - local colors = {} local caster_pos = self.object:get_pos() minetest.sound_play(self.sounds.polymorph or "witches_magic02", { pos = caster_pos, gain = 1.0, max_hear_distance = self.sounds and self.sounds.distance or 32 }, true) - - for _, col in ipairs(wsc) do - table.insert(colors,col[1]) - end - local r_sheep = "witches:sheep_"..colors[math.random(#colors)] - mob = mob or r_sheep - + local ent = target:get_luaentity() local ent_pos = ent.object:get_pos() @@ -167,9 +159,10 @@ function witches.magic.polymorph(self, target, mob, duration) witches.magic.effect_area01(vol_ent[1],vol_ent[2],200) - local new_obj = minetest.add_entity(ent_pos, mob) - --local new_ent = new_obj:get_luaentity() - --new_ent.old_mob_name = ent.name + mob = mob or witches.sheep[math.random(1, #witches.sheep)] + if mob then + local new_obj = minetest.add_entity(ent_pos, mob) + end end --volume is a vector! @@ -190,9 +183,9 @@ function witches.magic.splash(self,target,volume,height,node) ) local air_nodes = minetest.find_nodes_in_area(vol[1],vol[2], {"air"}) - + if air_nodes then - for i=1, #air_nodes do + for i=1, #air_nodes do minetest.add_node(air_nodes[i], {name=node}) witches.magic.effect_area01(vol[1],vol[2],100) diff --git a/mod.conf b/mod.conf index e62f136..b889961 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,6 @@ name = witches descriptions = adds witches and their cottages depends = default, mobs -optional_depends = protector + +optional_depends = protector, animalia, mobs_animal +