• 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+ [1.4.2] Critical Hit Animation.

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
425
Solutions
1
Reaction score
44
Hi,
In which version of the client was the animated CRIT text added when critical damage is inflicted?
How can I add something similar to version 1.4.2 - 10.98 client?
 
Is it possible to add a critical attribute to a weapon via setAttribute ?
Just add it to your items.xml, and any weapons you desire, add and save. Then, you should register it in movements.xml... there you go, the weapon will react to critical hits (Critical Hit Animation). Done!

XML:
 <attribute key="criticalhitchance" value="100" />
  <attribute key="criticalhitamount" value="100" />

Set the value you want to hit directly or delay the critical hit reaction. With 100%, it happens every time without stopping. Set the values according to your preference!
 
Just add it to your items.xml, and any weapons you desire, add and save. Then, you should register it in movements.xml... there you go, the weapon will react to critical hits (Critical Hit Animation). Done!

XML:
 <attribute key="criticalhitchance" value="100" />
  <attribute key="criticalhitamount" value="100" />
Ok, this i now.
But i have upgrade system, and need add crit to weapons in lua.
 
Okay, let's talk about how it works in weapons.xml... this 'combat1' that targets regular hits won't trigger a critical hit, only normal hits.

In 'combat2,' which triggers the critical hit, yes, there's a percentage based on the level. You can increase it to make it stronger or decrease it to adjust the critical hit chance.


royal axe.lua
Lua:
-- Creation of Combat objects and setting the damage type as physical for combat1
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat1
function onGetFormulaValues1(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3) --This skill number 3 is for Axe. 0 is for Fist, 1 for Club, 2 for Sword, 3 for Axe, 4 for Distance, 5 for Shield, 6 for SKILL_FISHING, and 7 for Magic Level (ml).
    level = player:getLevel()
    local min = -((skill * 15) + level * 6) --This is based on the level. You can adjust the numbers to make the damage stronger or weaker, etc. If it's too much damage, just decrease the numbers,
    local max = -((skill * 21) + level * 6)
    return min, max
end

-- Set the callback function to get formula values for combat1
combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues1")

-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat2
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat2
function onGetFormulaValues2(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3)
    level = player:getLevel()
    local min = -((skill * 39) + level * 9)
    local max = -((skill * 42) + level * 9)
    return min, max
end

-- Set the callback function to get formula values for combat2
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat3
local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat3
function onGetFormulaValues3(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3)
    level = player:getLevel()
    local min = -((skill * 48) + level * 11)
    local max = -((skill * 55) + level * 15)
    return min, max
end

-- Set the callback function to get formula values for combat3
combat3:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues3")

-- Function called when the player uses the weapon
function onUseWeapon(cid, var)
    local player = Player(cid)
    local critical = math.random(1, 100) --This is the percentage that triggers the critical hit. You can increase or decrease it to make it happen more quickly or take longer, depending on your preference.
    local life = 10 * player:getMaxHealth() / 100 --This is the one that will give life according to the critical, gaining random life.
    local position = player:getPosition()

    -- If the attack is critical, send animated text "Critical!" and execute combat2
    if critical > 90 then
        --Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
        player:addHealth(life)
        combat2:execute(cid, var)
    -- If the attack is critical (less than 10%), send animated text "Critical!" and execute combat3
    elseif critical < 10 then
        --Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
        player:addHealth(life)
        combat3:execute(cid, var)
    -- Otherwise, execute combat1
    else
        combat1:execute(cid, var)
    end
end
 
Last edited:
Okay, let's talk about how it works in weapons.xml... this 'combat1' that targets regular hits won't trigger a critical hit, only normal hits.

In 'combat2,' which triggers the critical hit, yes, there's a percentage based on the level. You can increase it to make it stronger or decrease it to adjust the critical hit chance.


weapons.xml
Lua:
-- Creation of Combat objects and setting the damage type as physical for combat1
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat1
function onGetFormulaValues1(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3) --This skill number 3 is for Axe. 0 is for Fist, 1 for Club, 2 for Sword, 3 for Axe, 4 for Distance, 5 for Shield, 6 for SKILL_FISHING, and 7 for Magic Level (ml).
    level = player:getLevel()
    local min = -((skill * 15) + level * 6) --This is based on the level. You can adjust the numbers to make the damage stronger or weaker, etc. If it's too much damage, just decrease the numbers,
    local max = -((skill * 21) + level * 6)
    return min, max
end

-- Set the callback function to get formula values for combat1
combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues1")

-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat2
local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat2
function onGetFormulaValues2(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3)
    level = player:getLevel()
    local min = -((skill * 39) + level * 9)
    local max = -((skill * 42) + level * 9)
    return min, max
end

-- Set the callback function to get formula values for combat2
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

-- Creation of Combat objects with effect 173 and setting the damage type as physical for combat3
local combat3 = Combat()
combat3:setParameter(COMBAT_PARAM_EFFECT, 173) --in this case, the effect with ID 173 is being set.
combat3:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

-- Function to determine formula values for combat3
function onGetFormulaValues3(cid, level, maglevel)
    local player = Player(cid)
    local skill = player:getSkillLevel(3)
    level = player:getLevel()
    local min = -((skill * 48) + level * 11)
    local max = -((skill * 55) + level * 15)
    return min, max
end

-- Set the callback function to get formula values for combat3
combat3:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues3")

-- Function called when the player uses the weapon
function onUseWeapon(cid, var)
    local player = Player(cid)
    local critical = math.random(1, 100) --This is the percentage that triggers the critical hit. You can increase or decrease it to make it happen more quickly or take longer, depending on your preference.
    local life = 10 * player:getMaxHealth() / 100 --This is the one that will give life according to the critical, gaining random life.
    local position = player:getPosition()

    -- If the attack is critical, send animated text "Critical!" and execute combat2
    if critical > 90 then
        --Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
        player:addHealth(life)
        combat2:execute(cid, var)
    -- If the attack is critical (less than 10%), send animated text "Critical!" and execute combat3
    elseif critical < 10 then
        --Game.sendAnimatedText("Critical!", position, 215) --If you want an animated text in white or your preferred colors, simply uncomment it. If you don't want it, leave it commented, okay?
        player:addHealth(life)
        combat3:execute(cid, var)
    -- Otherwise, execute combat1
    else
        combat1:execute(cid, var)
    end
end
Ok thanks, but I have problem with this.
I add ths to Royal Axe, and when I use critical not working.
The only thing that changed was the description of the weapon that it has a % crit, but that doesn't work.

XML:
 <attribute key="criticalhitchance" value="100" />
  <attribute key="criticalhitamount" value="100" />
 
Ok thanks, but I have problem with this.
I add ths to Royal Axe, and when I use critical not working.
The only thing that changed was the description of the weapon that it has a % crit, but that doesn't work.

XML:
 <attribute key="criticalhitchance" value="100" />
  <attribute key="criticalhitamount" value="100" />
Have you already registered it in movements? Without registering, of course, it won't work. That's why.

see what's written as 'xxx'? Replace it with the ID of your Royal Axe and test!
XML:
<movevent event="Equip" slot="hand" itemid="xxx" level="80" function="onEquipItem" />
<movevent event="DeEquip" slot="hand" itemid="xxx" function="onDeEquipItem" />
 
Back
Top