Working on weapons

master
npx 2016-03-20 23:21:42 +01:00
parent 557b9925a9
commit 52f8a5a4a3
3 changed files with 83 additions and 19 deletions

View File

@ -53,7 +53,7 @@ dofile(path.."/mese_dragon.lua")
dofile(path.."/rainbow_staff.lua")
dofile(path.."/darts.lua")
dofile(path.."/nssm_materials.lua")
dofile(path.."/kienzan.lua")
--dofile(path.."/kienzan.lua")
--dofile(path.."/kamehameha.lua")
dofile(path.."/nssm_spears.lua")
dofile(path.."/nssm_api.lua")

View File

@ -71,16 +71,18 @@ function nssm:explosion(pos, exp_radius, fire)
local obj_p = obj:getpos()
local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
local damage = 21-dist*5
obj:set_hp(obj:get_hp()-damage)
local damage = -exp_radius*dist+exp_radius^2
obj:set_hp(obj:get_hp()-damage)
if (obj:get_hp() <= 0) then
if (not obj:is_player()) and obj:get_entity_name() ~= "nssm:kamehameha" then
obj:remove()
end
end
--minetest.chat_send_all("HP: "..obj:get_hp())
end
end
--damages blocks around and if necessary put some fire
pos = vector.round(pos) -- voxelmanip doesn't work properly unless pos is rounded ?!?!
local vm = VoxelManip()

View File

@ -30,7 +30,7 @@ function weapons_shot(itemstack, placer, pointed_thing, velocity, name)
return itemstack
end
function default_on_step(self, dtime, name, max_time, damage, dir, not_transparent, vel)
function default_on_step(self, dtime, name, max_time, damage, dir, radius, not_transparent, vel)
local timer = 0
local pos = self.object:getpos()
minetest.register_globalstep(function(dtime)
@ -41,7 +41,7 @@ function default_on_step(self, dtime, name, max_time, damage, dir, not_transpare
end)
--while going around it damages entities
local objects = minetest.env:get_objects_inside_radius(pos, 2)
local objects = minetest.env:get_objects_inside_radius(pos, 0)
for _,obj in ipairs(objects) do
if (obj:is_player()) then
elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item") then
@ -56,14 +56,54 @@ function default_on_step(self, dtime, name, max_time, damage, dir, not_transpare
local n = minetest.env:get_node(pos).name
if n ~=not_transparent then
minetest.env:set_node(pos, {name="air"})
if n ~=not_transparent or not_transparent==nil then
--minetest.env:set_node(pos, {name="air"})
local vec = self.object:getvelocity()
local c=3
local c=vel/10
--calculate how many blocks around need to be removed
local i = nssm:round(math.abs(math.abs(vec.x)-vel)*0.01*c*dir.x)
local j = nssm:round(math.abs(math.abs(vec.y)-vel)*0.01*c*dir.y)
local k = nssm:round(math.abs(math.abs(vec.z)-vel)*0.01*c*dir.z)
local max = 0
local posmax = 0
if max<vec.x then
max = math.abs(vec.x)
posmax = 1
end
if max<vec.y then
max = math.abs(vec.y)
posmax = 2
end
if max<vec.z then
max = math.abs(vec.z)
posmax = 3
end
local i = radius
local j = radius
local k = radius
if dir.x == 0 then
i = 0
end
if dir.y == 0 then
j = 0
end
if dir.z == 0 then
k = 0
end
if posmax==1 then
i = 0
end
if posmax==2 then
j = 0
end
if posmax==3 then
k = 0
end
--local i = nssm:round(math.abs(math.abs(vec.x)-vel)*0.01*c*dir.x)*radius
--local j = nssm:round(math.abs(math.abs(vec.y)-vel)*0.01*c*dir.y)*radius
--local k = nssm:round(math.abs(math.abs(vec.z)-vel)*0.01*c*dir.z)*radius
for dx = -i,i do
for dy= -j,j do
@ -102,9 +142,19 @@ function nssm_register_weapon(name, def)
end,
})
--[[
minetest.register_craft({
output = "nssm:"..name.."_hand",
output = 'nssm:'..name.."_hand",
recipe = {
{'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'},
{'nssm:great_energy_globe', def.material, 'nssm:great_energy_globe'},
{'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'}
}
})
--[[
--this recipe doesn't work for a misterious reason
minetest.register_craft({
output = "nssm:caccamerda",
recipe = {
{
{'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'},
@ -113,32 +163,44 @@ function nssm_register_weapon(name, def)
}
}
})
]]--
]]
end
--function default_on_step(self, pos, node, name, max_time, damage, dir, not_transparent, vel, dtime)
--function default_on_step(self, dtime, name, max_time, damage, dir, not_transparent, vel)
nssm_register_weapon("kamehameha", {
on_step = function(self, dtime)
default_on_step(self, dtime, "kamehameha", 10, 20, default_dir, "default:stone", 30)
default_on_step(self, dtime, "kamehameha", 10, 20, default_dir, 10, "group:cracky", 25)
end,
hit_node = function(self, pos, node)
nssm:explosion(pos, 8, 1)
end,
material = "default:stick",
description = "Kamehameha from DragonBall",
velocity = 30,
velocity = 25,
})
nssm_register_weapon("kienzan", {
on_step = function(self, dtime)
default_on_step(self, dtime, "kienzan", 5, 20, {x=1, y=0, z=1}, 1, nil, 25)
end,
hit_node = function(self, pos, node)
end,
material = "",
description = "Kienzan from DragonBall",
velocity = 25,
})
--[[
minetest.register_craft({
output = "nssm:kamehameha_hand",
output = 'nssm:_hand',
recipe = {
{
{'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'},
{'nssm:great_energy_globe', "default:stick", 'nssm:great_energy_globe'},
{'nssm:great_energy_globe', 'default:stick', 'nssm:great_energy_globe'},
{'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'},
}
}
})
]]
]]--