Infinite mana problem

01/01/2012 00:13 macht102#1
the problem is I have 30/30 MP on login like it should be. but it jumps to around 65000/30 after casting and then goes down from there.

if searched the forums. only found
[Only registered and activated users can see links. Click Here To Register...]

and nothing in that thread has worked.
Its the same problem i think but cant figure it out.
01/01/2012 00:44 Kiyono#2
So which source are you using?
01/01/2012 01:04 macht102#3
I am using this one [Only registered and activated users can see links. Click Here To Register...]
01/01/2012 01:22 Kiyono#4
I guess that the best answer is to not use a LOTF based source.
01/01/2012 20:37 I don't have a username#5
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.
01/01/2012 22:10 Spirited#6
Quote:
Originally Posted by I don't have a username View Post
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?!
01/01/2012 22:12 I don't have a username#7
Quote:
Originally Posted by Fаng View Post
Are you serious?! That's the "Mana Problem" that everyone who uses LOTF brags about fixing?!
No. The original LOTF didn't even have mana.
01/02/2012 00:00 Spirited#8
Quote:
Originally Posted by I don't have a username View Post
No. The original LOTF didn't even have mana.
*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.
01/02/2012 02:04 macht102#9
any hints to where i should put this check?
01/02/2012 02:29 pro4never#10
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;}
}
}
01/02/2012 06:46 macht102#11
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));
}
}
01/02/2012 07:14 Spirited#12
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;}
}
}
^
Is a better answer. That way you only have to write the check once and forget about it.
01/02/2012 07:43 I don't have a username#13
Quote:
Originally Posted by Fаng View Post
^
Is a better answer. That way you only have to write the check once and forget about it.
You would be amazed how shit the 5017 lotf source is.

@OP If you really want to use 5017, then use Hybrids base or if you seek one with a bit features, then find Arco's version of it.
01/02/2012 17:43 Lateralus#14
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;}
}
}
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.
01/02/2012 22:10 Arco.#15
Quote:
Originally Posted by I don't have a username View Post
@OP If you really want to use 5017, then use Hybrids base or if you seek one with a bit features, then find Arco's version of it.
Remember its not mine. I don't have the talent to make something like that.