Jump to content

Project Overload


LEGOanimal22

Recommended Posts

  • Replies 112
  • Created
  • Last Reply

Top Posters In This Topic

The IV's are a little tricky.

So the IV block is 32 bits. Let that be an integer. Read that like this:

BitConverter.ToUInt32(binary, offset)

An IV is 5 bits. You grabbed 32 bits. Now to remove the rest.

HP is the easiest to get. In the below, suppose all IVs are 31 except HP. Converting the IV block integer to binary results in this:

11111111111111111111111111100000

You don't necessarily know what the data where the 1's are when finding HP. But you don't need to. You just need to set all of those bits to 0.

Dim HP as Byte = (IVBlock Or &HFFFFFFE0) - &HFFFFFFE0

The above will set all those irrelevant bits to 1 then subtract that number. Something like this:

     11111111111111111111111111101010
   -11111111111111111111111111100000
   ---------------------------------
                               01010 - the value you wanted

And there you go. The HP.

Now for the Attack. A little harder.

In this case, if the attack was all 0, it would be:

11111111111111111111110000011111

How do we solve that? A Bit Shift!

Basically, before you do the Or-ing like above, use: (IVBlock >> 5) Or &H111.. whatever.

The >> is a right shift. It moves all the bits to the right, 5 times. So, it makes 11111111111111111111110000011111 become 11111111111111111111111111100000.

I'm sure you want more than the explanation I gave above, but I wanted you to know what I was doing before I posted some code I conveniently already wrote.

Public Property IVBlock As IVs
       Get
           Return New IVs(BitConverter.ToUInt32(_rawData, BlockBOffset() + 16))
       End Get
       Set(value As IVs)
           Dim buffer As Byte() = BitConverter.GetBytes(value.GetUInt32)
           For x As Byte = 0 To 3
               _rawData(BlockBOffset() + 16 + x) = buffer(x)
           Next
       End Set
   End Property
   Public Class IVs
       Dim _rawdata As UInt32
       Public Sub New(IVBlock As UInt32)
           _rawdata = IVBlock
       End Sub
       Public Function GetUInt32() As UInt32
           Return _rawdata
       End Function
       Public Property HP As Byte
           Get
               Return ((_rawdata >> 0) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata >> 0) Or 31) - 31) Or value) << 0
           End Set
       End Property
       Public Property Attack As Byte
           Get
               Return ((_rawdata >> 5) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata << 5) Or 31) - 31) Or value) << 5
           End Set
       End Property
       Public Property Defense As Byte
           Get
               Return ((_rawdata >> 10) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata >> 10) Or 31) - 31) Or value) << 10
           End Set
       End Property
       Public Property Speed As Byte
           Get
               Return ((_rawdata >> 15) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata >> 15) Or 31) - 31) Or value) << 15
           End Set
       End Property
       Public Property SpAttack As Byte
           Get
               Return ((_rawdata >> 20) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata >> 20) Or 31) - 31) Or value) << 20
           End Set
       End Property
       Public Property SpDefense As Byte
           Get
               Return ((_rawdata >> 25) Or 4294967264) - 4294967264
           End Get
           Set(value As Byte)
               _rawdata = ((((_rawdata >> 25) Or 31) - 31) Or value) << 25
           End Set
       End Property
       Public Property IsEgg As Boolean
           Get
               Return ((_rawdata >> 30) Or 4294967294) - 4294967294
           End Get
           Set(value As Boolean)
               _rawdata = ((((_rawdata >> 30) Or 1) - 1) Or value) << 30
           End Set
       End Property
       Public Property IsNicknamned As Boolean
           Get
               Return ((_rawdata >> 31) Or 4294967294) - 4294967294
           End Get
           Set(value As Boolean)
               _rawdata = ((((_rawdata >> 31) Or 1) - 1) Or value) << 31
           End Set
       End Property
   End Class

Link to comment
Share on other sites

please tell me what im doing wrong

Dim IVs As New IVs

Dim IVBlock As UInt32 = PKML.ReadUInt32()

IVs.GetUInt32(IVBlock)

HP_IV_Box.Value = IVs.HP

Attack_IV_Box.Value = IVs.Attack

Defense_IV_Box.Value = IVs.Defense

Speed_IV_Box.Value = IVs.Speed

SpA_IV_Box.Value = IVs.SpAttack

SpD_IV_Box.Value = IVs.SpDefense

IsEgg_Box.Checked = IVs.IsEgg

