Originally Posted By MisUnderstood
Well I was wondering how to do this myself and I just thought I would share. Though I'm not sure what shannara will think of this since I *think* he has some kinda job with pw, well not a job but ya know... So I wouldn't be too surprised if you delete it.
Well anyway I'm just gonna tell you how to convert to a normal ms rec. Nothing more.
This method works without even knowing the whole pw rec, I think I have it, but I don't know if it would be right to post it so I wont. Its not necessary anyway.
Anyway this is the normal msrec
Code:
Type TileRec
Ground As Integer
Mask As Integer
Anim As Integer
Fringe As Integer
Type As Byte
Data1 As Integer
Data2 As Integer
Data3 As Integer
End Type
Type MapRec
Name As String * 20
Revision As Long
Moral As Byte
Up As Integer
Down As Integer
Left As Integer
Right As Integer
Music As Byte
BootMap As Integer
BootX As Byte
BootY As Byte
Shop As Byte
Indoors As Byte
Tile(0 To 15, 0 To 11) As TileRec
Npc(1 To 5) As Byte
End Type
Heres is the sub I use to convert it, well I don't use this exact sub, but this works.
Code:
Public Sub ConvertToMS(ByVal filename As String)
Dim f As Integer
Dim NewMap As MapRec
Dim x As Integer, y As Integer
Dim TempByte as byte
f = FreeFile
With NewMap
Open filename For Binary As #f
Get #f, , .Name
Get #f, , .Revision
Get #f, , .Moral
If .Moral > 1 Then 'Since MS does not have an arena or savage land(I think thats the name of it)
.Moral = 0
End If
Get #f, , .Up
Get #f, , .Down
Get #f, , .Left
Get #f, , .Right
Get #f, , .Music
Get #f, , .BootMap
Get #f, , .BootX
Get #f, , .BootY
Get #f, , .Shop
Get #f, , .Indoors
For x = 0 To 15
For y = 0 To 11
Get #f, , .Tile(x, y)
if .Tile(x,y).Type = 10 Then
.Tile(x,y).Type = 2 'In pw, 10 is the number for the warppoint, which is like warpdoor, only different somehow
'So i'm just changing it to the only one warp Ms has, which is good enough
ElseIf .Tile(x,y).Type > 6 Then 'These don't exist in MS, see the bottom of the tutorial for more information.
.Tile(x,y).type = 0
.Tile(x,y).data1 = 0
.Tile(x,y).data2 = 0
.Tile(x,y).data3 = 0
End If
Next y
Next x
For x = 1 To 14
if x <= 5 then
Get #f, , .Npc(x)
Else
Get #f, ,TempByte 'Since pw has 14 npcs, and MS only has 5, if you wanna change Ms's rec to 14 be my guest.
Next x
Close #f
End With
f = FreeFile 'Replace the file
Open filename For Binary As #f
Put #f, , NewMap
Close #f
End Sub
Heres some information about what I think each attribute in PW is. I think I'm right, but I make no guarentees
Code:
' ::::::::::::::::::::::::
' :: Map Atributes Info ::
' ::::::::::::::::::::::::
'Blocked Attrubte-Type=1
'Warp(door)Type=2,map=data1,x=data2,y=data3
'WarpPoint Type=10,map=data1,x=data2,y=data3
'Item Type=3,Item=data1,Value=data2
'NpcAvoid Type=4
'Key Type=5,x=data1,y=data2
'KeyOpen Type=6,x=data1,y=data2
'Damage Type=7 DamageItDoes=data1,Item that Protects You=data2
'Heal Type=8
'Signs Type=11,Sign Number=data1
So if you wanna add these types to your game then you might want to edit this
Code:
ElseIf .Tile(x,y).Type > 6 Then 'These don't exit in MS, see the bottom of the tutorial for more information.
.Tile(x,y).type = 0
.Tile(x,y).data1 = 0
.Tile(x,y).data2 = 0
Tile(x,y).data3 = 0
End If
and change it so it won't clear the typetype that you have added to your game.
Btw this is for converting the serverside pw maps. Though clientside is almost the same, except for one variable.
There is also an extra variable in PW's map rec which deals with the respawn settings but I didn't add that in this tutorial.
If you don't want me posting this here, then sorry, but I figued It might be ok if I didn't post the map rec for pw. If its ok to post the map rec for pw too then let me know
If theres a problem with this and it doesn't work, let me know since this isn't what I used exactly, I edited it a little bit for this tutorial.
EDIT:
Don't change the MS rec when loading your pw maps like I showed above, if you wanna do that, edit the convertoldmapstonew sub in MS and have the oldmaps maprec as the server or clientpw map rec(depending which maps they are...duh) You cant use the MS rec if you change it(atleast the data types) because if you change the data type it will look for a different amount of bytes and will screw the whole thing up.
Thanks. So here is the pw maprec, now if you don't want me posting this just go ahead and delete it
Code:
Type ServerPWMapRec
Name As String * 20
Revision As Long
Moral As Byte
Up As Integer
Down As Integer
Left As Integer
Right As Integer
Music As Byte
BootMap As Integer
BootX As Byte
BootY As Byte
Shop As Byte
Indoors As Byte
Tile(0 To 15, 0 To 11) As MSTileRec
Npc(1 To 14) As Byte
Server As Boolean 'some 2 byte thing here I think this how the server knows its a server map, not a client map
Respawn As Byte 'Boolean 'Boolean
End Type
Type ClientPWMapRec
Name As String * 20
Revision As Long
Moral As Byte
Up As Integer
Down As Integer
Left As Integer
Right As Integer
Music As Byte
BootMap As Integer
BootX As Byte
BootY As Byte
Shop As Byte
'Indoors As Byte
Tile(0 To 15, 0 To 11) As MSTileRec
Npc(1 To 14) As Byte
'Server As Boolean 'some 2 byte thing here I think this how the server knows its a server map, not a client map
Respawn As Byte 'Boolean 'Boolean
End Type
This is what I think it is anyway. The server side im pretty sure of, clientside im not ass ure, but pretty sure.
To get this stuff I just compared the binary files to the MS while editing each valule to see where it changed.
I also have one that can convert client to server
If you want me to post that.
And if you wanna acually look at the bytes, this is what I did, maybe not the best but it works.
PWMaps is a variable which holds the location of the map folder (with a \ on the end)
Code:
Private Sub Command1_Click()
Dim PWBytes() As Byte
Dim MapNum as integer
Dim i As Integer
txtPW = ""
MapNum = InputBox("Enter the map number", , 1)
PWBytes = FileBytes(PWMaps & "map" & MapNum & ".dat")
For i = 0 To UBound(PWBytes)
txtPW = txtPW & PWBytes(i)
Next i
End Sub
And here is Function FileBytes
Code:
Function FileBytes(ByVal filename As String) As Byte()
Dim f As Integer
Dim ByteAry() As Byte
' open in binary mode
f = FreeFile
Open filename For Binary As #f
' read the string and close the file
ReDim ByteAry(LOF(f))
Get #f, , ByteAry
Close #f
FileBytes = ByteAry
End Function