That's basically what I had, but it doesn't work.
'IV is the hex value of hex offsets 38-3B in little endian
IV = String.Format("{0,2:X2}", data(41)) + String.Format("{0,2:X2}", data(40)) + String.Format("{0,2:X2}", data(39)) + String.Format("{0,2:X2}", data(38))
'value2 is IV converted to integer
Dim value2 As Integer = Integer.Parse(IV, Globalization.NumberStyles.HexNumber)
'exactly what you have, I sometimes use And Binary where Binary is int 31
DEF_IV = ((value2 >> (10)) And &H1F)
When it is in little endian format, I constantly get 0's for any IV. If I do it in big endian, I get wrong answers. This particular file has the IVs: HP = 0, Attack = 6, Defense = 28. When I print the 3 IVs in big endian (as little returns all 0's), I get 0, 8 and 26.
Part of the problem I am seeing is that you are using decimal instead of hexadecimal for your offsets. In VB you use the prefix &H to specify hex instead of decimal; so 38 should actually be &H38, 39 should be &H39, and the next two are actually &H3A and &H3B.
Why are you doing it this way, anyway? How about doing this instead:
The BitConverter class will automatically put your number together. DATA is your byte array, and &H38 is the starting offset. Easy, right?Code:IV = BitConverter.ToUInt32(DATA, &H38)
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
The offsets are hex. That value does indeed produce a hex. I am using String.Format. X makes the value a hexadecimal.
C0 70 FE 00 is the hex 38-3B for this particular file.
Using the way I wrote it, in little endian.
txtIV.AppendText(IV)
returns "00FE70C0"
NEVERMIND. I got it to work this way. I was using the wrong offsets hahaha.
Now, I've got another couple of questions. Ability and moves, do they follow regular patterns or do I have to just make a chart of them. I'm asking because you had the chart last time, maybe you have more for this =P.
And for gender, nature and shiny, I didn't see any info for it, so I'm kind of in the dark here how to figure it out.
Last edited by greentea; Jul 12th, 2009 at 02:08 PM.
http://bulbapedia.bulbagarden.net/wi...sonality_value
There you go.
I'm a Natu.
Spoiler
Figures I wouldn't think to look on Bulbapedia for this. Thanks, it looks like I'll be able to code it from that, hopefully.
greentea, most of the database information I use came originally from Legendary Pokémon. Some of it had to be edited / revised / reformatted for my needs, but there's a bunch there that I think you will find useful.
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
I'm a little stuck on the gender now, and the shiny or not part.
First off, ability and nature were pretty easy. I'll use a text file for the abilities, nature I coded straight in, there's only 25.
With gender, I have a Charizard I was checking. Charizard, according to Serebii, is 87.5% Male (which makes sense). It returned 189 with my code. Since the value is 31, we know it is male, which it is. However, I went and used a Lugia. It returned 166. We know Lugia to be genderless, so the site says it should return 255. Pokesav shows it as genderless.
The code I am using is:
gender = PID mod 256
which is just what the site says "essentially p % 256" which is easier to code than whatever other stuff they were talking about (clearly I didn't get it).
Secondly, we get to shininess. This Lugia I am using, it has a PID that is 9 digits long, so in binary, it is only 27 digits long. These are 32 bit binary numbers, so do I assume the first 5 are 0? Or how else should I go about this. The rest of that code makes sense to me. I know truth tables and all, I understand XOR logic. The code is there and easy enough to do.
Yes, assume the leading 5 digits are 0.
For Lugia, the 255 is a reference to the gender value that is part of the Pokemon's base stat structure. IE, it's the same as the 31 is for Charizard. It is not what the p % 256 needs to output.
Pokemon with 255 as their base gender value will always be genderless, regardless of what p%256 outputs. Pokemon 254 as the gender value will always be female.
I'm a Natu.
Spoiler
It is worth asking about this though:
Also, if you don't want to do the gender check manually (and if you are not validating the legality or integrity of the Pokémon data all that vigorously), you should see bytes 0x40-0x41.
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
It's likely that there's a manual check before or after the PID calculation that checks the Pokemon's
If you think about it, there already has to be a check for 255 to make the Pokemon genderless. It's not that farfetch'dto think there's another check for 254, the all female value.
I'm a Natu.
Spoiler
Actually, the way I was currently checking, it was using the FE. When I programmed it, I saw the part about male and female so I did that. However, I ran into a slight problem. For the few pokemon that have alternate forms, their FE doesn't respond to male or female. What of those few?
EDIT: Ah, son of a gun. Jiggy got me again.
The information for Fateful Encounter, gender, and alternate forms are stored in completely separate bits of the bytes at 0x40-0x41. Look at the two bytes this way:
0|0|0|0 0000 0000 0000
Where Blue is the flag for Fateful Encounter, Red is the flag for female, dark red is the flag for genderless, and the rest is for alternate forms.
Bear in mind that the data is stored in little-endian, which means the bits (and bytes) go from least significant to most significant from right to left.
Last edited by codemonkey85; Jul 20th, 2009 at 10:56 PM.
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
I'm a Natu.
Spoiler
I guess I gotta review some stuff about bits and bytes.
From what I understand though, I just need to access the first 3 parts of the binary to check. I guess it's simple enough as long as I understand the bits and bytes, haha. And I guess I can assume non-female, non-genderless is male.
You guys always come to my rescue. This is what happens when you take a mixed (in between college level and university level) CS course. That you ace (with 100%) and do nothing half the time cause you're done (and everyone but one aren't) because they're stupid. Did I mention the class average was 68% and my teacher knows C/C++ and never did VB? If I had learned any of this... hahaha
I took a VB beginner's course recently because I have to (college degree and all), and the teacher knew nothing at all about binary file handling. I was disappointed to find this out when I asked him some questions.
But anyway.
Just remember that VB handles a lot of things for you. Don't go reinventing the wheel; if you need to do some kind of bitwise operation or conversion, look and see what VB has to offer first.
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
Bookmarks