Mirage Source http://miragesource.net/forums/ |
|
Pixel Based Movement (Part 1) http://miragesource.net/forums/viewtopic.php?f=210&t=351 |
Page 1 of 1 |
Author: | Liz [ Sat Aug 05, 2006 6:03 am ] |
Post subject: | Pixel Based Movement (Part 1) |
Now, first, before you attempt this, please remember, there's really no going back, so make a copy of your code, there's no telling how this will turn out. Infact untill it's perfected, I suggest you don't use it for your game or engine, just try it on a vanilla MSE, and help to perfect it. Anyways, this probably won't work if you try just copy + pasting it into a non-vanilla source. Although, it might. Also, currently I'm not sure if any attributes but blocking and warping work. I'm not even sure if the warping works. And blocking is sort of... half assed? You'll see what I mean... This first part, will only strip away tile based movement, and add in some very rudimentary block detection. It will also, take away animation, although there is a fairly easy way to put this back in, but I won't go in to that in the first part. Unforetunately there are still some bugs, so be forewarned! ::// CLIENT SIDE \\:: In ::ModGameLogic:: Replace: All of "Sub CheckMovement()" With: Code: Sub CheckMovement() If GettingMap = False Then If IsTryingToMove Then If CanMove Then ' Check if player has the shift key down for running If ShiftDown Then Player(MyIndex).Moving = MOVING_RUNNING Else Player(MyIndex).Moving = MOVING_WALKING End If Select Case GetPlayerDir(MyIndex) Case DIR_UP Call SendPlayerMove Call SetPlayerY(MyIndex, (GetPlayerY(MyIndex)) - 4) Case DIR_DOWN Call SendPlayerMove Call SetPlayerY(MyIndex, (GetPlayerY(MyIndex)) + 4) Case DIR_LEFT Call SendPlayerMove Call SetPlayerX(MyIndex, GetPlayerX(MyIndex) - 4) Case DIR_RIGHT Call SendPlayerMove Call SetPlayerX(MyIndex, (GetPlayerX(MyIndex)) + 4) End Select ' Gotta check :) If Map.Tile((GetPlayerX(MyIndex)) / 32, (GetPlayerY(MyIndex)) / 32).Type = TILE_TYPE_WARP Then GettingMap = True End If End If End If End If End Sub Replace: All of "Function CanMove() as boolean" With: Code: Function CanMove() As Boolean Dim i As Long, d As Long CanMove = True ' Make sure they aren't trying to move when they are already moving If Player(MyIndex).Moving <> 0 Then ' CanMove = False ' Exit Function End If ' Make sure they haven't just casted a spell If Player(MyIndex).CastedSpell = YES Then If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then Player(MyIndex).CastedSpell = NO Else CanMove = False Exit Function End If End If d = GetPlayerDir(MyIndex) If DirUp Then Call SetPlayerDir(MyIndex, DIR_UP) ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) / 32 > 0 Then ' Check to see if the map tile is blocked or not If Map.Tile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 - 1).Type = TILE_TYPE_BLOCKED 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 ' Check to see if the key door is open or not If Map.Tile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 - 1).Type = TILE_TYPE_KEY Then ' This actually checks if its open or not If TempTile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 - 1).DoorOpen = NO 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 ' Check to see if a player is already on that tile For i = 1 To MAX_PLAYERS If IsPlaying(i) Then If GetPlayerMap(i) = GetPlayerMap(MyIndex) Then If (GetPlayerX(i) / 32 = GetPlayerX(MyIndex) / 32) And (GetPlayerY(i) / 32 = GetPlayerY(MyIndex) / 32 - 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 End If Next i ' 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) / 32) And (MapNpc(i).y = GetPlayerY(MyIndex) / 32 - 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 Else ' Check if they can warp to a new map If Map.Up > 0 Then Call SendPlayerRequestNewMap GettingMap = True End If CanMove = False Exit Function End If End If If DirDown Then Call SetPlayerDir(MyIndex, DIR_DOWN) ' Check to see if they are trying to go out of bounds If GetPlayerY(MyIndex) / 32 < MAX_MAPY Then ' Check to see if the map tile is blocked or not If Map.Tile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 + 1).Type = TILE_TYPE_BLOCKED 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 ' Check to see if the key door is open or not If Map.Tile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 + 1).Type = TILE_TYPE_KEY Then ' This actually checks if its open or not If TempTile(GetPlayerX(MyIndex) / 32, GetPlayerY(MyIndex) / 32 + 1).DoorOpen = NO 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 ' Check to see if a player is already on that tile For i = 1 To MAX_PLAYERS If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then If (GetPlayerX(i) / 32 = GetPlayerX(MyIndex) / 32) And (GetPlayerY(i) / 32 = GetPlayerY(MyIndex) / 32 + 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 ' 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) / 32) And (MapNpc(i).y = GetPlayerY(MyIndex) / 32 + 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 Else ' Check if they can warp to a new map If Map.Down > 0 Then Call SendPlayerRequestNewMap GettingMap = True End If CanMove = False Exit Function End If End If If DirLeft Then Call SetPlayerDir(MyIndex, DIR_LEFT) ' Check to see if they are trying to go out of bounds If GetPlayerX(MyIndex) / 32 > 0 Then ' Check to see if the map tile is blocked or not If Map.Tile(GetPlayerX(MyIndex) / 32 - 1, GetPlayerY(MyIndex) / 32).Type = TILE_TYPE_BLOCKED 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 ' Check to see if the key door is open or not If Map.Tile(GetPlayerX(MyIndex) / 32 - 1, GetPlayerY(MyIndex) / 32).Type = TILE_TYPE_KEY Then ' This actually checks if its open or not If TempTile(GetPlayerX(MyIndex) / 32 - 1, GetPlayerY(MyIndex) / 32).DoorOpen = NO 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 ' Check to see if a player is already on that tile For i = 1 To MAX_PLAYERS If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then If (GetPlayerX(i) / 32 = GetPlayerX(MyIndex) / 32 - 1) And (GetPlayerY(i) / 32 = GetPlayerY(MyIndex) / 32) 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 ' 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) / 32 - 1) And (MapNpc(i).y = GetPlayerY(MyIndex) / 32) 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 Else ' Check if they can warp to a new map If Map.Left > 0 Then Call SendPlayerRequestNewMap GettingMap = True End If CanMove = False Exit Function End If End If If DirRight Then Call SetPlayerDir(MyIndex, DIR_RIGHT) ' Check to see if they are trying to go out of bounds If GetPlayerX(MyIndex) / 32 < MAX_MAPX Then ' Check to see if the map tile is blocked or not If Map.Tile(GetPlayerX(MyIndex) / 32 + 1, GetPlayerY(MyIndex) / 32).Type = TILE_TYPE_BLOCKED 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 ' Check to see if the key door is open or not If Map.Tile(GetPlayerX(MyIndex) / 32 + 1, GetPlayerY(MyIndex) / 32).Type = TILE_TYPE_KEY Then ' This actually checks if its open or not If TempTile(GetPlayerX(MyIndex) / 32 + 1, GetPlayerY(MyIndex) / 32).DoorOpen = NO 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 ' Check to see if a player is already on that tile For i = 1 To MAX_PLAYERS If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then If (GetPlayerX(i) / 32 = GetPlayerX(MyIndex) / 32 + 1) And (GetPlayerY(i) / 32 = GetPlayerY(MyIndex) / 32) 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 ' 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) / 32 + 1) And (MapNpc(i).y = GetPlayerY(MyIndex) / 32) 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 Else ' Check if they can warp to a new map If Map.Right > 0 Then Call SendPlayerRequestNewMap GettingMap = True End If CanMove = False Exit Function End If End If End Function Sub CheckMovement() If GettingMap = False Then If IsTryingToMove Then If CanMove Then ' Check if player has the shift key down for running If ShiftDown Then Player(MyIndex).Moving = MOVING_RUNNING Else Player(MyIndex).Moving = MOVING_WALKING End If 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 ' Gotta check :) If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Then GettingMap = True End If End If End If End If End Sub Comment out the entire guts of "Sub ProcessMovement()" In ::ModTypes:: Change the X and Y variable's in PlayerRec to integers. ::// SERVER SIDE \\:: In ::ModTypes:: Change the X and Y variable's in PlayerRec to integers. In ::ModGameLogic:: Replace: All of "Sub PlayerMove()" With: Code: Sub PlayerMove(ByVal Index As Long, ByVal Dir As Long, ByVal Movement As Long) Dim Packet As String Dim MapNum As Long Dim x As Long Dim y As Long Dim i As Long Dim Moved As Byte ' Check for subscript out of range If IsPlaying(Index) = False Or Dir < DIR_UP Or Dir > DIR_RIGHT Or Movement < 1 Or Movement > 2 Then Exit Sub End If Call SetPlayerDir(Index, Dir) Moved = NO Select Case Dir Case DIR_UP ' Check to make sure not outside of boundries If GetPlayerY(Index) / 32 > 0 Then ' Check to make sure that the tile is walkable If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 - 1).Type <> TILE_TYPE_BLOCKED Then ' Check to see if the tile is a key and if it is check if its opened If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 - 1) = YES) Then Call SetPlayerY(Index, GetPlayerY(Index) - 4) Packet = "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet) Moved = YES End If End If Else ' Check to see if we can move them to the another map If Map(GetPlayerMap(Index)).Up > 0 Then Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Up, GetPlayerX(Index), MAX_MAPY) Moved = YES End If End If Case DIR_DOWN ' Check to make sure not outside of boundries If GetPlayerY(Index) / 32 < MAX_MAPY Then ' Check to make sure that the tile is walkable If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 + 1).Type <> TILE_TYPE_BLOCKED Then ' Check to see if the tile is a key and if it is check if its opened If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 + 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) / 32, GetPlayerY(Index) / 32 + 1) = YES) Then Call SetPlayerY(Index, GetPlayerY(Index) + 4) Packet = "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet) Moved = YES End If End If Else ' Check to see if we can move them to the another map If Map(GetPlayerMap(Index)).Down > 0 Then Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Down, GetPlayerX(Index), 0) Moved = YES End If End If Case DIR_LEFT ' Check to make sure not outside of boundries If GetPlayerX(Index) / 32 > 0 Then ' Check to make sure that the tile is walkable If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 - 1, GetPlayerY(Index) / 32).Type <> TILE_TYPE_BLOCKED Then ' Check to see if the tile is a key and if it is check if its opened If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 - 1, GetPlayerY(Index) / 32).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 - 1, GetPlayerY(Index) / 32).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) / 32 - 1, GetPlayerY(Index) / 32) = YES) Then Call SetPlayerX(Index, GetPlayerX(Index) - 4) Packet = "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet) Moved = YES End If End If Else ' Check to see if we can move them to the another map If Map(GetPlayerMap(Index)).Left > 0 Then Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Left, MAX_MAPX, GetPlayerY(Index)) Moved = YES End If End If Case DIR_RIGHT ' Check to make sure not outside of boundries If GetPlayerX(Index) < MAX_MAPX Then ' Check to make sure that the tile is walkable If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 + 1, GetPlayerY(Index) / 32).Type <> TILE_TYPE_BLOCKED Then ' Check to see if the tile is a key and if it is check if its opened If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 + 1, GetPlayerY(Index) / 32).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index) / 32 + 1, GetPlayerY(Index) / 32).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(GetPlayerX(Index) / 32 + 1, GetPlayerY(Index) / 32) = YES) Then Call SetPlayerX(Index, GetPlayerX(Index) + 4) Packet = "PLAYERMOVE" & SEP_CHAR & Index & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR Call SendDataToMapBut(Index, GetPlayerMap(Index), Packet) Moved = YES End If End If Else ' Check to see if we can move them to the another map If Map(GetPlayerMap(Index)).Right > 0 Then Call PlayerWarp(Index, Map(GetPlayerMap(Index)).Right, 0, GetPlayerY(Index)) Moved = YES End If End If End Select ' Check to see if the tile is a warp tile, and if so warp them If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_WARP Then MapNum = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1 x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2 y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data3 Call PlayerWarp(Index, MapNum, x, y) Moved = YES End If ' Check for key trigger open If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_KEYOPEN Then x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1 y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2 If Map(GetPlayerMap(Index)).Tile(x, y).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(Index)).DoorOpen(x, y) = NO Then TempTile(GetPlayerMap(Index)).DoorOpen(x, y) = YES TempTile(GetPlayerMap(Index)).DoorTimer = GetTickCount Call SendDataToMap(GetPlayerMap(Index), "MAPKEY" & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & 1 & SEP_CHAR & END_CHAR) Call MapMsg(GetPlayerMap(Index), "A door has been unlocked.", White) End If End If ' They tried to hack If Moved = NO Then Call HackingAttempt(Index, "Position Modification") End If End Sub Function CanNpcMove(ByVal MapNum As Long, ByVal MapNpcNum As Long, ByVal Dir) As Boolean Dim i As Long, n As Long Dim x As Long, y As Long CanNpcMove = False ' Check for subscript out of range If MapNum <= 0 Or MapNum > MAX_MAPS Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or Dir < DIR_UP Or Dir > DIR_RIGHT Then Exit Function End If x = MapNpc(MapNum, MapNpcNum).x y = MapNpc(MapNum, MapNpcNum).y CanNpcMove = True Select Case Dir Case DIR_UP ' Check to make sure not outside of boundries If y > 0 Then n = Map(MapNum).Tile(x, y - 1).Type ' Check to make sure that the tile is walkable If n <> TILE_TYPE_WALKABLE And n <> TILE_TYPE_ITEM Then CanNpcMove = False Exit Function End If ' Check to make sure that there is not a player in the way For i = 1 To MAX_PLAYERS If IsPlaying(i) Then If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y - 1) Then CanNpcMove = False Exit Function End If End If Next i ' Check to make sure that there is not another npc in the way For i = 1 To MAX_MAP_NPCS If (i <> MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y - 1) Then CanNpcMove = False Exit Function End If Next i Else CanNpcMove = False End If Case DIR_DOWN ' Check to make sure not outside of boundries If y < MAX_MAPY Then n = Map(MapNum).Tile(x, y + 1).Type ' Check to make sure that the tile is walkable If n <> TILE_TYPE_WALKABLE And n <> TILE_TYPE_ITEM Then CanNpcMove = False Exit Function End If ' Check to make sure that there is not a player in the way For i = 1 To MAX_PLAYERS If IsPlaying(i) Then If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y + 1) Then CanNpcMove = False Exit Function End If End If Next i ' Check to make sure that there is not another npc in the way For i = 1 To MAX_MAP_NPCS If (i <> MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y + 1) Then CanNpcMove = False Exit Function End If Next i Else CanNpcMove = False End If Case DIR_LEFT ' Check to make sure not outside of boundries If x > 0 Then n = Map(MapNum).Tile(x - 1, y).Type ' Check to make sure that the tile is walkable If n <> TILE_TYPE_WALKABLE And n <> TILE_TYPE_ITEM Then CanNpcMove = False Exit Function End If ' Check to make sure that there is not a player in the way For i = 1 To MAX_PLAYERS If IsPlaying(i) Then If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x - 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y) Then CanNpcMove = False Exit Function End If End If Next i ' Check to make sure that there is not another npc in the way For i = 1 To MAX_MAP_NPCS If (i <> MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x - 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y) Then CanNpcMove = False Exit Function End If Next i Else CanNpcMove = False End If Case DIR_RIGHT ' Check to make sure not outside of boundries If x < MAX_MAPX Then n = Map(MapNum).Tile(x + 1, y).Type ' Check to make sure that the tile is walkable If n <> TILE_TYPE_WALKABLE And n <> TILE_TYPE_ITEM Then CanNpcMove = False Exit Function End If ' Check to make sure that there is not a player in the way For i = 1 To MAX_PLAYERS If IsPlaying(i) Then If (GetPlayerMap(i) = MapNum) And (GetPlayerX(i) = MapNpc(MapNum, MapNpcNum).x + 1) And (GetPlayerY(i) = MapNpc(MapNum, MapNpcNum).y) Then CanNpcMove = False Exit Function End If End If Next i ' Check to make sure that there is not another npc in the way For i = 1 To MAX_MAP_NPCS If (i <> MapNpcNum) And (MapNpc(MapNum, i).Num > 0) And (MapNpc(MapNum, i).x = MapNpc(MapNum, MapNpcNum).x + 1) And (MapNpc(MapNum, i).y = MapNpc(MapNum, MapNpcNum).y) Then CanNpcMove = False Exit Function End If Next i Else CanNpcMove = False End If End Select End Function If you do not wish to make these changes, you can download the source that I did these to as I made the tutorial right, here. If you download the source. You will need to find, client side... in modgamelogic Code: If Player(MyIndex).Moving <> 0 Then CanMove = False Exit Function End If and replace it with Code: If Player(MyIndex).Moving <> 0 Then
' CanMove = False ' Exit Function End If |
Author: | Liz [ Sat Aug 05, 2006 6:04 am ] |
Post subject: | |
Reserved for part 2 |
Author: | Liz [ Sat Aug 05, 2006 6:05 am ] |
Post subject: | |
Reserved for part 3 |
Author: | genusis [ Fri Jul 20, 2007 6:33 am ] |
Post subject: | Re: Pixel Based Movement (Part 1) |
im woundering but did you or anyone else finish this at all. becuase i would like to use this in my game if it works. and what is part 2 and 3 for anyways. |
Author: | Iluvlamp [ Fri Jul 20, 2007 6:46 am ] |
Post subject: | Re: Pixel Based Movement (Part 1) |
genusis wrote: im woundering but did you or anyone else finish this at all. becuase i would like to use this in my game if it works. and what is part 2 and 3 for anyways. Clearly part 2 and 3 is the rest of the tutorial which he either decided to not finish or just not post. I'm assuming no one finished this and John just disappeared. |
Author: | Liz [ Thu Aug 23, 2007 8:31 pm ] |
Post subject: | Re: Pixel Based Movement (Part 1) |
Hey, I'm still around I just never finished it, because there were some bugs I couldn't work out. However, I was just talking about this with someone, and I think I've figure out a way to make it work. (Maybe) |
Author: | genusis [ Sat Aug 25, 2007 8:00 am ] |
Post subject: | Re: Pixel Based Movement (Part 1) |
yai!!! this would be interesting |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |