• 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 DAMAGE FIX

hyz

Member
Joined
Oct 30, 2008
Messages
39
Reaction score
16
Can anyone tell me if I can make this rune work in player and also in monsters?
I've tried everything but it always gives an error


Lua:
local combat = COMBAT_FIREDAMAGE
local effect = 79
local disteffect = 28
local tiempo = 200
local hits = 25
local count = 50
local Range = 2;

local function sendAttack(pos, cid)   
    
    local player = Player(cid)   
    local hit_min = player:getLevel()*0.05 + 50
    local hit_max = player:getLevel()*0.10 + 500   
    local specs = Game.getSpectators(pos,false, false, Range, Range, Range, Range)
            
    for i = 1, #specs do
        if specs[i]:isPlayer() == true then
            if isSightClear(player:getPosition(), specs[i]:getPosition(), true) then
                if specs[i]:getMaster() == nil    then
                    doTargetCombatHealth(player, Creature(specs[i]), combat, -hit_min, -hit_max, effect)                   
                end               
            end   
        end
    end
end

local function Aura(pos, cid)
    local player = Player(cid)   
    Position(pos.x+2, pos.y+1, pos.z):sendDistanceEffect(Position(pos.x+2, pos.y-1, pos.z), disteffect)
    Position(pos.x+2, pos.y-1, pos.z):sendDistanceEffect(Position(pos.x+1, pos.y-2, pos.z), disteffect)
    Position(pos.x+1, pos.y-2, pos.z):sendDistanceEffect(Position(pos.x-1, pos.y-2, pos.z), disteffect)
    Position(pos.x-1, pos.y-2, pos.z):sendDistanceEffect(Position(pos.x-2, pos.y-1, pos.z), disteffect)
    Position(pos.x-2, pos.y-1, pos.z):sendDistanceEffect(Position(pos.x-2, pos.y+1, pos.z), disteffect)
    Position(pos.x-2, pos.y+1, pos.z):sendDistanceEffect(Position(pos.x-1, pos.y+2, pos.z), disteffect)
    Position(pos.x-1, pos.y+2, pos.z):sendDistanceEffect(Position(pos.x+1, pos.y+2, pos.z), disteffect)
    Position(pos.x+1, pos.y+2, pos.z):sendDistanceEffect(Position(pos.x+2, pos.y+1, pos.z), disteffect)
    sendAttack(pos, player.uid)
    
    count = count +1
    
    if(hits >= count) then
        addEvent(Aura, tiempo, pos, player.uid)   
    end   
end

local function Boom(pos)
    pos:sendMagicEffect(effect)
end


function onCastSpell(creature, variant, isHotkey)
    count = 1   
    local player = Player(creature)
    local targetPOS = Position(variant.pos.x, variant.pos.y, variant.pos.z)   
        
    player:getPosition():sendDistanceEffect(targetPOS, disteffect)
    addEvent(Aura, 200, targetPOS, player.uid)   
    addEvent(Boom, 200, targetPOS)   
    
    return true
end
 
Solution
Lua:
local function reflect(cid, target, toPosi)
    local player = Player(cid)
    local _target = Creature(target)   
    local hit_min = player:getLevel()*0.1 + 100
    local hit_max = player:getLevel()*0.2 + 800
    
    if _target ~= nil then   
        if _target:isPlayer() or _target:isMonster() then
            if isSightClear(player:getPosition(), _target:getPosition(), true) then
                doTargetCombatHealth(player, _target, combat, -hit_min/count, -hit_max/count, effect)
                toPosi:sendDistanceEffect(_target:getPosition(), disteffect)
                count = count +1               
            end   
        end
    end   
    
    if(hits >= count) then
        addEvent(reflect, tiempo, player.uid...
It worked perfectly, thank you very much!

I was trying to do this one, but I believe it has to change in more places...
Lua:
local combat = COMBAT_EARTHDAMAGE
local effect = CONST_ME_ICEATTACK
local disteffect = 8
local tiempo = 200
local hits = 25
local count = 50


local function reflect(cid, target, toPosi)
    local player = Player(cid)
    local spectator = Creature(target)   
    local hit_min = player:getLevel()*0.1 + 100
    local hit_max = player:getLevel()*0.2 + 800
    
    if spectator ~= nil then   
        if spectator:isCreature() then
            if spectator:isPlayer() then
                if isSightClear(player:getPosition(), spectator:getPosition(), true) then
                    doTargetCombatHealth(player, spectator, combat, -hit_min/count, -hit_max/count, effect)
                    toPosi:sendDistanceEffect(spectator:getPosition(), disteffect)
                    count = count +1               
                end   
            end
        end   
    
        if(hits >= count) then
            addEvent(reflect, tiempo, player.uid, spectator.uid, player:getPosition())   
        end
    end   
    
    return true
end


function onCastSpell(creature, variant, isHotkey)
    count = 1
    
    local player = Player(creature)
    local target = Creature(variant.number)   
    reflect(player.uid, target.uid, player:getPosition())
    
    return true
end

in this rune I changed
if specs:isPlayer() == true then
to
if specs:isPlayer() or specs:isMonster() then

however, it didn't work...

I'm using TFS 1.3
 
Lua:
local function reflect(cid, target, toPosi)
    local player = Player(cid)
    local _target = Creature(target)   
    local hit_min = player:getLevel()*0.1 + 100
    local hit_max = player:getLevel()*0.2 + 800
    
    if _target ~= nil then   
        if _target:isPlayer() or _target:isMonster() then
            if isSightClear(player:getPosition(), _target:getPosition(), true) then
                doTargetCombatHealth(player, _target, combat, -hit_min/count, -hit_max/count, effect)
                toPosi:sendDistanceEffect(_target:getPosition(), disteffect)
                count = count +1               
            end   
        end
    end   
    
    if(hits >= count) then
        addEvent(reflect, tiempo, player.uid, _target.uid, player:getPosition())   
    end
    
    return true
end
 
Solution
Back
Top