Ir para conteúdo
  • Cadastre-se

[Revscripts][Spell] Sword Attack - Metin2


Posts Recomendados

Boa tarde, eu estava de bobeira e criei uma magia com base em uma skill do Metin2. A magia se chama Sword Attack.
Essa magia dá dano físico em uma pequena área à sua frente e também aplica o efeito de paralyze em seus inimigos.

Essa magia possui um sistema de nível, então quanto maior o nível da magia, maior será o dano, maior será a probabilidade de paralizar o inimigo e maior será o gasto de mana.

Testado hoje 17/11/2023 na versão mais atual do Canary

 

Esse é o script:
 

local config = {
    --[[
        * addManaSpentSystem:
            In Metin2, there is no magic level system based on spent mana points, commonly known as addManaSpent.
            If you want the magic to increase the player's magic level, leave this option as true.
        
        * limitSkillCombatLevel:
            In Metin2, the maximum combat level with swords that a player can reach is 90; however, in Tibia, there is no such limit.
            This option is used to restrict the maximum damage that the magic will deal.

        * damageBasedOnSkillOnly:
            In Metin2, the damage of spells is solely based on the player's sword skill.
            In Tibia, however, the damage may also include the weapon's attack.

        * isDamageBasedOnSwords:
            In Metin2, only swords exist. In Tibia, there are swords, axes, and clubs.
    ]]

    addManaSpentSystem = false,
    limitSkillCombatLevel = true,
    damageBasedOnSkillOnly = true,
    isDamageBasedOnSwords = true,
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setArea(createCombatArea(AREA_WAVE6, AREADIAGONAL_WAVE6))

function onGetFormulaValues(player, skill, attack, factor)
    local spellLevel = player:getSpellLevelById(SPELL_SWORD_ATTACK)
    local formula = spellLevel >= 4 and 25.333 or spellLevel >= 3 and 19.6 or spellLevel >= 2 and 15.333 or 9.333

    if config.isDamageBasedOnSwords then
        skill = player:getSkillLevel(SKILL_SWORD) or 1
    end

    if config.limitSkillCombatLevel then
        if skill > 90 then
            skill = 90
        end
    end

    local damage = formula * skill * attack * 0.0175

    if config.damageBasedOnSkillOnly then
        damage = formula * skill
    end
    
    return -damage, -damage
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local spell = Spell("instant")

function spell.onCastSpell(creature, var)
    local player = Player(creature)
    local spellLevel = player:getSpellLevelById(SPELL_SWORD_ATTACK)
    local mana = spellLevel >= 4 and 190 or spellLevel >= 3 and 138 or spellLevel >= 2 and 100 or 46

    if player:getMana() < mana then
        player:sendCancelMessage("Not enough mana.")
        return false
    end

    player:addMana(-mana)
    if config.addManaSpentSystem then
        player:addManaSpent(mana)
    end

    local paralyzeChance = spellLevel >= 4 and 30 or spellLevel >= 3 and 23 or spellLevel >= 2 and 18 or 10
    local targets = combat:getTargets(creature, var)

    for _, target in ipairs(targets) do
        if target:isCreature() then
            local condition = Condition(CONDITION_PARALYZE)
            condition:setParameter(CONDITION_PARAM_TICKS, 20000)
            condition:setFormula(-0.9, 0, -0.9, 0)
            if math.random(1, 100) <= paralyzeChance then
                target:addCondition(condition)
                target:say("OH, I'M SLOW!", TALKTYPE_MONSTER_SAY)
            end
        end
    end

    return true
end

spell:group("attack")
spell:name("Sword Attack")
spell:words("exori ico immo")
spell:needDirection(true)
spell:cooldown(20 * 1000)
spell:groupCooldown(1 * 1000)
spell:needWeapon(true)
spell:needLearn(true)
spell:vocation("knight;true", "elite knight;true")
spell:register()

 


E aqui estão dois novos métodos que deverão adicionar à biblioteca para funcionar:
 

SPELL_SWORD_ATTACK = 599961

function Player.getSpellLevelById(self, spellId)
    if self:isPlayer() then
        local storage = self:getStorageValue(spellId)
        local minValue, maxValue = 1, 4
        if storage then
            storage = math.min(math.max(storage, minValue), maxValue)
            return storage
        else
            error("Invalid spellId in Player.getSpellLevelById.")
        end
    end
    error("Invalid player in Player.getSpellLevelById.")
end

function Player.setSpellLevelById(self, spellId, value)
    if self:isPlayer() then
        local minValue, maxValue = 1, 4
        if value <= minValue then
            value = minValue
        elseif value >= maxValue then
            value = maxValue
        end
        self:setStorageValue(spellId, value)
    else
        error("Invalid player in Player.setSpellLevelById.")
    end
end

 

Editado por Anderson Sacani
Adicioneis configurações na magia. (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo