pkmtuts Posted December 3, 2013 Share Posted December 3, 2013 The problem is that I cant get the bits from 0x38-0x3B Might you help me please :smile: Im using this code for pokémon ID UInt16 pkmID = BitConverter.ToUInt16(pkm, 8); This code works fine :smile: for stats im using this code; UInt32 Stats = BitConverter.ToUInt32(pkm, (0x38 << 0)); This code dont work :frown: then i try this UInt32 Stats = BitConverter.ToUInt32(pkm, 0x38 ( [0-31] << 0 )); But noting same problem help me please Link to comment Share on other sites More sharing options...
codemonkey85 Posted December 3, 2013 Share Posted December 3, 2013 for stats im using this code; UInt32 Stats = BitConverter.ToUInt32(pkm, (0x38 << 0)); This code dont work :frown: So pkm is the byte array containing the PKM data and 0x38 is the offset for the IVs, right? This is the syntax for BitConverter.ToUInt32: 'Declaration <CLSCompliantAttribute(False)> _ Public Shared Function ToUInt16 ( _ [b]value[/b] As Byte(), _ [b]startIndex[/b] As Integer _ ) As UShort This is what you are doing: UInt32 Stats = BitConverter.ToUInt32([b]ARRAY[/b], ([b]startIndex[/b] << 0)); See the problem yet? You're shifting the index, not the value at that index. You need to fix your parentheses, I think: UInt32 Stats = BitConverter.ToUInt32(pkm, 0x38) << 0); then i try this UInt32 Stats = BitConverter.ToUInt32(pkm, 0x38 ( [0-31] << 0 )); But noting same problem You do realize [0-31] is the range of values, right? That doesn't go in your code. Link to comment Share on other sites More sharing options...
pkmtuts Posted December 5, 2013 Author Share Posted December 5, 2013 So pkm is the byte array containing the PKM data and 0x38 is the offset for the IVs, right? This is the syntax for BitConverter.ToUInt32: 'Declaration <CLSCompliantAttribute(False)> _ Public Shared Function ToUInt16 ( _ [b]value[/b] As Byte(), _ [b]startIndex[/b] As Integer _ ) As UShort This is what you are doing: UInt32 Stats = BitConverter.ToUInt32([b]ARRAY[/b], ([b]startIndex[/b] << 0)); See the problem yet? You're shifting the index, not the value at that index. You need to fix your parentheses, I think: UInt32 Stats = BitConverter.ToUInt32(pkm, 0x38) << 0); You do realize [0-31] is the range of values, right? That doesn't go in your code. Thanks a lot , I get the values by doing this: UInt32 Stats = BitConverter.ToUInt32(pkm, 0x38); byte PsIV = Convert.ToByte((Stats >> 0) & 31); byte AtaIV = Convert.ToByte((Stats >> 5) & 31); byte DefIV = Convert.ToByte((Stats >> 10) & 31); byte VelIV = Convert.ToByte((Stats >> 15) & 31); byte AtaSIV = Convert.ToByte((Stats >> 20) & 31); byte DefSIV = Convert.ToByte((Stats >> 25) & 31); byte EggF = Convert.ToByte((Stats >> 30) & 1); byte NickF = Convert.ToByte((Stats >> 31) & 1); texbox1.Text = (Convert.ToString(PsIV) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now