Modified the attack of the phoenix and the envy sword

This commit is contained in:
npx 2017-03-24 00:11:49 +01:00
parent 19e251efc6
commit 2b574182da
2 changed files with 62 additions and 52 deletions

View File

@ -69,6 +69,7 @@ mobs:register_mob("nssm:phoenix", {
local p = self.attack:getpos()
local s = self.object:getpos()
local vel = vector.subtract(p,s)
set_animation(self, "shoot")
minetest.add_particlespawner(
125, --amount
@ -87,23 +88,35 @@ mobs:register_mob("nssm:phoenix", {
"phoenix_fire.png" --texture
)
--local dir = placer:get_look_dir()
--local playerpos = placer:getpos()
local obj = minetest.add_entity(s, "nssm:phoenix_dart")
local ran = math.random(7,14)/10
local vec = vector.multiply(vel, ran)
obj:setvelocity(vec)
minetest.after(0.5, function()
local p = self.attack:getpos()
local vel = vector.subtract(p,s)
local obj = minetest.add_entity(s, "nssm:phoenix_dart")
local ran = math.random(7,14)/10
local vec = vector.multiply(vel, ran)
obj:setvelocity(vec)
if self.attack then
local p = self.attack:getpos()
local vel = vector.subtract(p,s)
local obj = minetest.add_entity(s, "nssm:phoenix_dart")
local ran = math.random(7,14)/10
local vec = vector.multiply(vel, ran)
obj:setvelocity(vec)
end
end)
end,
do_custom = function (self)
--minetest.chat_send_all(s.y.."-"..p.y.."="..(s.y-p.y))
if self.state == "attack" then
if self.attack then
local s = self.object:getpos()
local p = self.attack:getpos()
if (s.y - p.y ) < 10 then
local v = self.object:getvelocity()
v.y = 10
self.object:setvelocity(v)
end
end
end
end,
})
@ -116,16 +129,23 @@ minetest.register_entity("nssm:phoenix_dart", {
if os.time() - self.timer > 4 then
self.object:remove()
end
local all_objects = minetest.get_objects_inside_radius(self.object:getpos(), 1)
local p = self.object:getpos()
local all_objects = minetest.get_objects_inside_radius(p, 1)
local players = {}
local _,obj
for _,obj in ipairs(all_objects) do
if obj:is_player() then
obj:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 1}
damage_groups = {fleshy = 7}
}, nil)
self.object:remove()
end
end
local node = minetest.get_node(p).name
if node ~= "air" then
self.object:remove()
end
end,
})

View File

@ -1242,49 +1242,39 @@ minetest.register_tool("nssm:sword_of_envy", {
if player_inv:is_empty('main') then
--minetest.chat_send_all("Inventory empty")
else
local found = 0
for i = 1,32 do
local items = player_inv:get_stack('main', i)
local n = items:get_name()
if n == "nssm:energy_globe" then
found = i
break
end
end
if found == 0 then
minetest.chat_send_player(pname, "You haven't got any Energy Globe!")
return
else
if (obj:is_player()) then
--minetest.chat_send_all("Giocatore")
if (obj:get_player_name()~=dropper:get_player_name()) then
local hpp = obj:get_hp()
local hp_num = nil
if (obj:is_player()) and (obj:get_player_name()~=dropper:get_player_name()) then
hp_num = obj:get_hp()
else
if obj:get_luaentity() and (obj:get_luaentity().health) then
hp_num = obj:get_luaentity().health
end
end
if hp_num ~= nil then
minetest.chat_send_all("hp_num = "..hp_num)
local stack = {name="nssm:life_energy", count=hp_num, wear=0, metadata=""}
if player_inv:contains_item("main", stack) then
--minetest.chat_send_all("trovato!")
if obj:is_player() and (obj:get_player_name()~=dropper:get_player_name()) then
obj:set_hp(dropper:get_hp())
dropper:set_hp(hpp)
flag = 1
local items = player_inv:get_stack('main', found)
items:take_item()
player_inv:set_stack('main', found, items)
end
else
if (obj:get_luaentity().health) then
local hpp = obj:get_luaentity().health
obj:get_luaentity().health = dropper:get_hp()
if hpp > 20 then
dropper:set_hp(20)
else
dropper:set_hp(hpp)
dropper:set_hp(hp_num)
else
if obj:get_luaentity() and (obj:get_luaentity().health) then
obj:get_luaentity().health = dropper:get_hp()
if hp_num > 20 then
dropper:set_hp(20)
else
dropper:set_hp(hp_num)
end
end
check_for_death(obj:get_luaentity())
flag = 1
end
local items = player_inv:get_stack('main', found)
items:take_item()
player_inv:set_stack('main', found, items)
end
end
end
player_inv:remove_item("main", stack)
else
minetest.chat_send_player(dropper:get_player_name(), "You haven't enough life energy!")
end
end
end
end
end