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

CreatureEvent [TFS 1.2] Critical Hit (Fist Skill = Critical Skill)

Jeffro

Alpha
Joined
Jan 17, 2015
Messages
235
Reaction score
262
Location
New York
Hello!
It was requested by Eldin and a great example was given to him. Plus, I haven't found anyone making an article about it on here and I feel it should be.

You will have to register this with each monster in their own individual XML file, this is the downside to not using C++.

Math info, say I have 50 fist skill, that will be 50% critical strike chance and a capability of landing +50% damage.

Code:
Fist Skill Level: 50
22:48 Critical Hit: +4 DMG
22:48 A bug loses 12 hitpoints due to your attack.

Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  if(Monster(attacker) ~= nil) then --if attacker is monster, then don't crit
  return primaryDamage, primaryType, secondaryDamage, secondaryType
   end
   if attacker == nil then --if attacker is dead, conditions apply after
  return primaryDamage, primaryType, secondaryDamage, secondaryType
   end
  
   if math.random(100) < attacker:getSkillLevel(SKILL_FIST) then
     local percDam = (attacker:getSkillLevel(SKILL_FIST) / 100) * primaryDamage
     attacker:sendTextMessage((MESSAGE_DAMAGE_DEALT), "Critical Hit: +".. percDam .." DMG")
     creature:getPosition():sendMagicEffect(CONST_ME_HITAREA)
     return primaryDamage + percDam, primaryType, secondaryDamage, secondaryType
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType
end
 
Last edited:
Found a bug with monsters that apply conditons(poison, flame, ect) and then die.

Fixed with if attacker == nil, meaning if attacker is no longer, just return to normal.
 
i have the same thing on mi server but a little diferent.
the Fist skill (renamed Critical %)
its the CHANCE to do an critical hit.
the Amount of the critical hit its based on the Level of the player and the skill (magic level if is spell, melee if is spell/melee etc)
so player level / 10
and skills / 10

example 1
level 100 / 10 = 10
skills (distance) 90 / 10 = 9
total attack of the critical hit = 19 + weapon attack / = in this case 40 total = 59 (attack of the critical hit)
total chance of the critical hit = fist fighting(critical %) in this case 10< = 10%
total critical = 59 x 4 = 236 / math.random (1,3) = 236 or 118 or 79.

Max hit with a weapon of attack 40 + level 100, skills 90 = 239 + primaryDamage
Min hit with a weapon of attack 40 + level 100, skills 90 = 70 + primaryDamage

return primaryDamage + critical , primaryType, secondaryDamage, secondaryType

example 2
level 200 / 10 = 20
skills(sword) 100/10 = 10
total attack of the critical hit = 30 + weapon attack / = in this case 45 total = 75 (attack of the critical hit)
total chance of the critical hit = fist fighting(critical %) in this case 20 < = 20% (because the player its using a super sword, critical +10% (10 fist +)
total critical 75 x 4 = 300 / math.random (1,3) = 300 or 200 or 100.

Max hit with a weapon of attack 45 + level 200, skills 100 = 300 + primaryDamage
Min hit with a weapon of attack 45 + level 200, skills 100 = 200 + primaryDamage

example 3
level 400 / 10 = 40
skills(magic) 111 / 10 = 11
total attack of the critical hit = 51 (no weapon attack because spell)
total chance of the critical hit = fist fighting(critical %) in this case 20 < = 25% (because the player its using a spells (up the fist on 15)
total critical 51 x 8 (because its magic) = 408 / math.random (1,3) = 408 or 204 or 136

Max hit with a spell + level 400 + ml 111 = 408 + primaryDamage
Min hit with a spell + level 400 + ml 111 = 136 + primaryDamage

so the chance depends of the skills fist, and the amount of critical damage its based on level+ skills/ml + weapon .

then higher levels get more critical "damage"
you can add items with "fist +" and
spells with "fist +"

and do more critical hits "chance"

if you wanna do MORE DAMAGE, Need more level and weapon attack :D
 
Last edited:
on mi server a vocation called "assassin" can increase the "chance" to 100% with an apell (5 minutes of exhausted)
they can use 2 weapons at time
like 15 of attack in each weapon
and they have x2 speed of attack (depends of the weapon)
then imagine its like = 2 hits + 2 criticals in 1 turn + spell attack< XD (the spells of assassin its like exori ico x 3 times ( 1 each 333 MS )
a total of 2 hits + 2 criticals + 3 hits of the spell (with the criticals)
so you see upper your character something like
CRITICAL
CRITICAL
CRITICAL
CRITICAL
CRITICAL

and the victim its like =

you lost 68 hp by ..
you lost 35 hp by .. critical
you lost 112 hp by ..
you lost 47 hp by .. critical
you lost 34 hp by ..
you lost 29 hp by ..
you lost 42 hp by ..
you lost 13 hp by .. critical
you lost 17 hp by .. critical
you lost 21 hp by .. critical
 
Too much to read right now, I have to go work on somethings for a bit, later tonight I'll take a look at it for you bud.
 
to resume, mi fist fighting its the chance to do hit, the amount of the hit become from the level/skills/weapon attack
 
Back
Top