Matt Posted October 16, 2012 Author Share Posted October 16, 2012 After seeing quite a few people requesting a skill system, I decided to release mine. This tutorial adds in the three most basic gathering skills; Mining, fishing, and Woodcutting. So let's get started!For all those who are just starting to use VB6 or add in tutorials, I urge you to make a copy of your server and client folders in case you do something wrong and mess up your code.We're going to start in the server. Open it up, then go to modTypes. At the bottom of Private Type PlayerRec we'll put there```WoodcuttingXP As LongMiningXP As LongFishingXP As Long```At the bottom of Private Type ItemRec we'll put there```WcXP As LongFXP As LongMXP As Long```At the bottom of Private Type ResourceRec we'll put there```'reward xpRewardXP As LongWcXP As BooleanFXP As BooleanMXP As Boolean'requirements for XPWcReq As LongFReq As LongMReq As Long```Just underneath the sub Sub SetPlayerExp(ByVal index As Long, ByVal exp As Long) in modPlayer we'll put there```Function GetPlayerMiningXP(ByVal index As Long) As LongIf index > MAX_PLAYERS Then Exit FunctionGetPlayerMiningXP = Player(index).MiningXPEnd FunctionFunction GetPlayerWoodcuttingXP(ByVal index As Long) As LongIf index > MAX_PLAYERS Then Exit FunctionGetPlayerWoodcuttingXP = Player(index).WoodcuttingXPEnd FunctionFunction GetPlayerFishingXP(ByVal index As Long) As LongIf index > MAX_PLAYERS Then Exit FunctionGetPlayerFishingXP = Player(index).FishingXPEnd Function```In modDatabase in Sub AddChar just underneath Player(index).Level = 1 we'll put there``` Player(index).WoodcuttingXP = 1 Player(index).MiningXP = 1 Player(index).FishingXP = 1```In modServerTCP underneath```Buffer.WriteLong SPlayerDataBuffer.WriteLong indexBuffer.WriteString GetPlayerName(index)Buffer.WriteLong GetPlayerLevel(index)Buffer.WriteLong GetPlayerPOINTS(index)Buffer.WriteLong GetPlayerSprite(index)Buffer.WriteLong GetPlayerMap(index)Buffer.WriteLong GetPlayerX(index)Buffer.WriteLong GetPlayerY(index)Buffer.WriteLong GetPlayerDir(index)Buffer.WriteLong GetPlayerAccess(index)Buffer.WriteLong GetPlayerPK(index)```in function PlayerData we'll put there```'skillsBuffer.WriteLong GetPlayerWoodcuttingXP(index)Buffer.WriteLong GetPlayerMiningXP(index)Buffer.WriteLong GetPlayerFishingXP(index)```In sub UseItem we'll put there this code for every equipable item just underneath its case. (for example, Case ITEM_TYPE_ARMOR)``` ' skill requirements If GetPlayerWoodcuttingXP(index) < Item(itemnum).WcXP Then PlayerMsg index, "You need " & Item(itemnum).WcXP - Player(index).WoodcuttingXP & " more experience in woodcutting in order to wear this.", Red Exit Sub End If If GetPlayerFishingXP(index) < Item(itemnum).FXP Then PlayerMsg index, "You need " & Item(itemnum).FXP - Player(index).FishingXP & " more experience in fishing in order to wear this.", Red Exit Sub End If If GetPlayerMiningXP(index) < Item(itemnum).MXP Then PlayerMsg index, "You need " & Item(itemnum).MXP - Player(index).MiningXP & " more experience in mining in order to wear this.", Red Exit Sub End If```In CheckResource (modPlayer) look for```GiveInvItem index, Resource(Resource_index).ItemReward, 1```Just underneath that we'll put there this``` If Resource(Resource_index).RewardXP > 0 Then If Resource(Resource_index).FXP = True Then Player(index).FishingXP = Player(index).FishingXP + Resource(Resource_index).RewardXP End If If Resource(Resource_index).MXP = True Then Player(index).MiningXP = Player(index).MiningXP + Resource(Resource_index).RewardXP End If If Resource(Resource_index).WcXP = True Then Player(index).WoodcuttingXP = Player(index).WoodcuttingXP + Resource(Resource_index).RewardXP End If SendPlayerData index End If```Just above``` ' check if already cut down If ResourceCache(GetPlayerMap(index)).ResourceData(Resource_num).ResourceState = 0 Then```We'll put there``` ' check to see if experienced If Resource(Resource_index).FReq > 0 Then If Player(index).FishingXP < Resource(Resource_index).FReq Then PlayerMsg index, "You need " & Resource(Resource_index).FReq - Player(index).FishingXP & " more experience in fishing to access this resource.", Red Exit Sub End If End If If Resource(Resource_index).MReq > 0 Then If Player(index).MiningXP < Resource(Resource_index).MReq Then PlayerMsg index, "You need " & Resource(Resource_index).FReq - Player(index).MiningXP & " more experience in mining to access this resource.", Red Exit Sub End If End If If Resource(Resource_index).WcReq > 0 Then If Player(index).WoodcuttingXP < Resource(Resource_index).WcReq Then PlayerMsg index, "You need " & Resource(Resource_index).WcReq - Player(index).WoodcuttingXP & " more experience in woodcutting to access this resource.", Red Exit Sub End If End If```I believe that's it for the server, so save it and compile it.Now for the client!The first thing we're going to do is go into modTypes.At the bottom of Private Type PlayerRec we'll put there```WoodcuttingXP As LongMiningXP As LongFishingXP As Long```At the bottom of Private Type ItemRec we'll put there```WcXP As LongFXP As LongMXP As Long```At the bottom of Private Type ResourceRec we'll put there```'reward xpRewardXP As LongWcXP As BooleanFXP As BooleanMXP As Boolean'requirements for XPWcReq As LongFReq As LongMReq As Long```Now, we'll go to modHandleData and look for Private Sub HandlePlayerDatajust under Call SetPlayerPK(i, Buffer.ReadLong) we'll put there```Call SetPlayerWoodcuttingXP(i, Buffer.ReadLong)Call SetPlayerMiningXP(i, Buffer.ReadLong)Call SetPlayerFishingXP(i, Buffer.ReadLong)```Now, we'll go to modDatabase and just above Sub SetPlayerExp we'll put there```Sub SetPlayerWoodcuttingXP(ByVal Index As Long, ByVal WoodcuttingXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).WoodcuttingXP = WoodcuttingXPEnd SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).MiningXP = MiningXPEnd SubSub SetPlayerFishingXP(ByVal Index As Long, ByVal FishingXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).FishingXP = FishingXPEnd Sub```Now for the form work. We'll go to frmEditor_Resource. Make four scroll bars. Name them scrlRewardXP, scrlWoodcutting, scrlMining, and scrlFishing. Now make four labels with similar names; lblRewardXP, lblWoodcutting, lblMining, and lblFishing. For the caption of the labels, put there the skill name and ": 0"For example, Fishing: 0Double click on scrlReward and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblRewardXP.Caption = "XP Rewarded: " & scrlRewardXP.ValueResource(EditorIndex).RewardXP = scrlRewardXP.Value' Error handlerExit Suberrorhandler:HandleError "scrlRewardXP_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on scrlWoodcutting and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblWoodcutting.Caption = "Woodcutting: " & scrlWoodcutting.ValueResource(EditorIndex).WcReq = scrlWoodcutting.Value' Error handlerExit Suberrorhandler:HandleError "scrlWoodcutting_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on scrlFishing and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblFishing.Caption = "Fishing: " & scrlFishing.ValueResource(EditorIndex).FReq = scrlFishing.Value' Error handlerExit Suberrorhandler:HandleError "scrlFishing_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on scrlMining and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblMining.Caption = "Mining: " & scrlMining.ValueResource(EditorIndex).MReq = scrlMining.Value' Error handlerExit Suberrorhandler:HandleError "scrlMining_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Now make three checkboxes and call them chkWcXP, chkMXP, and chkFXP.Double click on chkWcXP and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf chkWcXP.Value = 0 Then Resource(EditorIndex).WcXP = FalseElse Resource(EditorIndex).WcXP = TrueEnd If' Error handlerExit Suberrorhandler:HandleError "chkWcXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on chkFXP and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf chkFXP.Value = 0 Then Resource(EditorIndex).FXP = FalseElse Resource(EditorIndex).FXP = TrueEnd If' Error handlerExit Suberrorhandler:HandleError "chkFXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on chkMXP and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf chkMXP.Value = 0 Then Resource(EditorIndex).MXP = FalseElse Resource(EditorIndex).MXP = TrueEnd If' Error handlerExit Suberrorhandler:HandleError "chkMXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Now, on to frmEditor_ItemMake three scroll bars and three labels. Name the scroll bars scrlWoodcutting, scrlMining, and scrlFishing. Name the labels lblWoodcutting, lblFishing, and lblMining. The caption for the labels should be Woodcutting: 0, Fishing: 0, and Mining: 0.Double click on scrlWoodcutting and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblWoodcutting.Caption = "Woodcuting: " & scrlWoodcutting.ValueItem(EditorIndex).WcXP = scrlWoodcutting.Value' Error handlerExit Suberrorhandler:HandleError "scrlWoodcutting_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on scrlFishing and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblFishing.Caption = "Fishing: " & scrlFishing.ValueItem(EditorIndex).FXP = scrlFishing.Value' Error handlerExit Suberrorhandler:HandleError "scrlFishing_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Double click on scrlMining and put there```' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerlblMining.Caption = "Mining: " & scrlMining.ValueItem(EditorIndex).MXP = scrlMining.Value' Error handlerExit Suberrorhandler:HandleError "scrlMining_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit Sub```Now you can rearrange it to however you want it to be. I'll give you an example of how I arranged it.![](http://www.freemmorpgmaker.com/files/imagehost/pics/798bb6b1d5213561ac4146efd88fab25.png)![](http://www.freemmorpgmaker.com/files/imagehost/pics/139a45000a9ee90ae32deaa7c63654b3.png)Now let's head on over to modGameEditors.In ResourceEditorInt right above``` ' find the sound we have set If .cmbSound.ListCount >= 0 Then For i = 0 To .cmbSound.ListCount If .cmbSound.List(i) = Trim$(Resource(EditorIndex).Sound) Then .cmbSound.ListIndex = i SoundSet = True End If Next If Not SoundSet Or .cmbSound.ListIndex = -1 Then .cmbSound.ListIndex = 0 End If```We'll put there``` .scrlRewardXP.Value = Resource(EditorIndex).RewardXP .scrlWoodcutting.Value = Resource(EditorIndex).WcReq .scrlFishing.Value = Resource(EditorIndex).FReq .scrlMining.Value = Resource(EditorIndex).MReq If Resource(EditorIndex).FXP Then frmEditor_Resource.chkFXP.Value = 1 Else frmEditor_Resource.chkFXP.Value = 0 End If If Resource(EditorIndex).WcXP Then frmEditor_Resource.chkWcXP.Value = 1 Else frmEditor_Resource.chkWcXP.Value = 0 End If If Resource(EditorIndex).MXP Then frmEditor_Resource.chkMXP.Value = 1 Else frmEditor_Resource.chkMXP.Value = 0 End If```Now to ItemEditorInt. Right underneath``` frmEditor_Item.scrlPaperdoll = .Paperdoll```We'll put there``` frmEditor_Item.scrlWoodcutting = .WcXP frmEditor_Item.scrlFishing = .FXP frmEditor_Item.scrlMining = .MXP```Now look for this in modInput```Case "/help"```Right underneath all the "Call AddText" put there``` Case "/skills" Call AddText("Woodcutting XP - " & Player(MyIndex).WoodcuttingXP, Cyan) Call AddText("Mining XP - " & Player(MyIndex).MiningXP, Cyan) Call AddText("Fishing XP - " & Player(MyIndex).FishingXP, Cyan)```And I believe that should be it! Save it, and compile. I believe you need to delete your players after adding this in, so before trying it out, delete your players. Feel free to follow this tutorial to add in other skills, or modify it to fit your needs. I hope you enjoy this feature and wish you luck on your projects. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2012 Share Posted October 16, 2012 Skimmed through it and it looks pretty good. An improvement would be putting the EXP for the different skills into an array, it's faster and cleaner. Also another minor thing would be using bytes, this is an assumption but I don't really expect mostly people to want to have over 255 levels. Link to comment Share on other sites More sharing options...
Matt Posted October 16, 2012 Author Share Posted October 16, 2012 When I started making a Skill System, I did use an array. I messed up the code and forgot to backup, so the next time around I was just trying to see if it would work. As for what you mentioned about levels, I don't quite understand what you mean by that. Instead of levels, I simply made it experience. Link to comment Share on other sites More sharing options...
Guest Posted October 16, 2012 Share Posted October 16, 2012 Oh I see, I read it wrong, I assumed a couple of those variables were meant to be levels. Link to comment Share on other sites More sharing options...
Ganjika Posted November 24, 2012 Share Posted November 24, 2012 I am trying to install this on Dragon Eclipse(Nightly Dx8) - the underlined text is red for me and I get a Syntax Error upon compile (in mod database):Sub SetPlayerWoodcuttingXP(ByVal Index As Long, ByVal WoodcuttingXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).WoodcuttingXP = WoodcuttingXPEnd SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).MiningXP = MiningXPEnd SubSub SetPlayerFishingXP(ByVal Index As Long, ByVal FishingXP As Long)If Index > MAX_PLAYERS Then Exit SubPlayer(Index).FishingXP = FishingXPEnd SubUPDATE: Turns out theres a typo in the tutorial:End SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)for example should beEnd SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)and so on, no biggie. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)This *WORKS* perfectly on Dragon Eclipse (Nightly) Dx8 Link to comment Share on other sites More sharing options...
Matt Posted November 25, 2012 Author Share Posted November 25, 2012 Ah my apologies. I copied the code directly from my engine, so I assumed there weren't any typos. Thanks for pointing it out! I'll change it now. Link to comment Share on other sites More sharing options...
SwiftSwamp Posted December 24, 2012 Share Posted December 24, 2012 So this system is setup for just pure exp without levels from what I understand? Link to comment Share on other sites More sharing options...
Matt Posted December 24, 2012 Author Share Posted December 24, 2012 It is. You're welcome to add in a level system if you choose. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Kemerd Posted March 10, 2013 Share Posted March 10, 2013 Really nice tutorial, I'll add this to my project, with a level system with resource level requirments. Thanks! Link to comment Share on other sites More sharing options...
Matt Posted March 10, 2013 Author Share Posted March 10, 2013 > Really nice tutorial, I'll add this to my project, with a level system with resource level requirments. Thanks!I'm glad you found it useful! Link to comment Share on other sites More sharing options...
Lurvik Posted March 15, 2013 Share Posted March 15, 2013 I get this error when i try to compile the server:User definition type not definedPrivate Sub lvwInfo_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)in Frmserver. Link to comment Share on other sites More sharing options...
Matt Posted March 15, 2013 Author Share Posted March 15, 2013 That has nothing to do with my tutorial. You messed up your code somehow. Revert to a backup and see if it happens again. Link to comment Share on other sites More sharing options...
Lurvik Posted March 15, 2013 Share Posted March 15, 2013 Okay, it works now.Thank you for this tutorial. ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) Link to comment Share on other sites More sharing options...
Matt Posted March 15, 2013 Author Share Posted March 15, 2013 > Okay, it works now.> > Thank you for this tutorial. ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)No problem! ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png) Enjoy it! Link to comment Share on other sites More sharing options...
Daneta Posted March 15, 2013 Share Posted March 15, 2013 AWesome 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