iHero Posted February 13, 2013 Author Share Posted February 13, 2013 **Client~Side**> modGameLogicIn _Sub GameLoop_ find:``` ' Lock fpsIf Not FPS_Lock ThenDo While GetTickCount < Tick + 15Sleep 1LoopEnd If```Replace for:``` ' Lock fpsIf Not FPS_Lock ThenDo While GetTickCount < Tick + 10Sleep 1LoopEnd If```**Server~Side**> modServerLoopAt the beginning of the Sub ServerLoop add:```Dim MapNum as Integer, LastUpdateMapLogic As Long```Find:``` If Tick > tmr25 ThenFor i = 1 To Player_HighIndexIf IsPlaying(i) Then' check if they've completed casting, and if so set the actual spell going```Replace for:``` ' Player loopFor i = 1 To Player_HighIndexIf IsPlaying(i) ThenIf Tick > tmr25 Then' check if they've completed casting, and if so set the actual Spell going```Find:```' Checks to update player vitals every 5 seconds - Can be tweakedIf Tick > LastUpdatePlayerVitals ThenUpdatePlayerVitalsLastUpdatePlayerVitals = GetTickCount + 5000End If' Checks to spawn map items every 5 minutes - Can be tweakedIf Tick > LastUpdateMapSpawnItems ThenUpdateMapSpawnItemsLastUpdateMapSpawnItems = GetTickCount + 300000End If' Checks to save players every 5 minutes - Can be tweakedIf Tick > LastUpdateSavePlayers ThenUpdateSavePlayersLastUpdateSavePlayers = GetTickCount + 300000End If```And deleteFind:``` End IfNextfrmServer.lblCPS.Caption = "CPS: " & Format$(GameCPS, "#,###,###,###")tmr25 = GetTickCount + 25End If```Replace for:``` tmr25 = GetTickCount + 25End If' Checks to update player vitals every 5 seconds - Can be tweakedIf Tick > LastUpdatePlayerVitals ThenUpdatePlayerVitals iLastUpdatePlayerVitals = GetTickCount + 5000End If' Checks to save players every 5 minutes - Can be tweakedIf Tick > LastUpdateSavePlayers ThenUpdateSavePlayers iLastUpdateSavePlayers = GetTickCount + 300000End IfEnd IfNext```Find:``` ' Check for disconnections every half secondIf Tick > tmr500 ThenFor i = 1 To MAX_PLAYERSIf frmServer.Socket(i).State > sckConnected ThenCall CloseSocket(i)End IfNextUpdateMapLogictmr500 = GetTickCount + 500End If```Replace for:``` ' Check for disconnections every half secondIf Tick > tmr500 ThenFor i = 1 To MAX_PLAYERSIf frmServer.Socket(i).State > sckConnected ThenCall CloseSocket(i)End IfNexttmr500 = GetTickCount + 500End If```Find:``` If Tick > tmr1000 ThenIf isShuttingDown ThenCall HandleShutdownEnd Iftmr1000 = GetTickCount + 1000End If```Below add:``` For MapNum = 1 To MAX_MAPS' Checks to spawn map items every 5 minutes - Can be tweakedIf Tick > LastUpdateMapSpawnItems ThenUpdateMapSpawnItems MapNumLastUpdateMapSpawnItems = GetTickCount + 300000End If' update map logicIf Tick > LastUpdateMapLogic ThenUpdateMapLogic MapNumLastUpdateMapLogic = GetTickCount + 500End IfNext```Find:``` ' Calculate CPSIf TickCPS < Tick ThenGameCPS = CPSTickCPS = Tick + 1000CPS = 0ElseCPS = CPS + 1End If```Below add:``` ' Set server CPS on labelfrmServer.lblCPS.Caption = "CPS: " & Format$(GameCPS, "#,###,###,###")```Replace _Sub UpdateSavePlayers_ for:```Private Sub UpdatePlayerVitals(ByVal index As Integer)If Not TempPlayer(index).stopRegen ThenIf GetPlayerVital(index, Vitals.HP) <> GetPlayerMaxVital(index, Vitals.HP) ThenCall SetPlayerVital(index, Vitals.HP, GetPlayerVital(index, Vitals.HP) + GetPlayerVitalRegen(index, Vitals.HP))Call SendVital(index, Vitals.HP)' send vitals to party if in oneIf TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, indexEnd IfIf GetPlayerVital(index, Vitals.MP) <> GetPlayerMaxVital(index, Vitals.MP) ThenCall SetPlayerVital(index, Vitals.MP, GetPlayerVital(index, Vitals.MP) + GetPlayerVitalRegen(index, Vitals.MP))Call SendVital(index, Vitals.MP)' send vitals to party if in oneIf TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, indexEnd IfEnd IfEnd Sub```Replace _Sub UpdateSavePlayers_ for:```Private Sub UpdateSavePlayers(ByVal index As Integer)Dim i As Long' Prevent subscript out rangeIf Not IsPlaying(index) Then Exit Sub' Save playerCall TextAdd("Saving all online players...")Call SavePlayer(index)Call SaveBank(index)End Sub```Find:```Private Sub UpdateMapSpawnItems()```Replace for:```Private Sub UpdateMapSpawnItems(Y As Integer)```Find:``` Dim Y As Long' ///////////////////////////////////////////' // This is used for respawning map items //' ///////////////////////////////////////////For Y = 1 To MAX_MAPS' Make sure no one is on the map when it respawnsIf Not PlayersOnMap(Y) Then```And delete. At the end of the sub find:``` End IfDoEventsNext```And delete. Find:```Private Sub UpdateMapLogic()```Replace for:```Private Sub UpdateMapLogic(MapNum As Integer)```Find:```, mapNum As Long```And delete. Find:``` For mapNum = 1 To MAX_MAPS```And delete. Find:``` If PlayersOnMap(mapnum) = YES Then```And delete. Find:``` End IfDoEventsNext' Make sure we reset the timer for npc hp regenerationIf GetTickCount > GiveNPCHPTimer + 10000 ThenGiveNPCHPTimer = GetTickCountEnd If' Make sure we reset the timer for door closingIf GetTickCount > KeyTimer + 15000 ThenKeyTimer = GetTickCountEnd If```Replace for:``` DoEvents' Make sure we reset the timer for npc hp regenerationIf GetTickCount > GiveNPCHPTimer + 10000 ThenGiveNPCHPTimer = GetTickCountEnd If```In _Sub NpcDir_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendMapItemsToAll_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendMapNpcVitals_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendMapNpcsTo_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendMapNpcsToMap_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendResourceCacheToMap_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(GetPlayerMap(index)) = NO Then Exit Sub```In _Sub SendMapSound_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(GetPlayerMap(index)) = NO Then Exit Sub```In _Sub SendSpawnItemToMap_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```In _Sub SendNpcXY_ above of:``` Set Buffer = New clsBuffer```Add:``` ' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub```**Credits**Ricardo Link to comment Share on other sites More sharing options...
Guest Posted February 13, 2013 Share Posted February 13, 2013 ``` ' Lock fps If Not FPS_Lock Then Do While GetTickCount < Tick + 10 Sleep 1 Loop End If```Yes this will render the game faster but overall it will lead to more CPU usage. Oh and stop using integers, they're slow in VB, use longs or bytes instead.Everything else however looks very good, great work! Link to comment Share on other sites More sharing options...
Solstice Posted February 13, 2013 Share Posted February 13, 2013 > ```> > ' Lock fps> > If Not FPS_Lock Then> > Do While GetTickCount < Tick + 10> > Sleep 1> > Loop> > End If> ```> > Yes this will render the game faster but overall it will lead to more CPU usage. Oh and stop using integers, they're slow in VB, use longs or bytes instead.> > Everything else however looks very good, great work!Sounds like a pretty decent compromise. Link to comment Share on other sites More sharing options...
Guest Posted February 13, 2013 Share Posted February 13, 2013 I'd much rather exchange CPU usage for a more fluent game play. Any game that reaches any players and contains decent features will lag intensely. Hopefully this helps! Link to comment Share on other sites More sharing options...
Larias Posted February 13, 2013 Share Posted February 13, 2013 Actually, question.It won't compile because the variable mapnum isn't defined. Do I need to add mapNum as long in every sub that we added' Check if have player on mapIf PlayersOnMap(MapNum) = NO Then Exit Sub? Link to comment Share on other sites More sharing options...
BugSICK Posted February 13, 2013 Share Posted February 13, 2013 what engine did you use for this? Link to comment Share on other sites More sharing options...
Larias Posted February 13, 2013 Share Posted February 13, 2013 > what engine did you use for this?All of the stuff he did was in EO 2.0, so I assume that /shrug Link to comment Share on other sites More sharing options...
iHero Posted February 13, 2013 Author Share Posted February 13, 2013 > Actually, question.> > It won't compile because the variable mapnum isn't defined. Do I need to add mapNum as long in every sub that we added> > ' Check if have player on map> > If PlayersOnMap(MapNum) = NO Then Exit Sub> > ?Sorry, I'll fix it. Wait a few seconds Link to comment Share on other sites More sharing options...
iHero Posted February 13, 2013 Author Share Posted February 13, 2013 The fix (In topic is already tidy)> In _Sub SendResourceCacheToMap_ above of:> > ```> Set Buffer = New clsBuffer> ```> > Add:> > ```> ' Check if have player on map> > If PlayersOnMap(GetPlayerMap(index)) = NO Then Exit Sub> ```> > In _Sub SendMapSound_ above of:> > ```> Set Buffer = New clsBuffer> ```> > Add:> > ```> ' Check if have player on map> > If PlayersOnMap(GetPlayerMap(index)) = NO Then Exit Sub> ``` Link to comment Share on other sites More sharing options...
Larias Posted February 13, 2013 Share Posted February 13, 2013 > Sorry, I'll fix it. Wait a few secondsAlso, on```' Checks to update player vitals every 5 seconds - Can be tweakedIf Tick > LastUpdatePlayerVitals ThenUpdatePlayerVitals iLastUpdatePlayerVitals = GetTickCount + 5000End If' Checks to save players every 5 minutes - Can be tweakedIf Tick > LastUpdateSavePlayers ThenUpdateSavePlayers iLastUpdateSavePlayers = GetTickCount + 300000End IfEnd IfNext```it won't compile with the "i" there after vitals and playersI removed it and it compiled. Link to comment Share on other sites More sharing options...
Larias Posted February 13, 2013 Share Posted February 13, 2013 > The fix (In topic is already tidy)In EO 2.0, you don't need to have the changes you made to _Sub SendResourceCacheToMap._ It already has mapnum in the sub itself.I haven't said it yet, though, so I wanted to say THANK YOU. This is fantastic. Link to comment Share on other sites More sharing options...
iHero Posted February 13, 2013 Author Share Posted February 13, 2013 > In EO 2.0, you don't need to have the changes you made to _Sub SendResourceCacheToMap._ It already has mapnum in the sub itself.> > I haven't said it yet, though, so I wanted to say THANK YOU. This is fantastic.Thank you Link to comment Share on other sites More sharing options...
BugSICK Posted February 13, 2013 Share Posted February 13, 2013 hmmm.. i cant add this in my engine. which i think very important. Link to comment Share on other sites More sharing options...
Comagothed Posted February 14, 2013 Share Posted February 14, 2013 is this engine decrease the game's lag ? Link to comment Share on other sites More sharing options...
teamokell Posted February 14, 2013 Share Posted February 14, 2013 Waiting for feedbacks… Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 > Waiting for feedbacks…-snip-Ricard updated. Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 -snip- Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 14, 2013 Share Posted February 14, 2013 > -snip-Please, if you're gonna make asumptions, at least make it something that is related to the topic…there is no edit what so ever inside this tutorial that edits the spells system. don't reflect your broken systems on someone else's fixes. Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 -snip- no longer relevant.Growlith admitted he was wrong and this part no longer needs to be here.> Alright then, i stand corrected. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 14, 2013 Share Posted February 14, 2013 That is not making your players stop. That is fixing a totally different prblem with it. So please stop trying to act cool unless you know what you are talking about.. Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 -snip- no longer relevant.Growlith admitted he was wrong and this part no longer needs to be here.> Alright then, i stand corrected. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 14, 2013 Share Posted February 14, 2013 no, that's your fault for adding that check so they can't move. it's not our fault you followed a tutorial that apparantly works for others…Sincerely,Growlith1223PS. you posting letters in bold to get at me is only making you look more and more like a child. Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 -snip- no longer relevant.Growlith admitted he was wrong and this part no longer needs to be here.> Alright then, i stand corrected. Link to comment Share on other sites More sharing options...
Growlith1223 Posted February 14, 2013 Share Posted February 14, 2013 please sir, elaborate where it makes you not move. show the code. im looking at the default 2.0 source right now but i don't see a line anywhere in the code that says you can't move.You even said in the shoutbox you added the "can't move" function yourself..Sincerely,Growlith1223 Link to comment Share on other sites More sharing options...
Larias Posted February 14, 2013 Share Posted February 14, 2013 -snip- no longer relevant.Growlith admitted he was wrong and this part no longer needs to be here.> Alright then, i stand corrected. 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