Register for your free account! | Forgot your password?

You last visited: Today at 03:23

  • Please register to post and access all features, it's quick, easy and FREE!

 

Infinite mana problem

Closed Thread
 
Old   #16
 
elite*gold: 0
Join Date: Jul 2011
Posts: 204
Received Thanks: 27
Quote:
Originally Posted by pro4never View Post
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;}
}
}

Because its a ushort and not a int, that won't actually work because it never goes below 0. So you would have to do something like this each time your subtracting from mana.

Code:
if (Amount > Mana)
{ Mana = 0; }
else { Mana -= Amount; }


#edit, little late on making that response haha, lateralus beat me


#edit 2


Quote:
Originally Posted by macht102 View Post
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));
}
}
That is JUST for thunder. and Elementary level for thunder.



12k is offline  
Old   #17
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,196
Received Thanks: 5,306
Quote:
Originally Posted by Lateralus View Post
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.
Yes I realize both of those points. Sorry for not correcting it at the time, was a bit sleepy xD.

@OP: To simplify what they are saying.... Most math (unless specifically told otherwise) will return an integer value. Because of that you will often get issues such as what you're facing where it's saying take int X away from ushort Y. Because ushort can never be negative it loops back to max value. The solution I posted was silly of me because well.. it's wrong :P I'm checking for a negative value after it's already been looped back to max.

Also, Math library functions are lovely and should be used when applicable (no clue why I didn't use them at the time but w/e, gonna blame being super tired)


pro4never is offline  
Old   #18
 
elite*gold: 0
Join Date: Jul 2008
Posts: 36
Received Thanks: 0
problem solved.

#request close


macht102 is offline  
Closed Thread



« Previous Thread | Next Thread »

Similar Threads
Infinite Mana & HP
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?
6 Replies - Dekaron



All times are GMT +2. The time now is 03:23.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2018 elitepvpers All Rights Reserved.