Just messing around again.
Code:
Type PositionRec
Map As Long
X As Byte
Y As Byte
End Type
Code:
Type PlayerRec
' General
Name As String * NAME_LENGTH
Sex As Byte
Class As Byte
Sprite As Integer
Level As Byte
Exp As Long
Access As Byte
PK As Byte
' Vitals
Vital(1 To Vitals.Vital_Count - 1) As Long
' Stats
Stat(1 To Stats.Stat_Count - 1) As Byte
POINTS As Byte
' Worn equipment
Equipment(1 To Equipment.Equipment_Count - 1) As Byte
' Inventory
Inv(1 To MAX_INV) As PlayerInvRec
Spell(1 To MAX_PLAYER_SPELLS) As Byte
' Position
Position As PositionRec
Bound As PositionRec
' Current Direction
Dir As Byte
End Type
Code:
Public Function Current_Position(ByVal Index As Long) As PositionRec
Current_Position = Player(Index).Char(Current_CharNum(Index)).Position
End Function
Sub Update_Position(ByVal Index As Long, ByRef NewPosition As PositionRec)
Player(Index).Char(Current_CharNum(Index)).Position = NewPosition
End Sub
Code:
Public Function Current_Bound(ByVal Index As Long) As PositionRec
Current_Bound = Player(Index).Char(Current_CharNum(Index)).Bound
End Function
Sub Update_Bound(ByVal Index As Long, ByRef NewBound As PositionRec)
Player(Index).Char(Current_CharNum(Index)).Bound = NewBound
End Sub
Code:
Sub PlayerWarpPosition(ByVal Index As Long, ByRef NewPosition As PositionRec)
Dim ShopNum As Long, OldMap As Long
' Check for subscript out of range
If IsPlaying(Index) = False Or NewPosition.Map <= 0 Or NewPosition.Map > MAX_MAPS Then
Exit Sub
End If
' Check if there was an npc on the map the player is leaving, and if so say goodbye
ShopNum = Map(Current_Map(Index)).Shop
If ShopNum > 0 Then
If LenB(Trim$(Shop(ShopNum).LeaveSay)) > 0 Then
Call PlayerMsg(Index, Trim$(Shop(ShopNum).Name) & " says, '" & Trim$(Shop(ShopNum).LeaveSay) & "'", SayColor)
End If
End If
' Save old map to send erase player data to
OldMap = Current_Map(Index)
Call SendLeaveMap(Index, OldMap)
Update_Position Index, NewPosition
' Check if there is an npc on the map and say hello if so
ShopNum = Map(Current_Map(Index)).Shop
If ShopNum > 0 Then
If LenB(Trim$(Shop(ShopNum).JoinSay)) > 0 Then
Call PlayerMsg(Index, Trim$(Shop(ShopNum).Name) & " says, '" & Trim$(Shop(ShopNum).JoinSay) & "'", SayColor)
End If
End If
' Now we check if there were any players left on the map the player just left, and if not stop processing npcs
If GetTotalMapPlayers(OldMap) = 0 Then
PlayersOnMap(OldMap) = NO
End If
' Sets it so we know to process npcs on the map
PlayersOnMap(NewPosition.Map) = YES
TempPlayer(Index).GettingMap = YES
Call SendDataTo(Index, SCheckForMap & SEP_CHAR & NewPosition.Map & SEP_CHAR & Map(NewPosition.Map).Revision & END_CHAR)
End Sub
Code:
Sub PlayerWarp(ByVal Index As Long, ByVal MapNum As Long, ByVal X As Long, ByVal Y As Long)
Dim ShopNum As Long, OldMap As Long
' Check for subscript out of range
If IsPlaying(Index) = False Or MapNum <= 0 Or MapNum > MAX_MAPS Then
Exit Sub
End If
' Check if there was an npc on the map the player is leaving, and if so say goodbye
ShopNum = Map(Current_Map(Index)).Shop
If ShopNum > 0 Then
If LenB(Trim$(Shop(ShopNum).LeaveSay)) > 0 Then
Call PlayerMsg(Index, Trim$(Shop(ShopNum).Name) & " says, '" & Trim$(Shop(ShopNum).LeaveSay) & "'", SayColor)
End If
End If
' Save old map to send erase player data to
OldMap = Current_Map(Index)
Call SendLeaveMap(Index, OldMap)
Update_Map Index, MapNum
Update_X Index, X
Update_Y Index, Y
' Check if there is an npc on the map and say hello if so
ShopNum = Map(Current_Map(Index)).Shop
If ShopNum > 0 Then
If LenB(Trim$(Shop(ShopNum).JoinSay)) > 0 Then
Call PlayerMsg(Index, Trim$(Shop(ShopNum).Name) & " says, '" & Trim$(Shop(ShopNum).JoinSay) & "'", SayColor)
End If
End If
' Now we check if there were any players left on the map the player just left, and if not stop processing npcs
If GetTotalMapPlayers(OldMap) = 0 Then
PlayersOnMap(OldMap) = NO
End If
' Sets it so we know to process npcs on the map
PlayersOnMap(MapNum) = YES
TempPlayer(Index).GettingMap = YES
Call SendDataTo(Index, SCheckForMap & SEP_CHAR & MapNum & SEP_CHAR & Map(MapNum).Revision & END_CHAR)
End Sub
Usage:
Current_Position(Index).Map
Current_Position(Index).X
Current_Position(Index).Y