Add files via upload
|
@ -0,0 +1,40 @@
|
|||
License: CC0
|
||||
Name: bows
|
||||
Created by: AiTechEye
|
||||
Version: 2
|
||||
|
||||
A very easy bow api mod with arrows
|
||||
|
||||
Load a bow:
|
||||
place a arrow left of the bow + use it
|
||||
|
||||
Bows / levels:
|
||||
Wooded
|
||||
Stone
|
||||
Steel
|
||||
Bronze
|
||||
Osidian
|
||||
Mese
|
||||
Diamond
|
||||
Rainbow
|
||||
Admin: bows:bow_admin (unlimited + very high level)
|
||||
|
||||
Arrows / level:
|
||||
Wooded
|
||||
Steel
|
||||
Gold
|
||||
Diamond
|
||||
Dig: digs the block it hits.
|
||||
Fire: spawning fire on the block or object it hits
|
||||
Build: placing a block from the right stack of the bow.
|
||||
Toxic: keep hurting after it hits.
|
||||
Tetanus: makes you cant move (will not work with other arrows)
|
||||
TNT: explosion
|
||||
Admin: bows:arrow_admin (always kill when hits)
|
||||
Nitrogen: freeze
|
||||
Nitrogen: TNT: freeze explosion
|
||||
Radioactive, keep hurting everything around the hit, makes them radioactive too in a unlimited range as long there are something more to affect.
|
||||
Nuke: massive explosion
|
||||
|
||||
|
||||
The target gives a mesecon signal when an arrow hits it.
|
|
@ -0,0 +1,158 @@
|
|||
bows.nothing=function(self,target,hp,user,lastpos)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.on_hit_object=function(self,target,hp,user,lastpos)
|
||||
local hp2=target:get_hp()-hp
|
||||
target:set_hp(hp2)
|
||||
target:punch(target,1,{full_punch_interval=1,damage_groups={fleshy=4}},nil)
|
||||
if hp2>0 then
|
||||
local pos=self.object:getpos()
|
||||
local opos=target:getpos()
|
||||
local dir = user:get_look_dir()
|
||||
self.object:set_attach(target, "", {x=(opos.x-pos.x)*4,y=(pos.y-opos.y)*4,z=(pos.z-opos.z)*4},{x=0,y=-90,z=0})
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
bows.on_hit_node=function(self,pos,user,lastpos)
|
||||
local node=minetest.get_node(pos)
|
||||
if node then
|
||||
self.node=minetest.get_node(pos).name
|
||||
self.node_pos={x=pos.x,y=pos.y,z=pos.z}
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[minetest.get_node(pos).name].node_box then
|
||||
|
||||
local mpos={x=(pos.x-lastpos.x),y=(pos.y-lastpos.y),z=(pos.z-lastpos.z)}
|
||||
local npos={x=bows.rnd(pos.x),y=bows.rnd(pos.y),z=bows.rnd(pos.z)}
|
||||
local m={x=-0.6,y=-0.6,z=-0.6}
|
||||
local bigest={x=mpos.x,y=mpos.y,z=mpos.z}
|
||||
if bigest.x<0 then bigest.x=bigest.x*-1 m.x=0.6 end
|
||||
if bigest.y<0 then bigest.y=bigest.y*-1 m.y=0.6 end
|
||||
if bigest.z<0 then bigest.z=bigest.z*-1 m.z=0.6 end
|
||||
local b=math.max(bigest.x,bigest.y,bigest.z)
|
||||
if b==bigest.x then
|
||||
pos.x=npos.x+m.x
|
||||
elseif b==bigest.y then
|
||||
pos.y=npos.y+m.y
|
||||
else
|
||||
pos.z=npos.z+m.z
|
||||
end
|
||||
self.object:setpos(pos)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
bows.rnd=function(r)
|
||||
return math.floor(r+ 0.5)
|
||||
end
|
||||
|
||||
bows.arrow_remove=function(self)
|
||||
if self.object:get_attach() then self.object:set_detach() end
|
||||
if self.target then self.target:punch(self.object, 1,{full_punch_interval=1,damage_groups={fleshy=4}}, nil) end
|
||||
self.object:set_hp(0)
|
||||
self.object:punch(self.object, 1,{full_punch_interval=1.0,damage_groups={fleshy=4}}, nil)
|
||||
return self
|
||||
end
|
||||
|
||||
minetest.register_entity("bows:arrow",{
|
||||
hp_max = 10,
|
||||
visual="wielditem",
|
||||
visual_size={x=.20,y=.20},
|
||||
collisionbox = {0,0,0,0,0,0},
|
||||
physical=false,
|
||||
textures={"air"},
|
||||
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
if not self.target then return self end
|
||||
if not self.hp then self.hp=self.object:get_hp() end
|
||||
local hp=self.object:get_hp()
|
||||
local hurt=self.hp-self.object:get_hp()
|
||||
self.hp=self.object:get_hp()
|
||||
self.target:set_hp(self.target:get_hp()-hurt)
|
||||
self.target:punch(self.object, hurt,{full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:sword_wood", nil)
|
||||
if hurt>100 or hp<=hurt then
|
||||
self.target:set_detach()
|
||||
self.target:setvelocity({x=0, y=4, z=0})
|
||||
self.target:setacceleration({x=0, y=-10, z=0})
|
||||
self.on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir) end
|
||||
bows.arrow_remove(self)
|
||||
end
|
||||
return self
|
||||
end,
|
||||
on_activate = function(self, staticdata)
|
||||
if bows.tmp and bows.tmp.arrow ~= nil then
|
||||
self.arrow=bows.tmp.arrow
|
||||
self.user=bows.tmp.user
|
||||
self.name=bows.tmp.name
|
||||
self.dmg=bows.registed_arrows[self.name].damage
|
||||
bows.tmp=nil
|
||||
self.object:set_properties({textures={self.arrow}})
|
||||
else
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
stuck=false,
|
||||
bow_arrow=true,
|
||||
timer=20,
|
||||
timer2=0,
|
||||
timer3=0,
|
||||
x=0,
|
||||
y=0,
|
||||
z=0,
|
||||
on_step= function(self, dtime)
|
||||
self.timer=self.timer-dtime
|
||||
self.timer3=self.timer3+dtime
|
||||
if self.timer3<self.timer2 then return self end
|
||||
self.timer3=0
|
||||
if self.stuck then
|
||||
if self.node and minetest.get_node(self.node_pos).name~=self.node then
|
||||
minetest.add_item(self.object:getpos(),self.name .." 1"):setvelocity({x = math.random(-0.5, 0.5),y=0.5,z = math.random(-0.5, 0.5)})
|
||||
self.timer=-1
|
||||
elseif self.node==nil and not self.object:get_attach() then
|
||||
minetest.add_item(self.object:getpos(),self.name .." 1"):setvelocity({x = math.random(-0.5, 0.5),y=0.5,z = math.random(-0.5, 0.5)})
|
||||
self.timer=-1
|
||||
end
|
||||
if self.timer<0 then
|
||||
bows.arrow_remove(self)
|
||||
end
|
||||
return self
|
||||
end
|
||||
local pos=self.object:getpos()
|
||||
local no=minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if not no then bows.arrow_remove(self) return self end
|
||||
if (self.user==nil or self.timer<16 ) or no.walkable then
|
||||
if bows.mesecons and minetest.get_node(pos).name=="bows:target" then
|
||||
|
||||
pos={x=bows.rnd(pos.x),y=bows.rnd(pos.y),z=bows.rnd(pos.z)}
|
||||
|
||||
mesecon.receptor_on(pos)
|
||||
minetest.get_node_timer(pos):start(2)
|
||||
end
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.stuck=true
|
||||
self.timer2=0.2
|
||||
bows.registed_arrows[self.name].on_hit_node(self,pos,self.user,{x=self.x,y=self.y,z=self.z})
|
||||
minetest.sound_play(bows.registed_arrows[self.name].on_hit_sound, {pos=pos, gain = 1.0, max_hear_distance = 7})
|
||||
return self
|
||||
end
|
||||
self.x=pos.x
|
||||
self.y=pos.y
|
||||
self.z=pos.z
|
||||
bows.registed_arrows[self.name].on_step(self,dtime,self.user,pos,{x=self.x,y=self.y,z=self.z})
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if ob and ((bows.pvp and ob:is_player() and ob:get_player_name()~=self.user:get_player_name()) or (ob:get_luaentity() and ob:get_luaentity().physical and ob:get_luaentity().bow_arrow==nil and ob:get_luaentity().name~="__builtin:item" )) then
|
||||
self.object:setvelocity({x=0, y=0, z=0})
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.stuck=true
|
||||
self.timer2=0.2
|
||||
bows.on_hit_object(self,ob,self.dmg,self.user,{x=self.x,y=self.y,z=self.z})
|
||||
bows.registed_arrows[self.name].on_hit_object(self,ob,self.dmg,self.user,{x=self.x,y=self.y,z=self.z})
|
||||
minetest.sound_play(bows.registed_arrows[self.name].on_hit_sound, {pos=pos, gain = 1.0, max_hear_distance = 7})
|
||||
return self
|
||||
end
|
||||
end
|
||||
return self
|
||||
end,
|
||||
})
|
After Width: | Height: | Size: 238 KiB |
|
@ -0,0 +1 @@
|
|||
nitroglycerine?
|
|
@ -0,0 +1,36 @@
|
|||
-- useful functions if you want to use this api.. all other functions are automatic used (no idea to use them in your code)
|
||||
|
||||
bows.arrow_remove(self) -- remove the arrow
|
||||
self.target= target -- punching its target when it self is punched
|
||||
self.node -- hited node
|
||||
self.node_pos -- hited node pos
|
||||
|
||||
|
||||
bows.register_bow("bow_test",{
|
||||
description="Test bow",
|
||||
texture="bows_bow.png",
|
||||
texture_loaded="bows_bow_loaded.png",
|
||||
uses=50,
|
||||
level=1,-- (19 is double speed)
|
||||
craft={
|
||||
{"","group:stick","farming:cotton"},
|
||||
{"group:stick","","farming:cotton"},
|
||||
{"","group:stick","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_test",{
|
||||
description="Test arrow",
|
||||
texture="bows_arrow_wood.png",
|
||||
damage=5,
|
||||
craft_count=8,-- count of items from craft
|
||||
craft={
|
||||
{"default:flint","group:stick","group:leaves"}
|
||||
}
|
||||
on_hit_node=function(self,pos,user,lastpos)
|
||||
end,
|
||||
on_hit_object=function(self,target,hp,user,lastpos)
|
||||
end,
|
||||
on_step=function(self,dtime,user,pos,lastpos)
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,144 @@
|
|||
bows={
|
||||
nuke=true,
|
||||
cluser=true,
|
||||
pvp=minetest.setting_getbool("enable_pvp") or nil,
|
||||
nitroglycerine=minetest.get_modpath("nitroglycerine")~=nil,
|
||||
creative=minetest.setting_getbool("creative_mode"),
|
||||
mesecons=minetest.get_modpath("mesecons"),
|
||||
registed_arrows={},
|
||||
registed_bows={},
|
||||
}
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "group:bow",
|
||||
burntime = 3,
|
||||
})
|
||||
|
||||
bows.register_arrow=function(name,def)
|
||||
if name==nil or name=="" then return false end
|
||||
|
||||
def.damage = def.damage or 0
|
||||
def.name = "bows:".. name
|
||||
def.level = def.level or 1
|
||||
def.on_hit_object = def.on_hit_object or bows.nothing
|
||||
def.on_hit_node = def.on_hit_node or bows.on_hit_node
|
||||
def.on_hit_sound= def.on_hit_sound or "default_dig_dig_immediate"
|
||||
def.on_step = def.on_step or bows.nothing
|
||||
|
||||
bows.registed_arrows[def.name]=def
|
||||
|
||||
minetest.register_craftitem("bows:".. name, {
|
||||
description = def.description or name,
|
||||
inventory_image = def.texture or "bows_arrow_wooden.png",
|
||||
groups = {arrow=1}
|
||||
})
|
||||
if def.craft then
|
||||
def.craft_count= def.craft_count or 4
|
||||
minetest.register_craft({
|
||||
output = def.name .." " .. def.craft_count,
|
||||
recipe = def.craft
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
bows.register_bow=function(name,def)
|
||||
if name==nil or name=="" then return false end
|
||||
|
||||
def.replace = "bows:" .. name .."_loaded"
|
||||
def.name = "bows:".. name
|
||||
def.uses = def.uses-1 or 49
|
||||
def.shots = def.shots or 1
|
||||
bows.registed_bows[def.replace]=def
|
||||
|
||||
minetest.register_tool(def.name, {
|
||||
description = def.description or name,
|
||||
inventory_image = def.texture or "bows_bow.png",
|
||||
on_use =bows.load,
|
||||
groups = {bow=1,stick=1},
|
||||
})
|
||||
minetest.register_tool(def.replace, {
|
||||
description = def.description or name,
|
||||
inventory_image = def.texture_loaded or "bows_bow_loaded.png",
|
||||
on_use =bows.shoot,
|
||||
groups = {bow=1,stick=1,not_in_creative_inventory=1},
|
||||
})
|
||||
if def.craft then
|
||||
minetest.register_craft({output = def.name,recipe = def.craft})
|
||||
end
|
||||
def.craft=nil
|
||||
end
|
||||
|
||||
bows.load=function(itemstack, user, pointed_thing)
|
||||
local inv=user:get_inventory()
|
||||
local index=user:get_wield_index()-1
|
||||
local arrow=inv:get_stack("main", index)
|
||||
if minetest.get_item_group(arrow:get_name(), "arrow")==0 then return itemstack end
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item.metadata)
|
||||
local shots=bows.registed_bows[item.name .. "_loaded"].shots
|
||||
if bows.creative==false then
|
||||
local c=arrow:get_count()-shots
|
||||
if c<0 then
|
||||
shots=arrow:get_count()
|
||||
c=0
|
||||
end
|
||||
inv:set_stack("main",index,ItemStack(arrow:get_name() .. " " .. c))
|
||||
end
|
||||
meta={arrow=arrow:get_name(),shots=shots}
|
||||
item.metadata=minetest.serialize(meta)
|
||||
item.meta=minetest.serialize(meta)
|
||||
item.name=item.name .. "_loaded"
|
||||
itemstack:replace(item)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
bows.shoot=function(itemstack, user, pointed_thing)
|
||||
local item=itemstack:to_table()
|
||||
local meta=minetest.deserialize(item.metadata)
|
||||
if (not (meta and meta.arrow)) or (not bows.registed_arrows[meta.arrow]) then
|
||||
return itemstack
|
||||
end
|
||||
local name=itemstack:get_name()
|
||||
local replace=bows.registed_bows[name].name
|
||||
local ar=bows.registed_bows[name].uses
|
||||
local wear=bows.registed_bows[name].uses
|
||||
local level=19 + bows.registed_bows[name].level
|
||||
local shots=meta.shots or 1
|
||||
|
||||
item.arrow=""
|
||||
item.metadata=minetest.serialize(meta)
|
||||
item.name=replace
|
||||
itemstack:replace(item)
|
||||
if bows.creative==false then
|
||||
itemstack:add_wear(65535/wear)
|
||||
end
|
||||
for i=0,shots-1,1 do
|
||||
minetest.after(0.05*i, function(level,user,meta)
|
||||
bows.tmp = {}
|
||||
bows.tmp.arrow = meta.arrow
|
||||
bows.tmp.user = user
|
||||
bows.tmp.name=meta.arrow
|
||||
bows.tmp.shots=shots
|
||||
|
||||
local pos = user:getpos()
|
||||
local dir = user:get_look_dir()
|
||||
|
||||
local x=math.random(-1,1)*0.1
|
||||
local y=math.random(-1,1)*0.1
|
||||
local z=math.random(-1,1)*0.1
|
||||
|
||||
local e=minetest.add_entity({x=pos.x+x,y=pos.y+1.5+y,z=pos.z+z}, "bows:arrow")
|
||||
e:setvelocity({x=dir.x*level, y=dir.y*level, z=dir.z*level})
|
||||
e:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
|
||||
e:setyaw(user:get_look_yaw()+math.pi)
|
||||
minetest.sound_play("bows_shoot", {pos=pos})
|
||||
end,level,user,meta)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath("bows") .. "/arrow.lua")
|
||||
dofile(minetest.get_modpath("bows") .. "/items_functions.lua")
|
||||
dofile(minetest.get_modpath("bows") .. "/items.lua")
|
|
@ -0,0 +1,417 @@
|
|||
minetest.register_node("bows:rainbow", {
|
||||
description = "Rainbow block",
|
||||
tiles = {"bows_rainbow_block.png"},
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2,mesecon = 2},
|
||||
drawtype="nodebox",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "bows:rainbow",
|
||||
recipe = {
|
||||
{"","dye:green",""},
|
||||
{"wool:red","dye:blue","wool:cyan"},
|
||||
{"","dye:magenta",""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("bows:target", {
|
||||
description = "Target",
|
||||
tiles = {"default_wood.png","default_wood.png","default_wood.png","default_wood.png","default_wood.png","default_wood.png^bows_target.png","default_wood.png"},
|
||||
groups = {choppy = 2, oddly_breakable_by_hand = 2,mesecon = 2},
|
||||
drawtype="nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.1875, 0.375, 0.5, 0.1875, 0.5},
|
||||
{-0.4375, -0.25, 0.375, 0.4375, 0.25, 0.5},
|
||||
{-0.375, -0.375, 0.375, 0.375, 0.375, 0.5},
|
||||
{-0.25, -0.4375, 0.375, 0.25, 0.4375, 0.5},
|
||||
{-0.125, -0.5, 0.375, 0.125, 0.5, 0.5},
|
||||
}
|
||||
},
|
||||
paramtype2="facedir",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
mesecons = {receptor = {state = "off"}},
|
||||
on_timer = function (pos, elapsed)
|
||||
mesecon.receptor_off(pos)
|
||||
return false
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bows:target",
|
||||
recipe = {
|
||||
{"","group:wood",""},
|
||||
{"group:wood","group:wood","group:wood"},
|
||||
{"","group:wood",""}
|
||||
}
|
||||
})
|
||||
minetest.register_craft({output = "default:flint",recipe = {{"default:gravel"},}})
|
||||
minetest.register_craft({output = "farming:cotton 4",recipe = {{"group:wool"},}})
|
||||
|
||||
bows.register_bow("bow_wood",{
|
||||
description="Wooden bow",
|
||||
texture="bows_bow.png",
|
||||
texture_loaded="bows_bow_loaded.png",
|
||||
uses=50,
|
||||
level=1,
|
||||
craft={
|
||||
{"","group:stick","farming:cotton"},
|
||||
{"group:stick","","farming:cotton"},
|
||||
{"","group:stick","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_stone",{
|
||||
description="Stone bow",
|
||||
texture="bows_bow_stone.png",
|
||||
texture_loaded="bows_bow_loaded_stone.png",
|
||||
uses=70,
|
||||
level=4,
|
||||
craft={
|
||||
{"","group:stone","farming:cotton"},
|
||||
{"group:stone","","farming:cotton"},
|
||||
{"","group:stone","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_steel",{
|
||||
description="Steel bow",
|
||||
texture="bows_bow_steel.png",
|
||||
texture_loaded="bows_bow_loaded_steel.png",
|
||||
uses=140,
|
||||
level=8,
|
||||
craft={
|
||||
{"","default:steel_ingot","farming:cotton"},
|
||||
{"default:steel_ingot","","farming:cotton"},
|
||||
{"","default:steel_ingot","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_bronze",{
|
||||
description="Bronze bow",
|
||||
texture="bows_bow_bronze.png",
|
||||
texture_loaded="bows_bow_loaded_bronze.png",
|
||||
uses=280,
|
||||
level=10,
|
||||
craft={
|
||||
{"","default:bronze_ingot","farming:cotton"},
|
||||
{"default:bronze_ingot","","farming:cotton"},
|
||||
{"","default:bronze_ingot","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_obsidian",{
|
||||
description="Obsidian bow",
|
||||
texture="bows_bow_ob.png",
|
||||
texture_loaded="bows_bow_loaded_ob.png",
|
||||
uses=400,
|
||||
level=11,
|
||||
craft={
|
||||
{"","default:obsidian","farming:cotton"},
|
||||
{"default:obsidian","","farming:cotton"},
|
||||
{"","default:obsidian","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_mese",{
|
||||
description="Mese bow",
|
||||
texture="bows_bow_mese.png",
|
||||
texture_loaded="bows_bow_loaded_mese.png",
|
||||
uses=500,
|
||||
level=13,
|
||||
craft={
|
||||
{"","default:mese_crystal","farming:cotton"},
|
||||
{"default:mese_crystal","","farming:cotton"},
|
||||
{"","default:mese_crystal","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_diamond",{
|
||||
description="Diamond bow",
|
||||
texture="bows_bow_diamond.png",
|
||||
texture_loaded="bows_bow_loaded_diamond.png",
|
||||
uses=800,
|
||||
level=19,
|
||||
craft={
|
||||
{"","default:diamond","farming:cotton"},
|
||||
{"default:diamond","","farming:cotton"},
|
||||
{"","default:diamond","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_rainbow",{
|
||||
description="Rainbow bow",
|
||||
texture="bows_bow_rain.png",
|
||||
texture_loaded="bows_bow_loaded_rain.png",
|
||||
uses=1100,
|
||||
level=19,
|
||||
craft={
|
||||
{"","bows:rainbow","farming:cotton"},
|
||||
{"bows:rainbow","","farming:cotton"},
|
||||
{"","bows:rainbow","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_admin",{
|
||||
description="Admin bow (admin arrows = bows:arrow_admin)",
|
||||
texture="bows_bow_admin.png",
|
||||
texture_loaded="bows_bow_loaded_admin.png",
|
||||
level=39,
|
||||
uses=0,
|
||||
})
|
||||
|
||||
|
||||
bows.register_arrow("arrow",{
|
||||
description="Arrow",
|
||||
texture="bows_arrow_wood.png",
|
||||
damage=5,
|
||||
craft_count=8,
|
||||
craft={{"default:flint","group:stick","group:leaves"},}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_admin",{
|
||||
description="Admin arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#ea00cccc",
|
||||
damage=9000,
|
||||
on_hit_object=bows.arrow_admin_object,
|
||||
on_hit_node=bows.arrow_remove,
|
||||
})
|
||||
minetest.override_item("bows:arrow_admin", {groups = {arrow=1,not_in_creative_inventory=1}})
|
||||
|
||||
|
||||
bows.register_arrow("arrow_steel",{
|
||||
description="Steel arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#FFFFFFcc",
|
||||
damage=8,
|
||||
craft_count=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:steel_ingot","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_gold",{
|
||||
description="Gold arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#d7c633cc",
|
||||
damage=10,
|
||||
craft_count=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:gold_ingot","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_mese",{
|
||||
description="Mese arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#e3ff00cc",
|
||||
damage=12,
|
||||
craft_count=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:mese_crystal","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_diamond",{
|
||||
description="Diamond arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#15d7c2cc",
|
||||
damage=15,
|
||||
craft_count=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:diamond","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
bows.register_arrow("arrow_fire",{
|
||||
description="Fire arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#ffb400cc",
|
||||
damage=10,
|
||||
craft_count=1,
|
||||
on_hit_node=bows.arrow_fire,
|
||||
on_hit_object=bows.arrow_fire_object,
|
||||
craft={
|
||||
{"group:arrow","default:torch"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_build",{
|
||||
description="Build arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#33336677",
|
||||
on_hit_node=bows.arrow_build,
|
||||
craft_count=8,
|
||||
damage=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:obsidian_shard","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"}
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_dig",{
|
||||
description="Dig arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#333333aa",
|
||||
on_hit_node=bows.arrow_dig,
|
||||
craft_count=16,
|
||||
damage=8,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","default:pick_steel","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"}
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_toxic",{
|
||||
description="Toxic arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#66aa11aa",
|
||||
on_hit_object=bows.arrow_toxic,
|
||||
craft_count=1,
|
||||
damage=0,
|
||||
craft={
|
||||
{"group:arrow","default:papyrus"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_Tetanus",{
|
||||
description="Tetanus arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#aa5500aa",
|
||||
on_hit_object=bows.arrow_tetanus,
|
||||
craft_count=4,
|
||||
damage=2,
|
||||
craft={
|
||||
{"","group:arrow",""},
|
||||
{"group:arrow","bucket:bucket_water","group:arrow"},
|
||||
{"","group:arrow",""}
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_rainbow",{
|
||||
description="Rainbow arrow",
|
||||
texture="bows_arrow_wood.png^bows_rainbow.png",
|
||||
craft_count=8,
|
||||
damage=11,
|
||||
craft={
|
||||
{"group:arrow","group:arrow","group:arrow"},
|
||||
{"group:arrow","bows:rainbow","group:arrow"},
|
||||
{"group:arrow","group:arrow","group:arrow"}
|
||||
},
|
||||
on_step=bows.arrow_rainbow_step,
|
||||
on_hit_object=bows.arrow_rainbow_object
|
||||
})
|
||||
|
||||
|
||||
if bows.nitroglycerine then
|
||||
bows.register_arrow("arrow_tnt",{
|
||||
description="TNT arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#aa0000aa",
|
||||
on_hit_object=bows.arrow_tnt_object,
|
||||
on_hit_node=bows.arrow_tnt_node,
|
||||
craft_count=1,
|
||||
craft={{"default:gravel","group:arrow","default:coal_lump"},
|
||||
}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_cooltnt",{
|
||||
description="Nitrogen TNT arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#49f5ffaa",
|
||||
on_hit_object=bows.arrow_cooltnt_object,
|
||||
on_hit_node=bows.arrow_cooltnt_node,
|
||||
craft_count=1,
|
||||
damage=0,
|
||||
craft={{"default:ice","bows:arrow_tnt"}}
|
||||
})
|
||||
|
||||
bows.register_arrow("arrow_nitrogen",{
|
||||
description="Nitrogen arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#00c482aa",
|
||||
on_hit_object=bows.arrow_nitrogen_object,
|
||||
craft_count=4,
|
||||
damage=0,
|
||||
craft={{"default:ice","group:arrow","default:coal_lump"}},
|
||||
})
|
||||
|
||||
if bows.cluser then
|
||||
bows.register_arrow("arrow_tnt_cluser",{
|
||||
description="TNT cluser arrow",
|
||||
texture="bows_arrow_wood.png^[colorize:#aa00aaaa",
|
||||
on_hit_object=bows.arrow_tnt_cluster_object,
|
||||
on_hit_node=bows.arrow_tnt_cluster_node,
|
||||
craft_count=1,
|
||||
craft={ {"default:coal_lump","default:coal_lump","default:coal_lump"},
|
||||
{"default:gravel","group:arrow","default:coal_lump"},
|
||||
{"default:coal_lump","default:coal_lump","default:coal_lump"}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
bows.register_arrow("arrow_radioactive",{
|
||||
description="Radioactive arrow",
|
||||
texture="bows_nuke.png^bows_arrow_wood.png^[colorize:#aaff00aa",
|
||||
on_hit_object=bows.arrow_radioactive_object,
|
||||
on_hit_node=bows.arrow_radioactive_node,
|
||||
craft_count=3,
|
||||
damage=10,
|
||||
craft={ {"default:copper_lump","default:mese_crystal_fragment","default:copper_lump"},
|
||||
{"default:mese_crystal_fragment","group:arrow","default:mese_crystal_fragment"},
|
||||
{"default:copper_lump","default:mese_crystal_fragment","default:copper_lump"}
|
||||
}
|
||||
})
|
||||
|
||||
if bows.nuke then
|
||||
bows.register_arrow("arrow_nuke",{
|
||||
description="Nuke arrow",
|
||||
texture="bows_nuke.png^bows_arrow_wood.png",
|
||||
on_hit_object=bows.arrow_nuke_object,
|
||||
on_hit_node=bows.arrow_nuke_node,
|
||||
craft_count=1,
|
||||
damage=0,
|
||||
craft={ {"","default:coalblock",""},
|
||||
{"default:coalblock","group:arrow","default:coalblock"},
|
||||
{"","default:coalblock",""}},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
bows.register_bow("bow_triple_steel",{
|
||||
description="Steel triple bow",
|
||||
texture="bows_bow_triple_steel.png",
|
||||
texture_loaded="bows_bow_loaded_triple_steel.png",
|
||||
uses=500,
|
||||
level=8,
|
||||
shots=3,
|
||||
craft={
|
||||
{"","default:steel_ingot","farming:cotton"},
|
||||
{"default:steelblock","","farming:cotton"},
|
||||
{"","default:steel_ingot","farming:cotton"}
|
||||
},
|
||||
})
|
||||
|
||||
bows.register_bow("bow_quintuple_mese",{
|
||||
description="Mese quintuple bow",
|
||||
texture="bows_bow_quintuple_mese.png",
|
||||
texture_loaded="bows_bow_loaded_quintuple_mese.png",
|
||||
uses=1500,
|
||||
level=8,
|
||||
shots=5,
|
||||
craft={
|
||||
{"","default:mese_crystal","farming:cotton"},
|
||||
{"default:mese","","farming:cotton"},
|
||||
{"","default:mese_crystal","farming:cotton"}
|
||||
},
|
||||
})
|
||||
bows.register_bow("bow_hail_admin",{
|
||||
description="Admin hail bow (admin arrows = bows:arrow_admin)",
|
||||
texture="bows_bow_hail_admin.png",
|
||||
texture_loaded="bows_bow_loaded_hail_admin.png",
|
||||
level=39,
|
||||
shots=34,
|
||||
uses=0,
|
||||
})
|
|
@ -0,0 +1,418 @@
|
|||
|
||||
bows.arrow_dig=function(self,pos,user,lastpos)
|
||||
minetest.node_dig(pos, minetest.get_node(pos), user)
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
bows.arrow_fire_object=function(self,target,hp,user,lastpos)
|
||||
bows.arrow_fire(self,lastpos,user,target:getpos())
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_fire=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local node=minetest.get_node(lastpos).name
|
||||
if minetest.is_protected(lastpos, name) then
|
||||
minetest.chat_send_player(name, minetest.pos_to_string(lastpos) .." is protected")
|
||||
elseif minetest.registered_nodes[node].buildable_to then
|
||||
minetest.set_node(lastpos,{name="fire:basic_flame"})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_build=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local node=minetest.get_node(lastpos).name
|
||||
local index=user:get_wield_index()+1
|
||||
local inv=user:get_inventory()
|
||||
local stack=inv:get_stack("main", index)
|
||||
if minetest.is_protected(lastpos, name) then
|
||||
minetest.chat_send_player(name, minetest.pos_to_string(lastpos) .." is protected")
|
||||
elseif minetest.registered_nodes[node].buildable_to
|
||||
and minetest.registered_nodes[stack:get_name()] then
|
||||
minetest.set_node(lastpos,{name=stack:get_name()})
|
||||
if bows.creative==false then
|
||||
inv:set_stack("main",index,ItemStack(stack:get_name() .. " " .. (stack:get_count()-1)))
|
||||
end
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_toxic=function(self,target,hp,user,lastpos)
|
||||
if self.object==nil or user==nil or target==nil or target:get_properties()==nil then
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
target:punch(user, 3,{full_punch_interval=1.0,damage_groups={fleshy=4}}, nil)
|
||||
local rnd=math.random(1,10)
|
||||
if rnd~=4 and target:get_hp()>0 then
|
||||
minetest.after(math.random(0.5,2), function(self,target,hp,user,lastpos)
|
||||
bows.arrow_toxic(self,target,hp,user,lastpos)
|
||||
end, self,target,hp,user,lastpos)
|
||||
else
|
||||
bows.arrow_remove(self)
|
||||
end
|
||||
end
|
||||
|
||||
bows.arrow_tetanus=function(self,target,hp,user,lastpos)
|
||||
if self.object==nil or user==nil or target==nil or target:get_properties()==nil then
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
if target:get_attach()==nil then
|
||||
self.object:set_detach()
|
||||
local col=target:get_properties().collisionbox
|
||||
self.object:set_properties({
|
||||
collisionbox=col,
|
||||
physical=true,
|
||||
visual_size={x=1,y=1},
|
||||
visual="sprite",
|
||||
textures={"bows_hidden.png"}
|
||||
})
|
||||
self.object:setpos(target:getpos())
|
||||
target:set_attach(self.object, "", {x=0,y=0,z=0},{x=0,y=0,z=0})
|
||||
self.target=target
|
||||
self.hp=self.object:get_hp()
|
||||
self.object:setvelocity({x=0, y=-3, z=0})
|
||||
self.object:setacceleration({x=0, y=-3, z=0})
|
||||
return self
|
||||
end
|
||||
|
||||
local rnd=math.random(1,10)
|
||||
if rnd~=4 and target:get_hp()>0 then
|
||||
minetest.after(math.random(4), function(self,target,hp,user,lastpos)
|
||||
bows.arrow_tetanus(self,target,hp,user,lastpos)
|
||||
end, self,target,hp,user,lastpos)
|
||||
else
|
||||
target:set_detach()
|
||||
target:setvelocity({x=0, y=4, z=0})
|
||||
target:setacceleration({x=0, y=-10, z=0})
|
||||
bows.arrow_remove(self)
|
||||
end
|
||||
end
|
||||
|
||||
bows.arrow_admin_object=function(self,target,hp,user,lastpos)
|
||||
target:set_hp(0)
|
||||
target:punch(self.object, 9000,{full_punch_interval=1.0,damage_groups={fleshy=4}}, "default:sword_wood", nil)
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_admin_node=function(self,pos,user,lastpos)
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_rainbow_step=function(self,dtime,user,pos,lastpos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 20,
|
||||
time =0.5,
|
||||
minpos = pos,
|
||||
maxpos =pos,
|
||||
minvel = {x=-1, y=-1, z=-1},
|
||||
maxvel = {x=1, y=-0.5, z=1},
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 1.0,
|
||||
maxexptime = 1.5,
|
||||
minsize = 1.6,
|
||||
maxsize = 0.2,
|
||||
texture = "bows_rainbow.png",
|
||||
})
|
||||
end
|
||||
|
||||
bows.arrow_rainbow_object=function(self,target,hp,user,lastpos)
|
||||
local pos=target:getpos()
|
||||
minetest.add_particle({
|
||||
pos = pos,
|
||||
velocity = vector.new(),
|
||||
acceleration = vector.new(),
|
||||
expirationtime = 0.4,
|
||||
size = 20,
|
||||
collisiondetection = false,
|
||||
vertical = false,
|
||||
texture = "bows_rainbow.png",
|
||||
})
|
||||
minetest.add_particlespawner({
|
||||
amount = 100,
|
||||
time = 0.5,
|
||||
minpos = vector.subtract(pos, 3),
|
||||
maxpos = vector.add(pos, 3),
|
||||
minvel = {x = -10, y = -10, z = -10},
|
||||
maxvel = {x = 10, y = 10, z = 10},
|
||||
minacc = vector.new(),
|
||||
maxacc = vector.new(),
|
||||
minexptime = 1,
|
||||
maxexptime = 2.5,
|
||||
minsize = 3,
|
||||
maxsize = 9,
|
||||
texture = "bows_rainbow.png",
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
bows.arrow_tnt_object=function(self,target,hp,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local pos=target:getpos()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_tnt_node=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_tnt_cluster_object=function(self,target,hp,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local pos=target:getpos()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
for i=1,6,1 do
|
||||
bows.tmp={
|
||||
user = user,
|
||||
arrow="bows:arrow_tnt",
|
||||
name="bows:arrow_tnt",
|
||||
shots=1}
|
||||
local x=math.random(-1,1)*0.1
|
||||
local y=math.random(-1,1)*0.1
|
||||
local z=math.random(-1,1)*0.1
|
||||
local e=minetest.add_entity({x=pos.x+x,y=pos.y+y,z=pos.z+z}, "bows:arrow")
|
||||
e:setvelocity({x=x, y=-8, z=z})
|
||||
e:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_tnt_cluster_node=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
for i=1,6,1 do
|
||||
bows.tmp={
|
||||
user = user,
|
||||
arrow="bows:arrow_tnt",
|
||||
name="bows:arrow_tnt",
|
||||
shots=1}
|
||||
local x=math.random(-1,1)*0.1
|
||||
local y=math.random(-1,1)*0.1
|
||||
local z=math.random(-1,1)*0.1
|
||||
local e=minetest.add_entity({x=pos.x+x,y=pos.y+y,z=pos.z+z}, "bows:arrow")
|
||||
e:setvelocity({x=x, y=-8, z=z})
|
||||
e:setacceleration({x=0, y=-10, z=0})
|
||||
end
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_cooltnt_node=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local radius=3
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
drops=0,
|
||||
hurt=0,
|
||||
place={"default:snowblock","default:ice","default:snowblock"},
|
||||
place_chance=1,
|
||||
})
|
||||
end
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, radius*2)) do
|
||||
local pos2=ob:getpos()
|
||||
local d=math.max(1,vector.distance(pos,pos2))
|
||||
local dmg=(8/d)*radius
|
||||
if not (ob:get_luaentity() and ob:get_luaentity().name=="nitroglycerine:ice") then
|
||||
if ob:get_hp()<=dmg+5 then
|
||||
nitroglycerine.freeze(ob)
|
||||
else
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=dmg}},nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
bows.arrow_cooltnt_object=function(self,target,hp,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local pos=target:getpos()
|
||||
local radius=3
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=1,
|
||||
user_name=name,
|
||||
drops=0,
|
||||
velocity=0,
|
||||
hurt=0,
|
||||
place={"default:snowblock","default:ice","default:snowblock"},
|
||||
place_chance=1,
|
||||
})
|
||||
end
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, radius*2)) do
|
||||
local pos2=ob:getpos()
|
||||
local d=math.max(1,vector.distance(pos,pos2))
|
||||
local dmg=(8/d)*radius
|
||||
|
||||
if not (ob:get_luaentity() and ob:get_luaentity().name=="nitroglycerine:ice") then
|
||||
if ob:get_hp()<=dmg+5 then
|
||||
nitroglycerine.freeze(ob)
|
||||
else
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=dmg}},nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_nitrogen_object=function(self,target,hp,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local pos=target:getpos()
|
||||
local dmg=8
|
||||
if target:get_hp()<=dmg+5 then
|
||||
nitroglycerine.freeze(target)
|
||||
else
|
||||
target:punch(target,1,{full_punch_interval=1,damage_groups={fleshy=dmg}},nil)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_nuke_object=function(self,target,hp,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
local pos=target:getpos()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=50,
|
||||
user_name=name,
|
||||
set="air",
|
||||
radius=20,
|
||||
drops=0,
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_nuke_node=function(self,pos,user,lastpos)
|
||||
local name=user:get_player_name()
|
||||
if not minetest.is_protected(lastpos, name) then
|
||||
nitroglycerine.explode(pos,{
|
||||
place_chance=50,
|
||||
user_name=name,
|
||||
set="air",
|
||||
radius=20,
|
||||
drops=0,
|
||||
})
|
||||
end
|
||||
bows.arrow_remove(self)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
bows.arrow_radioactive_object=function(self,target,hp,user,lastpos)
|
||||
bows.arrow_radioactive_node(self,nil,nil,lastpos)
|
||||
return self
|
||||
end
|
||||
|
||||
bows.arrow_radioactive_node=function(self,pos,user,lastpos)
|
||||
minetest.sound_play("nitroglycerine_explode", {pos=lastpos, gain = 0.5, max_hear_distance = 20})
|
||||
bows.arrow_remove(self)
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(lastpos, 10)) do
|
||||
if bows.visiable(self,lastpos) then
|
||||
local n
|
||||
local is=ob:is_player()
|
||||
if is then
|
||||
n=ob:get_player_name()
|
||||
else
|
||||
ob:get_luaentity().bows_rad=1
|
||||
end
|
||||
bows.rad(ob,is,n)
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
bows.visiable=function(self,pos2)
|
||||
if pos2 and not (pos2.x and pos2.y and pos2.z) then
|
||||
pos2=pos2:getpos()
|
||||
end
|
||||
if not (pos2 and pos2.x) then return nil end
|
||||
local pos1
|
||||
if self.x and self.y and self.z then
|
||||
pos1=self
|
||||
else
|
||||
pos1=self.object:getpos()
|
||||
end
|
||||
local v = {x = pos1.x - pos2.x, y = pos1.y - pos2.y-1, z = pos1.z - pos2.z}
|
||||
v.y=v.y-1
|
||||
local amount = (v.x ^ 2 + v.y ^ 2 + v.z ^ 2) ^ 0.5
|
||||
local d=math.sqrt((pos1.x-pos2.x)*(pos1.x-pos2.x) + (pos1.y-pos2.y)*(pos1.y-pos2.y)+(pos1.z-pos2.z)*(pos1.z-pos2.z))
|
||||
v.x = (v.x / amount)*-1
|
||||
v.y = (v.y / amount)*-1
|
||||
v.z = (v.z / amount)*-1
|
||||
for i=1,d,1 do
|
||||
local node=minetest.get_node({x=pos1.x+(v.x*i),y=pos1.y+(v.y*i),z=pos1.z+(v.z*i)})
|
||||
if node and node.name and minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].walkable then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
bows.rad=function(ob,is,n)
|
||||
if math.random(1,40)==1 or not ob or ob:get_hp()<=1 or not (ob:is_player() or ob:get_luaentity()) then
|
||||
if ob and ob:get_hp()<=1 then
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=10}},nil)
|
||||
elseif is==false then
|
||||
ob:get_luaentity().bows_rad=nil
|
||||
end
|
||||
return
|
||||
end
|
||||
local pos=ob:getpos()
|
||||
pos.y=pos.y+1
|
||||
for _, ob2 in ipairs(minetest.get_objects_inside_radius(pos, 10)) do
|
||||
if bows.visiable(pos,ob2) then
|
||||
local n2
|
||||
local is2=ob2:is_player()
|
||||
if is2 and not (is and n==ob2:get_player_name()) then
|
||||
bows.rad(ob2,is2,ob2:get_player_name())
|
||||
elseif is2==false and not ob2:get_luaentity().bows_rad then
|
||||
ob2:get_luaentity().bows_rad=1
|
||||
bows.rad(ob2,is2)
|
||||
end
|
||||
end
|
||||
end
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=2}},nil)
|
||||
|
||||
minetest.after(math.random(1,2), function(ob)
|
||||
bows.rad(ob)
|
||||
end,ob)
|
||||
end
|
After Width: | Height: | Size: 197 B |
After Width: | Height: | Size: 322 B |
After Width: | Height: | Size: 300 B |
After Width: | Height: | Size: 307 B |
After Width: | Height: | Size: 282 B |
After Width: | Height: | Size: 339 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 401 B |
After Width: | Height: | Size: 360 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 423 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 380 B |
After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 406 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 440 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 286 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 281 B |
After Width: | Height: | Size: 290 B |
After Width: | Height: | Size: 296 B |
After Width: | Height: | Size: 291 B |
After Width: | Height: | Size: 328 B |
After Width: | Height: | Size: 126 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 807 B |
After Width: | Height: | Size: 887 B |
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 30 KiB |
|
@ -0,0 +1,301 @@
|
|||
catchballs={type=0}
|
||||
|
||||
minetest.register_craft({
|
||||
output = "catchballs:catchball1",
|
||||
recipe = {
|
||||
{"default:gold_ingot","default:steel_ingot","default:gold_ingot"},
|
||||
{"default:steel_ingot","default:mese_crystal","default:steel_ingot"},
|
||||
{"default:gold_ingot","default:steel_ingot","default:gold_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "catchballs:catchball2",
|
||||
recipe = {
|
||||
{"default:gold_ingot","default:steel_ingot","default:gold_ingot"},
|
||||
{"default:steel_ingot","default:mese","default:steel_ingot"},
|
||||
{"default:gold_ingot","default:steel_ingot","default:gold_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_entity("catchballs:catchball",{
|
||||
hp_max = 10,
|
||||
physical =true,
|
||||
weight = 1,
|
||||
collisionbox = {-0.2,-0.2,-0.2,0.2,0.2,0.2},
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.3,y=0.3},
|
||||
textures ={"catchballs:catchball1"},
|
||||
colors = {},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = true,
|
||||
automatic_rotate =3.14,
|
||||
kill=function(self)
|
||||
self.object:set_hp(0)
|
||||
self.object:punch(self.object, 100,{full_punch_interval=1.0,damage_groups={fleshy=4}})
|
||||
return self
|
||||
end,
|
||||
ret=function(self)
|
||||
local pos=self.object:getpos()
|
||||
if not self.retur and self.meta then
|
||||
self.retur=1
|
||||
local e=minetest.add_entity({x=pos.x,y=pos.y+1,z=pos.z}, self.meta.name)
|
||||
local en=e:get_luaentity()
|
||||
if en.on_activate then
|
||||
en.on_activate(en,self.meta.data)
|
||||
end
|
||||
self.object:set_properties({physical=false})
|
||||
self.object:setacceleration({x =0, y =0, z =0})
|
||||
minetest.add_particlespawner({
|
||||
amount = 40,
|
||||
time =0.5,
|
||||
minpos = pos,
|
||||
maxpos =pos,
|
||||
minvel = {x=-2, y=0, z=-2},
|
||||
maxvel = {x=2, y=2, z=2},
|
||||
minacc = {x=0, y=0, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 2,
|
||||
maxexptime = 1,
|
||||
minsize = 0.5,
|
||||
maxsize = 1,
|
||||
glow=10,
|
||||
texture = "catchballs_catchball.png^[colorize:#ffcf42ff",
|
||||
})
|
||||
local nod=minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if nod and nod.buildable_to==true then minetest.set_node(pos,{name="catchballs:light"}) end
|
||||
end
|
||||
if self.retur then
|
||||
local pos2=self.user:getpos()
|
||||
pos2.y=pos2.y+1
|
||||
local v={x=(pos.x-pos2.x)*-4,y=(pos.y-pos2.y)*-4,z=(pos.z-pos2.z)*-4}
|
||||
self.object:setvelocity(v)
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 1.5)) do
|
||||
if ob:is_player() and ob:get_player_name()==self.user_name then
|
||||
ob:get_inventory():add_item("main", self.item)
|
||||
self.kill(self)
|
||||
return self
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.timer<=0 then
|
||||
minetest.add_item(pos,self.item)
|
||||
self.kill(self)
|
||||
return self
|
||||
end
|
||||
end,
|
||||
on_activate=function(self, staticdata)
|
||||
self.type=catchballs.type
|
||||
self.item=catchballs.item
|
||||
self.object:set_properties({textures={self.item}})
|
||||
if self.type==1 then
|
||||
elseif self.type==2 then
|
||||
self.user=catchballs.user
|
||||
self.meta=catchballs.meta
|
||||
self.user_name=self.user:get_player_name()
|
||||
self.rego=1
|
||||
elseif self.type==3 then
|
||||
self.user=catchballs.user
|
||||
self.user_name=self.user:get_player_name()
|
||||
else
|
||||
minetest.add_item(self.object:getpos(),self.item)
|
||||
self.kill(self)
|
||||
return self
|
||||
end
|
||||
catchballs.type=0
|
||||
catchballs.user=nil
|
||||
catchballs.meta=nil
|
||||
catchballs.item=nil
|
||||
self.object:setacceleration({x =0, y =-10, z =0})
|
||||
return self
|
||||
end,
|
||||
on_step=function(self, dtime)
|
||||
self.time=self.time-dtime
|
||||
if self.time>0 then return self end
|
||||
if self.catch and self.rego then
|
||||
self.timer=self.timer-dtime
|
||||
self.ret(self)
|
||||
return self
|
||||
end
|
||||
if self.object:getvelocity().y==0 and not self.catch then
|
||||
self.catch=1
|
||||
if self.type==2 then self.rego=1 end
|
||||
if self.rego then return end
|
||||
local pos=self.object:getpos()
|
||||
local ob1
|
||||
local d1=10
|
||||
local d2=10
|
||||
local en1
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 5)) do
|
||||
local en=ob:get_luaentity()
|
||||
local pos2=ob:getpos()
|
||||
d2=vector.distance(pos,pos2)
|
||||
if en and d2<d1 and en.type and en.type~="" and not en.catchball and en.itemstring==nil then
|
||||
ob1=ob
|
||||
en1=en
|
||||
d1=d2
|
||||
end
|
||||
end
|
||||
if not ob1 then
|
||||
if self.type==3 then
|
||||
self.object:set_properties({physical=false})
|
||||
self.retur=1
|
||||
self.rego=1
|
||||
self.object:setacceleration({x =0, y =0, z =0})
|
||||
return
|
||||
end
|
||||
minetest.add_item(pos,self.item)
|
||||
self.kill(self)
|
||||
return self
|
||||
end
|
||||
local item=ItemStack(self.item):to_table()
|
||||
item.wear=1
|
||||
local data=""
|
||||
if en1.get_staticdata then
|
||||
data=en1.get_staticdata(en1)
|
||||
end
|
||||
if type(data)~="string" then data="" end
|
||||
item.meta.data=data
|
||||
item.meta.name=en1.name
|
||||
item.meta.description=en1.name
|
||||
|
||||
|
||||
en1.on_step=nil
|
||||
ob1:remove()
|
||||
if self.type==3 then
|
||||
self.object:set_properties({physical=false})
|
||||
self.retur=1
|
||||
self.rego=1
|
||||
self.item=item
|
||||
self.object:setacceleration({x =0, y =0, z =0})
|
||||
return self
|
||||
end
|
||||
minetest.add_item(pos,item)
|
||||
self.kill(self)
|
||||
return self
|
||||
end
|
||||
end,
|
||||
time=0.2,
|
||||
timer=15,
|
||||
type="",
|
||||
catchball=1,
|
||||
})
|
||||
|
||||
minetest.register_tool("catchballs:catchball1", {
|
||||
description = "Catch ball",
|
||||
range=1,
|
||||
inventory_image = "catchballs_catchball.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if user.fakeplayer then return end
|
||||
local dir
|
||||
local pos
|
||||
if user:get_luaentity() then
|
||||
user=user:get_luaentity():get_luaentity()
|
||||
pos=user.object:getpos()
|
||||
dir=catchballs.get_dir(pos,catchballs.pointat(user))
|
||||
else
|
||||
dir=user:get_look_dir()
|
||||
pos=user:getpos()
|
||||
end
|
||||
local item=itemstack:to_table()
|
||||
catchballs.user=user
|
||||
if item.meta and item.meta.data then
|
||||
catchballs.type=2
|
||||
catchballs.meta=item.meta
|
||||
else
|
||||
catchballs.type=1
|
||||
end
|
||||
catchballs.item="catchballs:catchball1"
|
||||
pos.y=pos.y+1
|
||||
local v={x=dir.x*15,y=dir.y*15,z=dir.z*15}
|
||||
local e=minetest.add_entity(pos, "catchballs:catchball")
|
||||
e:setvelocity(v)
|
||||
itemstack:take_item()
|
||||
if user.inv and user.inv["catchballs:catchball1"] and type(user.inv["catchballs:catchball1"])=="number" then
|
||||
user.inv["catchballs:catchball1"]=user.inv["catchballs:catchball1"]-1
|
||||
if user.inv["catchballs:catchball1"]<=0 then user.inv["catchballs:catchball1"]=nil end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_tool("catchballs:catchball2", {
|
||||
description = "Master catch ball",
|
||||
inventory_image = "catchballs_catchball2.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
if user.fakeplayer then return end
|
||||
local dir
|
||||
local pos
|
||||
local item=itemstack:to_table()
|
||||
catchballs.user=user
|
||||
catchballs.item="catchballs:catchball2"
|
||||
if item.meta and item.meta.data then
|
||||
catchballs.type=2
|
||||
catchballs.meta=item.meta
|
||||
else
|
||||
catchballs.type=3
|
||||
end
|
||||
|
||||
if user:get_luaentity() then
|
||||
catchballs.type=1
|
||||
user=user:get_luaentity():get_luaentity()
|
||||
pos=user.object:getpos()
|
||||
dir=catchballs.get_dir(pos,catchballs.pointat(user))
|
||||
else
|
||||
dir=user:get_look_dir()
|
||||
pos=user:getpos()
|
||||
end
|
||||
|
||||
pos.y=pos.y+1
|
||||
local v={x=dir.x*15,y=dir.y*15,z=dir.z*15}
|
||||
local e=minetest.add_entity(pos, "catchballs:catchball")
|
||||
e:setvelocity(v)
|
||||
itemstack:take_item()
|
||||
if user.inv and user.inv["catchballs:catchball2"] and type(user.inv["catchballs:catchball2"])=="number" then
|
||||
user.inv["catchballs:catchball2"]=user.inv["catchballs:catchball2"]-1
|
||||
if user.inv["catchballs:catchball2"]<=0 then user.inv["catchballs:catchball2"]=nil end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("catchballs:light", {
|
||||
description = "Light",
|
||||
drop="",
|
||||
light_source = 10,
|
||||
paramtype = "light",
|
||||
alpha = 50,
|
||||
walkable=false,
|
||||
drawtype = "airlike",
|
||||
sunlight_propagates = false,
|
||||
pointable = false,
|
||||
buildable_to = true,
|
||||
groups = {not_in_creative_inventory=1},
|
||||
on_construct=function(pos)
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
minetest.set_node(pos,{name="air"})
|
||||
return false
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
catchballs.pointat=function(self)
|
||||
local pos=self.object:getpos()
|
||||
local yaw=self.object:getyaw()
|
||||
if yaw ~= yaw or type(yaw)~="number" then
|
||||
yaw=0
|
||||
end
|
||||
local x =math.sin(yaw) * -1
|
||||
local z =math.cos(yaw) * 1
|
||||
return {x=pos.x+x,y=pos.y,z=pos.z+z}
|
||||
end
|
||||
|
||||
catchballs.get_dir=function(pos1,pos2)
|
||||
local d=math.floor(vector.distance(pos1,pos2)+0.5)
|
||||
return {x=(pos1.x-pos2.x)/-d,y=(pos1.y-pos2.y)/-d,z=(pos1.z-pos2.z)/-d}
|
||||
end
|
After Width: | Height: | Size: 519 B |
After Width: | Height: | Size: 565 B |
|
@ -0,0 +1 @@
|
|||
default
|
|
@ -0,0 +1,495 @@
|
|||
nitroglycerine={}
|
||||
nitroglycerine.explode=function(pos,node)
|
||||
if not (pos and pos.x and pos.y and pos.z) then return end
|
||||
if not node then node={} end
|
||||
|
||||
node.radius= node.radius or 3
|
||||
node.set= node.set or ""
|
||||
node.place= node.place or {"nitroglycerine:fire","air","air","air","air"}
|
||||
node.place_chance=node.place_chance or 5
|
||||
node.user_name=node.user_name or ""
|
||||
node.drops=node.drops or 1
|
||||
node.velocity=node.velocity or 1
|
||||
node.hurt=node.hurt or 1
|
||||
node.blow_nodes=node.blow_nodes or 1
|
||||
|
||||
if node.blow_nodes==1 then
|
||||
|
||||
local nodes={}
|
||||
if node.set~="" then node.set=minetest.get_content_id(node.set) end
|
||||
|
||||
local nodes_n=0
|
||||
for i, v in pairs(node.place) do
|
||||
nodes_n=i
|
||||
nodes[i]=minetest.get_content_id(v)
|
||||
end
|
||||
|
||||
if node.place_chance<=1 then node.place_chance=2 end
|
||||
if nodes_n<=1 then nodes_n=2 end
|
||||
|
||||
local air=minetest.get_content_id("air")
|
||||
pos=vector.round(pos)
|
||||
local pos1 = vector.subtract(pos, node.radius)
|
||||
local pos2 = vector.add(pos, node.radius)
|
||||
local vox = minetest.get_voxel_manip()
|
||||
local min, max = vox:read_from_map(pos1, pos2)
|
||||
local area = VoxelArea:new({MinEdge = min, MaxEdge = max})
|
||||
local data = vox:get_data()
|
||||
for z = -node.radius, node.radius do
|
||||
for y = -node.radius, node.radius do
|
||||
for x = -node.radius, node.radius do
|
||||
local rad = vector.length(vector.new(x,y,z))
|
||||
local v = area:index(pos.x+x,pos.y+y,pos.z+z)
|
||||
local p={x=pos.x+x,y=pos.y+y,z=pos.z+z}
|
||||
|
||||
if data[v]~=air and node.radius/rad>=1 and minetest.is_protected(p, node.user_name)==false then
|
||||
|
||||
local no=minetest.registered_nodes[minetest.get_node(p).name]
|
||||
|
||||
if no and no.on_blast then
|
||||
no.on_blast(p,node.radius)
|
||||
end
|
||||
|
||||
if node.set~="" then
|
||||
data[v]=node.set
|
||||
end
|
||||
|
||||
if math.random(1,node.place_chance)==1 then
|
||||
data[v]=nodes[math.random(1,nodes_n)]
|
||||
end
|
||||
|
||||
if node.drops==1 and data[v]==air and math.random(1,4)==1 then
|
||||
local n=minetest.get_node(p)
|
||||
|
||||
if no and no.walkable and math.random(1,2)==1 then
|
||||
nitroglycerine.spawn_dust(p)
|
||||
else
|
||||
for _, item in pairs(minetest.get_node_drops(n.name, "")) do
|
||||
if p and item then minetest.add_item(p, item) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
vox:set_data(data)
|
||||
vox:write_to_map()
|
||||
vox:update_map()
|
||||
vox:update_liquids()
|
||||
end
|
||||
|
||||
if node.hurt==1 then
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, node.radius*2)) do
|
||||
if not (ob:get_luaentity() and (ob:get_luaentity().itemstring or ob:get_luaentity().nitroglycerine_dust)) then
|
||||
local pos2=ob:getpos()
|
||||
local d=math.max(1,vector.distance(pos,pos2))
|
||||
local dmg=(8/d)*node.radius
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=dmg}})
|
||||
elseif ob:get_luaentity() then
|
||||
ob:get_luaentity().age=890
|
||||
end
|
||||
end
|
||||
end
|
||||
if node.velocity==1 then
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, node.radius*2)) do
|
||||
local pos2=ob:getpos()
|
||||
local d=math.max(1,vector.distance(pos,pos2))
|
||||
local dmg=(8/d)*node.radius
|
||||
if ob:get_luaentity() and not ob:get_luaentity().attachplayer and not (ob:get_luaentity().nitroglycerine_dust and ob:get_luaentity().nitroglycerine_dust==2) then
|
||||
ob:setvelocity({x=(pos2.x-pos.x)*dmg, y=(pos2.y-pos.y)*dmg, z=(pos2.z-pos.z)*dmg})
|
||||
|
||||
|
||||
if ob:get_luaentity() and ob:get_luaentity().nitroglycerine_dust then ob:get_luaentity().nitroglycerine_dust=2 end
|
||||
|
||||
elseif ob:is_player() then
|
||||
nitroglycerine.new_player=ob
|
||||
minetest.add_entity({x=pos2.x,y=pos2.y+1,z=pos2.z}, "nitroglycerine:playerp"):setvelocity({x=(pos2.x-pos.x)*dmg, y=(pos2.y-pos.y)*dmg, z=(pos2.z-pos.z)*dmg})
|
||||
nitroglycerine.new_player=nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.sound_play("nitroglycerine_explode", {pos=pos, gain = 0.5, max_hear_distance = node.radius*8})
|
||||
if node.radius>9 then
|
||||
minetest.sound_play("nitroglycerine_nuke", {pos=pos, gain = 0.5, max_hear_distance = node.radius*30})
|
||||
end
|
||||
minetest.add_particlespawner({
|
||||
amount = 20,
|
||||
time =0.2,
|
||||
minpos = {x=pos.x-1, y=pos.y, z=pos.z-1},
|
||||
maxpos = {x=pos.x+1, y=pos.y, z=pos.z+1},
|
||||
minvel = {x=-5, y=0, z=-5},
|
||||
maxvel = {x=5, y=5, z=5},
|
||||
minacc = {x=0, y=2, z=0},
|
||||
maxacc = {x=0, y=0, z=0},
|
||||
minexptime = 1,
|
||||
maxexptime = 2,
|
||||
minsize = 5,
|
||||
maxsize = 10,
|
||||
texture = "default_item_smoke.png",
|
||||
collisiondetection = true,
|
||||
})
|
||||
end
|
||||
|
||||
nitroglycerine.punchdmg=function(ob,hp)
|
||||
if not ob or type(ob)~="userdata" then return end
|
||||
hp=hp or 1
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=hp}})
|
||||
end
|
||||
|
||||
|
||||
nitroglycerine.freeze=function(ob)
|
||||
local p=ob:get_properties()
|
||||
local pos=ob:getpos()
|
||||
if ob:is_player() then
|
||||
pos=vector.round(pos)
|
||||
local node=minetest.get_node(pos)
|
||||
if node==nil or node.name==nil or minetest.registered_nodes[node.name].buildable_to==false then return end
|
||||
minetest.set_node(pos, {name = "nitroglycerine:icebox"})
|
||||
minetest.after(0.5, function(pos, ob)
|
||||
pos.y=pos.y-0.5
|
||||
ob:moveto(pos,false)
|
||||
end, pos, ob)
|
||||
return
|
||||
end
|
||||
if not ob:get_luaentity() then return end
|
||||
if p.visual=="mesh" and p.mesh~="" and p.mesh~=nil and ob:get_luaentity().name~="nitroglycerine:ice" then
|
||||
nitroglycerine.newice=true
|
||||
local m=minetest.add_entity(pos, "nitroglycerine:ice")
|
||||
m:setyaw(ob:getyaw())
|
||||
m:set_properties({
|
||||
visual_size=p.visual_size,
|
||||
visual="mesh",
|
||||
mesh=p.mesh,
|
||||
textures={"default_ice.png","default_ice.png","default_ice.png","default_ice.png","default_ice.png","default_ice.png"},
|
||||
collisionbox=p.collisionbox
|
||||
})
|
||||
elseif ob:get_luaentity().name~="nitroglycerine:ice" then
|
||||
minetest.add_item(pos,"default:ice")
|
||||
end
|
||||
local hp=ob:get_hp()+1
|
||||
|
||||
ob:get_luaentity().destroy=1
|
||||
|
||||
ob:punch(ob,1,{full_punch_interval=1,damage_groups={fleshy=hp}})
|
||||
if ob:get_luaentity().aliveai then
|
||||
for _, ob in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
if ob:get_luaentity() and ob:get_luaentity().type and ob:get_luaentity().type=="" then
|
||||
ob:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
nitroglycerine.spawn_dust=function(pos)
|
||||
if not pos then return end
|
||||
|
||||
local drop=minetest.get_node_drops(minetest.get_node(pos).name)[1]
|
||||
local n=minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if not (n and n.walkable) or drop=="" or type(drop)~="string" then return end
|
||||
local t=n.tiles
|
||||
if not t[1] then return end
|
||||
local tx={}
|
||||
local tt={}
|
||||
tt.t1=t[1]
|
||||
tt.t2=t[1]
|
||||
tt.t3=t[1]
|
||||
|
||||
if t[2] then tt.t2=t[2] tt.t3=t[2] end
|
||||
if t[3] and t[3].name then tt.t3=t[3].name
|
||||
elseif t[3] then tt.t3=t[3]
|
||||
end
|
||||
if type(tt.t3)=="table" then return end
|
||||
tx[1]=tt.t1
|
||||
tx[2]=tt.t2
|
||||
tx[3]=tt.t3
|
||||
tx[4]=tt.t3
|
||||
tx[5]=tt.t3
|
||||
tx[6]=tt.t3
|
||||
|
||||
nitroglycerine.new_dust={t=tx,drop=drop}
|
||||
minetest.add_entity(pos, "nitroglycerine:dust")
|
||||
|
||||
nitroglycerine.new_dust=nil
|
||||
end
|
||||
|
||||
minetest.register_entity("nitroglycerine:ice",{
|
||||
hp_max = 1,
|
||||
physical = true,
|
||||
weight = 5,
|
||||
collisionbox = {-0.3,-0.3,-0.3, 0.3,0.3,0.3},
|
||||
visual = "sprite",
|
||||
visual_size = {x=0.7, y=0.7},
|
||||
textures = {},
|
||||
colors = {},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = true,
|
||||
automatic_rotate = false,
|
||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local pos=self.object:getpos()
|
||||
minetest.sound_play("default_break_glass", {pos=pos, gain = 1.0, max_hear_distance = 10,})
|
||||
nitroglycerine.crush(pos)
|
||||
end,
|
||||
on_activate=function(self, staticdata)
|
||||
if nitroglycerine.newice then
|
||||
nitroglycerine.newice=nil
|
||||
else
|
||||
self.object:remove()
|
||||
end
|
||||
self.object:setacceleration({x = 0, y = -10, z = 0})
|
||||
self.object:setvelocity({x = 0, y = -10, z = 0})
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
self.timer=self.timer+dtime
|
||||
if self.timer<1 then return true end
|
||||
self.timer=0
|
||||
self.timer2=self.timer2+dtime
|
||||
if self.timer2>0.8 then
|
||||
minetest.sound_play("default_break_glass", {pos=self.object:getpos(), gain = 1.0, max_hear_distance = 10,})
|
||||
self.object:remove()
|
||||
nitroglycerine.crush(self.object:getpos())
|
||||
return true
|
||||
end
|
||||
end,
|
||||
timer = 0,
|
||||
timer2 = 0,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_entity("nitroglycerine:dust",{
|
||||
hp_max = 1000,
|
||||
physical =true,
|
||||
weight = 0,
|
||||
collisionbox = {-0.5,-0.5,-0.5,0.5,0.5,0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x=1,y=1},
|
||||
textures ={"nitroglycerine_air.png"},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = true,
|
||||
on_punch2=function(self)
|
||||
minetest.add_item(self.object:getpos(),self.drop)
|
||||
self.object:remove()
|
||||
return self
|
||||
end,
|
||||
on_activate=function(self, staticdata)
|
||||
if not nitroglycerine.new_dust then self.object:remove() return self end
|
||||
self.drop=nitroglycerine.new_dust.drop
|
||||
self.object:set_properties({textures = nitroglycerine.new_dust.t})
|
||||
self.object:setacceleration({x=0,y=-10,z=0})
|
||||
return self
|
||||
end,
|
||||
on_step=function(self, dtime)
|
||||
self.time=self.time+dtime
|
||||
if self.time<self.timer then return self end
|
||||
self.time=0
|
||||
self.timer2=self.timer2-1
|
||||
local pos=self.object:getpos()
|
||||
local u=minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name]
|
||||
if u and u.walkable then
|
||||
local n=minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if n and n.buildable_to and minetest.registered_nodes[self.drop] then
|
||||
minetest.set_node(pos,{name=self.drop})
|
||||
self.object:remove()
|
||||
else
|
||||
self.on_punch2(self)
|
||||
end
|
||||
return self
|
||||
elseif self.timer2<0 then
|
||||
self.on_punch2(self)
|
||||
end
|
||||
return self
|
||||
end,
|
||||
time=0,
|
||||
timer=2,
|
||||
timer2=10,
|
||||
nitroglycerine_dust=1,
|
||||
})
|
||||
|
||||
minetest.register_entity("nitroglycerine:playerp",{
|
||||
hp_max = 1000,
|
||||
physical =true,
|
||||
collisionbox = {-0.5,-0.5,-0.5,0.5,1.5,0.5},
|
||||
visual = "sprite",
|
||||
textures ={"nitroglycerine_air.png"},
|
||||
is_visible = true,
|
||||
makes_footstep_sound = false,
|
||||
pointable=false,
|
||||
on_punch=function(self)
|
||||
local v=self.object:getvelocity().y
|
||||
if v<0.2 and v>-0.2 then
|
||||
self.kill(self)
|
||||
end
|
||||
end,
|
||||
kill=function(self,liquid)
|
||||
if self.ob and self.ob:get_attach() then
|
||||
self.ob:set_detach()
|
||||
if not (liquid and liquid>0) then
|
||||
|
||||
local from=math.floor((self.y+0.5)/2)
|
||||
local hit=math.floor((self.object:getpos().y+0.5)/2)
|
||||
local d=from-hit
|
||||
if d>=0 then
|
||||
nitroglycerine.punchdmg(self.ob,d)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.object:remove()
|
||||
return self
|
||||
end,
|
||||
on_activate=function(self, staticdata)
|
||||
if not nitroglycerine.new_player or minetest.check_player_privs(nitroglycerine.new_player:get_player_name(), {fly=true}) then self.object:remove() return self end
|
||||
self.ob=nitroglycerine.new_player
|
||||
self.ob:set_attach(self.object, "",{x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
self.object:setacceleration({x=0,y=-10,z=0})
|
||||
self.y=self.object:getpos().y
|
||||
return self
|
||||
end,
|
||||
on_step=function(self, dtime)
|
||||
self.time=self.time+dtime
|
||||
if self.time<self.timer then return self end
|
||||
self.time=0
|
||||
self.timer2=self.timer2-1
|
||||
local pos=self.object:getpos()
|
||||
|
||||
if pos.y>self.y then self.y=pos.y end
|
||||
|
||||
local u=minetest.registered_nodes[minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name]
|
||||
if (u and u.walkable or u.liquid_viscosity>0) or self.timer2<0 or (not self.ob or not self.ob:get_attach()) then
|
||||
self.kill(self,u.liquid_viscosity)
|
||||
end
|
||||
return self
|
||||
end,
|
||||
time=0,
|
||||
timer=0.5,
|
||||
timer2=100,
|
||||
attachplayer=1,
|
||||
})
|
||||
|
||||
minetest.register_node("nitroglycerine:icebox", {
|
||||
description = "Ice box",
|
||||
wield_scale = {x=2, y=2, z=2},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
||||
{-0.5, -0.5, -0.5, 0.5, 1.5, -0.4375},
|
||||
{-0.5, -0.5, 0.4375, 0.5, 1.5, 0.5},
|
||||
{0.4375, -0.5, -0.4375, 0.5, 1.5, 0.4375},
|
||||
{-0.5, -0.5, -0.4375, -0.4375, 1.5, 0.4375},
|
||||
{-0.5, 1.5, -0.5, 0.5, 1.4375, 0.5},
|
||||
}
|
||||
},
|
||||
drop="default:ice",
|
||||
tiles = {"default_ice.png"},
|
||||
groups = {cracky = 1, level = 2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
alpha = 30,
|
||||
is_ground_content = false,
|
||||
drowning = 1,
|
||||
damage_per_second = 2,
|
||||
on_construct = function(pos)
|
||||
minetest.get_node_timer(pos):start(20)
|
||||
end,
|
||||
on_timer = function (pos, elapsed)
|
||||
for i, ob in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||
return true
|
||||
end
|
||||
minetest.sound_play("default_break_glass", {pos=pos, gain = 1.0, max_hear_distance = 10,})
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
nitroglycerine.crush(pos)
|
||||
return false
|
||||
end,
|
||||
type="",
|
||||
})
|
||||
|
||||
nitroglycerine.crush=function(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 15,
|
||||
time =0.1,
|
||||
minpos = pos,
|
||||
maxpos = pos,
|
||||
minvel = {x=-2, y=-2, z=-2},
|
||||
maxvel = {x=2, y=2, z=2},
|
||||
minacc = {x=0, y=-8, z=0},
|
||||
maxacc = {x=0, y=-10, z=0},
|
||||
minexptime = 2,
|
||||
maxexptime = 1,
|
||||
minsize = 0.1,
|
||||
maxsize = 3,
|
||||
texture = "default_ice.png",
|
||||
collisiondetection = true,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_node("nitroglycerine:fire", {
|
||||
description = "fire",
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = 10,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
groups = {dig_immediate = 2,not_in_creative_inventory=1},
|
||||
drop="",
|
||||
})
|
||||
|
||||
minetest.register_node("nitroglycerine:fire2", {
|
||||
description = "fire",
|
||||
inventory_image = "fire_basic_flame.png",
|
||||
drawtype = "firelike",
|
||||
tiles = {
|
||||
{
|
||||
name = "fire_basic_flame_animated.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w = 16,
|
||||
aspect_h = 16,
|
||||
length = 1
|
||||
},
|
||||
},
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = 5,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
sunlight_propagates = true,
|
||||
damage_per_second = 4,
|
||||
groups = {dig_immediate = 2,not_in_creative_inventory=1},
|
||||
drop="",
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"nitroglycerine:fire","nitroglycerine:fire2"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local n=minetest.get_node(pos).name
|
||||
if n=="nitroglycerine:fire" and math.random(1,20)==1 then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
elseif n=="nitroglycerine:fire2" and math.random(1,5)==1 then
|
||||
minetest.set_node(pos, {name = "air"})
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,20 @@
|
|||
Version: 2.1
|
||||
name: nitroglycerine
|
||||
By: AiTechEye
|
||||
|
||||
powerful explosion / nitrogen api
|
||||
|
||||
======freese object======
|
||||
nitroglycerine.freese(object)
|
||||
|
||||
======all alternatives have standard values, so nothing hav to be set======
|
||||
nitroglycerine.explotion(pos,{
|
||||
radius=5,
|
||||
set="node",
|
||||
place={nodes},
|
||||
place_chance=5,
|
||||
user_name="name",
|
||||
drops=1
|
||||
velocity=1
|
||||
hurt=1
|
||||
})
|
After Width: | Height: | Size: 126 B |