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

TFS 1.X+ Help Critical System TFS 1.2

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
380
Solutions
1
Reaction score
89
Hello,
I'm using this critical system, but it doesn't work when the opponent has "utamo vita". Any soul want to help me?

Lua:
local config = {
    magic_effect = 173, -- magic effect you want to send when critical hit lands
    damage_magic = 1.8, -- Sorcerers and Druids
    damage_physical = 2.0 -- Paladins and Knights
}

local function getSkill(player)
    local vocation = player:getVocation()
    while vocation:getDemotion() do
        vocation = vocation:getDemotion()
    end

    local vocId = vocation:getId()
    if vocId == 1 or vocId == 2 then
        return player:getMagicLevel() * 0.05, config.damage_magic
    elseif vocId == 3 then
        return player:getEffectiveSkillLevel(SKILL_DISTANCE) * 0.07, config.damage_physical
    elseif vocId == 4 then
        local sword = player:getEffectiveSkillLevel(SKILL_SWORD)
        local club = player:getEffectiveSkillLevel(SKILL_CLUB)
        local axe = player:getEffectiveSkillLevel(SKILL_AXE)
        return math.max(sword, club, axe) * 0.07, config.damage_physical
    end
    return nil
end

function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not attacker:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

     local chance, multiplier = getSkill(attacker)
    if not chance then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if math.random(100) <= chance then
        creature:getPosition():sendMagicEffect(config.magic_effect)
        return primaryDamage * multiplier, primaryType, secondaryDamage, secondaryType
    end
    
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Solution
XML:
<event type="healthchange" name="criticalHitSystemXHP" script="critical_hit_system.lua"/>
<event type="manachange" name="criticalHitSystemXMP" script="critical_hit_system.lua"/>

remember to register it to the creature if players are going to crit creatures, or on players if players can crit each other.

Lua:
function onManaChange(creature, attacker, manaChange, origin)
    if not attacker:isPlayer() then
        return manaChange
    end

     local chance, multiplier = getSkill(attacker)
    if not chance then
        return manaChange
    end
  
   if math.random(100) <= chance then
        creature:getPosition():sendMagicEffect(config.magic_effect)
        return manaChange * multiplie
    end

    return manaChange
end
you need to add the same system to "onManaChange"
you know how to do?
I've added
creaturescripts.xml
XML:
    <event type="healthchange" name="criticalHitSystemX" script="critical_hit_system.lua"/>
    <event type="manachange" name="criticalHitSystemX" script="critical_hit_system.lua"/>

But inside the script I don’t know how to add the
Lua:
onManaChange
 
Last edited:
XML:
<event type="healthchange" name="criticalHitSystemXHP" script="critical_hit_system.lua"/>
<event type="manachange" name="criticalHitSystemXMP" script="critical_hit_system.lua"/>

remember to register it to the creature if players are going to crit creatures, or on players if players can crit each other.

Lua:
function onManaChange(creature, attacker, manaChange, origin)
    if not attacker:isPlayer() then
        return manaChange
    end

     local chance, multiplier = getSkill(attacker)
    if not chance then
        return manaChange
    end
  
   if math.random(100) <= chance then
        creature:getPosition():sendMagicEffect(config.magic_effect)
        return manaChange * multiplie
    end

    return manaChange
end
 
Last edited:
Solution
XML:
<event type="healthchange" name="criticalHitSystemXHP" script="critical_hit_system.lua"/>
<event type="manachange" name="criticalHitSystemXMP" script="critical_hit_system.lua"/>

remember to register it to the creature if players are going to crit creatures, or on players if players can crit each other.

Lua:
function onManaChange(creature, attacker, manaChange, origin)
    if not attacker:isPlayer() then
        return manaChange
    end

     local chance, multiplier = getSkill(attacker)
    if not chance then
        return manaChange
    end
 
   if math.random(100) <= chance then
        creature:getPosition():sendMagicEffect(config.magic_effect)
        return manaChange * multiplie
    end

    return manaChange
end

Line 13
Lua:
        return manaChange * multiplier

Thanks @Aeronx
 
XML:
<event type="healthchange" name="criticalHitSystemXHP" script="critical_hit_system.lua"/>
<event type="manachange" name="criticalHitSystemXMP" script="critical_hit_system.lua"/>

remember to register it to the creature if players are going to crit creatures, or on players if players can crit each other.

Lua:
function onManaChange(creature, attacker, manaChange, origin)
    if not attacker:isPlayer() then
        return manaChange
    end

     local chance, multiplier = getSkill(attacker)
    if not chance then
        return manaChange
    end
 
   if math.random(100) <= chance then
        creature:getPosition():sendMagicEffect(config.magic_effect)
        return manaChange * multiplie
    end

    return manaChange
end
how to modify so that the critic would be influenced by the skill club?
the higher the level, the greater the chance and value
 
Back
Top