2551ddbf1d
This commit contains changes best credited to flyc0r <flyc0r@localhost.localdomain>, although the changes were separated out from waspsaliva's original initial commit rev. 0e9e1f352, which added the files from DFC work tree, and squashed in numerous additions by flyc0r and collaborators. That commit log: commit 0e9e1f3528c3d2fa1f1e9a79d4a00576be8552f5 Author: flyc0r <flyc0r@localhost.localdomain> Date: Sun Oct 4 03:37:08 2020 +0200 init This rebase had the effect of griefing the git history xD, so for example `git blame` of DFC and even upstream Minetest sources appear to be originally authored by `flyc0r` in that commit. To fix this, I will recommit only the changes onto the appropriate commit in DFC, and recreate the following git history (incl. merges). After this, the git history will be at least visually the same as the original Waspsaliva, even if commit sha1sums have changed. AFAICT, the closest commit from DFC was af085acbd. That commit was found simply by running `git diff wsc-master <some_DFC_rev>`, and locating the commit with the smallest number of differences. This commit was then created as follows: # Check out the DFC base commit git checkout af085acbd # Check out the *files* from WSC's initial commit git checkout 0e9e1f352 -- . # Make sure everything is added and commit the changes git add -A git commit
133 lines
3.9 KiB
Lua
133 lines
3.9 KiB
Lua
--
|
|
-- cora's defensive combat hax
|
|
-- * undying
|
|
-- * damagepanic
|
|
|
|
panicm = {}
|
|
local undying = true --will automatically /sethome when taking damage below 3 hp, tp you back when you die and dig the bones undying needs autorespawn enabled in dragonfire (might steal the code at some point to enable it for vanilla / other clients)
|
|
local damagepanic = true --will tp you 50 nodes up on damage taken when hp is < paniclimit
|
|
|
|
local check_target = true
|
|
|
|
local paniclimit=17
|
|
|
|
local tprange=50;
|
|
|
|
|
|
local function sleep(n) -- seconds
|
|
local t0 = os.clock()
|
|
while os.clock() - t0 <= n do end
|
|
end
|
|
|
|
|
|
local function mwarp(pos)
|
|
if not pos then return end
|
|
--minetest.display_chat_message("Flightaura: Damage taken, target clear. Tping up to "..pos['y'])
|
|
minetest.localplayer:set_pos(pos)
|
|
|
|
end
|
|
|
|
minetest.register_on_death(function()
|
|
if not minetest.settings:get_bool("undying") then return end
|
|
minetest.send_chat_message("/home")
|
|
sleep(2)
|
|
local bn=minetest.find_node_near(minetest.localplayer:get_pos(), 4, {"bones:bones"},true)
|
|
if not bn then return end
|
|
minetest.dig_node(bn)
|
|
end)
|
|
|
|
local tprangeh=20
|
|
local tprangepy=50
|
|
local tprangeny=60
|
|
|
|
function panicm.find_target(check_target)
|
|
if not minetest.settings:get_bool("damagepanic") then return end
|
|
local ppos=minetest.localplayer:get_pos()
|
|
local tpos=vector.add(ppos,{x=0,y=tprange,z=0})
|
|
if check_target then return tpos end
|
|
local pos=false
|
|
for i = 0,tprangepy,1 do
|
|
local nod=minetest.get_node_or_nil(vector.add(tpos,{x=0,y=-i,z=0}))
|
|
if nod and (nod["name"] == "air") then fnd=true break end
|
|
end
|
|
if not fnd then
|
|
for i = -tprangeh,tprangeh,1 do
|
|
local nod=minetest.get_node_or_nil(vector.add(tpos,{x=i,y=0,z=0}))
|
|
if nod and (nod["name"] == "air") then fnd=true break end
|
|
local nod=minetest.get_node_or_nil(vector.add(tpos,{x=0,y=0,z=i}))
|
|
if nod and (nod["name"] == "air") then fnd=true break end
|
|
end
|
|
end
|
|
if not fnd then
|
|
for i = -tprangeny,0,1 do
|
|
local nod=minetest.get_node_or_nil(vector.add(tpos,{x=0,y=i,z=0}))
|
|
if nod and (nod["name"] == "air") then fnd=true break end
|
|
end
|
|
end
|
|
if not fnd then
|
|
minetest.display_chat_message("no clear node to flee. turning on Killaura.")
|
|
minetest.settings:set_bool("killaura",true)
|
|
return false
|
|
end
|
|
return pos
|
|
end
|
|
|
|
minetest.register_on_damage_taken(function(hp)
|
|
local hhp=minetest.localplayer:get_hp()
|
|
minetest.display_chat_message("hp:"..hp)
|
|
minetest.display_chat_message("hhp:"..hhp)
|
|
if (hp==0 ) then return end
|
|
if ( hhp < paniclimit ) and (hhp >= 3 ) then
|
|
cpos=panicm.find_target(check_target)
|
|
if minetest.settings:get_bool("damagepanic") then
|
|
minetest.settings:set("free_move", "true")
|
|
mwarp(vector.add(cpos,{x=0,y=-1,z=0}))
|
|
--sleep(2)
|
|
end
|
|
elseif (hp < 3 ) then
|
|
if minetest.settings:get_bool("undying") then
|
|
minetest.settings:set_bool("autorespawn",true)
|
|
minetest.send_chat_message("/sethome") end
|
|
end
|
|
end
|
|
)
|
|
|
|
|
|
minetest.register_chatcommand("eat", {
|
|
params = "",
|
|
description = "",
|
|
func = function()
|
|
local pl = minetest.localplayer
|
|
local inv = minetest.get_inventory("current_player")
|
|
for index, stack in pairs(inv.main) do
|
|
minetest.display_chat_message(stack)
|
|
if (stack == "mcl_farming:carrot_item_gold") then pl.set_wield_index(index) break end
|
|
break
|
|
end
|
|
return
|
|
end})
|
|
minetest.register_chatcommand("dhead", {
|
|
params = "",
|
|
description = "",
|
|
func = function()
|
|
--eat()
|
|
-- minetest.display_chat_message("head")
|
|
-- minetest.display_chat_message(dump(minetest.get_inventory("current_player").main))
|
|
minetest.settings:set_bool("autotool",true)
|
|
sleep(1)
|
|
local ppos=vector.add(minetest.localplayer:get_pos(),{x=0,y=1,z=0})
|
|
if ppos then minetest.dig_node(ppos) end
|
|
return
|
|
end
|
|
})
|
|
|
|
|
|
-- REG cheats on DF
|
|
if (_G["minetest"]["register_cheat"] ~= nil) then
|
|
minetest.register_cheat("Flightaura", "Combat", "damagepanic")
|
|
minetest.register_cheat("Undying", "Combat", "undying")
|
|
else
|
|
minetest.settings:set_bool('undying',true)
|
|
minetest.settings:set_bool('damagepanic',true)
|
|
end
|