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

Critical System TFS 1.3

nanduzenho

Member
Joined
Mar 21, 2021
Messages
183
Solutions
1
Reaction score
14
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
 

Dakos

Well-Known Member
Joined
Jan 1, 2010
Messages
122
Solutions
19
Reaction score
68
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
 

arthurluna

Member
Joined
Apr 12, 2008
Messages
169
Reaction score
5
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
 
OP
OP
N

nanduzenho

Member
Joined
Mar 21, 2021
Messages
183
Solutions
1
Reaction score
14
GitHub
nanduzenho
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
 
Top