Merge branch 'use_animal_mods' into 'master'
Use animal mods if available for sheep See merge request freelikegnu/witches!1master
commit
94d42cbdd9
20
init.lua
20
init.lua
|
@ -68,7 +68,25 @@ dofile(path .. "/utilities.lua")
|
||||||
dofile(path .. "/ui.lua")
|
dofile(path .. "/ui.lua")
|
||||||
dofile(path .. "/items.lua")
|
dofile(path .. "/items.lua")
|
||||||
dofile(path .. "/nodes.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 .. "/magic.lua")
|
||||||
|
|
||||||
dofile(path .. "/cottages.lua")
|
dofile(path .. "/cottages.lua")
|
||||||
|
|
21
magic.lua
21
magic.lua
|
@ -1,5 +1,4 @@
|
||||||
witches.magic = {}
|
witches.magic = {}
|
||||||
local wsc = witches.sheep_colors
|
|
||||||
|
|
||||||
local magic_texture = "bubble.png"
|
local magic_texture = "bubble.png"
|
||||||
local magic_animation = nil
|
local magic_animation = nil
|
||||||
|
@ -136,20 +135,13 @@ end
|
||||||
|
|
||||||
function witches.magic.polymorph(self, target, mob, duration)
|
function witches.magic.polymorph(self, target, mob, duration)
|
||||||
duration = duration or 0
|
duration = duration or 0
|
||||||
local colors = {}
|
|
||||||
local caster_pos = self.object:get_pos()
|
local caster_pos = self.object:get_pos()
|
||||||
minetest.sound_play(self.sounds.polymorph or "witches_magic02", {
|
minetest.sound_play(self.sounds.polymorph or "witches_magic02", {
|
||||||
pos = caster_pos,
|
pos = caster_pos,
|
||||||
gain = 1.0,
|
gain = 1.0,
|
||||||
max_hear_distance = self.sounds and self.sounds.distance or 32
|
max_hear_distance = self.sounds and self.sounds.distance or 32
|
||||||
}, true)
|
}, 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 = target:get_luaentity()
|
||||||
local ent_pos = ent.object:get_pos()
|
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)
|
witches.magic.effect_area01(vol_ent[1],vol_ent[2],200)
|
||||||
|
|
||||||
local new_obj = minetest.add_entity(ent_pos, mob)
|
mob = mob or witches.sheep[math.random(1, #witches.sheep)]
|
||||||
--local new_ent = new_obj:get_luaentity()
|
if mob then
|
||||||
--new_ent.old_mob_name = ent.name
|
local new_obj = minetest.add_entity(ent_pos, mob)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
--volume is a vector!
|
--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"})
|
local air_nodes = minetest.find_nodes_in_area(vol[1],vol[2], {"air"})
|
||||||
|
|
||||||
if air_nodes then
|
if air_nodes then
|
||||||
for i=1, #air_nodes do
|
for i=1, #air_nodes do
|
||||||
|
|
||||||
minetest.add_node(air_nodes[i], {name=node})
|
minetest.add_node(air_nodes[i], {name=node})
|
||||||
witches.magic.effect_area01(vol[1],vol[2],100)
|
witches.magic.effect_area01(vol[1],vol[2],100)
|
||||||
|
|
Loading…
Reference in New Issue