RyokuHasu Posted July 20, 2011 Author Share Posted July 20, 2011 I couldn't fit the new stuff in only 2 posts, Please go find the re-posted update. Link to comment Share on other sites More sharing options...
Domino_ Posted July 20, 2011 Share Posted July 20, 2011 Add that if your are in party than if you open doors all party members can go though them. :) This would be good for gaming. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 20, 2011 Author Share Posted July 20, 2011 **Part 2****CLIENT**Add the attached door and switch editor to your client project.[http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=73764.0;attach=18927](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=73764.0;attach=18927)In 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.![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=73764.0;attach=19171)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 Button![](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=73764.0;attach=18970)double 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...
Domino_ Posted July 20, 2011 Share Posted July 20, 2011 btw thanks for sharing. xD Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 20, 2011 Author Share Posted July 20, 2011 I found a problem with movement and Im now rewiting the player move sub so you can't walk on a locked door tile.The mod will be done shortly Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 Ok the movement calc was very dificult for such a complex tile, but it's done.Tutorial updated. See section on modPlayer to fix player movement.Next update: Doors for parties… (when i feel like it)OH MY GAWD >.< my tut was sooo long after the update that it overflowed the post limit on characters and cut off my last chunck of code....Its fixed now. Please, no one blame me if I make another topic for more updates. Link to comment Share on other sites More sharing options...
GrimReaperReborn Posted July 21, 2011 Share Posted July 21, 2011 To do the party thing, just find instances of```Player(index).PlayerDoors(Door_num).state = ```and make it check if the player is in a party, if so do the same for the rest of the group. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 @Mïlk:> To do the party thing, just find instances of> > ```> Player(index).PlayerDoors(Door_num).state = > ```> and make it check if the player is in a party, if so do the same for the rest of the group.Not Quite. Ill be making the party doors so that the rest of the party only gets the unlocked effect when the door gets unlocked.The way you say it will cause wide spread "door-Sharing" witch if one member of the party leaves and joins another party then he transfers the unlocked door to every one in the new party. Link to comment Share on other sites More sharing options...
GrimReaperReborn Posted July 21, 2011 Share Posted July 21, 2011 Although not completely sure, if he transfers parties, then only the door will be open for him because he did open it with the previous group. His new group will just have to unlock the new door as well. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 Exactly! thats how I want it. That player already did the work, BUT none of the other players did, why should they leach his door state … and guess what its done! =D(Its to way too much to add to the original post since I already hit the max character count x.x)To add Party doors just replace Sub CheckDoor with```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) 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 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 key = Doors(Door_num).Switch If Doors(key).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) 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 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) 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 Next Else Player(index).PlayerDoors(Door_num).state = 1 Player(index).PlayerDoors(Doors(Door_num).Switch).state = 1 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...
Justn Posted July 21, 2011 Share Posted July 21, 2011 Has anyone added this to their project yet? I'm getting a compile error on both server side and client side and was wondering if it was just me…SERVERgetting variable not defined in modplayer>! ' Check to see if the tile is a door tile If .Type = TILE_TYPE_DOOR Then **DoorNum** = .Data1CLIENTgetting variable not defined on my cmdDoor>! Private Sub cmdDoor_Click() **DoorEditorNum** = scrlDoor.Value picAttributes.Visible = False fraDoor.Visible = FalseEnd Sub Link to comment Share on other sites More sharing options...
Dzastin Posted July 21, 2011 Share Posted July 21, 2011 Justn, give this code to this sub:Dim DoorNum as longDim DoorEditorNum as long Link to comment Share on other sites More sharing options...
Jaiden Posted July 21, 2011 Share Posted July 21, 2011 This looks good, I might look into it when all of the bugs are worked out. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 @Piernik:> Justn, give this code to this sub:> > Dim DoorNum as long> Dim DoorEditorNum as longNo. one of those was sposed to be a global.@Justn:> Has anyone added this to their project yet? I'm getting a compile error on both server side and client side and was wondering if it was just me…> > -code-you are right XD i added the wrong Thing to the GlobalsClientAdd anywhere to modGlobals```'map doorsPublic DoorEditorNum As Long```serverIn modPlayer at the top of sub PlayerMove add```Dim DoorNum As Long```* * *Thanks for the info. It was a lot of data to keep track of, I knew i forgot somthing. The tut is updated.Just feed me any more errors and ill patch them up =P Link to comment Share on other sites More sharing options...
Justn Posted July 21, 2011 Share Posted July 21, 2011 Thanks for the help guys everything works perfectly now.. This is the most effective mod ever!!!:star: :star: :star: :star: :star: Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 Ok I found a bud on Re-Locking the doors using switches I messed up personal Switches and doors witht the party doors.Its fixed now Just replace checkdoors in the server. Link to comment Share on other sites More sharing options...
Hornie Bear Posted July 21, 2011 Share Posted July 21, 2011 how do i get the door editor i added to pop up? Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 21, 2011 Author Share Posted July 21, 2011 Whoops XD ummmm… one sec... >.< I forgot that part.Just give me 3 min.* * *DONESorry, In the big Tuts is always the small things that get left out.on frmMain stretch the right side a bit and you will find the admin pannel make a new Button![](http://www.mediafire.com/imgbnc.php/a3e68d3b7411246fdbc64375f97bc53c427f9f71b1eaf11aa2d1e602838524ca6g.jpg)double 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. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 22, 2011 Author Share Posted July 22, 2011 HOLY CRAP >.< I forgot the Inti MessagesIn modHandleDataClient```HandleDataSub(SDoorsEditor) = GetAddress(AddressOf HandleDoorsEditor) HandleDataSub(SUpdateDoors) = GetAddress(AddressOf HandleUpdateDoors)```Server``` HandleDataSub(CSaveDoor) = GetAddress(AddressOf HandleSaveDoor) HandleDataSub(CRequestDoors) = GetAddress(AddressOf HandleRequestDoors) HandleDataSub(CRequestEditDoors) = GetAddress(AddressOf HandleEditDoors)```TUT UPDATED!!! x.x lol now i feel like a jack ass… Link to comment Share on other sites More sharing options...
tsuki Posted July 22, 2011 Share Posted July 22, 2011 great tutorial. All the bugs are fixed? Link to comment Share on other sites More sharing options...
Hornie Bear Posted July 22, 2011 Share Posted July 22, 2011 yes havent seen any bugs so far he fixed everything that was left out of the tutorial everything is working even party doors!This is the best and only door system!!! ;) Link to comment Share on other sites More sharing options...
azure Posted July 22, 2011 Share Posted July 22, 2011 It's the only one because this is one of those things best programmed in instances where it's needed and then reuesed later if need be. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 22, 2011 Author Share Posted July 22, 2011 @Azure:> It's the only one because this is one of those things best programmed in instances where it's needed and then reuesed later if need be.Thats not entirely true. =P doors like this are kinda hard to make from scratch. Doors in my opinion are really good for making dungeons and such, it adds that standard bit of Puzzling that RPGs kinda need.* * *@Jimmy:> great tutorial. All the bugs are fixed?Yep! Just grab the editor and add everything. Link to comment Share on other sites More sharing options...
azure Posted July 22, 2011 Share Posted July 22, 2011 So… we need 8657 rehashes of the same simple puzzles in every game made with origins. :D Way to win with generic systems. Link to comment Share on other sites More sharing options...
RyokuHasu Posted July 22, 2011 Author Share Posted July 22, 2011 Oh Im sorry, do you have a better door system?If you do, take pride in it then leave.If you don't, Take mine and say "thank you".its just a tut, a long and complex one, but still just a TuT, nothing to bash.Also im not saying WOOHOo generic! Of course people still have to make some custom features for them selves. 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