Register for your free account! | Forgot your password?

You last visited: Today at 05:12

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

Advertisement



Infinite mana problem

Discussion on Infinite mana problem within the CO2 Private Server forum part of the Conquer Online 2 category.

Closed Thread
 
Old 01/02/2012, 23:14   #16
 
12k's Avatar
 
elite*gold: 0
Join Date: Jul 2011
Posts: 218
Received Thanks: 33
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 01/03/2012, 01:03   #17
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
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 01/03/2012, 01:51   #18
 
macht102's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 36
Received Thanks: 1
problem solved.

#request close
macht102 is offline  
Closed Thread


Similar Threads Similar Threads
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?



All times are GMT +2. The time now is 05:12.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.