Hello
I have problems using this script:
1- i want to clean no needed lines.
2- i want to make it with a right way.
3- when a player deal damage to monster and get a chance to hit critical he deal x2 value as normal but when player vs player it not deal x2 value, that’s why i added lines to check if cid is monster or is player, is that correct?
4- players with protections like physical protection when i deal damage vs them with a chance to hit critical the damage not correct. (Sometimes damage dealt (critical dmg) is lower than normal damage)
5- idk what is this creature table for?
i am using tfs 0.3.7
any help?
this is the script
I have problems using this script:
1- i want to clean no needed lines.
2- i want to make it with a right way.
3- when a player deal damage to monster and get a chance to hit critical he deal x2 value as normal but when player vs player it not deal x2 value, that’s why i added lines to check if cid is monster or is player, is that correct?
4- players with protections like physical protection when i deal damage vs them with a chance to hit critical the damage not correct. (Sometimes damage dealt (critical dmg) is lower than normal damage)
5- idk what is this creature table for?
i am using tfs 0.3.7
any help?
this is the script
Lua:
local creature_table = {}
local lvlcrit = 16221 -- storage (the same like givecritical.lua script)
local chance = 10 -- critical chance = 10%
function onStatsChange(cid, attacker, type, combat, value)
if not isPlayer(attacker) then
return true
elseif cid == attacker then
return true
end
if not creature_table[cid] then
creature_table[cid] = false
elseif creature_table[cid] == true then
creature_table[cid] = false
return true
end
if getPlayerStorageValue(attacker, lvlcrit) < 1 then
return true
end
if (math.random(0, 100) <= chance) then
if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
creature_table[cid] = true
local multiplier = (getPlayerStorageValue(attacker, lvlcrit) / 100) + 1
local new_value = math.ceil(value * multiplier)
local new_value2 = math.ceil(2 * value * multiplier)
if isPlayer(cid) then
doTargetCombatHealth(attacker, cid, combat, -new_value2, -new_value2, 255)
end
if isMonster(cid) then
doTargetCombatHealth(attacker, cid, combat, -new_value, -new_value, 255)
end
doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!", 138)
return false
end
end
return true
end