RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 Ok last time I tried making a tutorial for doors I did it 1/2 arsed and there where complaints coming out the wazu. I eventually went over the entire case Dir line by line and rewote the entire thing using the original as a reference.What it dose it give your game an advanced doors system an option on how to unlock them.I also found a few other bugs that i ironed out in EXTENSIVE testing and debugging.Again this has to be cut in parts because of the posting limit on content.~~**PLEASE DO NOT POST A REPLY UNTIL ALL PARTS ARE POSTED.**~~Now its all been posted, enjoy.****WARNING DO NOT PLACE "EMPTY" DOORS ON MAP******This is NOT recommended if you are just starting with EO, or if you haven't done a few easier tutorials first.**BOTH SERVER AND CLIENT**Most of the constants for the doors and tile type are already there!In mod constantsunder ' General constants add```Public Const MAX_DOORS As Byte = 255```under ' Game editor constants add```Public Const EDITOR_DOORS As Byte = 7 'or the next number you dont have```In modTypesat the top add```Public Doors(1 To MAX_DOORS) As DoorRec```Find "Private Type PlayerRec" and add above it```Public Type DoorRec  Name As String * NAME_LENGTH  DoorType As Long  WarpMap As Long  WarpX As Long  WarpY As Long  UnlockType As Long  key As Long  Switch As Long  state As LongEnd Type```In Private Type PlayerRec at the bottom add```PlayerDoors(1 To MAX_DOORS) As DoorRec```In modEnumerationsadd to the bottom of the "c" list```  CSaveDoor  CRequestDoors  CRequestEditDoors```add to the "s" list```  SDoorsEditor  SUpdateDoors```**SERVER**in modHandleDataAt the top in InitMessages() add```  HandleDataSub(CSaveDoor) = GetAddress(AddressOf HandleSaveDoor)  HandleDataSub(CRequestDoors) = GetAddress(AddressOf HandleRequestDoors)  HandleDataSub(CRequestEditDoors) = GetAddress(AddressOf HandleEditDoors)```find "Sub HandleAttack" and add to the bottom```CheckDoor index, x, y```at the bottom of modHandleData add```' //////////////////////////////////' //Request/Save edit Door packets//'//////////////////////////////////Sub HandleEditDoors(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)  Dim Buffer As clsBuffer  ' Prevent hacking  If GetPlayerAccess(index) < ADMIN_DEVELOPER Then    Exit Sub  End If  Set Buffer = New clsBuffer  Buffer.WriteLong SDoorsEditor  SendDataTo index, Buffer.ToArray()  Set Buffer = NothingEnd SubSub HandleRequestDoors(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)  SendDoors indexEnd SubPrivate Sub HandleSaveDoor(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)  Dim DoorNum As Long  Dim Buffer As clsBuffer  Dim DoorSize As Long  Dim DoorData() As Byte  ' Prevent hacking  If GetPlayerAccess(index) < ADMIN_DEVELOPER Then    Exit Sub  End If  Set Buffer = New clsBuffer  Buffer.WriteBytes Data()  DoorNum = Buffer.ReadLong  ' Prevent hacking  If DoorNum < 0 Or DoorNum > MAX_DOORS Then    Exit Sub  End If  DoorSize = LenB(Doors(DoorNum))  ReDim DoorData(DoorSize - 1)  DoorData = Buffer.ReadBytes(DoorSize)  CopyMemory ByVal VarPtr(Doors(DoorNum)), ByVal VarPtr(DoorData(0)), DoorSize  ' Save it  Call SendUpdateDoorToAll(DoorNum)  Call SaveDoor(DoorNum)  Call AddLog(GetPlayerName(index) & " saved Door #" & DoorNum & ".", ADMIN_LOG)End Sub```In modDatabase add at the bottom```' ***********' ** Doors **' ***********Sub SaveDoors()  Dim i As Long  For i = 1 To MAX_DOORS    Call SaveDoor(i)  NextEnd SubSub SaveDoor(ByVal DoorNum As Long)  Dim filename As String  Dim F As Long  filename = App.Path & "\data\doors\door" & DoorNum & ".dat"  F = FreeFile  Open filename For Binary As #F    Put #F, , Doors(DoorNum)  Close #FEnd SubSub LoadDoors()  Dim filename As String  Dim i As Long  Dim F As Long  Dim sLen As Long  Call CheckDoors  For i = 1 To MAX_DOORS    filename = App.Path & "\data\doors\door" & i & ".dat"    F = FreeFile    Open filename For Binary As #F      Get #F, , Doors(i)    Close #F  NextEnd SubSub CheckDoors()  Dim i As Long  For i = 1 To MAX_DOORS    If Not FileExist("\Data\doors\door" & i & ".dat") Then      Call SaveDoor(i)    End If  NextEnd SubSub ClearDoor(ByVal index As Long)  Call ZeroMemory(ByVal VarPtr(Doors(index)), LenB(Doors(index)))  Doors(index).Name = vbNullString  ReDim door(index)End SubSub ClearDoors()  Dim i As Long  For i = 1 To MAX_DOORS    Call ClearDoor(i)  NextEnd Sub```In modServerTCP add at the bottom```Sub SendDoors(ByVal index As Long)  Dim i As Long  For i = 1 To MAX_DOORS    If LenB(Trim$(Doors(i).Name)) > 0 Then      Call SendUpdateDoorsTo(index, i)    End If  NextEnd SubSub SendUpdateDoorToAll(ByVal DoorNum As Long)  Dim packet As String  Dim Buffer As clsBuffer  Dim DoorSize As Long  Dim DoorData() As Byte  SetStatus ("sending doors")  Set Buffer = New clsBuffer  DoorSize = LenB(Doors(DoorNum))  ReDim DoorData(DoorSize - 1)  CopyMemory DoorData(0), ByVal VarPtr(Doors(DoorNum)), DoorSize  Buffer.WriteLong SUpdateDoors  Buffer.WriteLong DoorNum  Buffer.WriteBytes DoorData  SendDataToAll Buffer.ToArray()  Set Buffer = NothingEnd SubSub SendUpdateDoorsTo(ByVal index As Long, ByVal DoorNum As Long)  Dim packet As String  Dim Buffer As clsBuffer  Dim DoorSize As Long  Dim DoorData() As Byte  SetStatus ("sending doors")  Set Buffer = New clsBuffer  DoorSize = LenB(Doors(DoorNum))  ReDim DoorData(DoorSize - 1)  CopyMemory DoorData(0), ByVal VarPtr(Doors(DoorNum)), DoorSize  Buffer.WriteLong SUpdateDoors  Buffer.WriteLong DoorNum  Buffer.WriteBytes DoorData  SendDataTo index, Buffer.ToArray()  Set Buffer = NothingEnd Sub```in modGeneralfind ' Check if the directory is there, if its not make it and add```ChkDir App.Path & "\Data\", "doors"```find "Public Sub ClearGameData()" and add```  Call SetStatus("Clearing Doors...")  Call ClearDoors```find "Private Sub LoadGameData()" and add```  Call SetStatus("Loading Doors...")  Call LoadDoors```In modPlayerFind Sub JoinGameadd under ' Send some more little goodies, no need to explain these```Call SendDoors(index)``` Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 Still in modPlayerfind "Sub PlayerMove"at the top add```Dim DoorNum As Long```Find "Select Case Dir" and replace the entire thing with (IT'S LARGE)```Select Case Dir    Case DIR_UP      ' Check to make sure not outside of boundries      If GetPlayerY(index) > 0 Then        ' Check to make sure that the tile is walkable        If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_UP + 1) Then          If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_RESOURCE Then                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_DOOR Then                  If Player(index).PlayerDoors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).state = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).DoorType = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).UnlockType = 0 Then                          PlayerMsg index, "You need the right kind of key to open this door. (" & Trim$(Item(Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).key).Name) & ")", BrightRed                        ElseIf Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).UnlockType = 1 Then                          PlayerMsg index, "You need to activate a switch to open this door. ", BrightRed                        Else                          mapNum = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).WarpMap                          x = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).WarpX                          y = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).WarpY                          Call PlayerWarp(index, mapNum, x, y)                          Moved = YES                        End If                        End If                      PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                      Exit Sub                  Else                      If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Data1).DoorType = 1 Then                        PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                        Exit Sub                      End If                  End If                End If                ' Check to see if the tile is a key and if it is check if its opened                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then                  Call SetPlayerY(index, GetPlayerY(index) - 1)                  SendPlayerMove index, movement, sendToSelf                  Moved = YES                End If            End If          End If        End If      Else        ' Check to see if we can move them to the another map        If Map(GetPlayerMap(index)).Up > 0 Then          NewMapY = Map(Map(GetPlayerMap(index)).Up).MaxY          Call PlayerWarp(index, Map(GetPlayerMap(index)).Up, GetPlayerX(index), NewMapY)          Moved = YES          ' clear their target          TempPlayer(index).target = 0          TempPlayer(index).targetType = TARGET_TYPE_NONE          SendTarget index        End If      End If    Case DIR_DOWN      ' Check to make sure not outside of boundries      If GetPlayerY(index) < Map(mapNum).MaxY Then        ' Check to make sure that the tile is walkable        If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_DOWN + 1) Then          If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_RESOURCE Then                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_DOOR Then                  If Player(index).PlayerDoors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).state = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).DoorType = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).UnlockType = 0 Then                          PlayerMsg index, "You need the right kind of key to open this door. (" & Trim$(Item(Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).key).Name) & ")", BrightRed                        ElseIf Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).UnlockType = 1 Then                          PlayerMsg index, "You need to activate a switch to open this door. ", BrightRed                        Else                          mapNum = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).WarpMap                          x = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).WarpX                          y = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).WarpY                          Call PlayerWarp(index, mapNum, x, y)                          Moved = YES                        End If                        End If                      PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                      Exit Sub                  Else                      If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Data1).DoorType = 1 Then                        PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                        Exit Sub                      End If                  End If                End If                ' Check to see if the tile is a key and if it is check if its opened                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) + 1) = YES) Then                  Call SetPlayerY(index, GetPlayerY(index) + 1)                  SendPlayerMove index, movement, sendToSelf                  Moved = YES                End If            End If          End If        End If      Else        ' Check to see if we can move them to the another map        If Map(GetPlayerMap(index)).Down > 0 Then          NewMapY = Map(Map(GetPlayerMap(index)).Down).MaxY          Call PlayerWarp(index, Map(GetPlayerMap(index)).Down, GetPlayerX(index), 0)          Moved = YES          ' clear their target          TempPlayer(index).target = 0          TempPlayer(index).targetType = TARGET_TYPE_NONE          SendTarget index        End If      End If    Case DIR_LEFT      ' Check to make sure not outside of boundries      If GetPlayerX(index) > 0 Then        ' Check to make sure that the tile is walkable        If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_LEFT + 1) Then          If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_RESOURCE Then                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_DOOR Then                  If Player(index).PlayerDoors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).state = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).DoorType = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).UnlockType = 0 Then                          PlayerMsg index, "You need the right kind of key to open this door. (" & Trim$(Item(Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).key).Name) & ")", BrightRed                        ElseIf Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).UnlockType = 1 Then                          PlayerMsg index, "You need to activate a switch to open this door. ", BrightRed                        Else                          mapNum = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).WarpMap                          x = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).WarpX                          y = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).WarpY                          Call PlayerWarp(index, mapNum, x, y)                          Moved = YES                        End If                        End If                      PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                      Exit Sub                  Else                      If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Data1).DoorType = 1 Then                        PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                        Exit Sub                      End If                  End If                End If                ' Check to see if the tile is a key and if it is check if its opened                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) - 1, GetPlayerY(index)) = YES) Then                  Call SetPlayerX(index, GetPlayerX(index) - 1)                  SendPlayerMove index, movement, sendToSelf                  Moved = YES                End If            End If          End If        End If      Else        ' Check to see if we can move them to the another map        If Map(GetPlayerMap(index)).Left > 0 Then          NewMapX = Map(Map(GetPlayerMap(index)).Left).MaxX          Call PlayerWarp(index, Map(GetPlayerMap(index)).Left, NewMapX, GetPlayerY(index))          Moved = YES          ' clear their target          TempPlayer(index).target = 0          TempPlayer(index).targetType = TARGET_TYPE_NONE          SendTarget index        End If      End If    Case DIR_RIGHT      ' Check to make sure not outside of boundries      If GetPlayerX(index) < Map(mapNum).MaxX Then        ' Check to make sure that the tile is walkable        If Not isDirBlocked(Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).DirBlock, DIR_RIGHT + 1) Then          If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then            If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_RESOURCE Then                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_DOOR Then                  If Player(index).PlayerDoors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).state = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).DoorType = 0 Then                        If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).UnlockType = 0 Then                          PlayerMsg index, "You need the right kind of key to open this door. (" & Trim$(Item(Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).key).Name) & ")", BrightRed                        ElseIf Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).UnlockType = 1 Then                          PlayerMsg index, "You need to activate a switch to open this door. ", BrightRed                        Else                          mapNum = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).WarpMap                          x = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).WarpX                          y = Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).WarpY                          Call PlayerWarp(index, mapNum, x, y)                          Moved = YES                        End If                        End If                      PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                      Exit Sub                  Else                      If Doors(Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Data1).DoorType = 1 Then                        PlayerWarp index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)                        Exit Sub                      End If                  End If                End If                ' Check to see if the tile is a key and if it is check if its opened                If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) + 1, GetPlayerY(index)) = YES) Then                  Call SetPlayerX(index, GetPlayerX(index) + 1)                  SendPlayerMove index, movement, sendToSelf                  Moved = YES                End If            End If          End If        End If      Else        ' Check to see if we can move them to the another map        If Map(GetPlayerMap(index)).Right > 0 Then          NewMapX = Map(Map(GetPlayerMap(index)).Right).MaxX          Call PlayerWarp(index, Map(GetPlayerMap(index)).Right, 0, GetPlayerY(index))          Moved = YES          ' clear their target          TempPlayer(index).target = 0          TempPlayer(index).targetType = TARGET_TYPE_NONE          SendTarget index        End If      End If  End Select```and also in Sub PlayerMove Find "If .Type = TILE_TYPE_DOOR Then" and replace It with``` ' Check to see if the tile is a door tile    If .Type = TILE_TYPE_DOOR Then      DoorNum = .Data1      If Player(index).PlayerDoors(DoorNum).state = 1 Then        mapNum = Doors(DoorNum).WarpMap        x = Doors(DoorNum).WarpX        y = Doors(DoorNum).WarpY        Call PlayerWarp(index, mapNum, x, y)        Moved = YES      End If    End If```At the bottom of modPlayer add```Sub CheckDoor(ByVal index As Long, ByVal x As Long, ByVal y As Long)  Dim Door_num As Long  Dim i As Long  Dim n As Long  Dim key As Long  Dim tmpIndex As Long  If Map(GetPlayerMap(index)).Tile(x, y).Type = TILE_TYPE_DOOR Then    Door_num = Map(GetPlayerMap(index)).Tile(x, y).Data1    If Door_num > 0 Then      If Doors(Door_num).DoorType = 0 Then        If Player(index).PlayerDoors(Door_num).state = 0 Then          If Doors(Door_num).UnlockType = 0 Then            For i = 1 To MAX_INV              key = GetPlayerInvItemNum(index, i)              If Doors(Door_num).key = key Then                TakeInvItem index, key, 1                If TempPlayer(index).inParty > 0 Then                  For n = 1 To MAX_PARTY_MEMBERS                    tmpIndex = Party(TempPlayer(index).inParty).Member(n)                    If tmpIndex > 0 Then                      Player(tmpIndex).PlayerDoors(Door_num).state = 1                      SendPlayerData (tmpIndex)                      If index <> tmpIndex Then                        PlayerMsg tmpIndex, "A member of your party unlocked a door.", BrightBlue                      Else                        PlayerMsg tmpIndex, "You used a key to unlock the door.", BrightBlue                      End If                    End If                  Next                Else                  Player(index).PlayerDoors(Door_num).state = 1                  PlayerMsg index, "You used a key to unlock the door.", BrightBlue                  SendPlayerData (index)                End If                Exit Sub              End If            Next            PlayerMsg index, "You do not have the right key to unlock the door.", BrightBlue          ElseIf Doors(Door_num).UnlockType = 1 Then            If Doors(Door_num).state = 0 Then              PlayerMsg index, "You have not fliped the right switch to unlock this door.", BrightBlue            End If          ElseIf Doors(Door_num).UnlockType = 2 Then            PlayerMsg index, "This door has no lock.", BrightBlue          End If        Else          PlayerMsg index, "This door is already unlocked.", BrightBlue        End If      ElseIf Doors(Door_num).DoorType = 1 Then        If Player(index).PlayerDoors(Door_num).state = 0 Then                If TempPlayer(index).inParty > 0 Then                  For n = 1 To MAX_PARTY_MEMBERS                    tmpIndex = Party(TempPlayer(index).inParty).Member(n)                    If tmpIndex > 0 Then                      Player(tmpIndex).PlayerDoors(Door_num).state = 1                      Player(tmpIndex).PlayerDoors(Doors(Door_num).Switch).state = 1                      SendPlayerData (tmpIndex)                      If index <> tmpIndex Then                        PlayerMsg tmpIndex, "A member of your party filped a switch on and unlocked a door.", BrightBlue                      Else                        PlayerMsg tmpIndex, "You filp the switch on and unlocked a door.", BrightBlue                      End If                    End If                  Next                Else                  Player(index).PlayerDoors(Door_num).state = 1                  Player(index).PlayerDoors(Doors(Door_num).Switch).state = 1                  PlayerMsg index, "You filp the switch on and unlocked a door.", BrightBlue                  SendPlayerData (index)                End If        Else                If TempPlayer(index).inParty > 0 Then                  For n = 1 To MAX_PARTY_MEMBERS                    tmpIndex = Party(TempPlayer(index).inParty).Member(n)                    If tmpIndex > 0 Then                      Player(tmpIndex).PlayerDoors(Door_num).state = 0                      Player(tmpIndex).PlayerDoors(Doors(Door_num).Switch).state = 0                      SendPlayerData (tmpIndex)                      If index <> tmpIndex Then                        PlayerMsg tmpIndex, "A member of your party filped a switch off and locked a door.", BrightBlue                      Else                        PlayerMsg tmpIndex, "You filp the switch off and locked a door.", BrightBlue                      End If                    End If                  Next                Else                  Player(index).PlayerDoors(Door_num).state = 0                  Player(index).PlayerDoors(Doors(Door_num).Switch).state = 0                  PlayerMsg index, "You filp the switch off and locked a door.", BrightBlue                  SendPlayerData (index)                End If        End If      End If    End If  End IfEnd Sub``` Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 **CLIENT**Add the attached door and switch editor to your client project.http://heroofathea.com/Downloads/frmEditor_Doors.frmIn modClientTCP at the bottom add```Public Sub SendSavedoor(ByVal DoorNum As Long)Dim Buffer As clsBufferDim DoorSize As LongDim DoorData() As Byte ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer DoorSize = LenB(Doors(DoorNum)) ReDim DoorData(DoorSize - 1) CopyMemory DoorData(0), ByVal VarPtr(Doors(DoorNum)), DoorSize Buffer.WriteLong CSaveDoor Buffer.WriteLong DoorNum Buffer.WriteBytes DoorData SendData Buffer.ToArray() Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "SendSavedoor", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd SubSub SendRequestDoors()Dim Buffer As clsBuffer ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer Buffer.WriteLong CRequestDoors SendData Buffer.ToArray() Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "SendRequestDoors", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd SubPublic Sub SendRequestEditdoors()Dim Buffer As clsBuffer ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer Buffer.WriteLong CRequestEditDoors SendData Buffer.ToArray() Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "SendRequestEditdoors", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```In modDatabase at the bottom add```Sub ClearDoor(ByVal Index As Long) ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Call ZeroMemory(ByVal VarPtr(Doors(Index)), LenB(Doors(Index))) Doors(Index).Name = vbNullString ' Error handler Exit Suberrorhandler: HandleError "ClearDoor", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd SubSub ClearDoors()Dim i As Long ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler For i = 1 To MAX_DOORS Call ClearDoor(i) Next ' Error handler Exit Suberrorhandler: HandleError "ClearDoors", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```In modGameEditorsfind "Public Sub MapEditorMouseDown"In "Public Sub MapEditorMouseDown" find "If frmEditor_Map.optDoor.Value Then" and replace with``` ' door If frmEditor_Map.optDoor.Value Then .Type = TILE_TYPE_DOOR .Data1 = DoorEditorNum .Data2 = 0 .Data3 = 0 End If```at the bottom of modGameEditors add```'/////////'//DOORS//'/////////Public Sub DoorEditorInit() If frmEditor_Doors.Visible = False Then Exit Sub EditorIndex = frmEditor_Doors.lstIndex.ListIndex + 1 With frmEditor_Doors .txtName.text = Doors(EditorIndex).Name If Doors(EditorIndex).DoorType = 0 Then .optDoor(0).Value = True Else .optDoor(1).Value = True End If .scrlKey.Value = Doors(EditorIndex).key .scrlSwitch.Value = Doors(EditorIndex).Switch .scrlMap.Value = Doors(EditorIndex).WarpMap .scrlX.Value = Doors(EditorIndex).WarpX .scrlY.Value = Doors(EditorIndex).WarpY If Doors(EditorIndex).UnlockType = 0 Then .OptUnlock(0).Value = True ElseIf Doors(EditorIndex).UnlockType = 1 Then .OptUnlock(1).Value = True Else .OptUnlock(2).Value = True End If End With Door_Changed(EditorIndex) = TrueEnd SubPublic Sub DoorEditorOk() Dim i As Long For i = 1 To MAX_DOORS If Door_Changed(i) Then Call SendSavedoor(i) End If Next Unload frmEditor_Doors Editor = 0 ClearChanged_DoorsEnd SubPublic Sub DoorEditorCancel() Editor = 0 Unload frmEditor_Doors ClearChanged_Doors ClearDoors SendRequestDoorsEnd SubPublic Sub ClearChanged_Doors() ZeroMemory Door_Changed(1), MAX_DOORS * 2 ' 2 = boolean lengthEnd Sub```In modGlobalsAdd anywhere to modGlobals```'map doorsPublic DoorEditorNum As Long```find ' Editor edited items array and add```Public Door_Changed(1 To MAX_DOORS) As Boolean```In modHandleData add to the Top in InitMessages()``` HandleDataSub(SDoorsEditor) = GetAddress(AddressOf HandleDoorsEditor) HandleDataSub(SUpdateDoors) = GetAddress(AddressOf HandleUpdateDoors)```In modHandleData add to the Bottom```Private Sub HandleDoorsEditor() Dim i As Long With frmEditor_Doors Editor = EDITOR_DOORS .lstIndex.Clear ' Add the names For i = 1 To MAX_DOORS .lstIndex.AddItem i & ": " & Trim$(Doors(i).Name) Next .Show .lstIndex.ListIndex = 0 DoorEditorInit End WithEnd SubPrivate Sub HandleUpdateDoors(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim DoorNum As LongDim Buffer As clsBufferDim DoorSize As LongDim DoorData() As Byte ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer Buffer.WriteBytes Data() DoorNum = Buffer.ReadLong DoorSize = LenB(Doors(DoorNum)) ReDim DoorData(DoorSize - 1) DoorData = Buffer.ReadBytes(DoorSize) ClearDoor DoorNum CopyMemory ByVal VarPtr(Doors(DoorNum)), ByVal VarPtr(DoorData(0)), DoorSize Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "HandleUpdateDoors", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```**FORM WORK/CODING**frmEditor_MapEnable the Door attrb.Now double click on the door attrb and replace the code with```Private Sub optDoor_Click() ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler ClearAttributeDialogue picAttributes.Visible = True fradoor.Visible = True ' Error handler Exit Suberrorhandler: HandleError "optDoor_Click", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```Now make a new Frame like shown![](http://www.mediafire.com/imgbnc.php/548f2518f1272635d96bc42c8a69b94b1b6855bf7baa4351110bfd42161c06ae6g.jpg)Name each of the parts as followsFrame = fradoorLabel = lblDoorHscroll = scrlDoorCommand Button = cmdDoorSet the frame visible to off in the propertiesDoubble click on the scrldoor and add```If scrlDoor.Value > 0 ThenlblDoor.Caption = "Door/Switch: " & Doors(scrlDoor.Value).NameElselblDoor.Caption = "Door/Switch: None"End If```double click on the cmbDoor and add```DoorEditorNum = scrlDoor.ValuepicAttributes.Visible = Falsefradoor.Visible = False```on frmMain stretch the right side a bit and you will find the admin pannel make a new Buttondouble click it and add```' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler If GetPlayerAccess(MyIndex) < ADMIN_DEVELOPER Then Exit Sub End If SendRequestEditdoors ' Error handler Exit Suberrorhandler: HandleError "cmdAItem_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit Sub```And dont forget to move the edge of your screen Back to normal.**CREDIT PLEASE** Link to comment Share on other sites More sharing options...
Robin Posted September 22, 2011 Share Posted September 22, 2011 Did you really need to put that in multiple posts? Link to comment Share on other sites More sharing options...
Justn Posted September 22, 2011 Share Posted September 22, 2011 Thanks alot Ryoku! I thought you had given up on this.. Trying it out now =) Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 @Robin:> Did you really need to put that in multiple posts?yes, there is a limit on how much you can post in one post…. not all of it will fit. (I'm not sure why, but it's not my fault)Mostly because of the Case Select for direction.... Link to comment Share on other sites More sharing options...
Robin Posted September 22, 2011 Share Posted September 22, 2011 Wow, that code is _ugly._ Stop using a select case and switch it out for a dynamic function which you can pass four times. Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 >.< but it was YOUR select case that i modded… Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2011 Share Posted September 22, 2011 so is the new part basicaly the direction blocking part? or what all is redone? Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 22, 2011 Author Share Posted September 22, 2011 The entire middle post pretty much., but it would have been a B**** to edit the extra content into the existing posts so i re-posted it =P Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2011 Share Posted September 22, 2011 ok so i just updated with the center section and all is well. thanks for the update. Link to comment Share on other sites More sharing options...
Robin Posted September 22, 2011 Share Posted September 22, 2011 @Ryoku:> >.< but it was YOUR select case that i modded…Default Mirage, my friend. Just because I haven't gotten around to optimising something doesn't mean it can't be optimised. Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 23, 2011 Author Share Posted September 23, 2011 Well, it's been a couple days… and I haven't heard a report from my number one fan one if the code works right or not... He said he was gona test it out.Justn, did you die from the epicness of the feature, of die from its horrible crashing? (not that i'm saying this thing crashes, because it dosnt.... for me at least)DAMN IT XD some feed back would be nice.. >.< sotvotkong, your tried it too, didn't you? any luck? Link to comment Share on other sites More sharing options...
Rotflturion Posted September 23, 2011 Share Posted September 23, 2011 It crashes like a motherfucking duck on crack. Link to comment Share on other sites More sharing options...
Justn Posted September 23, 2011 Share Posted September 23, 2011 Just didnt want to speak too soon but I been playing around with it for an hour or so made like 20 doors and guess what…. They all work!! Entering a door from any direction works switches and keys work (keys were messing up on me in your old one) this is great! Only thing i havent tested out is opening a door while in a party but im sure it works. Thanks alot man glad you took time to rewrite this, it was a must have for my project im working on!! Will let you know if i run into any problems but I doubt I will:star: :star: :star: :star: :star: Link to comment Share on other sites More sharing options...
Excalibur Posted September 27, 2011 Share Posted September 27, 2011 what different from the old system ?did it fix some bugs ? Link to comment Share on other sites More sharing options...
Guest Posted September 27, 2011 Share Posted September 27, 2011 well i didnt really have errors to begin with, but the new code seems to work fine for me, i just redid the center section of this tut on top of the old one. so for what its worth it works great. as for errors i personally didnt find any. but that doesnt mean those that had errors before could grasp this one. Link to comment Share on other sites More sharing options...
RyokuHasu Posted September 28, 2011 Author Share Posted September 28, 2011 @Excalibur:> what different from the old system ?> did it fix some bugs ?Yes I did a complete rewrite of the Middle section.@sotvotkong: thanks for using this ^_^ Link to comment Share on other sites More sharing options...
RyokuHasu Posted October 19, 2011 Author Share Posted October 19, 2011 bump for advertising Link to comment Share on other sites More sharing options...
kibbelz Posted October 28, 2011 Share Posted October 28, 2011 This is awful. I would never even think about making an editor for this. It would have been better if you had just fixed the doors and keys without adding a stupid and unnecessary editor. Link to comment Share on other sites More sharing options...
Justn Posted October 28, 2011 Share Posted October 28, 2011 Whats wrong with having the editor? I like this add on it works good for my project…. Link to comment Share on other sites More sharing options...
RyokuHasu Posted October 28, 2011 Author Share Posted October 28, 2011 I didn't want to try and sort out a 1/2 finished system made by Robin, I had no Idea the direction it was going. As far as I can tell he left no room for the state of the door, just where it warped to.And I made an editor for this version because I gave it a slightly more advanced options for what you can do with the doors rather than just use a key on them.If you don't like it fix Robin's doors yourself. Link to comment Share on other sites More sharing options...
kibbelz Posted October 29, 2011 Share Posted October 29, 2011 @Ryoku:> If you don't like it fix Robin's doors yourself.Done it. Link to comment Share on other sites More sharing options...
RyokuHasu Posted October 29, 2011 Author Share Posted October 29, 2011 Good, then GTFO. Link to comment Share on other sites More sharing options...
kibbelz Posted October 30, 2011 Share Posted October 30, 2011 @Ryoku:> Good, then GTFO.No. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now