Because it goes into negative and it's an ushort. unsigned integers cannot be negative, so it will jump to max value once it reaches a negative value. A simple if check can fix your problem, now it's up to you to do the rest yourself.
Because it goes into negative and it's an ushort. unsigned integers cannot be negative, so it will jump to max value once it reaches a negative value. A simple if check can fix your problem, now it's up to you to do the rest yourself.
Are you serious?! That's the "Mana Problem" that everyone who uses LOTF brags about fixing?!
*exhales* Mk... that sounds a bit more understandable of a problem.
I can see how the problem could be overwhelming for some people that don't know how to break it down into manageable steps.
ok now the problem is mana doesnt decrease after casting a spell
even if i do this for example under public void UseSkill
if (SkillId == 1000)
{
if (SkillLvl == 0)
{
if (CurMP >= 1)
{
CurMP -= 1;
MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));
}
else
{
MyClient.SendPacket(General.MyPackets.SendMsg(MyCl ient.MessageId, "SYSTEM", Name, "You do not have enough mana to cast this spell!", 2005));
}
}
Personally I'd write an accessor for mana which makes sure it never goes negative...
example..
public ushort Mana
{
get {return _mana;}
set{if(value < 0) value = 0; _mana = value;}
}
}
If he's going to do that, he's going to have to cast the (implicitly casted) int to a ushort before setting the value, which means that the value will never be < 0 and he'd have the same problem he has now. I'd also suggest using Math.Max... It looks cleaner, is probably inlined, and does the exact same thing.
Infinite Mana & HP 05/26/2009 - Dekaron - 6 Replies Is possible is you scam mana and hp numbers freeze them and them just have unlimited of both, like you never die or run out of mana?