193 lines
5.2 KiB
Lua
Raw Normal View History

2021-05-11 12:02:19 +02:00
kamikaze={}
kamikaze.active=false
local fnd=false
2021-02-15 23:41:56 +01:00
local cpos=vector.new(0,0,0)
local hud_wp=nil
2021-02-15 23:41:56 +01:00
local zz=vector.new(42,42,42)
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
2021-02-15 23:41:56 +01:00
local tob=nil
local function set_kwp(name,pos)
if hud_wp then
minetest.localplayer:hud_change(hud_wp, 'world_pos', pos)
minetest.localplayer:hud_change(hud_wp, 'name', name)
else
hud_wp = minetest.localplayer:hud_add({
hud_elem_type = 'waypoint',
name = name,
text = 'm',
number = 0x00ff00,
world_pos = pos
})
end
end
local nextzz=0
local function randomzz()
if nextzz > os.clock() then return false end
math.randomseed(os.time())
2021-02-15 23:41:56 +01:00
zz.x=math.random(-128,129)
zz.y=math.random(0,searchheight)
zz.z=math.random(-128,128)
2021-02-15 23:41:56 +01:00
nextzz=os.clock()+ 30
end
2021-02-15 23:41:56 +01:00
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
2021-02-15 23:41:56 +01:00
for kk,txt in pairs(txts) do
if ( v:get_item_textures():find(txt) ) then
2021-02-13 04:00:34 +01:00
local npos=v:get_pos()
local dst=vector.distance(npos,minetest.localplayer:get_pos())
2021-02-15 23:41:56 +01:00
if odst > dst then
searchtxt=v:get_item_textures()
cpos=npos
set_kwp(searchtxt,v:get_pos())
odst=dst
2021-02-13 04:00:34 +01:00
fnd=true
2021-02-15 23:41:56 +01:00
tob=v
rt=v
2021-02-13 04:00:34 +01:00
end
2021-02-15 23:41:56 +01:00
end
end
end
2021-02-15 23:41:56 +01:00
return rt
end
2021-05-11 12:02:19 +02:00
2021-02-15 23:41:56 +01:00
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
2021-02-15 23:41:56 +01:00
for k,v in pairs(epos) do
local node=minetest.get_node_or_nil(v)
2021-02-13 04:00:34 +01:00
local lp=minetest.localplayer:get_pos()
2021-02-15 23:41:56 +01:00
local dst=vector.distance(lp,v)
if odst > dst then
odst=dst
cpos=vv
rt=vv
fnd=true
end
end
end
2021-02-15 23:41:56 +01:00
return rt
end
2021-02-15 23:41:56 +01:00
local function find_bad_things()
if fnd then return true end
local lp=minetest.localplayer:get_pos()
local ob=find_ob(badobs)
if not ob then ob=find_nd(badnodes) end
if not ob then
set_kwp('nothing found',zz)
randomzz()
fnd=false
return false
end
return true
end
local function flythere()
2021-02-15 23:41:56 +01:00
if not minetest.localplayer then return end
if not cpos then return end
ws.aim(cpos)
2021-05-11 12:02:19 +02:00
minetest.settings:set_bool("killaura",false)
2021-02-15 23:41:56 +01:00
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)
end
2021-05-11 12:02:19 +02:00
local function stopflight()
2021-02-15 23:41:56 +01:00
local lp = minetest.localplayer:get_pos()
local dst=vector.distance(lp,cpos)
2021-02-13 04:00:34 +01:00
minetest.settings:set_bool("continuous_forward",false)
2021-02-15 23:41:56 +01:00
if tob and tob:get_item_textures():find(searchtxt) then
2021-05-11 12:02:19 +02:00
if searchtxt == 'mcl_end_crystal.png' then
minetest.dig_node(cpos)
tob:punch()
minetest.interact('start_digging')
2021-02-15 23:41:56 +01:00
searchtxt=""
2021-05-11 12:02:19 +02:00
tob=nil
else
minetest.settings:set_bool("killaura",true)
2021-02-15 23:41:56 +01:00
end
end
fnd=false
tob=nil
end
2021-02-13 04:00:34 +01:00
2021-02-13 04:00:34 +01:00
ws.rg('Kamikaze','Bots','kamikaze', function()
local lp = minetest.localplayer:get_pos()
2021-02-15 23:41:56 +01:00
local dst=vector.distance(lp,cpos)
2021-05-11 12:02:19 +02:00
if not find_bad_things() then
2021-05-11 12:02:19 +02:00
if vector.distance(lp,zz) < 1 then
stopflight()
else
cpos=zz
2021-05-11 12:02:19 +02:00
flythere()
end
2021-05-11 12:02:19 +02:00
elseif dst < 1 then
stopflight()
2021-02-15 23:41:56 +01:00
else
2021-05-11 12:02:19 +02:00
flythere()
end
2021-05-11 12:02:19 +02:00
-- ws.dignodes(minetest.find_nodes_near(minetest.localplayer:get_pos(),5,badnodes,true))
2021-02-15 23:41:56 +01:00
if cpos then
2021-05-11 12:02:19 +02:00
minetest.dig_node(cpos)
--minetest.interact('start_digging')
2021-02-15 23:41:56 +01:00
end
2021-02-13 04:00:34 +01:00
end,function()
core.set_keypress("special1", true)
2021-05-11 12:02:19 +02:00
kamikaze.active=true
2021-02-13 04:00:34 +01:00
end, function()
2021-05-11 12:02:19 +02:00
kamikaze.active=false
2021-02-13 04:00:34 +01:00
core.set_keypress("special1", false)
fnd=false
if hud_wp then
minetest.localplayer:hud_remove(hud_wp)
hud_wp=nil
2021-02-13 04:00:34 +01:00
end
2021-05-11 12:02:19 +02:00
end,{"noclip","pitch_move","dighead","digbadnodes"})
2021-02-13 04:00:34 +01:00
minetest.register_on_death(function()
if not minetest.settings:get_bool("kamikaze") then return end
2021-02-15 23:41:56 +01:00
tob=nil
-- incremental_tp.tpactive=false
2021-02-13 04:00:34 +01:00
minetest.after("5.0",function()
fnd=false
end)
end)
ws.on_connect(function()
2021-05-11 12:02:19 +02:00
minetest.settings:set_bool("kamikaze",false)
--if minetest.localplayer and minetest.localplayer:get_name():find("kamikaze") then
-- minetest.settings:set_bool("kamikaze",true)
--else minetest.settings:set_bool("kamikaze",false)
--end
end)
2021-02-15 23:41:56 +01:00
minetest.register_cheat('KamiCrystals','Bots','kamikaze_crystals')