I have the following code:
The first if statement checks for the following:
- The player is unable to dodge players with level higher than 100, and there is also a chance of 15% of that happening
It works perfectly but here is the problem with the elseif:
it works as well despite the first one being executed, but I want only one of these to occur
if higher than 100, there is 15% chance that the text will appear saying you cannot dodge him and that SHOULD END THE IF STATEMENT after that, but it is not.
I would appreciate help
TFS 1.0
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker:getLevel() - creature:getLevel() >= 100 and math.random(100) < 15 then -- cannot dodge players if level higher by 100
creature:say("Cant dodge!", TALKTYPE_MONSTER_SAY)
elseif math.random(100) < 15 then
creature:say("Dodge!", TALKTYPE_MONSTER_SAY)
primaryDamage = 0
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
The first if statement checks for the following:
- The player is unable to dodge players with level higher than 100, and there is also a chance of 15% of that happening
It works perfectly but here is the problem with the elseif:
it works as well despite the first one being executed, but I want only one of these to occur
if higher than 100, there is 15% chance that the text will appear saying you cannot dodge him and that SHOULD END THE IF STATEMENT after that, but it is not.
I would appreciate help
TFS 1.0