Page 1 of 1

Halo 2 Programming Question

Posted: Sun May 17, 2009 2:55 am
by Click16
I was thinking of making a Halo 2 Program. My only problem is that I don't know what the offset of the tag's data is. I downloaded the tutorial in the tutorial section, but it doesn't teach me anything. It only taught me how to read. I don't know how to open the map, or read the map. It is all too new to me. I would make the program in VB only because I know VB all too well. I have not the slightest clue how to work with C# or C++. Any help will be appreciated. Also, when you tell me code, tell me what it is, what it does, and how it might work in a simple way.

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 3:45 am
by XZodia
I advise using my dll's or write a contribute applet. it'll save you a lot of time.

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 4:23 am
by OwnZ joO
Basically you need to read the Map Header, which then tells you the offset to the ObjectIndex. That will tell you the offset to the tag table. Then you need to read TagCount amount of Tags from that table. You will need to subtract the secondary magic from the raw offset of each tag in order to find where they are in the map. Then in order to read the meta for the tag into a byte array for example you would use code something like this:
[code]
br.BaseStream.Position = tag.MetaOffset; // seek to the translated offset
byte[] meta = br.ReadBytes(tag.MetaSize); // read the size of the meta from the meta's offset
[/code]

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 7:05 am
by troymac1ure
Grimdoomer obviously put ALOT of time into this very question, so look at his thread on Programming an H2 App:
http://forums.remnantmods.com/viewtopic.php?f=12&t=16

It also shows the header layout and more info.

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 6:25 pm
by Click16
Ok, when i read trough that tutorial, i understand it alot! i have the program built, I just dont know how to make the open file dialog do something with the class. Like i understand the binary reader, i just want to ask this question.

If the Open File Dialog is in Form1, how can i make it so when i click ok (OpenFileDialog.FileOK) it sends the map's location to the class where the data needs to go?

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 6:28 pm
by OwnZ joO
Well if you have a basic understanding of coding, you should be able to figure it out by taking that advice. It might also be a good idea to set a breakpoint in the tutorial(I'm assuming you mean the one I helped with that Supermodder released) where it opens the map and step through that. You should be able to find out what order things go in using that.

Re: Halo 2 Programming Question

Posted: Sun May 17, 2009 7:09 pm
by Click16

Code: Select all

 Private Sub OpenMapDialog_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenMapDialog.FileOk
        Dim OMD As String = OpenMapDialog.FileName
        If OpenMapDialog.ShowDialog() = DialogResult.OK Then
            Map.MapLocation = New Halo2Map(OMD)
        End If
    End Sub
OK, This is what I have so far. My only error is that OMD in brackets gives this error: Too many arguments to 'Public Sub New() I have searched around, but no luck. Anyone else wana shoot at it?

Re: Halo 2 Programming Question

Posted: Mon May 18, 2009 10:07 am
by Grimdoomer
Well first off MapLocation is a string, and HaloMap is an object.

Code: Select all

Private Sub OpenMapDialog_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenMapDialog.FileOk
        If OpenMapDialog.ShowDialog() = DialogResult.OK Then
            Map.MapLocation = OpenMapDialog.FileName
            Map.Read()
        End If
    End Sub
I don't know exactly how your Halo2Map class is organized.