• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X Spells/Rune SD ONE HIT KILL - no function on creature and monsters

Enderlop

Banned User
Joined
Jan 10, 2024
Messages
93
Reaction score
16
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1000000000, -10000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Post automatically merged:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)

function damage(cid, level, maglevel)
    local min = 1000000000
    local max = 1000000000
    return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "damage")

function oneShot(cid, target)
    if isPlayer(target) or isMonster(target) then
        doCreatureAddHealth(target, -getCreatureMaxHealth(target))
    end
    return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "oneShot")

local area = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local combatArea = createCombatArea(area)
setCombatArea(combat, combatArea)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

I wanted to attack the creature and attack in a local area like needtarget="1"
 
Last edited:
needtarget="1" is part of spells.xml and it defines, if spell will be execute at all (no target = cancel spell) and what will be in var of function onCastSpell (needTarget=1 = rune target position or target attacked on battle, needTarget=0 = casting player position).

Then it calls doCombat with given combat and var (target position/target creature). In case of spell (combat) with area, it will call area with center at target of spell. If it does not needTarget, then area center will be at casting player position.
One of positions in area must be 3, not 1 to tell script where is center of area ex. ( 3777/data/spells/lib/spells.lua at 29eb7a67e6994950687967f5afb69c39b04dd622 · Fir3element/3777 (https://github.com/Fir3element/3777/blob/29eb7a67e6994950687967f5afb69c39b04dd622/data/spells/lib/spells.lua#L124-L136) ):
Lua:
AREA_CROSS5X5 = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
}
I see all set to 1 in your script - script cannot find center position.

Problem with:
Lua:
function oneShot(cid, target)
    if isPlayer(target) or isMonster(target) then
        doCreatureAddHealth(target, -getCreatureMaxHealth(target))
    end
    return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "oneShot")
is that doCreatureAddHealth does take attacker as parameter. It will remove HP from target and kill it, but player who casted spell won't be treated as killer.

Combat with 1kkk dmg should be better:
Lua:
function damage(cid, level, maglevel)
    local min = 1000000000
    local max = 1000000000
    return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "damage")
 
You can drop the target with area AREA_CROSS5X5 = {drop on target line effect with CONST_ANI_SUDDENDEATH

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0}

1. SD TARGET WITH EFFECTS SD
COMBAT_DEATHDAMAGE)
CONST_ME_MORTAREA
CONST_ANI_SUDDENDEATH

2. (UE) LOCAL AREA TARGET

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function damage(cid, level, maglevel)
    local min = 1000000000
    local max = 1000000000
    return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "damage")

function oneShot(cid, target)
    if isPlayer(target) or isMonster(target) then
        doCreatureAddHealth(target, -getCreatureMaxHealth(target))
    end
    return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "oneShot")

local area = { ---> FOLLOW ATTACK SD WITH UE TARGET
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0},
}
local combatArea = createCombatArea(area)
setCombatArea(combat, combatArea)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Last edited:
what I modified works thanks @Gesior.pl @Edit:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function damage(cid, level, maglevel)
    local min = 1000000000
    local max = 1000000000
    return -min, -max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "damage")

function oneShot(cid, target)
    if isPlayer(target) or isMonster(target) then
        doCreatureAddHealth(target, -getCreatureMaxHealth(target))
    end
    return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "oneShot")

local area = {
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}
local combatArea = createCombatArea(area)
setCombatArea(combat, combatArea)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Last edited:
Back
Top