simple request

07/30/2010 23:04 Fish*#1
I tried to figure this out, but seems to be kinda stucked.
How can i convert VP(ulong) to CPs(ushort).

Dosnt seems to work for me x.X

btw. is for the 5165.
07/30/2010 23:20 _DreadNought_#2
uh?
Code:
ulong VP = GC.MyChar.VPS;
GC.MyChar.CPs += VP;
GC.MyChar.VP -= VP;
VP = 0;
Easy?
07/30/2010 23:30 kinshi88#3
Code:
CPs = Math.Min((ushort)VPs + CPs, ushort.MaxValue);
?
07/30/2010 23:46 Fish*#4
I meant, so they keep the current VP.
Like:
GC.MyChar.CPs = GC.MyChar.VP;
but everything i do, always get the can't convert thing lol :D
the one that was closest to work was urs kinshi.
But it just mde value higher, it should be same for both :D

this was how i tested urs kinshin:
Code:
                ulong VP = 0;
                uint CP = 0;
                CP = 9999;
                    Program.WriteLine("CP: " + CP);
                VP = 15000;
                Program.WriteLine("VP: " + VP);
                CP = Math.Min((ushort)VP + CP, ushort.MaxValue);
                Program.WriteLine("CP: " + CP);
                Console.ReadLine();
07/31/2010 01:06 teroareboss1#5
cps += (ushort)vp;
07/31/2010 01:30 kinshi88#6
Quote:
Originally Posted by teroareboss1 View Post
cps += (ushort)vp;
VPs are a ulong, and a ulong can hold a lot more than a ushort.
So my way would be about right.
07/31/2010 01:33 Fish*#7
tero's worked.
And yeah kinshin, but i never think they will get that much vp anyway D:
07/31/2010 03:05 Arcо#8
Well it is a big possibility they'll get more than 65355
07/31/2010 03:06 kinshi88#9
Not a very smart choice. At all.
But whatever, your loss =P
07/31/2010 03:18 Arcо#10
Quote:
Originally Posted by kinshi88 View Post
Not a very smart choice. At all.
But whatever, your loss =P
Lol we'll just sit here, expecting another help thread saying his vps got bugged.
07/31/2010 03:29 _tao4229_#11
Quote:
Originally Posted by kinshi88 View Post
Code:
CPs = Math.Min((ushort)VPs + CPs, ushort.MaxValue);
?
What you're doing doesn't satisfy what you think it should do.

If VPs is already over 0xFFFF then it'll rollback over (as you cast it to a ushort first), but if (VPs % 0xFFFF) + CPs > 0xFFFF it'll rollback over again. You should let it without the cast and you'll have to cast ushort.MaxValue to a uint64 as well as the return type to a ushort as well. (if Math.Min has params for uint64s, I don't know).
07/31/2010 04:29 Fish*#12
Well, is solved.
#Request closed
07/31/2010 06:07 kinshi88#13
Quote:
Originally Posted by _tao4229_ View Post
What you're doing doesn't satisfy what you think it should do.

If VPs is already over 0xFFFF then it'll rollback over (as you cast it to a ushort first), but if (VPs % 0xFFFF) + CPs > 0xFFFF it'll rollback over again. You should let it without the cast and you'll have to cast ushort.MaxValue to a uint64 as well as the return type to a ushort as well. (if Math.Min has params for uint64s, I don't know).
Yeah, I did say my way would be about right =P
I had the right idea
07/31/2010 10:36 Huseby#14
#Closed