Ir para conteúdo

Nova Spell arrow repel para paladins


gusinhi

Posts Recomendados

Spoiler

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)

function onGetFormulaValues(player, attack, factor)
    local skillTotal = 2 * player:getEffectiveSkillLevel(SKILL_DISTANCE)
    local levelTotal = player:getLevel() / 5
    return -(((skillTotal + attack / 2500) * 0.5) + (levelTotal) + 7), -(((skillTotal + attack / 1875) * 0.75) + (levelTotal) + 13)
end

 
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
local function isWalkable(pos, creature, proj, pz)
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end
 
 
local function push(id, dir, t)
    if t < 0 or not(isCreature(id)) then return true end
    local pos = getPositionByDirection(getThingPos(id), dir)
    if not(isWalkable(pos, true, false, true)) then
        return true
    end
    doTeleportThing(id, pos, true)
    addEvent(push, 0, id, dir, t-1)
end
 
local config = {
    ammu = {2543,2544,2545,2546,2547,6529,7363,7364,7365,7838,7839,7840,7850},
    pushBack = 2
}
function onCastSpell(cid, var)
    local removed = false
    for _, itemid in pairs(config.ammu) do
        if getPlayerItemCount(cid, itemid) >= 1 then
            doPlayerRemoveItem(cid, itemid, 1)
            removed = true
            end
            if getPlayerSlotItem(cid, 5).itemid == 7438 or getPlayerSlotItem(cid, 6).itemid == 7438 then
            removed = true
            break
        
        end
    end
    if not(removed) then return doPlayerSendCancel(cid, "You need ammunation for this spell.") and false end    
    local ret = doCombat(cid, combat, var)
    if ret then
        local dirTo = getDirectionTo(getThingPos(cid), getThingPos(variantToNumber(var)))
        push(variantToNumber(var), dirTo, config.pushBack)
    end
    return ret
end

 

 

 
Link para o comentário
Compartilhar em outros sites

  • 5 weeks later...
×
×
  • Criar Novo...