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

Lua function onManaChange dont work negative

Joined
Aug 15, 2014
Messages
143
Reaction score
24
I am trying reduce damage of players with specific conditions...


onHealthChange work fine!
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
primaryDamage = primaryDamage * 0.7
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin 
end

onManaChange dont work !
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
primaryDamage = primaryDamage * 0.7
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin 
end

onManaChange just accept more positive numbers not negative.
like: primaryDamage = primaryDamage * 1.1
But when I tried reduce damages in mana this return in life.

Can someone help me?
 
Seems ok to me, Maybe add some checks. Have you registered it onLogin?
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker and attacker:isPlayer() then
        if creature:isPlayer() then
            primaryDamage = primaryDamage * 0.7
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
 
do an if-statement to check if the new primarydamage is below 0, if it is. just change it to 0 and you wont have negative numbers.

Also i have no idea of this but are those the correct parameters for onManaChange?
 
I am trying reduce damage of players with specific conditions...


onHealthChange work fine!
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
primaryDamage = primaryDamage * 0.7
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

onManaChange dont work !
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
primaryDamage = primaryDamage * 0.7
return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end

onManaChange just accept more positive numbers not negative.
like: primaryDamage = primaryDamage * 1.1
But when I tried reduce damages in mana this return in life.

Can someone help me?
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  primaryDamage = primaryDamage * 0.7
  if primaryDamage < 0 then
    primaryDamage = 0
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end
 
Last edited:
Lua:
function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
  primaryDamage = primaryDamage * 0.7
  if primaryDamage < 0 then
    primaryDamage = 0
  end
  return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
end


07:26 Sorcerer Test loses 326 mana due to your attack.
07:26 Sorcerer Test loses 141 hitpoints due to your attack.

The correct damage that was taken is 467.
He took 326 it from mana. And then 30% of that value is 141.

But that 30% value was not absorbed, but returned in life/hp.

because there is some function in the source that detects the input value and when it is smaller it means that there is no more mana then it removes it from life to compensate the difference as a form of the game itself.
 
Back
Top