'============================================================================== '迷路マップファイル作成 by はにわ 2009/11/22 ver0.10 '============================================================================== '■概要 ' 迷路マップファイル(gat,rsw,gnd)を自動作成するスクリプトです。 ' '■使い方 ' 拡張子をvbsにしてクリックして下さい。 ' デフォルトではCドライブ直下にmaze.gat、maze.rsw、maze.gndファイルが作成されます。 ' 一緒にアップされているbmpと一緒にgrfファイルへ変換して使って下さい。 ' 作成した迷路の内容はC:\maze.txtに出力されますのでご確認下さい。 ' ファイル出力先、マップ名、マップサイズなどは定数部分で調整可能です。 ' '■注意 ' 試作品です。 ' 定数の通路幅を1にするとマップ端が歩けなくなるので注意して下さい。 ' マップサイズは(通路幅+1)*任意値でないとなりません。 ' マップサイズを1000*1000程にすると処理に数分かかります。 '============================================================================== Option Explicit '================================================================= '定数宣言 '================================================================= Const ENCODE_UNICODE = "unicode" Const adTypeBinary = 1 Const adTypeText = 2 Const adWriteCreate = 1 Const adWriteOver = 2 Const INT_MAP_BUFF = 9 '↓↓↓調整部分↓↓↓ Const STR_OUTPUT_FOLDER = "C:\" '出力フォルダパス Const STR_OUTPUT_FILE_NAME = "maze" '出力ファイル名 Const STR_OUTPUT_PREVIEW = "C:\maze.txt" '作成結果確認用ファイルフルパス Const INT_ROAD_WIDTH = 5 '通路幅 Const INT_MAP_SIZE_X = 120 'マップサイズX軸 (通路幅+1)*任意値 Const INT_MAP_SIZE_Y = 120 'マップサイズY軸 (通路幅+1)*任意値 '↑↑↑調整部分↑↑↑ Dim aGatCell Randomize Call Main '********************************************************************* 'メイン処理 '********************************************************************* Function Main() Dim iLpCnt Dim bRet ReDim aGatCell(INT_MAP_SIZE_X+1,INT_MAP_SIZE_Y+1) iLpCnt = 0 Do while true bRet = CreateMaze if bRet = true then exit do else iLpCnt = iLpCnt + 1 end if if iLpCnt > 0 then WScript.echo "Failed Create Maze." Call OutputView exit function end if loop Call OutputView Call CreateGAT Call CreateRSW Call CreateGND WScript.echo "Finish." End Function Function OutputView() Dim iX Dim iY Dim objFileSys Dim objOutFile Set objFileSys = WScript.CreateObject("Scripting.FileSystemObject") Set objOutFile = objFileSys.OpenTextFile(STR_OUTPUT_PREVIEW,2,true) for iX = 0 to INT_MAP_SIZE_X+1 for iY = 0 to INT_MAP_SIZE_Y+1 if aGatCell(iX,iY) = 1 then objOutFile.Write "1" else objOutFile.Write " " end if next objOutFile.Write vbCrLf next objOutFile.Close End Function '********************************************************************* '迷路作成 '********************************************************************* Function CreateMaze() Dim iRnd Dim iX Dim iY Dim iXPos Dim iYPos Dim iXPosP Dim iYPosP Dim iChk Dim bExitFlg for iY = 0 to INT_MAP_SIZE_Y+1 for iX = 0 to INT_MAP_SIZE_X+1 aGatCell(iX,iY) = 1 next next for iY = 1 to INT_ROAD_WIDTH for iX = 1 to INT_ROAD_WIDTH aGatCell(iX,iY) = 0 next next iXPos = 1 iYPos = 1 do while true do while true iRnd = Int(4 * Rnd) if iRnd = 0 then iXPosP = iXPos + (INT_ROAD_WIDTH+1) iYPosP = iYPos elseif iRnd = 1 then iXPosP = iXPos iYPosP = iYPos + (INT_ROAD_WIDTH+1) elseif iRnd = 2 then iXPosP = iXPos - (INT_ROAD_WIDTH+1) iYPosP = iYPos else iXPosP = iXPos iYPosP = iYPos - (INT_ROAD_WIDTH+1) end if if iXPosP < 0 or iXPosP > INT_MAP_SIZE_X-INT_ROAD_WIDTH then elseif iYPosP < 0 or iYPosP > INT_MAP_SIZE_Y-INT_ROAD_WIDTH then elseif aGatCell(iXPosP,iYPosP) = 0 then elseif iXPosP = 1 and aGatCell(iXPosP,iYPosP+(INT_ROAD_WIDTH+1)) = 0 then elseif iYPosP = 1 and aGatCell(iXPosP+(INT_ROAD_WIDTH+1),iYPosP) = 0 then elseif iXPosP = INT_MAP_SIZE_X-INT_ROAD_WIDTH and aGatCell(iXPosP,iYPosP+(INT_ROAD_WIDTH+1)) = 0 then elseif iYPosP = INT_MAP_SIZE_Y-INT_ROAD_WIDTH and aGatCell(iXPosP+(INT_ROAD_WIDTH+1),iYPosP) = 0 then else exit do end if loop if iRnd = 0 then for iY = iYPosP to iYPosP+INT_ROAD_WIDTH-1 for iX = iXPosP-1 to iXPosP+INT_ROAD_WIDTH-1 aGatCell(iX,iY) = 0 next next elseif iRnd = 1 then for iY = iYPosP-1 to iYPosP+INT_ROAD_WIDTH-1 for iX = iXPosP to iXPosP+INT_ROAD_WIDTH-1 aGatCell(iX,iY) = 0 next next elseif iRnd = 2 then for iY = iYPosP to iYPosP+INT_ROAD_WIDTH-1 for iX = iXPosP to iXPosP+INT_ROAD_WIDTH aGatCell(iX,iY) = 0 next next else for iY = iYPosP to iYPosP+INT_ROAD_WIDTH for iX = iXPosP to iXPosP+INT_ROAD_WIDTH-1 aGatCell(iX,iY) = 0 next next end if iXPos = iXPosP iYPos = iYPosP if iXPos = INT_MAP_SIZE_X-INT_ROAD_WIDTH and iYPos = INT_MAP_SIZE_Y-INT_ROAD_WIDTH then exit do end if iChk = 0 if iXPos+(INT_ROAD_WIDTH+1) > INT_MAP_SIZE_X then iChk = iChk + 1 elseif aGatCell(iXPos+(INT_ROAD_WIDTH+1),iYPos) = 0 then iChk = iChk + 1 end if if iYPos+(INT_ROAD_WIDTH+1) > INT_MAP_SIZE_Y then iChk = iChk + 1 elseif aGatCell(iXPos,iYPos+(INT_ROAD_WIDTH+1)) = 0 then iChk = iChk + 1 end if if iXPos-(INT_ROAD_WIDTH+1) < 0 then iChk = iChk + 1 elseif aGatCell(iXPos-(INT_ROAD_WIDTH+1),iYPos) = 0 then iChk = iChk + 1 end if if iYPos-(INT_ROAD_WIDTH+1) < 0 then iChk = iChk + 1 elseif aGatCell(iXPos,iYPos-(INT_ROAD_WIDTH+1)) = 0 then iChk = iChk + 1 end if bExitFlg = false if iChk = 4 then for iY = INT_MAP_SIZE_Y-INT_ROAD_WIDTH to 1 step (-1)*(INT_ROAD_WIDTH+1) for iX = INT_MAP_SIZE_X-INT_ROAD_WIDTH to 1 step (-1)*(INT_ROAD_WIDTH+1) if aGatCell(iX,iY) = 0 then bExitFlg = true exit for end if next if bExitFlg = true then exit for end if next iXPos = iX iYPos = iY end if loop do while true bExitFlg = true for iY = 1 to INT_MAP_SIZE_Y-INT_ROAD_WIDTH step INT_ROAD_WIDTH+1 for iX = 1 to INT_MAP_SIZE_X-INT_ROAD_WIDTH step INT_ROAD_WIDTH+1 if aGatCell(iX,iY) = 1 then Call SetRoad(iX,iY) bExitFlg = false end if next next if bExitFlg = true then exit do end if loop CreateMaze = true End Function '********************************************************************* '通路作成 '********************************************************************* Function SetRoad(ByVal iX, ByVal iY) Dim iRnd Dim iXCnt Dim iYCnt iRnd = Int(4 * Rnd) if iRnd = 0 then if aGatCell(iX+(INT_ROAD_WIDTH+1),iY) = 0 then for iYCnt = iY to iY+INT_ROAD_WIDTH-1 for iXCnt = iX to iX+INT_ROAD_WIDTH aGatCell(iXCnt,iYCnt) = 0 next next end if elseif iRnd = 1 then if aGatCell(iX,iY+(INT_ROAD_WIDTH+1)) = 0 then for iYCnt = iY to iY+INT_ROAD_WIDTH for iXCnt = iX to iX+INT_ROAD_WIDTH-1 aGatCell(iXCnt,iYCnt) = 0 next next end if elseif iRnd = 2 then if iX-(INT_ROAD_WIDTH+1) > 0 then if aGatCell(iX-(INT_ROAD_WIDTH+1),iY) = 0 then for iYCnt = iY to iY+INT_ROAD_WIDTH-1 for iXCnt = iX-1 to iX+INT_ROAD_WIDTH-1 aGatCell(iXCnt,iYCnt) = 0 next next end if end if else if iY-(INT_ROAD_WIDTH+1) > 0 then if aGatCell(iX,iY-(INT_ROAD_WIDTH+1)) = 0 then for iYCnt = iY-1 to iY+INT_ROAD_WIDTH-1 for iXCnt = iX to iX+INT_ROAD_WIDTH-1 aGatCell(iXCnt,iYCnt) = 0 next next end if end if end if End Function '********************************************************************* 'GATファイル作成 '********************************************************************* Function CreateGAT() Dim oOut Dim bStream Dim iX Dim iY Set oOut = CreateObject("ADODB.Stream") oOut.Type = adTypeBinary Set bStream = New ByteStream oOut.Open oOut.Write = bStream.getByte(CInt("&H47")) oOut.Write = bStream.getByte(CInt("&H52")) oOut.Write = bStream.getByte(CInt("&H41")) oOut.Write = bStream.getByte(CInt("&H54")) oOut.Write = bStream.getByte(CInt("&H01")) oOut.Write = bStream.getByte(CInt("&H02")) oOut.Write = bStream.getByte(INT_MAP_SIZE_X mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_X/256) mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_X/256/256) mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_X/256/256/256) mod 256) oOut.Write = bStream.getByte(INT_MAP_SIZE_Y mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_Y/256) mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_Y/256/256) mod 256) oOut.Write = bStream.getByte(Int(INT_MAP_SIZE_Y/256/256/256) mod 256) for iY = INT_MAP_SIZE_Y-1 to 0 step -1 for iX = 0 to INT_MAP_SIZE_X-1 oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(aGatCell(iX,iY)) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) next next oOut.SaveToFile STR_OUTPUT_FOLDER & "\" & STR_OUTPUT_FILE_NAME & ".gat", adWriteOver oOut.Flush oOut.Close End Function '********************************************************************* 'RSWファイル作成 '********************************************************************* Function CreateRSW() Dim oInp Dim oOut Dim bStream Dim sRswExt(65519) Dim iCnt Set oInp = CreateObject("ADODB.Stream") oInp.Type = adTypeBinary Set oOut = CreateObject("ADODB.Stream") oOut.Type = adTypeBinary Set bStream = New ByteStream oOut.Open oOut.Write = bStream.getByte(CInt("&H47")) oOut.Write = bStream.getByte(CInt("&H52")) oOut.Write = bStream.getByte(CInt("&H53")) oOut.Write = bStream.getByte(CInt("&H57")) oOut.Write = bStream.getByte(2) oOut.Write = bStream.getByte(0) for iCnt=0 to 39 oOut.Write = bStream.getByte(0) next for iCnt=0 to 39 if Len(STR_OUTPUT_FILE_NAME & ".gnd") > iCnt then oOut.Write = bStream.getByte(Asc(Mid(STR_OUTPUT_FILE_NAME & ".gnd",iCnt+1,1))) else oOut.Write = bStream.getByte(0) end if next for iCnt=0 to 39 if Len(STR_OUTPUT_FILE_NAME & ".gat") > iCnt then oOut.Write = bStream.getByte(Asc(Mid(STR_OUTPUT_FILE_NAME & ".gat",iCnt+1,1))) else oOut.Write = bStream.getByte(0) end if next for iCnt=0 to 39 if iCnt = 0 then oOut.Write = bStream.getByte(0) elseif Len(STR_OUTPUT_FILE_NAME & ".gat") > iCnt then oOut.Write = bStream.getByte(Asc(Mid(STR_OUTPUT_FILE_NAME & ".gat",iCnt+1,1))) else oOut.Write = bStream.getByte(0) end if next oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H80")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H40")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H48")) oOut.Write = bStream.getByte(CInt("&H42")) oOut.Write = bStream.getByte(CInt("&H03")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H2D")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H2D")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H80")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H80")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H80")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&HCD")) oOut.Write = bStream.getByte(CInt("&HCC")) oOut.Write = bStream.getByte(CInt("&H0C")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H09")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&HD4")) oOut.Write = bStream.getByte(CInt("&H84")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H02")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.SaveToFile STR_OUTPUT_FOLDER & "\" & STR_OUTPUT_FILE_NAME & ".rsw", adWriteOver oOut.Flush oOut.Close End Function '********************************************************************* 'GNDファイル作成 '********************************************************************* Function CreateGND() Dim oOut Dim bStream Dim iCnt Dim iXCnt Dim iYCnt Dim iX Dim iY Dim iTexNum Dim iTileNum Dim iTileCnt Dim iMapSizeX_Harf Dim iMapSizeY_Harf iMapSizeX_Harf = IntUp(INT_MAP_SIZE_X/2) iMapSizeY_Harf = IntUp(INT_MAP_SIZE_Y/2) Set oOut = CreateObject("ADODB.Stream") oOut.Type = adTypeBinary Set bStream = New ByteStream oOut.Open oOut.Write = bStream.getByte(CInt("&H47")) oOut.Write = bStream.getByte(CInt("&H52")) oOut.Write = bStream.getByte(CInt("&H47")) oOut.Write = bStream.getByte(CInt("&H4E")) oOut.Write = bStream.getByte(CInt("&H01")) oOut.Write = bStream.getByte(CInt("&H07")) oOut.Write = bStream.getByte(iMapSizeX_Harf mod 256) oOut.Write = bStream.getByte(Int(iMapSizeX_Harf/256) mod 256) oOut.Write = bStream.getByte(Int(iMapSizeX_Harf/256/256) mod 256) oOut.Write = bStream.getByte(Int(iMapSizeX_Harf/256/256/256) mod 256) oOut.Write = bStream.getByte(iMapSizeY_Harf mod 256) oOut.Write = bStream.getByte(Int(iMapSizeY_Harf/256) mod 256) oOut.Write = bStream.getByte(Int(iMapSizeY_Harf/256/256) mod 256) oOut.Write = bStream.getByte(Int(iMapSizeY_Harf/256/256/256) mod 256) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&H41")) oOut.Write = bStream.getByte(1) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(CInt("&H50")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&HC7")) oOut.Write = bStream.getByte(CInt("&HCA")) oOut.Write = bStream.getByte(CInt("&HB5")) oOut.Write = bStream.getByte(CInt("&HE5")) oOut.Write = bStream.getByte(CInt("&HB9")) oOut.Write = bStream.getByte(CInt("&HD9")) oOut.Write = bStream.getByte(CInt("&HB4")) oOut.Write = bStream.getByte(CInt("&HDA")) oOut.Write = bStream.getByte(CInt("&H5C")) oOut.Write = bStream.getByte(CInt("&H6D")) oOut.Write = bStream.getByte(CInt("&H61")) oOut.Write = bStream.getByte(CInt("&H7A")) oOut.Write = bStream.getByte(CInt("&H65")) oOut.Write = bStream.getByte(CInt("&H2E")) oOut.Write = bStream.getByte(CInt("&H62")) oOut.Write = bStream.getByte(CInt("&H6D")) oOut.Write = bStream.getByte(CInt("&H70")) for iCnt=17 to 39 oOut.Write = bStream.getByte(CInt("&H00")) next oOut.Write = bStream.getByte(CInt("&H31")) oOut.Write = bStream.getByte(CInt("&H32")) oOut.Write = bStream.getByte(CInt("&H34")) oOut.Write = bStream.getByte(CInt("&H33")) oOut.Write = bStream.getByte(CInt("&H36")) oOut.Write = bStream.getByte(CInt("&H31")) oOut.Write = bStream.getByte(CInt("&H33")) oOut.Write = bStream.getByte(CInt("&H35")) oOut.Write = bStream.getByte(CInt("&H31")) oOut.Write = bStream.getByte(CInt("&H37")) for iCnt=50 to 79 oOut.Write = bStream.getByte(CInt("&H00")) next oOut.Write = bStream.getByte(CInt("&H01")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H08")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H08")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H01")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) for iCnt = 0 to 63 oOut.Write = bStream.getByte(255) next for iCnt = 64 to 255 oOut.Write = bStream.getByte(0) next iTileNum = iMapSizeX_Harf * iMapSizeY_Harf oOut.Write = bStream.getByte(iTileNum mod 256) oOut.Write = bStream.getByte(Int(iTileNum/256) mod 256) oOut.Write = bStream.getByte(Int(iTileNum/256/256) mod 256) oOut.Write = bStream.getByte(Int(iTileNum/256/256/256) mod 256) for iYCnt = iMapSizeY_Harf-1 to 0 step -1 for iXCnt = 0 to iMapSizeX_Harf-1 iX = aGatCell(iXCnt*2, iYCnt*2+1) + aGatCell(iXCnt*2+1, iYCnt*2+1)*2 iY = aGatCell(iXCnt*2, iYCnt*2 ) + aGatCell(iXCnt*2+1, iYCnt*2 )*2 oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iX*32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iX*32+32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iX*32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iX*32+32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iY*32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iY*32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iY*32+32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(iY*32+32) oOut.Write = bStream.getByte(CInt("&H3F")) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(0) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) next next iTileCnt = 0 for iYCnt = iMapSizeY_Harf-1+INT_MAP_BUFF to 0 step -1 for iXCnt = 0 to iMapSizeX_Harf-1+INT_MAP_BUFF oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H00")) oOut.Write = bStream.getByte(CInt("&H20")) oOut.Write = bStream.getByte(CInt("&HC2")) oOut.Write = bStream.getByte(iTileCnt mod 256) oOut.Write = bStream.getByte(Int(iTileCnt/256) mod 256) oOut.Write = bStream.getByte(Int(iTileCnt/256/256) mod 256) oOut.Write = bStream.getByte(Int(iTileCnt/256/256/256) mod 256) iTileCnt = iTileCnt + 1 oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) oOut.Write = bStream.getByte(255) next next oOut.SaveToFile STR_OUTPUT_FOLDER & "\" & STR_OUTPUT_FILE_NAME & ".gnd", adWriteOver oOut.Flush oOut.Close End Function '********************************************************************* ' IntEx '********************************************************************* Function IntEx(iTmp) if iTmp >= 0 then IntEx = Int(iTmp) else IntEx = Int(iTmp * (-1)) * (-1) end if End Function '********************************************************************* ' IntUp '********************************************************************* Function IntUp(iTmp) if iTmp - IntEx(iTmp) <> 0 then if iTmp >= 0 then IntUp = Int(iTmp) + 1 else IntUp = Int(iTmp * (-1)) * (-1) - 1 end if else IntUp = iTmp end if End Function '********************************************************************* ' ByteReadInt '********************************************************************* Function ByteReadInt(sTmp) ByteReadInt = AscB(sTmp.Read(1)) End Function '********************************************************************* ' ByteStreamクラス(ネットからの拾いもの) '********************************************************************* Class ByteStream Private innerArray(255) '================================================================= ' クラスの初期化処理 '================================================================= Private Sub Class_Initialize() Dim wkStream Set wkStream = WScript.CreateObject("ADODB.Stream") wkStream.Type = adTypeText wkStream.Charset = ENCODE_UNICODE wkStream.Open Dim i For i=0 To &hff wkStream.WriteText ChrW(i) Next wkStream.Position = 0 wkStream.Type = adTypeBinary If ("fe" = LCase(Hex(AscB(wkStream.Read(1))))) Then wkStream.Position = 2 End If For i=0 To &hff wkStream.Position = wkStream.Position + 1 innerArray(i) = wkStream.Read(1) Next wkStream.Close Set wkStream = Nothing End Sub '================================================================= ' 指定した数値のByte()を返す '================================================================= Public Function getByte(num) If (num < 0) Or (UBound(innerArray) < num) Then getByte = innerArray(0) '0x00を返す Else getByte = innerArray(num) End If End Function End Class