Facebook
From Movie#4361, 2 Years ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 206
  1. --[[
  2.     Dodge & Critical fixado por Movie (Movie#4361)
  3.     Disponibilizado para o TibiaKing e não autorizo outras reproduções
  4.     Mantenha os créditos <3
  5. --]]
  6.  
  7. function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  8.  
  9.     if (not attacker or not creature) then  
  10.         return primaryDamage, primaryType, secondaryDamage, secondaryType
  11.     end
  12.  
  13.     if primaryType == COMBAT_HEALING then
  14.         return primaryDamage, primaryType, secondaryDamage, secondaryType
  15.     end
  16.  
  17.     if ((creature:getDodgeLevel() * 3) >= math.random (0, 1000) and creature:isPlayer()) then
  18.         primaryDamage = 0
  19.         secondaryDamage = 0
  20.         creature:say("DODGE!", TALKTYPE_MONSTER_SAY)
  21.         creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
  22.     end
  23.  
  24.     if (attacker:isPlayer() and (attacker:getCriticalLevel() * 3) >= math.random (0, 1000)) then
  25.                 primaryDamage = primaryDamage + math.ceil(primaryDamage * CRITICAL.PERCENT)
  26.                 attacker:say("CRITICAL!", TALKTYPE_MONSTER_SAY)
  27.                 creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONHIT)
  28.         end
  29.  
  30.     return primaryDamage, primaryType, secondaryDamage, secondaryType
  31. end
  32. <event type="healthchange" name="DodgeCritical" script="dodgeCritical.lua"/>