Ir para conteúdo
  • 0

-=[TFS]=- 0.4 8.60 - USAR SOMENTE AS AURAS Soul System


Muvuka

Pergunta

 

Como faço para usar o Soul System para usar auras sem precisar capturar monstros, basta digitar o nome da aura e atacar os monstros e jogadores com a aura

 

Auras.lua Creaturescript.lua Soul System.xml Soul.lua Action.lua

Editado por Muvuka
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 1
function checkDam(uid, AurAz, st)
    if (isCreature(uid)) and (os.time() - st < L_Soul.auras[AurAz].duration) then
        local p = getThingPos(uid)
        local poz = {
            {x = p.x, y = p.y - 2, z = p.z},
            {x = p.x - 2, y = p.y, z = p.z},
            {x = p.x, y = p.y + 2, z = p.z},
            {x = p.x + 2, y = p.y, z = p.z}
        }

        -- Verifica se a tile está protegida
        if (getTileInfo(p).protection) then
            st = st - L_Soul.auras[AurAz].duration
        end

        local function getBest(a)
            local pz = poz[1]
            for i, v in pairs(poz) do
                if (getDistanceBetween(v, getThingPos(a)) < getDistanceBetween(pz, getThingPos(a))) then
                    pz = v
                end
            end
            return pz
        end

        local creat = getUidsInArea({x = p.x - L_Soul.auras[AurAz].raio, y = p.y - L_Soul.auras[AurAz].raio, z = p.z}, {x = p.x + L_Soul.auras[AurAz].raio, y = p.y + L_Soul.auras[AurAz].raio, z = p.z})
        local target = ((isCreature(getCreatureTarget(uid))) and getCreatureTarget(uid)) or 0

        local cs = {}
        if (target == 0) then
            for _, v in pairs(creat) do
                -- Verifica se a criatura é um monstro ou se tem um alvo válido
                if ((getCreatureTarget(v) == uid) or (isMonster(v) or ((getCreatureSkullType(v) > 2) and (getCreatureTarget(v) == uid))) and (v ~= uid)) then
                    table.insert(cs, v)
                end
            end
            target = (#cs > 0 and cs[math.random(#cs)]) or 0
        end

        -- Verifica se o ataque foi feito pelo jogador
        if (isPlayer(uid)) then
            target = uid
        end

        if (target ~= 0) then
            doSendDistanceShoot(getBest(target), getThingPos(target), L_Soul.souls[AurAz].effects.distance)
            doTargetCombatHealth(uid, target, L_Soul.souls[AurAz].combat, -L_Soul.auras[AurAz].damage[1], -L_Soul.auras[AurAz].damage[2], 255)
        end

        addEvent(checkDam, L_Soul.auras[AurAz].interval, uid, AurAz, st)
    end
end

function sendEffect(uid, interval, at, st, AurAz)
    local at = at or 1

    if (isCreature(uid)) then
        local p = getThingPos(uid)

        if (getTileInfo(p).protection) then
            st = st - L_Soul.auras[AurAz].duration
        end

        local poz = {
            {x = p.x, y = p.y - 2, z = p.z},
            {x = p.x - 2, y = p.y, z = p.z},
            {x = p.x, y = p.y + 2, z = p.z},
            {x = p.x + 2, y = p.y, z = p.z}
        }

        if (os.time() - st > L_Soul.auras[AurAz].duration) then
            for i, v in ipairs(poz) do
                doSendDistanceShoot(v, p, L_Soul.souls[AurAz].effects.distance)
            end
            setPlayerStorageValue(uid, L_Soul.auras_sto, -1)
            addEvent(doSendMagicEffect, 250, p, L_Soul.souls[AurAz].effects.eff)
            return true
        end

        local next = poz[at + 1] and at + 1 or 1
        doSendDistanceShoot(poz[at], poz[next], L_Soul.souls[AurAz].effects.distance)
        addEvent(sendEffect, interval, uid, interval, next, st, AurAz)
    end

    return true
end

function onSay(cid, words, param)
    domodlib("Soul System[LIB]")

    local lan = L_Soul.lang[L_Soul.language]

    local AurAz = words:explode(" ")[1]

    -- Verifica se a aura é válida
    if not (L_Soul.auras[AurAz]) then
        return false
    end

    -- Verifica se o jogador possui pedras de alma suficientes para ativar a aura
    if (#getPlayerSoulStonesByType(cid, AurAz) < L_Soul.auras[AurAz].stones_n) then
        return doPlayerSendCancel(cid, string.format(lan[19], AurAz, L_Soul.auras[AurAz].stones_n))
    end

    -- Verifica se o jogador já está sob efeito de uma aura
    if (getPlayerStorageValue(cid, L_Soul.auras_sto) > 0) then
        return doPlayerSendCancel(cid, string.format(lan[20], math.floor(L_Soul.auras[AurAz].duration / 60)))
    end

    -- Verifica se o jogador está em uma área protegida
    if (getTileInfo(getThingPos(cid)).protection) then
        return doPlayerSendCancel(cid, lan[21])
    end

    -- Define a aura que será ativada quando o jogador atacar
    setPlayerStorageValue(cid, "current_aura", AurAz)

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, string.format("Agora você pode atacar para ativar a aura '%s'.", AurAz))

    return true
end

function onCreatureHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    local auraName = getPlayerStorageValue(attacker, "current_aura")

    -- Verifica se o ataque foi feito por um jogador e se uma aura está definida para ser ativada
    if isPlayer(attacker) and auraName then
        -- Ativa a aura quando o jogador atacar um monstro ou outro jogador
        sendEffect(attacker, L_Soul.auras[auraName].speed, nil, os.time(), auraName)
        checkDam(attacker, auraName, os.time())
        setPlayerStorageValue(attacker, "current_aura", nil) -- Limpa a aura após ser ativada
    end
end

 

--[[
    System developed by MaXwEllDeN[maxwellden@hotmail.com]
    Version 1.0
]]

function onKill(cid, target, lastHit)
    if (getPlayerStorageValue(target, 7148) ~= -1) then
        doCreatureSetDropLoot(target, {})
    end

    return registerCreatureEvent(target, "SoulD")
end

function onLogin(cid)
    setPlayerStorageValue(cid, 7126, -1)
    registerCreatureEvent(cid, "SoulATK")
    setPlayerStorageValue(cid, L_Soul.auras_sto, -1)
    return registerCreatureEvent(cid, "SoulKill")
end

local function TransformAMerda(cas)
    for a = 0, 255 do
        local pos = cas.pos
        pos.stackpos = a

        local item = getThingFromPos(pos)

        if (item.uid > 0) and (item.itemid == cas.it.itemid) and (cas.n == getItemAttribute(item.uid, "criaturaS")) and (not getItemAttribute(item.uid, "M_Time")) then
            return doTransformItem(item.uid, cas.nid)
        end
    end

    return false
end

function onDeath(cid, corpse, deathList)
    doItemSetAttribute(corpse.uid, "criaturaS", getCreatureName(cid):formal())

    if (getPlayerStorageValue(cid, 7148) ~= -1) then
        addEvent(TransformAMerda, 1, {pos = getThingPos(cid), it = corpse, n = getCreatureName(cid), nid = getMonsterInfo(getPlayerStorageValue(cid, 7148)).lookCorpse})
        return true
    end

    doItemSetAttribute(corpse.uid, "M_Time", os.clock())
    return doItemSetAttribute(corpse.uid, "M_Soul", getCreatureName(cid):formal())
end

local function Atacar(cid)
    if (not isCreature(cid)) then
        return false
    elseif (not isCreature(getCreatureTarget(cid))) then
        setPlayerStorageValue(cid, 7126, -1)
        return false
    end
    local target = getCreatureTarget(cid)

    local enc = isWithEnchantedW(cid)

    if (enc) then
        if (isWeapon(enc.arma.uid)) and (getDistanceBetween(getThingPos(getCreatureTarget(cid)), getThingPos(cid)) > 1) then
            setPlayerStorageValue(cid, 7126, -1)
            return false
        end

        local typ, enchant = L_Soul.souls[L_Soul.creatures[getItemAttribute(enc.arma.uid, "ES_Type")].type:lower()], L_Soul.creatures[getItemAttribute(enc.arma.uid, "ES_Type")].enchant

        doTargetCombatHealth(cid, target, typ.combat, -enchant.min, -enchant.max, typ.effects.eff)
        doSendDistanceShoot(getThingPos(cid), getThingPos(target), typ.effects.distance)

        if (enc.at == 1) then
            doPlayerSendTextMessage(cid, 27, string.format(lan[17], getItemNameById(enc.arma.itemid)))
            doItemSetAttribute(enc.arma.uid, "description", false)
            doItemSetAttribute(enc.arma.uid, "ES_Charges", false)
        else
            doItemSetAttribute(enc.arma.uid, "description", string.format(lan[16], getItemAttribute(enc.arma.uid, "ES_Type"), enc.at - 1, enchant.charges))
            doItemSetAttribute(enc.arma.uid, "ES_Charges", enc.at - 1)
        end

        addEvent(Atacar, enchant.attack_speed, cid)
    else
        setPlayerStorageValue(cid, 7126, -1)
    end

end

function onAttack(cid, target)

    if (getPlayerStorageValue(cid, 7126) < 1) then
        setPlayerStorageValue(cid, 7126, 5)
        Atacar(cid)
    end

    return true
end


function isWithEnchantedW(uid)

    for a = 5, 6 do
        local item = getPlayerSlotItem(uid, a)
        if (item.uid > 2) and (getItemAttribute(item.uid, "ES_Charges")) then
            return {arma = item, at = getItemAttribute(item.uid, "ES_Charges")}
        end
    end

    return false
end



 

L_Soul = {
    souls = {
        ["dark"] = {effects = {distance = 31, eff = 17}, combat = COMBAT_DEATHDAMAGE},
        ["flame"] = {effects = {distance = 3, eff = 15}, combat = COMBAT_FIREDAMAGE},
        ["frozen"] = {effects = {distance = 36, eff = 43}, combat = COMBAT_ICEDAMAGE},
        ["holy"] = {effects = {distance = 37, eff = 39}, combat = COMBAT_HOLYDAMAGE},
        ["electric"] = {effects = {distance = 35, eff = 11}, combat = COMBAT_ENERGYDAMAGE},
    },

    creatures = {
        ["Necromancer"] = {chance = 50, type = "dark",
                            summ = {
                                    hp = {hpb = 50, maxb = 700},
                                    needSoulPoints = 50,
                                    needMana = 0,
                                    needHealth = 20,
                                    minP = 50,
                                    },
                            enchant = {charges = 100, min = 10, max = 60, attack_speed = 250},
                        },

        ["Dragon Lord"] = {chance = 100, type = "flame",
                            summ = {
                                    hp = {hpb = 50, maxb = 700},
                                    needSoulPoints = 50,
                                    needMana = 0,
                                    needHealth = 20,
                                    minP = 50,
                                    },
                            enchant = {charges = 200, min = 50, max = 150, attack_speed = 1000},
                        },

        ["Frost Dragon"] = {chance = 100, type = "frozen",
                            summ = {
                                    hp = {hpb = 50, maxb = 700},
                                    needSoulPoints = 50,
                                    needMana = 0,
                                    needHealth = 20,
                                    minP = 50,
                                    },
                            enchant = {charges = 200, min = 50, max = 160, attack_speed = 1500},
                        },

        ["Wyrm"] = {chance = 100, type = "electric",
                            summ = {
                                    hp = {hpb = 50, maxb = 700},
                                    needSoulPoints = 50,
                                    needMana = 0,
                                    needHealth = 20,
                                    minP = 50,
                                    },
                            enchant = {charges = 200, min = 50, max = 160, attack_speed = 550},
                        },
        ["Monk"] = {chance = 150, type = "holy",
                            summ = {
                                    hp = {hpb = 50, maxb = 700},
                                    needSoulPoints = 50,
                                    needMana = 0,
                                    needHealth = 20,
                                    minP = 50,
                                    },
                            enchant = {charges = 200, min = 50, max = 160, attack_speed = 550},
                        },
    },

    ids = {8300},
    max_distance = 5,
    language = "en",
    auras_sto = 77143,
    soul_t = 10, -- Em Minutos
}

---------------------- A U R A S ----------------------------
L_Soul.auras = {
    ["dark"] = {stones_n = 7, damage = {25, 250}, interval = 1200, duration = 120, raio = 4, speed = 150},
    ["flame"] = {stones_n = 5, damage = {250, 650}, interval = 500, duration = 60, raio = 7, speed = 75},
    ["frozen"] = {stones_n = 2, damage = {150, 350}, interval = 750, duration = 60, raio = 2, speed = 150},
    ["electric"] = {stones_n = 5, damage = {150, 350}, interval = 750, duration = 60, raio = 2, speed = 150},
    ["holy"] = {stones_n = 0, damage = {150, 350}, interval = 750, duration = 60, raio = 7, speed = 150},
}

------------------- E N C A N T A M E N T O -----------------

L_Soul.enchant = {
    weapons = {
        [2408] = {"dark", "flame", "frozen"}, -- Warlord Sword
        [2190] = {"dark", "holy"}, -- Wand of Vortex
        [2456] = {"dark", "holy"}, -- Bow
        [2400] = {"dark", "holy", "frozen", "flame", "electric"}, -- Magic Sword(SOV)
    },
}

------------------ L I N G U A G E M ------------------------

L_Soul.lang = {
    ["en"] = {
        "This soul stone is filled with a %s's %s soul!",
        "This soul stone must be near the creature's corpse.",
        "There's no soul!",
        "Your soul stone didn't supported the soul and broke! This %s's %s soul escaped!",
        "Congratulations, you caught a %s's soul[%s]!",
        "Filled with a %s's %s soul.",
        "This item can't be enchanted.",
        "To summon a %s you must have at least %d soul points.",
        "You can't summon a %s there.",
        "To summon a %s you must have at least %d mana points.",
        "To summon a %s you must have at least %d health points.",
        "The soul stone broke and the corpse was possessed by %s's %s soul!",
        "This corpse doesn't support this %s's powerful %s soul. The soul has escaped and is roaming the world and tormenting people.",
        "A body can't have two souls.",
        "The %s's soul was aprisioned in weapon.",
        "This weapon is enchanted with a %s's soul. Charges: %d/%d.",
        "Your %s lost charm.",
        "This weapon already is enchanted with a soul!",    -- 18

                --> AURAS <--
        "You haven't enought %s souls[%d].",
        "You need wait %d minutes to use an aura protection again.",
        "You can't use an aura protection on protected zones.",

        {
            "Alive again!? How!? AH! It doesn't matter, i just want to get my revenge! MUHAUHAUHUAUA!",
            "OH how is sweet live!",
        },
    }
}


function isWeapon(uid) -- Function by Mock the bear.
    local uid = uid or 0
    local f = getItemWeaponType(uid)

    return (f == 1 or f == 2 or f == 3) or false
end

function string:formal()
    local self = self:sub(1, 1):upper() .. self:sub(2, #self)
    while (self:find(" (%l)")) do
        local a = self:find(" (%l)")
        self = self:sub(1, a) .. self:sub(a + 1, a + 1):upper() .. self:sub(a + 2, #self)
    end

    return self
end

function getUidsInArea(ext1, ext2)
   local uids = {}
   for a = 0, ext2.x-ext1.x do
       for b = 0, ext2.y-ext1.y do
          local pos = {x = ext1.x+a, y = ext1.y+b, z = ext1.z, stackpos = 255}
          local cid = getTopCreature(pos).uid
          if (isCreature(cid)) then
             table.insert(uids, cid)
          end
       end
   end
   return uids
end

function getItemsInContainerById(container, itemid) -- Function By Kydrai
    local items = {}
    if isContainer(container) and getContainerSize(container) > 0 then
        for slot = 0, getContainerSize(container) - 1 do
            local item = getContainerItem(container, slot)
            if isContainer(item.uid) then
                for i, v in ipairs (getItemsInContainerById(item.uid, itemid)) do
                    table.insert(items, v)
                end
            elseif itemid == item.itemid then
                table.insert(items, item)
            end
        end
    end
    return items
end

function getAllPlayerItemsById(uid, itemid)
    local items = {}

    for a = CONST_SLOT_FIRST, CONST_SLOT_LAST do
        local item = getPlayerSlotItem(uid, a)
        if ((item.uid > 0) and (item.itemid == itemid)) then
            table.insert(items, item)
        end

        if ((isContainer(item.uid)) and (getContainerSize(item.uid) > 0)) then
            for i, v in ipairs(getItemsInContainerById(item.uid, itemid)) do
                table.insert(items, v)
            end
        end
    end
    return items
end

function getAllPlayerSoulStones(uid, empty)
    local stones = {}

    for _, s in ipairs(L_Soul.ids) do
        for _, v in pairs(getAllPlayerItemsById(uid, s)) do
            if not ((empty) and (not getItemAttribute(v.uid, "Soul"))) then
                table.insert(stones, v)
            end
        end
    end

    return stones
end

function getPlayerSoulStonesByType(uid, type)
    local stones = {}

    for _, v in pairs(getAllPlayerSoulStones(uid)) do
        if ((getItemAttribute(v.uid, "Soul")) and (L_Soul.creatures[getItemAttribute(v.uid, "Soul")].type:lower() == type:lower())) then
            table.insert(stones, v)
        end
    end

    return stones
end

function doPlayerRemoveSoulStoneByType(uid, type, ammount)
    local stones = getPlayerSoulStonesByType(uid, type)
    local ammount = ammount or 1

    if (#stones < ammount) then
        return false
    end

    local a = 0
    for _, v in pairs(stones) do
        if (a ~= ammount) then
            a = a + 1
            doRemoveItem(v.uid, 1)
        else
            break
        end
    end

    return true
end

function getPlayerSoulStonesCount(uid, type)
    return #getPlayerSoulStonesByType(uid, type)
end

function onCreatureHealthChange(creature, attacker, attackerName, damage, damType, damMsg)
    if isPlayer(attacker) and isCreature(creature) and attackerName ~= creature then
        local auraName = getPlayerStorageValue(attacker, "current_aura")
        if auraName then
            local AuraAz = auraName:lower()
            if L_Soul.auras[AuraAz] and os.time() - creature:getStorageValue("last_hit_" .. AuraAz) > L_Soul.auras[AuraAz].interval then
                doCreatureSetStorageValue(creature, "last_hit_" .. AuraAz, os.time())
                doSendDistanceShoot(creature:getPosition(), creature:getPosition(), L_Soul.souls[AuraAz].effects.distance)
                doTargetCombatHealth(attacker, creature, L_Soul.souls[AuraAz].combat, -L_Soul.auras[AuraAz].damage[1], -L_Soul.auras[AuraAz].damage[2], 255)
            end
        end
    end
end

function onSay(cid, words, param)
    domodlib("Soul System[LIB]")

    local lan = L_Soul.lang[L_Soul.language]

    local AuraAz = words:explode(" ")[1]

    if not (L_Soul.auras[AuraAz]) then
        return false
    end

    if (#getPlayerSoulStonesByType(cid, AuraAz) < L_Soul.auras[AuraAz].stones_n) then
        return doPlayerSendCancel(cid, string.format(lan[19], AuraAz, L_Soul.auras[AuraAz].stones_n))
    end

    if (getPlayerStorageValue(cid, L_Soul.auras_sto) > 0) then
        return doPlayerSendCancel(cid, string.format(lan[20], math.floor(L_Soul.auras[AuraAz].duration/60)))
    end

    if (getTileInfo(getThingPos(cid)).protection) then
        return doPlayerSendCancel(cid, lan[21])
    end

    setPlayerStorageValue(cid, L_Soul.auras_sto, os.time())
    doPlayerRemoveSoulStoneByType(cid, AuraAz, L_Soul.auras[AuraAz].stones_n)
    setPlayerStorageValue(cid, "current_aura", AuraAz) -- Armazena a aura atual do jogador
    return true
end

 

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...