I made a simple function that checks if the player has manashield or not to remove mana or health.
Add this to global.lua
cid - Who will recieve the damage
damage - Amount of damage the creature will receive
colour - The colour of the animated text(if you lose mana, the text will always be blue)
effect - Effect that will be shown
This is what it does:
If the monster/player has Manashield(of course, only players can have manashield) then:
if the player's mana is higher than the damage, it will simply lose mana.
if the damage is higher, then the player will lose all his mana and part of his hp, for example, the damage is 300, the player has mana shield, and 255 mana, the player will lose 255 mana and 45 hp.
if the player/monster doesn't have manashield, it will simply lose hp.
Hope you like it.
(You know how to thank me if you like it *cough* rep *cough*)
Add this to global.lua
PHP:
function doDamageCreature(cid, damage, color, effect)
damage = math.abs(damage)
if getCreatureCondition(cid, CONDITION_MANASHIELD) == 1 then
doSendMagicEffect(getThingPos(cid),CONST_ME_LOSEENERGY)
doPlayerAddMana(cid, -math.min(damage, getPlayerMana(cid)))
damage = damage - getPlayerMana(cid)
end
if damage > 0 then
doCreatureAddHealth(cid, -damage)
doSendAnimatedText(getThingPos(cid), damage, color or TEXTCOLOR_RED)
end
if effect then
doSendMagicEffect(getThingPos(cid),effect)
end
return 1
end
damage - Amount of damage the creature will receive
colour - The colour of the animated text(if you lose mana, the text will always be blue)
effect - Effect that will be shown
This is what it does:
If the monster/player has Manashield(of course, only players can have manashield) then:
if the player's mana is higher than the damage, it will simply lose mana.
if the damage is higher, then the player will lose all his mana and part of his hp, for example, the damage is 300, the player has mana shield, and 255 mana, the player will lose 255 mana and 45 hp.
if the player/monster doesn't have manashield, it will simply lose hp.
Hope you like it.
(You know how to thank me if you like it *cough* rep *cough*)
Last edited: