Print Page | Close Window

Seamless/Scrolling Maps

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=231
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Seamless/Scrolling Maps
Posted By: Sync
Subject: Seamless/Scrolling Maps
Date Posted: 11 February 2006 at 3:42pm
Difficulty: Hard 5/5

This tutorial will show you how to modify a vanilla copy of Mirage Source 3.0.3 to put in seamless scrolling maps. This has only been tested on vanilla Mirage Source 3.0.3, and is not guaranteed to work on your game, especially if you have modified your map sizes.

This particular code allows for animation across maps, but has a tiny bug that pops up from time to time that causes the player to jump back a bit. I was unable to find and fix this bug at the time of writing this tutorial, but if a fix is found, it will be posted here.

The intent of these modifications is to make it seem like your game has never-ending maps. It will blt the surrounding maps around the map the player is currently on. To do this, the player must have the map downloaded. (This does not provide code to automatically download the maps, and does not verify that the player has the correct revision of the surrounding maps.)

Anyways... On to the tutorial. :P

Files to Modify
    [*]modClientTCP.bas
    [*]modDatabase.bas
    [*]modDirectX.bas
    [*]modGameLogic.bas
    [*]modTypes.bas[/list:u]
    [size=18px]modClientTCP.bas
    ModClientTCP is where the game handles all incoming/outgoing packets.

    In Sub HandleData()
    Replace this code:
            ' Make sure they aren't walking
            Player(i).Moving = 0
            Player(i).XOffset = 0
            Player(i).YOffset = 0
    with this code:
            ' Make sure they aren't walking
            If i <> MyIndex Then
              Player(i).Moving = 0
              Player(i).XOffset = 0
              Player(i).YOffset = 0
            End If

    Replace this code:
            If FileExist("maps\map" & x & ".dat") Then
                 ' Check to see if the revisions match
                 If GetMapRevision(x) = y Then
                     ' We do so we dont need the map
                     
                     ' Load the map
                     Call LoadMap(x)
    with this code:
            If FileExist("maps\map" & x & ".dat") Then
                 ' Check to see if the revisions match
                 If GetMapRevision(x) = y Then
                     ' We do so we dont need the map
                    
                     ' Load the map
                     Call LoadMap(x)
                     Call LoadSurroundingMaps

    Replace this code:
        If LCase(Parse(0)) = "mapdone" Then
            Map = SaveMap
    with this code:
        If LCase(Parse(0)) = "mapdone" Then
            Map = SaveMap
            Call LoadSurroundingMaps


    [size=18px]modDatabase.bas
    ModDatabase handles loading data for the client.

    Under the following code:
    Sub LoadMap(ByVal MapNum As Long)
    Dim FileName As String
    Dim f As Long

        FileName = App.Path & "\maps\map" & MapNum & ".dat"
           
        f = FreeFile
        Open FileName For Binary As #f
            Get #f, , SaveMap
        Close #f
    End Sub
    add the following code:
    Private Function iLoadMap(MapNum As Long) As MapRec
      Dim FileName As String
      Dim f As Long
     
      FileName = "maps\map" & MapNum & ".dat"
     
      If FileExist(FileName) Then
        f = FreeFile
        Open FileName For Binary As #f
          Get #f, , iLoadMap
        Close #f
      End If
    End Function
    Sub LoadSurroundingMaps()
      Dim MapNum As Long
     
      ReDim SMaps(7) 'Loading up to 8 maps
     
      MapNum = Map.Up
      If MapNum > 0 Then
        SMaps(0) = iLoadMap(MapNum)
      End If
      MapNum = Map.Right
      If MapNum > 0 Then
        SMaps(2) = iLoadMap(MapNum)
      End If
      MapNum = Map.Down
      If MapNum > 0 Then
        SMaps(4) = iLoadMap(MapNum)
      End If
      MapNum = Map.Left
      If MapNum > 0 Then
        SMaps(6) = iLoadMap(MapNum)
      End If
      MapNum = SMaps(0).Right
      If MapNum = 0 And SMaps(2).Up > 0 Then MapNum = SMaps(2).Up
      If MapNum > 0 Then
        SMaps(1) = iLoadMap(MapNum)
      End If
      MapNum = SMaps(2).Down
      If MapNum = 0 And SMaps(4).Right > 0 Then MapNum = SMaps(4).Right
      If MapNum > 0 Then
        SMaps(3) = iLoadMap(MapNum)
      End If
      MapNum = SMaps(4).Left
      If MapNum = 0 And SMaps(6).Down > 0 Then MapNum = SMaps(6).Down
      If MapNum > 0 Then
        SMaps(5) = iLoadMap(MapNum)
      End If
      MapNum = SMaps(6).Up
      If MapNum = 0 And SMaps(0).Left > 0 Then MapNum = SMaps(0).Left
      If MapNum > 0 Then
        SMaps(7) = iLoadMap(MapNum)
      End If
    End Sub


    [size=18px]modDirectX.bas
    ModDirectX handles all the DirectX settings for the game.

    In Sub InitSurfaces()
    Replace this code:
        ' Initialize back buffer
        DDSD_BackBuffer.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        DDSD_BackBuffer.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
        DDSD_BackBuffer.lWidth = (MAX_MAPX + 1) * PIC_X
        DDSD_BackBuffer.lHeight = (MAX_MAPY + 1) * PIC_Y
        Set DD_BackBuffer = DD.CreateSurface(DDSD_BackBuffer)
    with this code:
        ' Initialize back buffer
        DDSD_BackBuffer.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        DDSD_BackBuffer.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
        DDSD_BackBuffer.lWidth = 3 * ((MAX_MAPX + 1) * PIC_X)
        DDSD_BackBuffer.lHeight = 3 * ((MAX_MAPY + 1) * PIC_Y)
        Set DD_BackBuffer = DD.CreateSurface(DDSD_BackBuffer)


    [size=18px]modGameLogic.bas
    ModGameLogic handles all the logic of the game, such as drawing graphics to the picscreen, map editing, etc.

    In Sub GameLoop()
    Under this code:
    Sub GameLoop()
    Dim Tick As Long
    Dim TickFPS As Long
    Dim FPS As Long
    Dim x As Long
    Dim y As Long
    Dim i As Long
    Dim rec_back As RECT
    add this code:
    Dim MapXOffset As Integer, MapYOffset As Integer
    Dim PXOffset As Long, PYOffset As Long
    Dim bRec As RECT, tRec As RECT

    Under this code:
        Do While InGame
            Tick = GetTickCount
    add this code:
            'For scrolling/Seamless
            MapXOffset = Int(MAX_MAPX / 2) - GetPlayerX(MyIndex)
            MapYOffset = Int(MAX_MAPY / 2) - GetPlayerY(MyIndex)

    Under this code:
            ' Blit out tile layer fringe
            For y = 0 To MAX_MAPY
                 For x = 0 To MAX_MAPX
                     Call BltFringeTile(x, y)
                 Next x
            Next y
    add this code:
            'If in editor, we need to put a line around the map so we can see where we
            'are able to edit.
            If InEditor Then
              'Top Side
              rec.top = PIC_Y * (MAX_MAPY + 1)
              rec.Bottom = rec.top + 1
              rec.Left = PIC_X * (MAX_MAPX + 1)
              rec.Right = rec.Left + (PIC_X * (MAX_MAPX + 1))
             
              Call DD_BackBuffer.BltColorFill(rec, RGB(255, 255, 255))
             
              'Left Side
              rec.top = PIC_Y * (MAX_MAPY + 1)
              rec.Bottom = rec.top + (PIC_Y * (MAX_MAPY + 1))
              rec.Left = PIC_X * (MAX_MAPX + 1)
              rec.Right = rec.Left + 1
             
              Call DD_BackBuffer.BltColorFill(rec, RGB(255, 255, 255))
             
              'Right Side
              rec.top = PIC_Y * (MAX_MAPY + 1)
              rec.Bottom = rec.top + PIC_Y * (MAX_MAPY + 1)
              rec.Left = PIC_X * (MAX_MAPX + 1) - 1 + (PIC_X * (MAX_MAPX + 1))
              rec.Right = rec.Left + 1
             
              Call DD_BackBuffer.BltColorFill(rec, RGB(255, 255, 255))
             
              'Bottom Side
              rec.top = PIC_Y * (MAX_MAPY + 1) - 1 + (PIC_Y * (MAX_MAPY + 1))
              rec.Bottom = rec.top + 1
              rec.Left = PIC_X * (MAX_MAPX + 1)
              rec.Right = rec.Left + PIC_X * (MAX_MAPX + 1)
             
              Call DD_BackBuffer.BltColorFill(rec, RGB(255, 255, 255))
            End If

    Replace this code:
            ' Blit out attribs if in editor
            If InEditor Then
                 For y = 0 To MAX_MAPY
                     For x = 0 To MAX_MAPX
                         With Map.Tile(x, y)
                               If .Type = TILE_TYPE_BLOCKED Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "B", QBColor(BrightRed))
                               If .Type = TILE_TYPE_WARP Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "W", QBColor(BrightBlue))
                               If .Type = TILE_TYPE_ITEM Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "I", QBColor(White))
                               If .Type = TILE_TYPE_NPCAVOID Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "N", QBColor(White))
                               If .Type = TILE_TYPE_KEY Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "K", QBColor(White))
                               If .Type = TILE_TYPE_KEYOPEN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "O", QBColor(White))
                         End With
                     Next x
                 Next y
            End If
    with this code:
            ' Blit out attribs if in editor
            If InEditor Then
                 For y = 0 To MAX_MAPY
                     For x = 0 To MAX_MAPX
                         With Map.Tile(x, y)
                               If .Type = TILE_TYPE_BLOCKED Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "B", QBColor(BrightRed))
                               If .Type = TILE_TYPE_WARP Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "W", QBColor(BrightBlue))
                               If .Type = TILE_TYPE_ITEM Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "I", QBColor(White))
                               If .Type = TILE_TYPE_NPCAVOID Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "N", QBColor(White))
                               If .Type = TILE_TYPE_KEY Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "K", QBColor(White))
                               If .Type = TILE_TYPE_KEYOPEN Then Call DrawText(TexthDC, (x * PIC_X + 8) + (PIC_X * (MAX_MAPX + 1)), (y * PIC_Y + 8) + (PIC_Y * (MAX_MAPY + 1)), "O", QBColor(White))
                         End With
                     Next x
                 Next y
            End If

    Delete this code:
            ' Blit the text they are putting in
            Call DrawText(TexthDC, 0, (MAX_MAPY + 1) * PIC_Y - 20, MyText, RGB(255, 255, 255))
           
            ' Draw map name
            If Map.Moral = MAP_MORAL_NONE Then
                 Call DrawText(TexthDC, Int((MAX_MAPX + 1) * PIC_X / 2) - (Int(Len(Trim(Map.Name)) / 2) * 8), 1, Trim(Map.Name), QBColor(BrightRed))
            Else
                 Call DrawText(TexthDC, Int((MAX_MAPX + 1) * PIC_X / 2) - (Int(Len(Trim(Map.Name)) / 2) * 8), 1, Trim(Map.Name), QBColor(White))
            End If
           
            ' Check if we are getting a map, and if we are tell them so
            'If GettingMap = True Then
            '    Call DrawText(TexthDC, 50, 50, "Receiving Map...", QBColor(BrightCyan))
            'End If

    Replace this code:
            ' Release DC
            Call DD_BackBuffer.ReleaseDC(TexthDC)
           
            ' Get the rect for the back buffer to blit from
            rec.top = 0
            rec.Bottom = (MAX_MAPY + 1) * PIC_Y
            rec.Left = 0
            rec.Right = (MAX_MAPX + 1) * PIC_X
           
            ' Get the rect to blit to
            Call DX.GetWindowRect(frmMirage.picScreen.hWnd, rec_pos)
            rec_pos.Bottom = rec_pos.top + ((MAX_MAPY + 1) * PIC_Y)
            rec_pos.Right = rec_pos.Left + ((MAX_MAPX + 1) * PIC_X)
           
            ' Blit the backbuffer
            Call DD_PrimarySurf.Blt(rec_pos, DD_BackBuffer, rec, DDBLT_WAIT)
    with this code:
            ' Release DC
            Call DD_BackBuffer.ReleaseDC(TexthDC)
           
            PXOffset = Player(MyIndex).XOffset
            PYOffset = Player(MyIndex).YOffset
           
            ' Get the rect for the back buffer to blit from
            rec.top = PIC_Y * (MAX_MAPY + 1)
            rec.Bottom = PIC_Y * (MAX_MAPY + 1) + rec.top
            rec.Left = PIC_X * (MAX_MAPX + 1)
            rec.Right = PIC_X * (MAX_MAPX + 1) + rec.Left
           
            rec.top = rec.top - (PIC_Y * MapYOffset)
            rec.Bottom = rec.Bottom - (PIC_Y * MapYOffset)
            rec.Left = rec.Left - (PIC_X * MapXOffset)
            rec.Right = rec.Right - (PIC_X * MapXOffset)
           
            ' Get the rect to blit to
            Call DX.GetWindowRect(frmMirage.picScreen.hWnd, rec_pos)
           
            rec_pos.Bottom = rec_pos.top + (PIC_Y * (MAX_MAPY + 1))
            rec_pos.Right = rec_pos.Left + (PIC_X * (MAX_MAPX + 1))
           
            'Handle player movement offset.
            rec.top = rec.top + PYOffset
            rec.Bottom = rec.Bottom + PYOffset
            rec.Left = rec.Left + PXOffset
            rec.Right = rec.Right + PXOffset
           
            ' Blit the backbuffer
            Call DD_PrimarySurf.Blt(rec_pos, DD_BackBuffer, rec, DDBLT_WAIT)
           
            ' Blit the text they are putting in
            TexthDC = frmMirage.picScreen.hdc
            Call DrawText(TexthDC, 0, (MAX_MAPY + 1) * PIC_Y - 20, MyText, RGB(255, 255, 255))
           
            ' Draw map name
            If Map.Moral = MAP_MORAL_NONE Then
                 Call DrawText(TexthDC, Int((MAX_MAPX + 1) * PIC_X / 2) - (Int(Len(Trim(Map.Name)) / 2) * 8), 1, Trim(Map.Name), QBColor(BrightRed))
            Else
                 Call DrawText(TexthDC, Int((MAX_MAPX + 1) * PIC_X / 2) - (Int(Len(Trim(Map.Name)) / 2) * 8), 1, Trim(Map.Name), QBColor(White))
            End If
           
            ' Check if we are getting a map, and if we are tell them so
            'If GettingMap = True Then
            '    Call DrawText(TexthDC, 50, 50, "Receiving Map...", QBColor(BrightCyan))
            'End If

    Replace Sub BltTile() with this code:
    Sub BltTile(ByVal x As Long, ByVal y As Long)
      Dim Bufx As Long, Bufy As Long
      Dim i As Integer
      Dim Ground As Long
      Dim Anim1 As Long
      Dim Anim2 As Long

      For i = -1 To 7
        If i = -1 Then
          Ground = Map.Tile(x, y).Ground
          Anim1 = Map.Tile(x, y).Mask
          Anim2 = Map.Tile(x, y).Anim
          Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
          Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
        Else
          Ground = SMaps(i).Tile(x, y).Ground
          Anim1 = SMaps(i).Tile(x, y).Mask
          Anim2 = SMaps(i).Tile(x, y).Anim
          Select Case i
          Case 0
            Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
            Bufy = y * PIC_Y
          Case 1
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = y * PIC_Y
          Case 2
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
          Case 3
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 4
            Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 5
            Bufx = x * PIC_X
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 6
            Bufx = x * PIC_X
            Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
          Case 7
            Bufx = x * PIC_X
            Bufy = y * PIC_Y
          End Select
        End If
       
        rec.top = Int(Ground / 7) * PIC_Y
        rec.Bottom = rec.top + PIC_Y
        rec.Left = (Ground - Int(Ground / 7) * 7) * PIC_X
        rec.Right = rec.Left + PIC_X
        Call DD_BackBuffer.BltFast(Bufx, Bufy, DD_TileSurf, rec, DDBLTFAST_WAIT)
       
        If (MapAnim = 0) Or (Anim2 <= 0) Then
            ' Is there an animation tile to plot?
            If Anim1 > 0 And TempTile(x, y).DoorOpen = NO Then
                 rec.top = Int(Anim1 / 7) * PIC_Y
                 rec.Bottom = rec.top + PIC_Y
                 rec.Left = (Anim1 - Int(Anim1 / 7) * 7) * PIC_X
                 rec.Right = rec.Left + PIC_X
                 Call DD_BackBuffer.BltFast(Bufx, Bufy, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
            End If
        Else
            ' Is there a second animation tile to plot?
            If Anim2 > 0 Then
                 rec.top = Int(Anim2 / 7) * PIC_Y
                 rec.Bottom = rec.top + PIC_Y
                 rec.Left = (Anim2 - Int(Anim2 / 7) * 7) * PIC_X
                 rec.Right = rec.Left + PIC_X
                 Call DD_BackBuffer.BltFast(Bufx, Bufy, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
            End If
        End If
      Next
    End Sub

    Replace Sub BltItem() with this code:
    Sub BltItem(ByVal ItemNum As Long)
        rec.top = Item(MapItem(ItemNum).Num).Pic * PIC_Y
        rec.Bottom = rec.top + PIC_Y
        rec.Left = 0
        rec.Right = rec.Left + PIC_X
       
        Call DD_BackBuffer.BltFast(MapItem(ItemNum).x * PIC_X + (PIC_X * (MAX_MAPX + 1)), MapItem(ItemNum).y * PIC_Y + (PIC_Y * (MAX_MAPY + 1)), DD_ItemSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
    End Sub

    Replace Sub BltFringeTile() with this code:
    Sub BltFringeTile(ByVal x As Long, ByVal y As Long)
      Dim Bufx As Long, Bufy As Long
      Dim i As Integer
      Dim Fringe As Long

      For i = -1 To 7
        If i = -1 Then
          Fringe = Map.Tile(x, y).Fringe
          Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
          Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
        Else
          Fringe = SMaps(i).Tile(x, y).Fringe
          Select Case i
          Case 0
            Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
            Bufy = y * PIC_Y
          Case 1
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = y * PIC_Y
          Case 2
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
          Case 3
            Bufx = (x * PIC_X) + (2 * (PIC_X * (MAX_MAPX + 1)))
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 4
            Bufx = (x * PIC_X) + (PIC_X * (MAX_MAPX + 1))
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 5
            Bufx = x * PIC_X
            Bufy = (y * PIC_Y) + (2 * (PIC_Y * (MAX_MAPY + 1)))
          Case 6
            Bufx = x * PIC_X
            Bufy = (y * PIC_Y) + (PIC_Y * (MAX_MAPY + 1))
          Case 7
            Bufx = x * PIC_X
            Bufy = y * PIC_Y
          End Select
        End If
       
        If Fringe > 0 Then
            rec.top = Int(Fringe / 7) * PIC_Y
            rec.Bottom = rec.top + PIC_Y
            rec.Left = (Fringe - Int(Fringe / 7) * 7) * PIC_X
            rec.Right = rec.Left + PIC_X
            Call DD_BackBuffer.BltFast(Bufx, Bufy, DD_TileSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
        End If
      Next
    End Sub

    In Sub BltPlayer()
    Under this code:
        x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
        y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
    add this code:
        x = x + (PIC_X * (MAX_MAPX + 1))
        y = y + (PIC_Y * (MAX_MAPY + 1))

    In Sub BltPlayerName()
    Under this code:
        TextX = GetPlayerX(Index) * PIC_X + Player(Index).XOffset + Int(PIC_X / 2) - ((Len(GetPlayerName(Index)) / 2) * 8)
        TextY = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - Int(PIC_Y / 2) - 4
    add this code:
        TextX = TextX + (PIC_X * (MAX_MAPX + 1))
        TextY = TextY + (PIC_Y * (MAX_MAPY + 1))

    In Sub BltNpc()
    Under this code:
        x = MapNpc(MapNpcNum).x * PIC_X + MapNpc(MapNpcNum).XOffset
        y = MapNpc(MapNpcNum).y * PIC_Y + MapNpc(MapNpcNum).YOffset - 4
    add this code:
        x = x + (PIC_X * (MAX_MAPX + 1))
        y = y + (PIC_Y * (MAX_MAPY + 1))

    In Sub ProcessMovement()
    Under this code:
    Sub ProcessMovement(ByVal Index As Long)
    add this code:
        If GettingMap Then Exit Sub

    In Sub CanMove()
    Replace the following code 4 times (4 different areas, up, down, right, left):
                 ' Check if they can warp to a new map
                 If Map.Up > 0 Then
                     Call SendPlayerRequestNewMap
                     GettingMap = True
                 End If
                 CanMove = False
                 Exit Function
    with this code:
                 ' Check if they can warp to a new map
                 If Map.Up > 0 Then
                   Call SendPlayerRequestNewMap
                   GettingMap = True
                 Else
                   CanMove = False
                 End If
                 Exit Function

    In Sub CheckMovement()
    Replace this code:
                     Select Case GetPlayerDir(MyIndex)
                         Case DIR_UP
                               Call SendPlayerMove
                               Player(MyIndex).YOffset = PIC_Y
                               Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
                    
                         Case DIR_DOWN
                               Call SendPlayerMove
                               Player(MyIndex).YOffset = PIC_Y * -1
                               Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
                    
                         Case DIR_LEFT
                               Call SendPlayerMove
                               Player(MyIndex).XOffset = PIC_X
                               Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
                    
                         Case DIR_RIGHT
                               Call SendPlayerMove
                               Player(MyIndex).XOffset = PIC_X * -1
                               Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
                     End Select
    with this code:
                     Select Case GetPlayerDir(MyIndex)
                         Case DIR_UP
                               Player(MyIndex).YOffset = PIC_Y
                               If Not GettingMap Then
                                 Call SendPlayerMove
                                 Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) - 1)
                               End If
                    
                         Case DIR_DOWN
                               Player(MyIndex).YOffset = PIC_Y * -1
                               If Not GettingMap Then
                                 Call SendPlayerMove
                                 Call SetPlayerY(MyIndex, GetPlayerY(MyIndex) + 1)
                               End If
                    
                         Case DIR_LEFT
                               Player(MyIndex).XOffset = PIC_X
                               If Not GettingMap Then
                                 Call SendPlayerMove
                                 Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 1)
                               End If
                    
                         Case DIR_RIGHT
                               Player(MyIndex).XOffset = PIC_X * -1
                               If Not GettingMap Then
                                 Call SendPlayerMove
                                 Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) + 1)
                               End If
                     End Select

    In Sub EditorMouseDown()
    Replace this code:
            x1 = Int(x / PIC_X)
            y1 = Int(y / PIC_Y)
    with this code:
        x1 = Int(x / PIC_X) + (Player(MyIndex).x - Int(MAX_MAPX / 2))
        y1 = Int(y / PIC_Y) + (Player(MyIndex).y - Int(MAX_MAPY / 2))

    In Sub PlayerSearch()
    Replace this code:
        x1 = Int(x / PIC_X)
        y1 = Int(y / PIC_Y)
    with this code:
      x1 = Int(x / PIC_X) + (Player(MyIndex).x - Int(MAX_MAPX / 2))
      y1 = Int(y / PIC_Y) + (Player(MyIndex).y - Int(MAX_MAPY / 2))


    [size=18px]modTypes.bas
    ModTypes holds all the information for different types used in the game, and some globally defined variables.

    Under this code:
    Public Map As MapRec
    add this code:
    Public SMaps() As MapRec


    Whew... That was a lot! Now.. Just so you know, this code works for me, but it is (minutely) possible that I forgot to put something in here. After I take a break, I will test it in a vanilla mirage, just to make sure everything works properly. I will post changes here if I forgot something.

    Also, this code does not send NPC/Item/Player data from the surrounding maps. (As you can see, we are only modifying the client side of the house.) I do not have any intention of coding this any time soon, but if I do, I'll post it in a separate tutorial, cause this one is already too big.

    Be warned, you can replace my old scrolling map code with this, but things are different, so make sure you undo what you did with my scrolling code, and replace with this.. And BACKUP YOUR SOURCE!!! (I have at least 30 copies of slightly modified 3.0.3 sources on my computer, and probably twice as many 3.0.7 copies. :P)

    Post suggestions/gripes/compliments/etc. as usual. :)



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info