IsNickname_Box.Checked = IVs.IsNicknamned

also made a few modifications

Sub New()

' TODO: Complete member initialization

End Sub

Public Function GetUInt32(ByVal _raw As UInt32) As UInt32

_raw = _rawdata

Return _rawdata

End Function

Link to comment
Share on other sites

Finished function ARGenerator, will post code later.

Here it is:

Public Sub ARGenerator(ByVal in_layout As String, ByVal in_offset As String, ByVal in_value As String, ByVal 4Z As String, ByVal VList As String, ByVal VList2 As String, ByVal new_line As String)
If in_layout = "0" Then
new_line = "0" + in_offset + " " + in_value
End If
If in_layout = "1" Then 
new_line = "1" + in_offset + " " + "0000" + in_value			 
End If
If in_layout = "2" Then
new_line = "2" + in_offset + " " + "000000" + in_value
End If
If in_layout = "3" Then
new_line = "3" + in_offset + " " + in_value
End If 
If in_layout = "4" Then
new_line = "4" + in_offset + " " + in_value
End If
If in_layout = "5" Then
new_line = "5" + in_offset + " " + in_value
End If
If in_layout = "6" Then
new_line = "6" + in_offset + " " + in_value
End If
If in_layout = "7" Then
new_line = "7" + in_offset + " " + 4Z + in_value
End If
If in_layout = "8" Then
new_line = "8" + in_offset + " " + 4Z + in_value
End If
If in_layout = "9" Then
new_line = "9" + in_offset + " " + 4Z + in_value
End If
If in_layout = "A" Then 
new_line = "A" + in_offset + " " + 4Z + in_value
End If
If in_layout = "B" Then
new_line = "B" + in_offset + " " + "[url="tel:00000000"]00000000[/url]"
End If
If in_layout = "C" Then 
new_line = "C" + "[url="tel:0000000"]0000000[/url]" + " " + in_value
End If
If in_layout = "D0" Then
new_line = "D0" + "000000" + " " + "[url="tel:00000000"]00000000[/url]"
End If
If in_layout = "D1" Then
new_line = "D1" + "000000" + " " + "[url="tel:00000000"]00000000[/url]"
End If
If in_layout = "D2" Then
new_line = "D2" + "000000" + " " + "[url="tel:00000000"]00000000[/url]"
End If
If in_layout = "D3" Then
new_line = "D3" + "000000" + " " + in_value
End If
If in_layout = "D4" Then
new_line = "D4" + "000000" + " " + in_value
End If
If in_layout = "D5" Then
new_line = "D5" + "000000" + " " + in_value
End If 
If in_layout = "D6" Then
new_line = "D6" + "000000" + " " + in_offset
End If
If in_layout = "D7" Then 
new_line = "D7" + "000000" + " " + in_offset
End If
If in_layout = "D8" Then
new_line = "D8" + "000000" + " " + in_offset
End If
If in_layout = "D9" Then
new_line = "D9" + "000000" + " " + in_offset
End If
If in_layout = "DA" Then
new_line = "DA" + "000000" + " " + in_offset
End If
If in_layout = "DB" Then
new_line = "DB" + "000000" + " " + in_offset
End If
If in_layout = "E" Then
new_line = "E" + in_offset + " " + in_value + " " + VList + " " + VList2End IfIf in_layout = "F" Then
new_line = "F" + in_offset + " " + in_value			 
End If
End Sub 

Uploaded current screenshots

Edited by wraith89
Merged posts; please learn to use the Edit Button
Link to comment
Share on other sites

Don't forget to set pkm equal to something. You cannot set item x of an array equal to something if the array is null.

Try this:

Dim pkm(900 - 1) As G5_PC_PKM

What this does is make pkm an array with 900 items. (The -1 is because the number in the parentheses specifies the last index of the array, not the number of items.)

...
Link to comment
Share on other sites

tried out my save reader for the box slots, I got this for the nickname

8D-EA-96-62-68-92-97-A3-49-1C-03-6E-AA-31-89-AA-C5-D3-EA-C3-D9-82-C6-E0-5C-94-3B-4E-5F-5A-28-24-B3-FB-E1-BF-8E-7B-7F-00-C4-40-48-C8-D1-BF-B6-38-3B-90-23-FB-23-7D-34-BE-00-DA-6A-70-C5-DF-84-BA

please tell me what I'm doing wrong

It does this for every blank slot

Edited by LEGOanimal22
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...