• 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!

Critical System TFS 1.3

nanduzenho

Member
Joined
Mar 21, 2021
Messages
187
Solutions
1
Reaction score
15
GitHub
nanduzenho
Good morning, i have this critical damage script and i would like the word "Critical!" appear as a one hit number. I don't know if I explained it right, the word "Critical!" should appear with the same animation as a normal hit. Can anyone help me with this?

Lua:
local config = {
    magic_effect = 15, -- magic effect you want to send when critical hit lands
    damage_multiplier = 1.8 -- default damage * 10 = critical damage
}

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker == nil then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    if not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    local skill = attacker:getEffectiveSkillLevel(SKILL_SWORD)
    local skill = attacker:getEffectiveSkillLevel(SKILL_AXE)
    local skill = attacker:getEffectiveSkillLevel(SKILL_CLUB)
    local skill = attacker:getEffectiveSkillLevel(SKILL_FIST)
    local skill = attacker:getEffectiveSkillLevel(SKILL_DIST)
    local chance = (skill * 0.5)
 
    if math.random(100) <= chance then
        attacker:getPosition():sendMagicEffect(config.magic_effect)
        attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        return primaryDamage * config.damage_multiplier, primaryType, secondaryDamage, secondaryType
    end
    
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Lua:
local config = {
    magic_effect = 15, -- magic effect you want to send when critical hit lands
    damage_multiplier = 1.8 -- default damage * 10 = critical damage
}

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker == nil then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    if not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 --- my god wtf is this part?
    local skill = attacker:getEffectiveSkillLevel(SKILL_SWORD)
    local skill = attacker:getEffectiveSkillLevel(SKILL_AXE)
    local skill = attacker:getEffectiveSkillLevel(SKILL_CLUB)
    local skill = attacker:getEffectiveSkillLevel(SKILL_FIST)
    local skill = attacker:getEffectiveSkillLevel(SKILL_DIST)
--- my god wtf is this part?
    local chance = (skill * 0.5)
 
    if math.random(100) <= chance then
        local pos = attacker:getPosition()
        pos:sendMagicEffect(config.magic_effect)
       -- attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        Game.sendAnimatedText("Critical!", pos, TEXTCOLOR_RED)
        return primaryDamage * config.damage_multiplier, primaryType, secondaryDamage, secondaryType
    end
   
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

tibia < 10.00 or otclient. otherwise debug
 
function Position.sendAnimatedText(self, message)
local specs = Game.getSpectators(self, false, true, 9, 9, 8, 8)
if #specs > 0 then
for i = 1, #specs do
local player = specs
player:say(message, TALKTYPE_MONSTER_SAY, false, player, self)
end
end
fim
 
Lua:
local config = {
    magic_effect = 15, -- magic effect you want to send when critical hit lands
    damage_multiplier = 1.8 -- default damage * 10 = critical damage
}

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker == nil then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 
    if not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
 --- my god wtf is this part?
    local skill = attacker:getEffectiveSkillLevel(SKILL_SWORD)
    local skill = attacker:getEffectiveSkillLevel(SKILL_AXE)
    local skill = attacker:getEffectiveSkillLevel(SKILL_CLUB)
    local skill = attacker:getEffectiveSkillLevel(SKILL_FIST)
    local skill = attacker:getEffectiveSkillLevel(SKILL_DIST)
--- my god wtf is this part?
    local chance = (skill * 0.5)
 
    if math.random(100) <= chance then
        local pos = attacker:getPosition()
        pos:sendMagicEffect(config.magic_effect)
       -- attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
        Game.sendAnimatedText("Critical!", pos, TEXTCOLOR_RED)
        return primaryDamage * config.damage_multiplier, primaryType, secondaryDamage, secondaryType
    end
  
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

tibia < 10.00 or otclient. otherwise debug

this error occurred
animatedtext.JPG
 
Back
Top