Programming: Loading Halo2 Maps In VB

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Programming: Loading Halo2 Maps In VB

Post by Jefff »

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
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

YAY thanks jefff
Sig breaks rules, read the rules before reposting.
[users]glitchyguardian





Posts: 10
Joined: Mon Apr 11, 2005 12:32 am

Post by [users]glitchyguardian »

YA now every one gets to write programs :lol:
I kNows i ca'nt spall ya dedint have to tell me
[users]glitchyguardian





Posts: 10
Joined: Mon Apr 11, 2005 12:32 am

Post by [users]glitchyguardian »

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
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

glitchyguardian 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
Meh, mine looks 13373|2 8)
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
[users]glitchyguardian





Posts: 10
Joined: Mon Apr 11, 2005 12:32 am

Post by [users]glitchyguardian »

:lol: But yours takes up so much space ;) ROFL
but ya got to admit it does do a nice job at taking up
space and looking good
I kNows i ca'nt spall ya dedint have to tell me
[users]glitchyguardian





Posts: 10
Joined: Mon Apr 11, 2005 12:32 am

Post by [users]glitchyguardian »

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
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

There's the TagTag (for lack of a better name )
\
TagClass is what they are
Sig breaks rules, read the rules before reposting.
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

Code: Select all

 
ByteArray(offset) = number between 0 and 255 
is there any way to change a double or a long with this
Sig breaks rules, read the rules before reposting.
[users]glitchyguardian





Posts: 10
Joined: Mon Apr 11, 2005 12:32 am

Post by [users]glitchyguardian »

do something like

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
User avatar
Excal




Socialist Pyre

Posts: 1779
Joined: Fri Jan 02, 2004 9:55 am
Location: Bronx, NY

Post by Excal »

Wow... nice to know you were generous to let the comunity know.
Image
User avatar
kornman00




ONI New Age

Posts: 146
Joined: Fri Dec 12, 2003 6:30 pm
Contact:

Post by kornman00 »

Code: Select all

Private Function Load4String(ByRef Offset As Double, r As Boolean) As String 
I'm not too savy with VB6's value types, but all the languages I've used, treat a "Double" as a real number that takes up 8 bytes (on 32bit platforms).
When dealing with offsets you would only want to use a integer. IE, short or a long
[users]zulux





Posts: 34
Joined: Fri Feb 27, 2004 3:44 pm

Post by [users]zulux »

Long int for offsets... :wink:
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

Glitchy i cant figure out htat code i know its a function but i cant figure out how ot use it
Sig breaks rules, read the rules before reposting.
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

i got it workin but Jefff could u explain how to use the tag stuff u have in the tutorial
Sig breaks rules, read the rules before reposting.
mrhyperpenguin




Revivalist Miner Wordewatician 250

Posts: 357
Joined: Sun Mar 07, 2004 4:34 pm

Post by mrhyperpenguin »

i want to show tags from specific tagclasses (say coll) in treeview1
i can access the index offset but how would i populate the treeview1 with the tags?
Image
smellylobster





Posts: 104
Joined: Sun Oct 10, 2004 5:12 pm

Post by smellylobster »

Jefff wrote:
glitchyguardian 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
Meh, mine looks 13373|2 8)
haha, I was just about to say that. But your long code is still useful for learning purposes.

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.
n3xg3n





Posts: 4
Joined: Thu Nov 03, 2005 1:40 pm

ok not to sound like a noob

Post by n3xg3n »

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

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))
what do i do with that? or

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
Thanks, N3XG3N
User avatar
JK-47




Bloodhound Pyre Socialist Grunge

Posts: 10883
Joined: Wed Dec 01, 2004 2:54 pm
Location: Utah

Post by JK-47 »

WOAH!! THANKS! :D
Image
superaison





Posts: 175
Joined: Mon Jul 25, 2005 5:06 pm

Post by superaison »

um, is this vb6 or vb 2005? if its vb6 then i need help
Post Reply