Programming: Loading Halo2 Maps In VB
Programming: Loading Halo2 Maps In VB
Ok, you can choose any method you want to get the filename of the map, and you can use the map however you want. This tutorial will just load the map and save the map.
First, lets assume your loading
First, lets assume your loading
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
-
- Posts: 10
- Joined: Mon Apr 11, 2005 12:32 am
-
- Posts: 10
- Joined: Mon Apr 11, 2005 12:32 am
here ya go a shorter sub for hextodec
Code: Select all
Private Function HexToDec(ByVal HexStr As String) As Double
HexToDec = val("&H" & HexStr)
End Function
I kNows i ca'nt spall ya dedint have to tell me
Meh, mine looks 13373|2glitchyguardian wrote:here ya go a shorter sub for hextodec
Code: Select all
Private Function HexToDec(ByVal HexStr As String) As Double HexToDec = val("&H" & HexStr) End Function
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
-
- Posts: 10
- Joined: Mon Apr 11, 2005 12:32 am
-
- Posts: 10
- Joined: Mon Apr 11, 2005 12:32 am
also sometimes if to do the HEX() command you will get an overflow command so here is a funtion i use to solve that
Code: Select all
Public Function BigDecToHex(ByVal DecNum) As String
' This function is 100% accurate untill
' 15,000,000,000,000,000 (1.5E+16)
Dim NextHexDigit As Double
Dim HexNum As String
HexNum = ""
While DecNum <> 0
NextHexDigit = DecNum - (Int(DecNum / 16) * 16)
If NextHexDigit < 10 Then
HexNum = Chr(Asc(NextHexDigit)) & HexNum
Else
HexNum = Chr(Asc("A") + NextHexDigit - 10) & HexNum
End If
DecNum = Int(DecNum / 16)
Wend
If HexNum = "" Then HexNum = "0"
BigDecToHex = HexNum
End Function
I kNows i ca'nt spall ya dedint have to tell me
Code: Select all
ByteArray(offset) = number between 0 and 255
Sig breaks rules, read the rules before reposting.
-
- Posts: 10
- Joined: Mon Apr 11, 2005 12:32 am
do something like
Put4Hex "0000FFFF",25443
Put4Hex "0000FFFF",25443
Code: Select all
Public Function Put4Hex(HexString As String, tLoc)
HexString = right("00000000" & HexString,8)
ByteArray(tLoc + 0) = HexToDec(Right(Left(HexString, 2), 2))
ByteArray(tLoc + 1) = HexToDec(Right(Left(HexString, 4), 2))
ByteArray(tLoc + 2) = HexToDec(Right(Left(HexString, 6), 2))
ByteArray(tLoc + 3) = HexToDec(Right(Left(HexString, 8), 2))
End Function
I kNows i ca'nt spall ya dedint have to tell me
Code: Select all
Private Function Load4String(ByRef Offset As Double, r As Boolean) As String
When dealing with offsets you would only want to use a integer. IE, short or a long
-
- Posts: 357
- Joined: Sun Mar 07, 2004 4:34 pm
-
- Posts: 104
- Joined: Sun Oct 10, 2004 5:12 pm
haha, I was just about to say that. But your long code is still useful for learning purposes.Jefff wrote:Meh, mine looks 13373|2glitchyguardian wrote:here ya go a shorter sub for hextodec
Code: Select all
Private Function HexToDec(ByVal HexStr As String) As Double HexToDec = val("&H" & HexStr) End Function
But thanks a lot for this tutorial. I've always wanted to learn how to read bytes from a file, not just an open process.
After I'm done reading, I'll let you know if there are any problems with it.
ok not to sound like a noob
ok i was making a program to edit bipd and wut not. i cant come close to figure out what to do with this code i can tell which code to put in the module and the form plus some you dont go into enough explaination of the code and usage. for instance
what do i do with that? or
Thanks, N3XG3N
Code: Select all
IndexHeader = Load4Hex(16, True)
IndexMagic = Load4Hex(IndexHeader, True) - (Load4Hex(16, True) + 32)
MapMagic = Load4Hex((Load4Hex(IndexHeader + 8, True) - IndexMagic) + 8, True) - (IndexHeader + Load4Hex(20, True))
Code: Select all
Dim TagID() As Double
Dim TagOffset() As Double
Dim TagMetaSize() As Double
Dim TagTag() As String
TagCount = Load4Hex(IndexHeader + 4, True)
RealTagOff = IndexHeader + 32 + TagCount * 12
RealTagCount = Load4Hex(indexheader + 24, True)
EndTagOff = RealTagOff + RealTagCount * 16
ReDim TagTag(0 To rtagcount + 1)
ReDim TagID(0 To rtagcount + 1)
ReDim TagOffset(0 To rtagcount + 1)
ReDim TagMetaSize(0 To rtagcount + 1)
j = 0
For i = RealTagOff To EndTagOff Step 16
j = j + 1
TagTag(j) = Load4String(i + 0, True)
TagID(j) = Load4Hex(i + 4, True)
TagOffset(j) = Load4Hex(i + 8, True) - MapMagic
TagMetaSize(j) = Load4Hex(i + 12, True)
Next i
-
- Posts: 175
- Joined: Mon Jul 25, 2005 5:06 pm