Spoiler
if POWERS_LUA ~= nil then return end
POWERS_LUA = 1
end
POWER_INVINCIBILITY = 1
POWER_ONESHOTKILL = 2
POWER_FORCEFIELD = 3
POWER_SPEED = 4
POWER_MONEY = 5
local power_enabled = false
local power_flags = {}
local power_forcefieldimgs = {}
function power_enable(enable)
if enable ~= nil then
if enable then
addhook("hit", "powers_lua__hit")
addhook("join", "powers_lua__join")
addhook("spawn", "powers_lua__spawn")
addhook("objectdamage", "powers_lua__objectdamage")
for _,id in ipairs(player(0,"table")) do
power_flags[id] = {}
end
else
freehook("hit", "powers_lua__hit")
freehook("join", "powers_lua__join")
freehook("spawn", "powers_lua__spawn")
freehook("objectdamage", "powers_lua__objectdamage")
for id in pairs(power_forcefieldimgs) do
power_destroyforcefield(id)
end
end
power_enabled = enable
end
return power_enabled
end
function power_set(id, power, enable)
power_flags[id][power] = enable
if power == POWER_FORCEFIELD then
if enable then
power_createforcefield(id)
power_forcefieldlooppl(id)
power_forcefieldloopbld(id)
else
power_destroyforcefield(id)
end
elseif power == POWER_SPEED then
parse("speedmod " .. id .. " " .. (enable and 200 or 0))
elseif power == POWER_MONEY then
power_moneyloop(id)
end
end
function power_get(id, power)
return power_enabled and not player(id, "bot") and player(id, "exists") and power_flags[id][power] == true
end
function powers_lua__join(id)
power_flags[id] = {}
settimeout(200,
function()
power_destroyforcefield(id)
end
)
end
function powers_lua__hit(id,source,weapon,hpdmg,apdmg)
if power_get(id, POWER_INVINCIBILITY) then
return 1
end
if power_get(source, POWER_ONESHOTKILL) then
if game("sv_friedlyfire") == 1 or player(source, "team") ~= player(id, "team") then
parse(string.format('customkill %d %s %d', source, itemtype(player(source, "weapon"), "name"), id))
return 1
end
end
end
function powers_lua__spawn(id)
if power_get(id, POWER_SPEED) then
parse("speedmod " .. id .. " 200")
end
if power_get(id, POWER_FORCEFIELD) then
settimeout(50,
function()
power_createforcefield(id)
end
)
end
end
function powers_lua__objectdamage(id,damage,player)
if power_get(player, POWER_ONESHOTKILL) then
parse(string.format("explosion %d %d 2 200000", object(id, "x")+16, object(id, "y")+16))
end
end
function power_createforcefield(id)
power_destroyforcefield(id)
power_forcefieldimgs[id] = createimage("gfx/sprites/flare3.bmp", 1, 0, 100+id, nil, 1, 0, 0.9)
end
function power_destroyforcefield(id)
if power_forcefieldimgs[id] == nil then return end
freeimage(power_forcefieldimgs[id])
power_forcefieldimgs[id] = nil
end
function power_moneyloop(id)
if not power_get(id, POWER_MONEY) then return end
if player(id, "money") < 16000 then
parse("setmoney " .. id .. " 16000")
end
settimeout(1000, power_moneyloop, id)
end
function power_forcefieldlooppl(id)
if not power_get(id, POWER_FORCEFIELD) then return end
if player(id, "health") > 0 then
local cx = player(id, "x")
local cy = player(id, "y")
for _,v in ipairs(player(0,"table")) do
if math.pow(cx - player(v, "x"), 2) + math.pow(cy - player(v, "y"), 2) < 5000 then
if player(v, "health") > 0 then
if v ~= id then parse("killplayer " .. v) end
end
end
end
end
settimeout(300, power_forcefieldlooppl, id)
end
function power_forcefieldloopbld(id)
if not power_get(id, POWER_FORCEFIELD) then return end
if player(id, "health") > 0 then
local cx = player(id, "tilex")
local cy = player(id, "tiley")
for _,v in ipairs(object(0,"table")) do
if math.pow(cx - object(v, "tilex"), 2) + math.pow(cy - object(v, "tiley"), 2) < 6 then
parse(string.format('effect "colorsmoke" %d %d 1 30 255 255 255', object(v, "x")+15, object(v, "y")+15))
parse("killobject " .. v)
end
end
end
settimeout(500, power_forcefieldloopbld, id)
end
cmd("powerenable",
function(args)
if #args == 1 then
power_enable(args[1] == "1")
end
print(power_enable() and "enabled" or "disabled")
end
)
cmd("powerset",
function(args)
if not power_enable() then
errortoconsole("enable first")
return
end
if #args ~= 3 then
errortoconsole("args")
return
end
power_set(_tonumber(args[1]), _tonumber(args[2]), args[3] == "1")
end
)
freehook("hit", "powers_lua__hit")
freehook("join", "powers_lua__join")
freehook("spawn", "powers_lua__spawn")
freehook("objectdamage", "powers_lua__objectdamage")
POWERS_LUA = 1
end
POWER_INVINCIBILITY = 1
POWER_ONESHOTKILL = 2
POWER_FORCEFIELD = 3
POWER_SPEED = 4
POWER_MONEY = 5
local power_enabled = false
local power_flags = {}
local power_forcefieldimgs = {}
function power_enable(enable)
if enable ~= nil then
if enable then
addhook("hit", "powers_lua__hit")
addhook("join", "powers_lua__join")
addhook("spawn", "powers_lua__spawn")
addhook("objectdamage", "powers_lua__objectdamage")
for _,id in ipairs(player(0,"table")) do
power_flags[id] = {}
end
else
freehook("hit", "powers_lua__hit")
freehook("join", "powers_lua__join")
freehook("spawn", "powers_lua__spawn")
freehook("objectdamage", "powers_lua__objectdamage")
for id in pairs(power_forcefieldimgs) do
power_destroyforcefield(id)
end
end
power_enabled = enable
end
return power_enabled
end
function power_set(id, power, enable)
power_flags[id][power] = enable
if power == POWER_FORCEFIELD then
if enable then
power_createforcefield(id)
power_forcefieldlooppl(id)
power_forcefieldloopbld(id)
else
power_destroyforcefield(id)
end
elseif power == POWER_SPEED then
parse("speedmod " .. id .. " " .. (enable and 200 or 0))
elseif power == POWER_MONEY then
power_moneyloop(id)
end
end
function power_get(id, power)
return power_enabled and not player(id, "bot") and player(id, "exists") and power_flags[id][power] == true
end
function powers_lua__join(id)
power_flags[id] = {}
settimeout(200,
function()
power_destroyforcefield(id)
end
)
end
function powers_lua__hit(id,source,weapon,hpdmg,apdmg)
if power_get(id, POWER_INVINCIBILITY) then
return 1
end
if power_get(source, POWER_ONESHOTKILL) then
if game("sv_friedlyfire") == 1 or player(source, "team") ~= player(id, "team") then
parse(string.format('customkill %d %s %d', source, itemtype(player(source, "weapon"), "name"), id))
return 1
end
end
end
function powers_lua__spawn(id)
if power_get(id, POWER_SPEED) then
parse("speedmod " .. id .. " 200")
end
if power_get(id, POWER_FORCEFIELD) then
settimeout(50,
function()
power_createforcefield(id)
end
)
end
end
function powers_lua__objectdamage(id,damage,player)
if power_get(player, POWER_ONESHOTKILL) then
parse(string.format("explosion %d %d 2 200000", object(id, "x")+16, object(id, "y")+16))
end
end
function power_createforcefield(id)
power_destroyforcefield(id)
power_forcefieldimgs[id] = createimage("gfx/sprites/flare3.bmp", 1, 0, 100+id, nil, 1, 0, 0.9)
end
function power_destroyforcefield(id)
if power_forcefieldimgs[id] == nil then return end
freeimage(power_forcefieldimgs[id])
power_forcefieldimgs[id] = nil
end
function power_moneyloop(id)
if not power_get(id, POWER_MONEY) then return end
if player(id, "money") < 16000 then
parse("setmoney " .. id .. " 16000")
end
settimeout(1000, power_moneyloop, id)
end
function power_forcefieldlooppl(id)
if not power_get(id, POWER_FORCEFIELD) then return end
if player(id, "health") > 0 then
local cx = player(id, "x")
local cy = player(id, "y")
for _,v in ipairs(player(0,"table")) do
if math.pow(cx - player(v, "x"), 2) + math.pow(cy - player(v, "y"), 2) < 5000 then
if player(v, "health") > 0 then
if v ~= id then parse("killplayer " .. v) end
end
end
end
end
settimeout(300, power_forcefieldlooppl, id)
end
function power_forcefieldloopbld(id)
if not power_get(id, POWER_FORCEFIELD) then return end
if player(id, "health") > 0 then
local cx = player(id, "tilex")
local cy = player(id, "tiley")
for _,v in ipairs(object(0,"table")) do
if math.pow(cx - object(v, "tilex"), 2) + math.pow(cy - object(v, "tiley"), 2) < 6 then
parse(string.format('effect "colorsmoke" %d %d 1 30 255 255 255', object(v, "x")+15, object(v, "y")+15))
parse("killobject " .. v)
end
end
end
settimeout(500, power_forcefieldloopbld, id)
end
cmd("powerenable",
function(args)
if #args == 1 then
power_enable(args[1] == "1")
end
print(power_enable() and "enabled" or "disabled")
end
)
cmd("powerset",
function(args)
if not power_enable() then
errortoconsole("enable first")
return
end
if #args ~= 3 then
errortoconsole("args")
return
end
power_set(_tonumber(args[1]), _tonumber(args[2]), args[3] == "1")
end
)
freehook("hit", "powers_lua__hit")
freehook("join", "powers_lua__join")
freehook("spawn", "powers_lua__spawn")
freehook("objectdamage", "powers_lua__objectdamage")