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

StatsChange Defenses (absorbPercentAll / armor)

DukeeH

Active Member
Joined
Dec 6, 2010
Messages
550
Solutions
3
Reaction score
39
Hello, I'd like some help to fix this script, it is a Critical System, you have X% chance to deal more damage on attack/spells, everything.
The problem is, I have items with high absorbPercentAll stats, so if I put the critical to deal *2 damage (double), and I deal 100 damage on someone with 0 armor, it will deal 200 when I crit. But now, the players have 20~40% protection all, so (100-40=60) it does 60 damage normally, when it crit it should deal 120 (double) but it does an amount lower than the normal damage, it's weird.
Is there some way to fix this or make this system through sources or something?

The same happens on the second script, it's a dodge system, if you dodge an attack, you should get half the damage, but it does alot less than this because it counts your defense twice (I think) so I have to put a higher amount to try and balance, but it's not right.

Thanks!

Code:
--[[Critical System
-------------------------  By Night Wolf]]

local lvlcrit = 48913
local multiplier = 2.0

function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then
if (getPlayerStorageValue(attacker, lvlcrit)*3) >= math.random (0,1000) then
dano = math.ceil(value*(multiplier))
doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
doSendAnimatedText(getCreaturePos(attacker), "CRITICAL!!", 144)
return false
end
end
return true
end

Code:
local lvldodge = 48902
local percent = 0.5

function onStatsChange(cid, attacker, type, combat, value)
if type == STATSCHANGE_HEALTHLOSS and isCreature(attacker) then
if (getPlayerStorageValue(cid, lvldodge)*3) >= math.random (0,1000) then
value = math.ceil(value*(percent))
doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
doSendAnimatedText(getCreaturePos(cid), "DODGE", 6)
return false
end
end
return true
end
 
are you using both scripts at the same time? they should be in one script, else it will execute both of them
It should execute both, i'm using both.
That's not related to the problem. It should be able to Critical and to Dodge or Dodge a Crit, doesn't matter.
 
with both scripts, if both dodge + critical procs, it will trigger doTargetCombatHealth twice, no?
try printing the values before and after modifying them, and see if theres something wrong there
 
with both scripts, if both dodge + critical procs, it will trigger doTargetCombatHealth twice, no?
try printing the values before and after modifying them, and see if theres something wrong there
Yeah, you should be able to dodge a critical, but the problem is not related to this, the problem is when the player has high armor/protectionall it does a really small damage (both critical and dodge) the critical is even lower than the normal damage, wich is weird.
 
Yeah, you should be able to dodge a critical, but the problem is not related to this, the problem is when the player has high armor/protectionall it does a really small damage (both critical and dodge) the critical is even lower than the normal damage, wich is weird.
as i said before, try printing the values before changing them to see if the error is before/inside/after onstatschange.
 
Help, wasn't able to test printing the values yet but if someone knows something that could help.
 
reason is probably that you don't have the original damage available in onStatsChange, but the reduced damage. so what you're doing here is multiplying the reduced damage by 2, and the damage is even less after being reduced twice.
suggesting you try to perform a source edit
 
reason is probably that you don't have the original damage available in onStatsChange, but the reduced damage. so what you're doing here is multiplying the reduced damage by 2, and the damage is even less after being reduced twice.
suggesting you try to perform a source edit
Yeah, I thought of that, it gets the damage reduced by items/defenses then reduces it again or multiplies and it gets lowered.
What can I do through sources? I know this system would be really better on sources, but have no idea where to start.
 
Look for the function where executeStatsChange is called, and then you can look for other functions which call the function you've found, repeat until you've found the right part
 
before changing the
dano = and value =
add print(value) to both and say what it prints and the actual dmg you should be doing
 
Back
Top