Mirage Source http://web.miragesource.net/forums/ |
|
Directional Blocking (My way) http://web.miragesource.net/forums/viewtopic.php?f=210&t=43 |
Page 1 of 1 |
Author: | funkynut [ Thu Jun 01, 2006 9:10 pm ] |
Post subject: | Directional Blocking (My way) |
Ok, quick note, I havent enabled this for npcs, I'mma very lazy person so if you want, you can complete it yourselfs, its not that hard. And asfar as I know, I works perfectly for players as it is... Originally posted by FunkyNut Directional Blocking (My way) Difficulty 4/5(Its not difficult to understand, but It can get a bit confusing since its not like a tile attibute and adds parts everywhere) Attachment: Directional Block Example2.png [ 34.17 KiB | Viewed 10628 times ] ^^^Forgot to show sample, so here is what mine finished looks like. I can walk on all the green tiles, but they wont allow me to walk on the grey tiles ok, This tut will give you the ability to Unblock/Block directions that a players on, if you want to stop a tile from access from all sides, its still easier to use a block attib (Which isnt removed by this tut),but this tile will allow a player to walk on a tile (Such as a ledge) but wont let them walk any further (so you dont waste a whole tile when stopping players walking over a ledge). Btw, I’m not sure, but I assume that this will muck up any maps you already have so you either have to redo the maps, or make a small app to convert all old maps to this new format Ok, lets Begin, first off lets change the way Tiles are read and saved, so find TileRec on both Client and Server and add to the bottom of the type: Code: WalkUp As Boolean WalkDown As Boolean WalkLeft As Boolean WalkRight As Boolean This will be used to record which directions are walkable, if a directions walkable, it will be set to true Now, lets just add the controls we’ll be using in Map Editor, Add a Checkbox called chkDirectionView and two command buttons called cmdFillDirections and cmdClearDirections Attachment: Directional Block Map Editor.png [ 7.33 KiB | Viewed 10627 times ] Ok, now we’ve added the controls, we need the server to send us the new Tile Records to the client so find the sub SendMap, find: Code: Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR and replace it with: Code: Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR & .WalkUp & SEP_CHAR & .WalkDown & SEP_CHAR & .WalkLeft & SEP_CHAR & .WalkRight & SEP_CHAR Now find SendMap in the Client and replace the same thing Now, we need the client to interpret this new data when its received so find: Code: SaveMap.Tile(x, y).Ground = Val(Parse(n)) SaveMap.Tile(x, y).Mask = Val(Parse(n + 1)) SaveMap.Tile(x, y).Anim = Val(Parse(n + 2)) SaveMap.Tile(x, y).Fringe = Val(Parse(n + 3)) SaveMap.Tile(x, y).Type = Val(Parse(n + 4)) SaveMap.Tile(x, y).Data1 = Val(Parse(n + 5)) SaveMap.Tile(x, y).Data2 = Val(Parse(n + 6)) SaveMap.Tile(x, y).Data3 = Val(Parse(n + 7)) n = n + 8 And after SaveMap.Tile(x, y).Data3 add: Code: SaveMap.Tile(x, y).WalkUp = Parse(n + 8) SaveMap.Tile(x, y).WalkDown = Parse(n + 9) SaveMap.Tile(x, y).WalkLeft = Parse(n + 10) SaveMap.Tile(x, y).WalkRight = Parse(n + 11) And change: Code: n = n + 8 To: Code: n = n + 12 So we can keep track on what we’ve received Now we’ve done all that, we need to make the server aware of all this malarkey that the clients sending so find: Code: Map(MapNum).Tile(x, y).Ground = Val(Parse(n)) Map(MapNum).Tile(x, y).Mask = Val(Parse(n + 1)) Map(MapNum).Tile(x, y).Anim = Val(Parse(n + 2)) Map(MapNum).Tile(x, y).Fringe = Val(Parse(n + 3)) Map(MapNum).Tile(x, y).Type = Val(Parse(n + 4)) Map(MapNum).Tile(x, y).Data1 = Val(Parse(n + 5)) Map(MapNum).Tile(x, y).Data2 = Val(Parse(n + 6)) Map(MapNum).Tile(x, y).Data3 = Val(Parse(n + 7)) And add: Code: Map(MapNum).Tile(x, y).WalkUp = Parse(n + 8) Map(MapNum).Tile(x, y).WalkDown = Parse(n + 9) Map(MapNum).Tile(x, y).WalkLeft = Parse(n + 10) Map(MapNum).Tile(x, y).WalkRight = Parse(n + 11) And again, change the n = n +8 to n = n + 12 Now the server can quite happily send and retrieve the new data, we need to allow the Client to edit this data, so let’s first make the Client Blt the arrows onto each tile by adding a new surface containing the arrows. First, save this image to your Client Gfx Folder and call it ‘Direction’ and the extension you use. Attachment: Direction.png [ 536 Bytes | Viewed 10628 times ] We want to do this neatly and as fully as possible so find Code: If FileExist(FileName & "sprites" & GFX_EXT, True) = False Or FileExist(FileName & "tiles" & GFX_EXT, True) = False Or FileExist(FileName & "items" & GFX_EXT, True) = False Then And replace it with: Code: If FileExist(FileName & "sprites" & GFX_EXT, True) = False Or FileExist(FileName & "tiles" & GFX_EXT, True) = False Or FileExist(FileName & "items" & GFX_EXT, True) = False Or FileExist(FileName & "Direction" & GFX_EXT, True) = False Then Now, we need to create the DirectDraw surface, so find Code: Public DDSD_Item As DDSURFACEDESC2 and underneath it add: Code: Public DDSD_Direction As DDSURFACEDESC2 Also find: Code: Public DD_ItemSurf As DirectDrawSurface7 and add underneath Code: Public DD_DirectionSurf As DirectDrawSurface7 Now we need to add the code that actually inits the surface, so find Code: ' Init items ddsd type and load the bitmap With DDSD_Item .lFlags = DDSD_CAPS .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY End With Set DD_ItemSurf = DD.CreateSurfaceFromFile(FileName & "items" & GFX_EXT, DDSD_Item) DD_ItemSurf.SetColorKey DDCKEY_SRCBLT, Key And add under it Code: ' Init Direction ddsd type and load the bitmap With DDSD_Direction .lFlags = DDSD_CAPS .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY End With Set DD_DirectionSurf = DD.CreateSurfaceFromFile(FileName & "Direction" & GFX_EXT, DDSD_Direction) DD_DirectionSurf.SetColorKey DDCKEY_SRCBLT, Key Lets go though this line by line, the .lFlags is telling Dx what properties to look at, so if we added, ddsd_Height, it will check the height property, in this case its checking the caps property. The .lCaps is describing how to load the surface, in this case its placed into the video memory. (Not 100% sure what the OffScreenPlain does, but you use it for any surface that’s in the background) The next line tells it to load a picture from file onto the surface using the properties we’ve just set, and the line after that just tells it what colours to make invisible. We also have to unload the surface from memory when we exit so find Code: Set DD_ItemSurf = Nothing and add Code: Set DD_DirectionSurf = Nothing Now we need to display the directions on the map when we choose to so, find: 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)) If .Type = TILE_TYPE_NPCSPAWN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "NS", QBColor(Yellow)) End With Next x Next y End If And replace it with Code: ' Blit out attribs if in editor If InEditor Then If frmMirage.chkDirectionView.Value = 0 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)) If .Type = TILE_TYPE_NPCSPAWN Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "NS", QBColor(Yellow)) End With Next x Next y End If End If All this does is disable viewing tile attribs when viewing Tile Directions Now to main part that displays the arrows, we need this to be displayed above everything including all text, so we need to place this just after the backbuffer is released when blting text, so find: Code: Call DD_BackBuffer.ReleaseDC(TexthDC) And add this Code: If InEditor Then If frmMirage.chkDirectionView.Value = 1 Then Call BltDirectionArrows End If End If and then add the end of modGameLogic add this sub Code: Public Sub BltDirectionArrows() Dim x As Long, y As Long Dim Walkable As Boolean ' If tile has at least one dir, change center to circle For y = 0 To MAX_MAPY For x = 0 To MAX_MAPX With Map.Tile(x, y) Walkable = False ' Reset for a new tile ' Lets check what to Blt for the Up arrow If .WalkUp Then With rec .top = 0 .Bottom = .top + PIC_X .Left = PIC_Y * 3 .Right = .Left + PIC_Y End With Walkable = True Else With rec .top = PIC_X .Bottom = .top + PIC_X .Left = PIC_Y * 3 .Right = .Left + PIC_Y End With End If Call DD_BackBuffer.BltFast(x * PIC_X, y * PIC_Y, DD_DirectionSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' Now lets check For Down Arrow If .WalkDown Then With rec .top = 0 .Bottom = .top + PIC_X .Left = PIC_Y * 2 .Right = .Left + PIC_Y End With Walkable = True Else With rec .top = PIC_X .Bottom = .top + PIC_X .Left = PIC_Y * 2 .Right = .Left + PIC_Y End With End If Call DD_BackBuffer.BltFast(x * PIC_X, y * PIC_Y, DD_DirectionSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' Now lets check For Left Arrow If .WalkLeft Then With rec .top = 0 .Bottom = .top + PIC_X .Left = PIC_Y * 0 .Right = .Left + PIC_Y End With Walkable = True Else With rec .top = PIC_X .Bottom = .top + PIC_X .Left = PIC_Y * 0 .Right = .Left + PIC_Y End With End If Call DD_BackBuffer.BltFast(x * PIC_X, y * PIC_Y, DD_DirectionSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' Now lets check For Right Arrow If .WalkRight Then With rec .top = 0 .Bottom = .top + PIC_X .Left = PIC_Y * 1 .Right = .Left + PIC_Y End With Walkable = True Else With rec .top = PIC_X .Bottom = .top + PIC_X .Left = PIC_Y * 1 .Right = .Left + PIC_Y End With End If Call DD_BackBuffer.BltFast(x * PIC_X, y * PIC_Y, DD_DirectionSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' If tile is totally blocked, place cross in center If Walkable Then With rec .top = 0 .Bottom = .top + PIC_X .Left = PIC_Y * 4 .Right = .Left + PIC_Y End With Else With rec .top = PIC_X .Bottom = .top + PIC_X .Left = PIC_Y * 4 .Right = .Left + PIC_Y End With End If Call DD_BackBuffer.BltFast(x * PIC_X, y * PIC_Y, DD_DirectionSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) ' We need to draw a grid so we can tell which tiles which (First set pen width to 1) DD_BackBuffer.DrawLine x * PIC_X, y * PIC_Y, x * PIC_X, y * PIC_Y + (PIC_Y * MAX_MAPY) + 1 DD_BackBuffer.DrawLine x * PIC_X, y * PIC_Y, x * PIC_X + (PIC_X * MAX_MAPX) + 1, y * PIC_Y End With Next x Next y End Sub All this sub does is, go though each tile, checks its walkable properties and blts the correct image, once it’s done that it blts 2 lines which will eventually create a grid. The only other thing to explain about this sub is that it blts the center shape by checking if the tile is totally blocked, and if it is, it will blt a cross, if not, it blts a circle. We still need to make use of them buttons we added earlier, so double click on cmdFillDirections and add: Code: Dim X As Long, Y As Long ' Go through each tile and set each direction to walkable For X = 0 To MAX_MAPX For Y = 0 To MAX_MAPY With Map.Tile(X, Y) .WalkUp = True .WalkDown = True .WalkLeft = True .WalkRight = True End With Next Y Next X All this does is scan each tile and make each direction walkable Now double click cmdClearDirections and add: Code: Dim X As Long, Y As Long ' Go through each tile and set each direction to walkable For X = 0 To MAX_MAPX For Y = 0 To MAX_MAPY With Map.Tile(X, Y) .WalkUp = False .WalkDown = False .WalkLeft = False .WalkRight = False End With Next Y Next X This also scans each tile, but this time, it cuts off all directions. Thats all for now, its 11:25pm, and i still need a bath ready for school tomoz, i'll try finish it tomoz but its not guaranteed, but i've posted it anyway incase someone wants to try finish it by themselves. All it needs is a way to flick a single direction on/off and mod to playermove to scan directions Btw, incase your wondering, this is what mine looks like so far: Attachment: Directional Block Example.png [ 38.5 KiB | Viewed 10630 times ] Direction Blocking Part 2 Finally gotten round to starting the second half I better explain first what I’m going to do next for detecting which tile and where on the tile you’ve clicked, so far, i've split the tile into sections like this... Attachment: Tile Section.png [ 2.62 KiB | Viewed 10630 times ] Each section is a different clickable area, for example, the green area is for Blocking/Unblocking walking up and if the user clicks in this area then it will toggle it, the only problem now, is the corners at each side of the green section. The easiest way to solve this is to divide the whole tile into nine sections, like this… Attachment: Tile Section Block.png [ 2.41 KiB | Viewed 10628 times ] What we need the client to do now when the mouse is clicked, is to scan which section was clicked. So, open up your client, find the sub EditorMouseDown. Now at the top with the variables declaration, add these variables: Code: Dim x2 As Long, y2 As Long ' Used to record where on the tile was clicked Dim CenterTolerence As RECT ' Controls how easy it is to press center Now, to make it look neat, indent this Code: If (Button = 1) And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then If frmMirage.optLayers.Value = True Then With Map.Tile(x1, y1) If frmMirage.optGround.Value = True Then .Ground = EditorTileY * 7 + EditorTileX If frmMirage.optMask.Value = True Then .Mask = EditorTileY * 7 + EditorTileX If frmMirage.optAnim.Value = True Then .Anim = EditorTileY * 7 + EditorTileX If frmMirage.optFringe.Value = True Then .Fringe = EditorTileY * 7 + EditorTileX End With Else With Map.Tile(x1, y1) If frmMirage.optBlocked.Value = True Then .Type = TILE_TYPE_BLOCKED If frmMirage.optWarp.Value = True Then .Type = TILE_TYPE_WARP .Data1 = EditorWarpMap .Data2 = EditorWarpX .Data3 = EditorWarpY End If If frmMirage.optItem.Value = True Then .Type = TILE_TYPE_ITEM .Data1 = ItemEditorNum .Data2 = ItemEditorValue .Data3 = 0 End If If frmMirage.optNpcAvoid.Value = True Then .Type = TILE_TYPE_NPCAVOID .Data1 = 0 .Data2 = 0 .Data3 = 0 End If If frmMirage.optKey.Value = True Then .Type = TILE_TYPE_KEY .Data1 = KeyEditorNum .Data2 = KeyEditorTake .Data3 = 0 End If If frmMirage.optKeyOpen.Value = True Then .Type = TILE_TYPE_KEYOPEN .Data1 = KeyOpenEditorX .Data2 = KeyOpenEditorY .Data3 = 0 End If If frmMirage.optNpcSpawn.Value = True Then .Type = TILE_TYPE_NPCSPAWN .Data1 = SpawnNpcNum .Data2 = 0 .Data3 = 0 End If End With End If End If If (Button = 2) And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then If frmMirage.optLayers.Value = True Then With Map.Tile(x1, y1) If frmMirage.optGround.Value = True Then .Ground = 0 If frmMirage.optMask.Value = True Then .Mask = 0 If frmMirage.optAnim.Value = True Then .Anim = 0 If frmMirage.optFringe.Value = True Then .Fringe = 0 End With Else With Map.Tile(x1, y1) .Type = 0 .Data1 = 0 .Data2 = 0 .Data3 = 0 End With End If End If Add Code: End If after it and then, add before the section you just indented, add Code: ' Check if we need to change directional block or tile attribs If frmMirage.chkDirectionView.Value = 1 Then With CenterTolerence .top = 9 .Bottom = 22 .Left = 9 .Right = 22 If Button = 1 And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then x2 = x - (x1 * PIC_X) y2 = y - (y1 * PIC_Y) ' Using CenterTolerence as a grid guide, check which part was clicked (Start from Bottom right) If x2 > .Right Then ' Right side If y2 > .Bottom Then ' Right Bottom ' Now check which side of that small section was clicked If x2 > y2 Then Map.Tile(x1, y1).WalkRight = True Else Map.Tile(x1, y1).WalkDown = True End If ElseIf y2 > .Left Then ' Right Middle Map.Tile(x1, y1).WalkRight = True Else ' Right Top ' Check which side was clicked, remember, minus from x because ' its not starting from 0 If x2 - .Right > y2 Then Map.Tile(x1, y1).WalkUp = True Else Map.Tile(x1, y1).WalkRight = True End If End If ElseIf x2 > .Left Then ' Middle side If y2 > .Bottom Then 'Bottom Map.Tile(x1, y1).WalkDown = True ElseIf y2 > .Left Then ' Middle Map.Tile(x1, y1).WalkUp = True Map.Tile(x1, y1).WalkDown = True Map.Tile(x1, y1).WalkLeft = True Map.Tile(x1, y1).WalkRight = True Else ' Top Map.Tile(x1, y1).WalkUp = True End If Else If y2 > .Bottom Then 'Left Bottom If x2 > y2 - .Bottom Then Map.Tile(x1, y1).WalkDown = True Else Map.Tile(x1, y1).WalkLeft = True End If ElseIf y2 > .Left Then ' Left Middle Map.Tile(x1, y1).WalkLeft = True Else ' Left Top If x2 > y2 Then Map.Tile(x1, y1).WalkUp = True Else Map.Tile(x1, y1).WalkLeft = True End If End If End If ElseIf Button = 2 And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then x2 = x - (x1 * PIC_X) y2 = y - (y1 * PIC_Y) ' Using CenterTolerence as a grid guide, check which part was clicked (Start from Bottom right) If x2 > .Right Then ' Right side If y2 > .Bottom Then ' Right Bottom ' Now check which side of that small section was clicked If x2 > y2 Then Map.Tile(x1, y1).WalkRight = False Else Map.Tile(x1, y1).WalkDown = False End If ElseIf y2 > .Left Then ' Right Middle Map.Tile(x1, y1).WalkRight = False Else ' Right Top ' Check which side was clicked, remember, minus from x because ' its not starting from 0 If x2 - .Right > y2 Then Map.Tile(x1, y1).WalkUp = False Else Map.Tile(x1, y1).WalkRight = False End If End If ElseIf x2 > .Left Then ' Middle side If y2 > .Bottom Then 'Bottom Map.Tile(x1, y1).WalkDown = False ElseIf y2 > .Left Then ' Middle Map.Tile(x1, y1).WalkUp = False Map.Tile(x1, y1).WalkDown = False Map.Tile(x1, y1).WalkLeft = False Map.Tile(x1, y1).WalkRight = False Else ' Top Map.Tile(x1, y1).WalkUp = False End If Else If y2 > .Bottom Then 'Left Bottom If x2 > y2 - .Bottom Then Map.Tile(x1, y1).WalkDown = False Else Map.Tile(x1, y1).WalkLeft = False End If ElseIf y2 > .Left Then ' Left Middle Map.Tile(x1, y1).WalkLeft = False Else ' Left Top If x2 > y2 Then Map.Tile(x1, y1).WalkUp = False Else Map.Tile(x1, y1).WalkLeft = False End If End If End If End If End With Else All this section does is scan for which of the nine parts of the tile we clicked, and changes the settings respectively. If it’s a corner, it will compare x and y to tell which side of the square its on, for, if X = Y, it will create a line from one corner to the other, if X > Y, it will make a point on one side of the line, if Y > X, it will create a point on the other side of the line. Ok, right now, we have to actually restrict player movement if the tile their standing on needs to so, in the client, find sub CanMove, find: Code: ' Check to see if a npc is already on that tile For i = 1 To MAX_MAP_NPCS If MapNpc(i).Num > 0 Then If (MapNpc(i).x = GetPlayerX(MyIndex)) And (MapNpc(i).y = GetPlayerY(MyIndex) - 1) Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_UP Then Call SendPlayerDir End If Exit Function End If End If Next i And after it, add: Code: ' Check if the tile will let us walk onto it If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).WalkUp = False Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_UP Then Call SendPlayerDir End If Exit Function End If Now, find this, which is a bit below it (This ones the walking down version) Code: ' Check to see if a npc is already on that tile For i = 1 To MAX_MAP_NPCS If MapNpc(i).Num > 0 Then If (MapNpc(i).x = GetPlayerX(MyIndex)) And (MapNpc(i).y = GetPlayerY(MyIndex) + 1) Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_DOWN Then Call SendPlayerDir End If Exit Function End If End If Next i and add below it Code: ' Check if the tile will let us walk onto it If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).WalkDown = False Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_DOWN Then Call SendPlayerDir End If Exit Function End If And now for the left movement, find Code: ' Check to see if a npc is already on that tile For i = 1 To MAX_MAP_NPCS If MapNpc(i).Num > 0 Then If (MapNpc(i).x = GetPlayerX(MyIndex) - 1) And (MapNpc(i).y = GetPlayerY(MyIndex)) Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_LEFT Then Call SendPlayerDir End If Exit Function End If End If Next I And add: Code: ' Check if the tile will let us walk onto it If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).WalkLeft = False Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_LEFT Then Call SendPlayerDir End If Exit Function End If Now the right side, find Code: ' Check to see if a npc is already on that tile For i = 1 To MAX_MAP_NPCS If MapNpc(i).Num > 0 Then If (MapNpc(i).x = GetPlayerX(MyIndex) + 1) And (MapNpc(i).y = GetPlayerY(MyIndex)) Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_RIGHT Then Call SendPlayerDir End If Exit Function End If End If Next I Then add: Code: ' Check if the tile will let us walk onto it If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).WalkRight = False Then CanMove = False ' Set the new direction if they weren't facing that direction If d <> DIR_RIGHT Then Call SendPlayerDir End If Exit Function End If Now, this alone would work, but if a player is using a hacked client, or has hacked the map somehow, this could be bypassed easily, so we need to change the Player movement in the server, so find in the server, sub PlayerMove, and we basically have to do something similar here so locate: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type <> TILE_TYPE_BLOCKED Then And Change it to: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) - 1).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).WalkUp Then Now do the same with: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type <> TILE_TYPE_BLOCKED Then And change to: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index) + 1).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).WalkDown Then Now do the same with: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index)-1, GetPlayerY(Index) ).Type <> TILE_TYPE_BLOCKED Then And change to: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index)-1, GetPlayerY(Index) + 1).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).WalkLeft Then Now do the same with: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index)+1, GetPlayerY(Index) + 1).Type <> TILE_TYPE_BLOCKED Then And change to: Code: If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index)+1, GetPlayerY(Index) + 1).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).WalkRight Then That should be everything, find any problems with this let me know. Btw, I wont be surprised if you dont understand it, I found it a kinda hard to explain some of the things, if anyone wanna convert this into laymans terms, be my guest |
Author: | ZS5 [ Sat Aug 05, 2006 11:06 pm ] |
Post subject: | |
Has anyone else tried it, yet? I triple checked and yes, I did this tutorial to the T, so to speak. That being said, it messes up for me when I walk through a one-way block onto a warp tile. It just sits there... Doing nothing. I have literaly spent says trying to figure out what is wrong, but to no avail. Works fine when the warps are nowhere near the directional blocks, but messes everything up when doing the afore mentioned. |
Author: | Misunderstood [ Sun Aug 06, 2006 12:32 am ] |
Post subject: | |
I haven't added it, but I might be able to help. I would think the problem would either be in canmove clientside or playermove serverside clientside I would compare the end(after the differnet checks for each direction) to a normal ms version to see if anything there might need to be changed. and also compare the serverside playermove with an unedited one, since its likely those 2 are the problems. Maybe gettingmap is set to true(which doesnt let you move till its set back to false) but the request to move to the tile isnt getting sent. I just looked over it so I could be wrong, but those would be my suggestions. Hopefully Mr. Funk knows more. |
Author: | funkynut [ Sun Aug 06, 2006 11:15 am ] |
Post subject: | |
Yea, Someone mentioned something like that on the old forums, but I couldnt find out what was wrong since mine was fine Perhaps I left a line out somewhere or maybe you placed a line of code the wrong place? I'll just try checking my source (If I still have it) to see if I can find whats wrong, but as mis says, its probably client since you see it doing nothing) *Edit* I have my source but I dont have visual basic anymroe (Reformatted the other day) and the code above doesnt really help much... |
Author: | Classified [ Sun Aug 06, 2006 5:07 pm ] |
Post subject: | |
There are several bugs in this which I posted about on the old forums.. Easily fixed though.. I just can't remember what they were.. |
Author: | Misunderstood [ Mon Aug 07, 2006 2:20 am ] |
Post subject: | |
Notepad |
Author: | ZS5 [ Tue Aug 08, 2006 4:17 pm ] |
Post subject: | |
I am thinking that it is caused by GetMapRevision (that is the sub, if I remember correctly), but that does not make sense, because it works perfectly fine when not being interfered with by this hack. See, I am not using the normal map###.dat files for my maps, but they work perfectly when warping in a place that has no directional blocking. (I take it I get no help if I did a mod?) Varrigan (sorry if I spelled it wrong!) helped me with that one, but he was way too busy to help debug it, since I could not figure out what was wrong with it. But even with a normal vanilla MS, there is one bug aside from the NPCs not being stopped by the blocking; I cannot attack them for the life of me. Rarely, I will be allowed to get a few hits off of them, but aside from that and them blocking me, it is like the NPCs are not there. Oh, right, and with the If GettingMap = True statements did not seem to be working, if I remember correctly... Hmm... I will try the debugging again and post the results, since I keep forgetting what was wrong. |
Author: | funkynut [ Tue Aug 08, 2006 8:21 pm ] |
Post subject: | |
*sigh* I got visual basic back, but now I dont have my source, so If you want, get in touch with me on msn and i'll help you debug it As for it not blocking npcs movement, thats not a bug, I didnt add that with this tut |
Author: | ZS5 [ Wed Aug 09, 2006 11:44 am ] |
Post subject: | |
Well, I know; I was just counting it as one since it did not seem very natural and I was also waiting to debug the other parts before adding that feature. But the non-NPC-blocking seems like a nice way to make a "Ghost NPC" tutorial. I will try to contact you sometime next week, because I will be busy this weekend; I have to release a Flash episode in less than... Ooo... Almost over-due... Ooops... Thanks! (PS: I noticed how you sometimes capitalize If. VB programmer's syndrom? ) |
Author: | funkynut [ Wed Aug 09, 2006 3:05 pm ] |
Post subject: | |
Yea, Just a habit I've carried over from it I also occasionally Capitalize important words in some sentences lol |
Author: | Krloz [ Wed Aug 09, 2006 9:24 pm ] |
Post subject: | |
Haha ya I do that too Always xD |
Author: | Misunderstood [ Fri Sep 01, 2006 4:03 am ] |
Post subject: | |
Or maybe...you messed up your game adding it wrong? Of course you made a backup before adding this so it shouldn't matter. right? |
Author: | Not2BeTrusted2 [ Fri Sep 01, 2006 4:30 am ] |
Post subject: | |
loll nvm i restore my files to normal |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |