• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 1.X+ Fatal or Dodge

ftsystem

New Member
Joined
Feb 17, 2019
Messages
19
Reaction score
4
How to add effect "Fatal" or "Dodge" in best hits?

Tfs 1.3

data/scripts/creaturescripts/best_elemental_damage.lua
Lua:
local creatureevent = CreatureEvent("BestElementalDamageHealthChange")

local baseStorage = 505050
BestElementalDamage =
{
    combatData =
    {
        [COMBAT_PHYSICALDAMAGE] = {name = 'physical',storage = baseStorage},
        [COMBAT_ENERGYDAMAGE] = {name = 'energy',storage = baseStorage + 1},
        [COMBAT_EARTHDAMAGE] = {name = 'earth',storage = baseStorage + 2},
        [COMBAT_FIREDAMAGE] = {name = 'fire',storage = baseStorage + 3},
        [COMBAT_ICEDAMAGE] = {name = 'ice',storage = baseStorage + 4},
        [COMBAT_HOLYDAMAGE] = {name = 'holy',storage = baseStorage + 5},
        [COMBAT_DEATHDAMAGE] = {name = 'death',storage = baseStorage + 6},
    },

    combatNames =
    {
        ['physical'] = COMBAT_PHYSICALDAMAGE,
        ['energy'] = COMBAT_ENERGYDAMAGE,
        ['earth'] = COMBAT_EARTHDAMAGE,
        ['fire'] = COMBAT_FIREDAMAGE,
        ['ice'] = COMBAT_ICEDAMAGE,
        ['holy'] = COMBAT_HOLYDAMAGE,
        ['death'] = COMBAT_DEATHDAMAGE,
    }
}

function BestElementalDamage:getDamage(player, combatType)
    if (player) then
        local data = self.combatData[combatType]
        if (data) then
            return player:getStorageValue(data.storage)
        end
    end
    return 0
end

function BestElementalDamage:setDamage(player, combatType, damage)
    if (player) then
        local data = self.combatData[combatType]
        if (data) then
            player:setStorageValue(data.storage, damage)
        end
    end
end

function BestElementalDamage:checkDamage(player, combatType, damage)
    if (player and self.combatData[combatType]) then
        if (self:getDamage(player, combatType) < damage) then
            local data = self.combatData[combatType]
            local str = string.format('New %s damage [%d]!', data.name, damage)
            player:say(str, TALKTYPE_MONSTER_SAY)
            self:setDamage(player, combatType, damage)
        end
    end
end

function creatureevent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if (attacker and attacker:isPlayer()) then
        BestElementalDamage:checkDamage(attacker, primaryType, primaryDamage)
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

creatureevent:register()

local talk = TalkAction("!bestdamage")

function talk.onSay(player, words, param)
    if (BestElementalDamage.combatNames[param:lower()]) then
        local combatType = BestElementalDamage.combatNames[param]
        local str = string.format('Your best %s damage is %d.', param:lower(), BestElementalDamage:getDamage(player, combatType))
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, str)
    else
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Invalid combat type name.')
    end
    return false
end

talk:separator(" ")
talk:register()
 
Top