JohnPony Posted September 9, 2012 Author Share Posted September 9, 2012 **Server Side:**in modDatabase replace loadmaps with```Public Sub LoadMaps()Dim filename As StringDim i As LongDim F As LongDim x As LongDim y As Long, z As Long, p As Long, w As LongDim newtileset As Long, newtiley As LongCall CheckMaps[size]For i = 1 To 99 filename = App.path & "\data\maps\map" & i & ".dat" F = FreeFile Open filename For Binary As #F Get #F, , Map(i).Name Get #F, , Map(i).Music Get #F, , Map(i).BGS Get #F, , Map(i).Revision Get #F, , Map(i).Moral Get #F, , Map(i).Up Get #F, , Map(i).Down Get #F, , Map(i).Left Get #F, , Map(i).Right Get #F, , Map(i).BootMap Get #F, , Map(i).BootX Get #F, , Map(i).BootY Get #F, , Map(i).Weather Get #F, , Map(i).WeatherIntensity Get #F, , Map(i).Fog Get #F, , Map(i).FogSpeed Get #F, , Map(i).FogOpacity Get #F, , Map(i).Red Get #F, , Map(i).Green Get #F, , Map(i).Blue Get #F, , Map(i).Alpha Get #F, , Map(i).MaxX Get #F, , Map(i).MaxY ' have to set the tile() ReDim Map(i).Tile(0 To Map(i).MaxX, 0 To Map(i).MaxY)[/size][size] For x = 0 To Map(i).MaxX For y = 0 To Map(i).MaxY Get #F, , Map(i).Tile(x, y) Next Next[/size][size] For x = 1 To MAX_MAP_NPCS Get #F, , Map(i).Npc(x) Get #F, , Map(i).NpcSpawnType(x) MapNpc(i).Npc(x).Num = Map(i).Npc(x) Next[/size][size] Close #F ClearTempTile i CacheResources i DoEvents CacheMapBlocks iNextEnd Sub[/size][size]And replace check maps with:[/size][size][code]Sub CheckMaps()Dim i As Long[size] For i = 1 To 99 If Not FileExist("\Data\maps\map" & i & ".dat") Then Call SaveMap(i) End IfNext[/size][size]End Sub[/size][size]And add this at the bottom of the module:[/size][size][code]Sub LoadMap(ByVal MapNum As Long, ByVal Max As Long)Dim filename As StringDim Filename2 As StringDim i As LongDim F As LongDim x As LongDim y As Long, z As Long, p As Long, w As LongDim newtileset As Long, newtiley As Long[size] i = MapNum filename = App.path & "\data\maps\map" & i & ".dat" F = FreeFile Open filename For Binary As #F Get #F, , Map(i).Name Get #F, , Map(i).Music Get #F, , Map(i).BGS Get #F, , Map(i).Revision Get #F, , Map(i).Moral Get #F, , Map(i).Up Get #F, , Map(i).Down Get #F, , Map(i).Left Get #F, , Map(i).Right Get #F, , Map(i).BootMap Get #F, , Map(i).BootX Get #F, , Map(i).BootY Get #F, , Map(i).Weather Get #F, , Map(i).WeatherIntensity Get #F, , Map(i).Fog Get #F, , Map(i).FogSpeed Get #F, , Map(i).FogOpacity Get #F, , Map(i).Red Get #F, , Map(i).Green Get #F, , Map(i).Blue Get #F, , Map(i).Alpha Get #F, , Map(i).MaxX Get #F, , Map(i).MaxY ' have to set the tile() ReDim Map(i).Tile(0 To Map(i).MaxX, 0 To Map(i).MaxY)[/size][size] For x = 0 To Map(i).MaxX For y = 0 To Map(i).MaxY Get #F, , Map(i).Tile(x, y) Next Next[/size][size] For x = 1 To MAX_MAP_NPCS Get #F, , Map(i).Npc(x) Get #F, , Map(i).NpcSpawnType(x) MapNpc(i).Npc(x).Num = Map(i).Npc(x) Next[/size][size] Close #F ClearTempTile i CacheResources i DoEvents CacheMapBlocks iEnd Sub[/size][size][/size][size]Next download the attachment below and add it to the server[/size][size]in modGeneral in InitServer add:[/size][size][code]Call SetStatus("Clearing Unused Maps...")Call ClearInstance[/code][/size][size]In modTypes in the playerrec at the bottom add:[/size][size][code]PrevMap As LongPrevX As LongPrevY As Long[/code][/size]Next in modServerTcp in SubSendLeaveMap at the bottom add:[code]If GetTotalMapPlayers(MapNum) = 0 Then If MapNum > 100 Then Call ClearInstancedMap(MapNum) End IfEnd If[/code]and at the bottom of the module add:[code]Sub SendInstance(ByVal Index As Long, ByVal OldMapNum As Long, ByVal NewMapNum As Long)Dim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteLong SInstancebuffer.WriteLong OldMapNumbuffer.WriteLong NewMapNumSendDataTo Index, buffer.ToArraySet buffer = NothingEnd Sub[/code]Next in modEnumerations with the server packets add:[code]SInstance[/code]and in modPlayer in the JoinGame sub add:[code]If Player(Index).PrevMap > 0 Then Call PlayerWarp(Index, Player(Index).PrevMap, Player(Index).PrevX, Player(Index).PrevY) Player(Index).PrevMap = 0 Player(Index).PrevX = 0 Player(Index).PrevY = 0 Call PlayerMsg(Index, "You Have Left The Instance!", Red)End If[/code]and at the bottom of modPlayer add:[code]Sub PartyWarp(ByVal Index As Long, ByVal MapNum As Long, ByVal x As Long, ByVal y As Long, Optional Instance As Boolean = False)Dim i As LongIf TempPlayer(Index).inParty Then For i = 1 To Party(TempPlayer(Index).inParty).MemberCount If Instance Then Player(Party(TempPlayer(Index).inParty).Member(i)).PrevMap = GetPlayerMap(Party(TempPlayer(Index).inParty).Member(i)) Player(Party(TempPlayer(Index).inParty).Member(i)).PrevX = GetPlayerX(Party(TempPlayer(Index).inParty).Member(i)) Player(Party(TempPlayer(Index).inParty).Member(i)).PrevY = GetPlayerY(Party(TempPlayer(Index).inParty).Member(i)) End If Call PlayerWarp(Party(TempPlayer(Index).inParty).Member(i), MapNum, x, y) NextEnd IfEnd Sub[/code]And at the bottom of Sub PlayerWarp add:[code]If GetTotalMapPlayers(OldMap) <= 0 Then If OldMap >= 100 Then Call ClearInstancedMap(OldMap) End IfEnd If[/code]And in the PlayerMove sub below the tile_type_slide procedure add:[code]If .Type = TILE_TYPE_INSTANCE Then ' Check if already on instanced map If GetPlayerMap(Index) >= 100 Then Moved = NO Else ' New Instance For i = 100 To MAX_MAPS If GetTotalMapPlayers(i) > 0 Then CanWarp = False Else CanWarp = True End If If CanWarp Then ' Save Previous Coords Player(Index).PrevMap = GetPlayerMap(Index) Player(Index).PrevX = GetPlayerX(Index) Player(Index).PrevY = GetPlayerY(Index) ' Instance New Map Call InstanceMap(.Data1, i, Index) ' Warp Player(s) If TempPlayer(Index).inParty Then Call PartyWarp(Index, i, .Data2, .Data3, True) Else Call PlayerWarp(Index, i, .Data2, .Data3) End If Exit For End If Next i End If Moved = YES End If[/code]And in modConstants with the Tile types add:[code]Public Const TILE_TYPE_INSTANCE As Byte = 16[/code][b][size]Client Side:[/size][/b]in modText in Public Function DrawMapAttributes() add:[code]Case TILE_TYPE_INSTANCE RenderText Font_Default, "MI", tx, ty, Red[/code]Next in modGameLogic in CheckMovement find:[code]If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP[/code]And replace it with[code]If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Or Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_INSTANCE[/code]Next in modConstants with the tile types add:[code]Public Const TILE_TYPE_INSTANCE As Byte = 16[/code]Now add the files from the attachment download to the client, you should know which ones ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)in modGameEditors in MapEditorMouseDown add:[code]' instance If frmEditor_Map.optInstance.value Then .Type = TILE_TYPE_INSTANCE .Data1 = EditorWarpMap .Data2 = EditorWarpX .Data3 = EditorWarpY End If[/code]In modEnumerations with the server packets add:[code]SInstance[/code]in modHandleData with the messages add:[code]HandleDataSub(SInstance) = GetAddress(AddressOf HandleInstanced)[/code]And at the bottom of the module add:[code]Private Sub HandleInstanced(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim OldMapNum As LongDim NewMapNum As LongDim filename As StringDim Filename2 As StringSet Buffer = New clsBufferWith Buffer .WriteBytes Data() OldMapNum = .ReadLong NewMapNum = .ReadLongEnd Withfilename = App.Path & MAP_PATH & "map" & NewMapNum & ".Map"Filename2 = App.Path & MAP_PATH & "map" & OldMapNum & ".Map" If Not Dir(filename) = vbNullString Then Kill filenameEnd IfIf Dir(filename) = vbNullString ThenFileCopy Filename2, filenameEnd If[/code][b]Attachment: [url]http://www.mmorpgcre....com/Attach.rar[/url][/b]If You find any bugs please notify me, if i have forgotten anything i will fix the tutorial. This was working 100% for me and i have tested it for awhile, so i don't think there are any bugs.Bug Fix:Remove: (Server Side, modInstance)[code] Call InstanceEvent(mapOriginalNum, mapCopyNum)[/code]Bug Fix #2:in modGlobals add:[code]Public CurrentMaxMaps As Long[/code]and in modServerInit before [code]ServerLoop[/code]Add:[code]CurrentMaxMaps = 99[/code]And replace your modInstance with this:[code]Option ExplicitPublic Sub InstanceMap(mapOriginalNum As Long, mapCopyNum As Long, Index As Long)Dim filename As StringDim Filename2 As String' Save new copyfilename = App.path & "\data\maps\map" & mapCopyNum & ".dat"Filename2 = App.path & "\data\maps\map" & mapOriginalNum & ".dat"If Not Dir(filename) = vbNullString Then Call ClearInstancedMap(mapCopyNum) Call Clear(mapCopyNum)End If'F = FreeFileFileCopy Filename2, filenameCall LoadMap(mapCopyNum, mapCopyNum)Call SendInstance(Index, mapOriginalNum, mapCopyNum)CurrentMaxMaps = CurrentMaxMaps + 1End SubPublic Sub ClearInstance()Dim i As LongDim filename As StringDim Filename2 As StringFor i = 100 To MAX_MAPS filename = App.path & "\data\maps\map" & i & ".dat" Filename2 = App.path & "\data\maps\map" & i & "_eventdata.dat" If Not Dir(filename) = vbNullString Then Kill filename Call SetStatus("Destroying Map # " & i) End If If Not Dir(Filename2) = vbNullString Then Kill Filename2 Call SetStatus("Destroying Event Map # " & i) End IfNext iEnd SubPublic Sub ClearInstancedMap(ByVal MapNum As Long)Dim filename As StringDim Filename2 As Stringfilename = App.path & "\data\maps\map" & MapNum & ".dat"Filename2 = App.path & "\data\maps\map" & MapNum & "_eventdata.dat" If Not Dir(filename) = vbNullString Then Kill filename Call SetStatus("Destroying Map # " & MapNum) End If If Not Dir(Filename2) = vbNullString Then Kill Filename2 Call SetStatus("Destroying Event Map # " & MapNum) End If CurrentMaxMaps = CurrentMaxMaps - 1End SubPublic Sub Clear(ByVal MapNum As Long)Call ClearMap(MapNum)End Sub[/code]And finally in UpdateMapLogic replace [code]For MapNum = 1 To MAX_MAPS[/code]with [code]For MapNum = 1 To CurrentMaxMaps[/code]Regards,General Pony[/code][/size][/code][/size]``` Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 9, 2012 Share Posted September 9, 2012 Wow. Damn, I was just going to have a programming contest, but I doubt anyone else here could beat this. People should be really happy you submitted this ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Good job Link to comment Share on other sites More sharing options...
Guest Posted September 9, 2012 Share Posted September 9, 2012 Even 2.3 ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) Link to comment Share on other sites More sharing options...
JohnPony Posted September 9, 2012 Author Share Posted September 9, 2012 Yeah, i'm pretty much done with Eclipse Games so i figured rather then just sitting around trolling the community and being a stick, i would start contributing.Tell me if you find any bugs and i will get the tutorial patched right away.Regards,General Pony Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 9, 2012 Share Posted September 9, 2012 Why are you done? School? As much as it disappoints me that I'm programming with a bum candy language for a game, the fact that it's fun keeps me here. You should get in on that bum candy, it's cool Link to comment Share on other sites More sharing options...
JohnPony Posted September 9, 2012 Author Share Posted September 9, 2012 > Why are you done? School? As much as it disappoints me that I'm programming with a bum candy language for a game, the fact that it's fun keeps me here. You should get in on that bum candy, it's coolI'm trying to move towards general programming design and theory rather then playing with a engine in a older language, not saying it wasn't enjoyable i just think that it's time for me to move on. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 10, 2012 Share Posted September 10, 2012 That was the answer I was looking for. Nice job GP Link to comment Share on other sites More sharing options...
minipimp Posted September 10, 2012 Share Posted September 10, 2012 Im getting an error serverside on this screenshots content. Link to comment Share on other sites More sharing options...
JohnPony Posted September 10, 2012 Author Share Posted September 10, 2012 Thanks, looks like i forgot about that part of the tutorial. Ill add it in now.In modTypes at the bottom of the playerRec add```PrevMap As Long PrevX As Long PrevY As Long``` Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 10, 2012 Share Posted September 10, 2012 Ok, got some problems. You forgot to put prevx, prevy, and prevmap in player rec, also, when I create a new account and login it errors on```And temptile(MapNum).DoorOpen(x1, y1) = YES Then```for closing doors. Also, CanWarp is undefined. And that's as far as I got xD Link to comment Share on other sites More sharing options...
minipimp Posted September 10, 2012 Share Posted September 10, 2012 Thanks, and ^ thats about the same for me aswell Link to comment Share on other sites More sharing options...
JohnPony Posted September 10, 2012 Author Share Posted September 10, 2012 > Ok, got some problems. You forgot to put prevx, prevy, and prevmap in player rec, also, when I create a new account and login it errors on> > ```> > And temptile(MapNum).DoorOpen(x1, y1) = YES Then> > ```> > for closing doors. Also, CanWarp is undefined. And that's as far as I got xD```Dim CanWarp As Boolean```at the top of the player move sub, and i'm pretty sure the rest is JC's fault. His event system doesn't like my instanced maps which is why i the version i used i cut out the events.I'm removing the event system portion from this tutorial, it's just too unstable and slow ATM. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 10, 2012 Share Posted September 10, 2012 Ok, we don't need instanced events anyways. But I don't think the door had to do with it…we'll see. Link to comment Share on other sites More sharing options...
JohnPony Posted September 10, 2012 Author Share Posted September 10, 2012 Find``` Call InstanceEvent(mapOriginalNum, mapCopyNum)```And remove it, and redo the map part of the tutorial as well. Link to comment Share on other sites More sharing options...
Link Posted September 10, 2012 Share Posted September 10, 2012 You did a nice job on this, hope you can't submit it for the contest.![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png) Link to comment Share on other sites More sharing options...
iSnow Posted September 11, 2012 Share Posted September 11, 2012 I've got an error, RTE9 highlighting the same line Whack had for the doors, but I dimmed CanWarp under PlayerMove but it doesn't work, This is serverside, UpdateMapLogic. Any ideas? Link to comment Share on other sites More sharing options...
JohnPony Posted September 11, 2012 Author Share Posted September 11, 2012 REDO the tutorial now without the Event System (I removed the instancing of events) and try, i believe the two were linked. Link to comment Share on other sites More sharing options...
iSnow Posted September 11, 2012 Share Posted September 11, 2012 Alright, I'll redo that side of it. Thanks.EDIT: Nothin. Still the same problem, server side on UpdateMapLogic for the 'close the doors area. I went through and redid both ends of the tutorial as well. Link to comment Share on other sites More sharing options...
JohnPony Posted September 11, 2012 Author Share Posted September 11, 2012 Figured it out, posting a Bug Fix ASAP. Link to comment Share on other sites More sharing options...
minipimp Posted September 11, 2012 Share Posted September 11, 2012 Sub not defined on```Call SendLoad(Index)```in mod instance. Link to comment Share on other sites More sharing options...
Whackeddie99 Posted September 11, 2012 Share Posted September 11, 2012 > Figured it out, posting a Bug Fix ASAP.*Waits patiently* Link to comment Share on other sites More sharing options...
JohnPony Posted September 11, 2012 Author Share Posted September 11, 2012 > Sub not defined on```> > Call SendLoad(Index)> > ```in mod instance.Just remove that, wasn't supposed to be in there.Should be working fine now, sorry for all these unexpected problems guy; as i stated in the other topic i can't seem to get the new forum post to work right with code, so half the time i have to go back and redo the tutorial code while in the post editor, which is where i forget stuff/leave stuff out. I apologize again for the inconvenience Link to comment Share on other sites More sharing options...
tslusny Posted September 14, 2012 Share Posted September 14, 2012 Fix:Under```Call SendInstance(Index, mapOriginalNum, mapCopyNum)```Add```Call SpawnMapNpcs(mapCopyNum)```There is alot more bugs of course, but i am too lazy to post them ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png) Link to comment Share on other sites More sharing options...
BeNjO Posted September 21, 2012 Share Posted September 21, 2012 Runtime error 53 file not found:FileCopy Filename2, filename Link to comment Share on other sites More sharing options...
tslusny Posted September 21, 2012 Share Posted September 21, 2012 If do not was on that originall map before and it isnt cached client side maps folder, this error will popupidk how to fix it 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