• 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!

Lua Healing Spear heal monsters...

Adorius Black

Advanced OT User
Joined
Mar 31, 2020
Messages
301
Solutions
3
Reaction score
180
Hi guys I want to create healing spear but here is problem. I want to heal only pleayers but it heals also monsters. I was searching little bit on OTland and found function
function onTargetCreature(creature, target)
with CallBack but can't figure out how to put it there. Is here any scripter who can fix it?

Thank you.

Lua:
local animEffect = 15 -- Custom effect ID/name for when the double hit procs
local procChance = 80 -- Chance for the Double Hit.

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
setCombatFormula(combat1, COMBAT_FORMULA_SKILL , 0, 0, 2, 0)

local arr = {
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 3, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0}
}

local area = createCombatArea(arr)
setCombatArea(combat1, area)

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING) -- Damage type
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
combat:setFormula(COMBAT_FORMULA_SKILL, 0, 0, 1, 0) -- Damage Formula

function doDoubleHit(player, variant) -- Function to be the callback of our addEvent later on
    return combat:execute(player, variant)
end

function onUseWeapon(player, variant)
local
distskill = getPlayerSkill(player,4)
chance = math.random(1,100) -- Defines a random number from 1 to 100
    if chance <= procChance then -- If the number defined on the above variable is lesser or equal to the procChance, runs the code below
        combat:setParameter(COMBAT_PARAM_EFFECT, animEffect)
        combat:execute(player, variant) -- Executes the first hit
        addEvent(doDoubleHit, 500, player:getId(), variant) -- Adds an event with the doDoubleHit callback, called in 500ms
        player:say("TARGET HEAL!", TALKTYPE_MONSTER_SAY) -- We would like the player to know he just heal his target, so we make him say "TARGET HEAL" in orange.
    else return player:say("GODEYE!", TALKTYPE_MONSTER_SAY) and doCombat(player, combat1, variant)  end
end
 
Back
Top