kamikaze stuff
This commit is contained in:
parent
ffafde1a27
commit
012d54843e
@ -28,6 +28,24 @@ function ws.set_bool_bulk(settings,value)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ws.shuffle(tbl)
|
||||||
|
for i = #tbl, 2, -1 do
|
||||||
|
local j = math.random(i)
|
||||||
|
tbl[i], tbl[j] = tbl[j], tbl[i]
|
||||||
|
end
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
|
function ws.in_list(val, list)
|
||||||
|
if type(list) ~= "table" then return false end
|
||||||
|
for i, v in ipairs(list) do
|
||||||
|
if v == val then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
function ws.globalhacktemplate(setting,func,funcstart,funcstop,daughters)
|
function ws.globalhacktemplate(setting,func,funcstart,funcstop,daughters)
|
||||||
funcstart = funcstart or function() end
|
funcstart = funcstart or function() end
|
||||||
funcstop = funcstop or function() end
|
funcstop = funcstop or function() end
|
||||||
@ -78,10 +96,11 @@ minetest.register_globalstep(ws.step_globalhacks)
|
|||||||
function ws.get_reachable_positions(range)
|
function ws.get_reachable_positions(range)
|
||||||
range=range or 2
|
range=range or 2
|
||||||
local rt={}
|
local rt={}
|
||||||
|
local lp=minetest.localplayer:get_pos()
|
||||||
for x = -range,range,1 do
|
for x = -range,range,1 do
|
||||||
for y = -range,range,1 do
|
for y = -range,range,1 do
|
||||||
for z = -range,range,1 do
|
for z = -range,range,1 do
|
||||||
table.insert(rt,vector.new(x,y,z))
|
table.insert(rt,vector.add(lp,vector.new(x,y,z)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -149,6 +168,21 @@ function ws.on_connect(func)
|
|||||||
if func then func() end
|
if func then func() end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ws.find_item(items,rnd)
|
||||||
|
if type(items) == 'string' then
|
||||||
|
return minetest.find_item(items)
|
||||||
|
end
|
||||||
|
if type(nodename) ~= 'table' then return end
|
||||||
|
if rnd then items=ws.shuffle(items) end
|
||||||
|
for i, v in pairs(items) do
|
||||||
|
local n = minetest.find_item(v)
|
||||||
|
if n then
|
||||||
|
return n
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function find_named(inv, name)
|
local function find_named(inv, name)
|
||||||
if not inv then return -1 end
|
if not inv then return -1 end
|
||||||
for i, v in ipairs(inv) do
|
for i, v in ipairs(inv) do
|
||||||
@ -315,28 +349,42 @@ function ws.dircoord(f, y, r)
|
|||||||
return ws.relcoord(0, 0, 0)
|
return ws.relcoord(0, 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ws.shuffle(tbl)
|
function ws.aim(tpos)
|
||||||
for i = #tbl, 2, -1 do
|
local ppos=minetest.localplayer:get_pos()
|
||||||
local j = math.random(i)
|
local dir=vector.direction(ppos,tpos)
|
||||||
tbl[i], tbl[j] = tbl[j], tbl[i]
|
local yyaw=0;
|
||||||
end
|
local pitch=0;
|
||||||
return tbl
|
if dir.x < 0 then
|
||||||
|
yyaw = math.atan2(-dir.x, dir.z) + (math.pi * 2)
|
||||||
|
else
|
||||||
|
yyaw = math.atan2(-dir.x, dir.z)
|
||||||
|
end
|
||||||
|
yyaw = ws.round2(math.deg(yyaw),2)
|
||||||
|
pitch = ws.round2(math.deg(math.asin(-dir.y) * 1),2);
|
||||||
|
minetest.localplayer:set_yaw(yyaw)
|
||||||
|
minetest.localplayer:set_pitch(pitch)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ws.find_item(items,rnd)
|
function ws.gaim(tpos,v,g)
|
||||||
if type(items) == 'string' then
|
local v = v or 40
|
||||||
return minetest.find_item(items)
|
local g = g or 9.81
|
||||||
--return minetest.localplayer:set_wield_index(minetest.find_item(items))
|
local ppos=minetest.localplayer:get_pos()
|
||||||
|
local dir=vector.direction(ppos,tpos)
|
||||||
|
local yyaw=0;
|
||||||
|
local pitch=0;
|
||||||
|
if dir.x < 0 then
|
||||||
|
yyaw = math.atan2(-dir.x, dir.z) + (math.pi * 2)
|
||||||
|
else
|
||||||
|
yyaw = math.atan2(-dir.x, dir.z)
|
||||||
end
|
end
|
||||||
if type(nodename) ~= 'table' then return end
|
yyaw = ws.round2(math.deg(yyaw),2)
|
||||||
items=ws.shuffle(items)
|
local y = dir.y
|
||||||
for i, v in ipairs(items) do
|
dir.y = 0
|
||||||
local n = minetest.find_item(v)
|
local x = vector.length(dir)
|
||||||
if n then
|
pitch=math.atan(math.pow(v, 2) / (g * x) + math.sqrt(math.pow(v, 4)/(math.pow(g, 2) * math.pow(x, 2)) - 2 * math.pow(v, 2) * y/(g * math.pow(x, 2)) - 1))
|
||||||
return n
|
--pitch = ws.round2(math.deg(math.asin(-dir.y) * 1),2);
|
||||||
end
|
minetest.localplayer:set_yaw(yyaw)
|
||||||
end
|
minetest.localplayer:set_pitch(math.deg(pitch))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ws.place(pos,nodename)
|
function ws.place(pos,nodename)
|
||||||
@ -352,3 +400,9 @@ function ws.dig(pos)
|
|||||||
minetest.dig_node(pos)
|
minetest.dig_node(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ws.dignodes(poss)
|
||||||
|
for k,v in pairs(poss) do
|
||||||
|
ws.dig(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
local fnd=false
|
local fnd=false
|
||||||
local cpos={x=0,y=0,z=0}
|
local cpos=vector.new(0,0,0)
|
||||||
local crange=500
|
|
||||||
local hud_wp=nil
|
local hud_wp=nil
|
||||||
local zz={x=0,y=64,z=0}
|
local zz=vector.new(42,42,42)
|
||||||
local badnodes={'mcl_tnt:tnt','mcl_fire:basic_flame','mcl_fire:eternal_fire','mcl_fire:fire','mcl_fire:fire_charge','mcl_sponges:sponge','mcl_sponges:sponge_wet','mcl_banners:hanging_banner','mcl_banners:standing_banner'}
|
local badnodes={'mcl_tnt:tnt','mcl_fire:basic_flame','mcl_fire:fire','mcl_banners:hanging_banner','mcl_banners:standing_banner','mcl_fire:fire_charge','mcl_sponges:sponge','mcl_sponges:sponge_wet','mcl_nether:soul_sand','mcl_heads:wither_skeleton'}
|
||||||
|
local badobs={'mcl_end_crystal','arrow_box','mobs_mc_wither.png'}
|
||||||
|
local searchtxt=nil
|
||||||
local searchheight=64
|
local searchheight=64
|
||||||
|
local tob=nil
|
||||||
|
|
||||||
local function set_kwp(name,pos)
|
local function set_kwp(name,pos)
|
||||||
if hud_wp then
|
if hud_wp then
|
||||||
@ -24,91 +26,137 @@ local nextzz=0
|
|||||||
local function randomzz()
|
local function randomzz()
|
||||||
if nextzz > os.clock() then return false end
|
if nextzz > os.clock() then return false end
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
zz.x=math.random(-128,128)
|
zz.x=math.random(-128,129)
|
||||||
zz.y=math.random(64,searchheight)
|
zz.y=math.random(0,searchheight)
|
||||||
zz.z=math.random(-128,128)
|
zz.z=math.random(-128,128)
|
||||||
nextzz=os.clock()+ 15
|
nextzz=os.clock()+ 30
|
||||||
|
end
|
||||||
|
local function find_ob(txts)
|
||||||
|
local odst=500
|
||||||
|
local rt=nil
|
||||||
|
local obs=minetest.localplayer.get_nearby_objects(500)
|
||||||
|
for k, v in ipairs(obs) do
|
||||||
|
for kk,txt in pairs(txts) do
|
||||||
|
if ( v:get_item_textures():find(txt) ) then
|
||||||
|
local npos=v:get_pos()
|
||||||
|
local dst=vector.distance(npos,minetest.localplayer:get_pos())
|
||||||
|
if odst > dst then
|
||||||
|
searchtxt=v:get_item_textures()
|
||||||
|
cpos=npos
|
||||||
|
set_kwp(searchtxt,v:get_pos())
|
||||||
|
odst=dst
|
||||||
|
fnd=true
|
||||||
|
tob=v
|
||||||
|
rt=v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return rt
|
||||||
|
end
|
||||||
|
local function find_nd(names)
|
||||||
|
local lp=minetest.localplayer:get_pos()
|
||||||
|
local epos=minetest.find_nodes_near(lp,60,names,true)
|
||||||
|
local rt=nil
|
||||||
|
local odst=500
|
||||||
|
if epos then
|
||||||
|
for k,v in pairs(epos) do
|
||||||
|
local node=minetest.get_node_or_nil(v)
|
||||||
|
local lp=minetest.localplayer:get_pos()
|
||||||
|
local dst=vector.distance(lp,v)
|
||||||
|
if odst > dst then
|
||||||
|
odst=dst
|
||||||
|
cpos=vv
|
||||||
|
rt=vv
|
||||||
|
fnd=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return rt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function find_bad_things()
|
local function find_bad_things()
|
||||||
if fnd then return true end
|
if fnd then return true end
|
||||||
local obs=minetest.localplayer.get_nearby_objects(crange)
|
|
||||||
local lp=minetest.localplayer:get_pos()
|
local lp=minetest.localplayer:get_pos()
|
||||||
local odst=500;
|
local ob=find_ob(badobs)
|
||||||
for k, v in ipairs(obs) do -- look for crystals first
|
if not ob then ob=find_nd(badnodes) end
|
||||||
if false and ( v:get_item_textures():find("mcl_end_crystal") ) then
|
if not ob then
|
||||||
local npos=v:get_pos()
|
set_kwp('nothing found',zz)
|
||||||
local dst=vector.distance(npos,minetest.localplayer:get_pos())
|
randomzz()
|
||||||
if odst > dst then cpos=npos
|
fnd=false
|
||||||
set_kwp(v:get_item_textures(),v:get_pos())
|
return false
|
||||||
fnd=true
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
odst=500
|
return true
|
||||||
for k, v in ipairs(obs) do
|
|
||||||
if false and ( v:get_item_textures():find("arrow_box") ) then
|
|
||||||
local npos=v:get_pos()
|
|
||||||
local dst=vector.distance(npos,minetest.localplayer:get_pos())
|
|
||||||
if odst > dst then cpos=npos
|
|
||||||
set_kwp(v:get_item_textures(),v:get_pos())
|
|
||||||
fnd=true
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
odst=500
|
|
||||||
local epos=minetest.find_nodes_in_area(vector.add(lp,{x=79,y=79,z=79}), vector.add(lp,{x=-79,y=-79,z=-79}), badnodes, true)
|
|
||||||
if epos then
|
|
||||||
for k,v in pairs(epos) do for kk,vv in pairs(v) do
|
|
||||||
local lp=minetest.localplayer:get_pos()
|
|
||||||
local dst=vector.distance(lp,vv)
|
|
||||||
if odst > dst then odst=dst cpos=vv fnd=true end
|
|
||||||
end end
|
|
||||||
if fnd then set_kwp('badnode',cpos) return true end
|
|
||||||
end
|
|
||||||
|
|
||||||
set_kwp('nothing found',zz)
|
|
||||||
randomzz()
|
|
||||||
fnd=false
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function flythere()
|
local function flythere()
|
||||||
|
if not minetest.localplayer then return end
|
||||||
|
if not cpos then return end
|
||||||
|
ws.aim(cpos)
|
||||||
|
if incremental_tp.tpactive then return end
|
||||||
|
local lp=minetest.localplayer:get_pos()
|
||||||
|
local dst=vector.distance(lp,cpos)
|
||||||
|
if tob and tob:get_item_textures() == searchtxt then
|
||||||
|
dst=vector.distance(lp,tob:get_pos())
|
||||||
|
cpos=tob:get_pos()
|
||||||
|
set_kwp(searchtxt,cpos)
|
||||||
|
end
|
||||||
minetest.settings:set_bool("continuous_forward",true)
|
minetest.settings:set_bool("continuous_forward",true)
|
||||||
autofly.aim(cpos)
|
if dst < 2 then
|
||||||
|
minetest.settings:set_bool("continuous_forward",false)
|
||||||
|
end
|
||||||
|
--incremental_tp.tp(cpos,1)
|
||||||
|
end
|
||||||
|
local nextthrow=0
|
||||||
|
local function throwegg()
|
||||||
|
if nextthrow > os.clock() then return false end
|
||||||
|
nextthrow=os.clock() + 0.5
|
||||||
|
if not ws.switch_inv_or_echest('mcl_throwing:snowball',1) then
|
||||||
|
ws.switch_inv_or_echest('mcl_throwing:egg',1)
|
||||||
|
end
|
||||||
|
ws.aim(cpos)
|
||||||
|
minetest.interact('use')
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stopflight()
|
local function stopflight()
|
||||||
|
local lp = minetest.localplayer:get_pos()
|
||||||
|
local dst=vector.distance(lp,cpos)
|
||||||
minetest.settings:set_bool("continuous_forward",false)
|
minetest.settings:set_bool("continuous_forward",false)
|
||||||
minetest.after("0",function()
|
if tob and tob:get_item_textures():find(searchtxt) then
|
||||||
minetest.interact("start_digging")
|
if tob and searchtxt == 'mcl_end_crystal.png' and dst < 5 then
|
||||||
minetest.dig_node(cpos)
|
throwegg()
|
||||||
fnd=false
|
searchtxt=""
|
||||||
end)
|
end
|
||||||
|
end
|
||||||
|
fnd=false
|
||||||
|
tob=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--minetest.register_globalstep(function()end)
|
|
||||||
|
|
||||||
ws.rg('Kamikaze','Bots','kamikaze', function()
|
ws.rg('Kamikaze','Bots','kamikaze', function()
|
||||||
local lp = minetest.localplayer:get_pos()
|
local lp = minetest.localplayer:get_pos()
|
||||||
|
local dst=vector.distance(lp,cpos)
|
||||||
if not find_bad_things() then
|
if not find_bad_things() then
|
||||||
if vector.distance(lp,zz) < 1 then
|
if vector.distance(lp,zz) < 4 then
|
||||||
stopflight()
|
stopflight()
|
||||||
return
|
|
||||||
else
|
else
|
||||||
cpos=zz
|
cpos=zz
|
||||||
end
|
end
|
||||||
elseif vector.distance(lp,cpos) < 1 then
|
elseif dst < 4 then
|
||||||
stopflight()
|
stopflight()
|
||||||
return
|
else
|
||||||
end
|
end
|
||||||
flythere()
|
flythere()
|
||||||
|
ws.dignodes(minetest.find_nodes_near(minetest.localplayer:get_pos(),5,badnodes,true))
|
||||||
|
if cpos then
|
||||||
|
-- minetest.dig_node(cpos)
|
||||||
|
-- minetest.interact('start_digging')
|
||||||
|
minetest.settings:set_bool("killaura",true)
|
||||||
|
end
|
||||||
|
|
||||||
end,function()
|
end,function()
|
||||||
core.set_keypress("special1", true)
|
core.set_keypress("special1", true)
|
||||||
@ -119,12 +167,14 @@ end, function()
|
|||||||
minetest.localplayer:hud_remove(hud_wp)
|
minetest.localplayer:hud_remove(hud_wp)
|
||||||
hud_wp=nil
|
hud_wp=nil
|
||||||
end
|
end
|
||||||
end,{"noclip","pitch_move"})
|
end,{"noclip","pitch_move","dighead"})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_death(function()
|
minetest.register_on_death(function()
|
||||||
if not minetest.settings:get_bool("kamikaze") then return end
|
if not minetest.settings:get_bool("kamikaze") then return end
|
||||||
|
tob=nil
|
||||||
|
-- incremental_tp.tpactive=false
|
||||||
minetest.after("5.0",function()
|
minetest.after("5.0",function()
|
||||||
fnd=false
|
fnd=false
|
||||||
end)
|
end)
|
||||||
@ -133,5 +183,8 @@ end)
|
|||||||
ws.on_connect(function()
|
ws.on_connect(function()
|
||||||
if minetest.localplayer and minetest.localplayer:get_name():find("kamikaze") then
|
if minetest.localplayer and minetest.localplayer:get_name():find("kamikaze") then
|
||||||
minetest.settings:set_bool("kamikaze",true)
|
minetest.settings:set_bool("kamikaze",true)
|
||||||
|
else minetest.settings:set_bool("kamikaze",false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_cheat('KamiCrystals','Bots','kamikaze_crystals')
|
||||||
|
@ -177,7 +177,6 @@ end
|
|||||||
function scaffold.place_if_able(pos)
|
function scaffold.place_if_able(pos)
|
||||||
if not pos then return end
|
if not pos then return end
|
||||||
if not inside_constraints(pos) then return end
|
if not inside_constraints(pos) then return end
|
||||||
if minetest.settings:get_bool('scaffold.locky') and math.round(pos.y) ~= math.round(scaffold.locky) then return end
|
|
||||||
if scaffold.can_place_wielded_at(pos) then
|
if scaffold.can_place_wielded_at(pos) then
|
||||||
minetest.place_node(pos)
|
minetest.place_node(pos)
|
||||||
end
|
end
|
||||||
@ -218,15 +217,9 @@ ws.rg('DigHead','Player','dighead',function() ws.dig(ws.dircoord(0,1,0)) end)
|
|||||||
ws.rg('SnapYaw','Bots','snapyaw',function() ws.setdir(snapdir) end,function() snapdir=ws.getdir() end)
|
ws.rg('SnapYaw','Bots','snapyaw',function() ws.setdir(snapdir) end,function() snapdir=ws.getdir() end)
|
||||||
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("Constrain", "scaffold_constrain", function(pos)
|
scaffold.register_template_scaffold("Constrain", "scaffold_constrain", function()end,false,function() scaffold.reset() end)
|
||||||
|
|
||||||
end,false,function() scaffold.reset() end)
|
ws.rg("LockYaw","Scaffold", "scaffold_lockyaw", function(pos) end, function() minetest.settings:set_bool('afly_snap',true) end, function() minetest.settings:set_bool('afly_snap',false) end)
|
||||||
|
|
||||||
scaffold.register_template_scaffold("LockYaw", "scaffold_lockyaw", function(pos)
|
|
||||||
if not scaffold.wason.scaffold_lockyaw then
|
|
||||||
minetest.settings:set_bool('afly_snap',true)
|
|
||||||
end
|
|
||||||
end, false, function() minetest.settings:set_bool('afly_snap',false) end)
|
|
||||||
|
|
||||||
|
|
||||||
scaffold.register_template_scaffold("CheckScaffold", "scaffold_check", function(pos)
|
scaffold.register_template_scaffold("CheckScaffold", "scaffold_check", function(pos)
|
||||||
@ -245,13 +238,14 @@ scaffold.register_template_scaffold("WaterScaffold", "scaffold_water", function(
|
|||||||
}, pos)
|
}, pos)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
scaffold.register_template_scaffold("WaterSpam", "scaffold_spamwater", function(pos)
|
scaffold.register_template_scaffold("WaterSpam", "scaffold_spamwater", function()
|
||||||
--if (pos.x % 2 + pos.z % 2) == 0 then
|
ws.do_area(3,function(pos)
|
||||||
scaffold.place_if_needed({
|
scaffold.place_if_needed({
|
||||||
"mcl_buckets:bucket_water",
|
"mcl_buckets:bucket_water",
|
||||||
"mcl_core:water_source"
|
"mcl_core:water_source"
|
||||||
}, pos)
|
}, pos)
|
||||||
--end
|
end,true)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
local function checknode(pos)
|
local function checknode(pos)
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node_or_nil(pos)
|
||||||
@ -297,13 +291,12 @@ scaffold.register_template_scaffold("TallTBM", "scaffold_ttbm", function(pos)
|
|||||||
ws.dircoord(1,1,0),
|
ws.dircoord(1,1,0),
|
||||||
ws.dircoord(1,0,0)
|
ws.dircoord(1,0,0)
|
||||||
}
|
}
|
||||||
for k,v in pairs(pos) do
|
ws.dignodes(pos)
|
||||||
scaffold.dig(v)
|
|
||||||
end
|
|
||||||
minetest.settings:set_bool('continuous_forward',true)
|
minetest.settings:set_bool('continuous_forward',true)
|
||||||
for k,v in pairs(pos) do
|
for k,v in pairs(pos) do
|
||||||
local n=minetest.get_node_or_nil(v)
|
local n=minetest.get_node_or_nil(v)
|
||||||
if n and n.name ~= "air" then
|
if not n or n.name ~= "air" then
|
||||||
minetest.settings:set_bool('continuous_forward',false)
|
minetest.settings:set_bool('continuous_forward',false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user