Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Gathering Skill System


Matt
 Share

Recommended Posts

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 Long

MiningXP As Long

FishingXP As Long

```

At the bottom of Private Type ItemRec we'll put there

```

WcXP As Long

FXP As Long

MXP As Long

```

At the bottom of Private Type ResourceRec we'll put there

```

'reward xp

RewardXP As Long

WcXP As Boolean

FXP As Boolean

MXP As Boolean

'requirements for XP

WcReq As Long

FReq As Long

MReq 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 Long

If index > MAX_PLAYERS Then Exit Function

GetPlayerMiningXP = Player(index).MiningXP

End Function

Function GetPlayerWoodcuttingXP(ByVal index As Long) As Long

If index > MAX_PLAYERS Then Exit Function

GetPlayerWoodcuttingXP = Player(index).WoodcuttingXP

End Function

Function GetPlayerFishingXP(ByVal index As Long) As Long

If index > MAX_PLAYERS Then Exit Function

GetPlayerFishingXP = Player(index).FishingXP

End 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 SPlayerData

Buffer.WriteLong index

Buffer.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

```

'skills

Buffer.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 Long

MiningXP As Long

FishingXP As Long

```

At the bottom of Private Type ItemRec we'll put there

```

WcXP As Long

FXP As Long

MXP As Long

```

At the bottom of Private Type ResourceRec we'll put there

```

'reward xp

RewardXP As Long

WcXP As Boolean

FXP As Boolean

MXP As Boolean

'requirements for XP

WcReq As Long

FReq As Long

MReq As Long

```

Now, we'll go to modHandleData and look for Private Sub HandlePlayerData

just 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 Sub

Player(Index).WoodcuttingXP = WoodcuttingXP

End Sub

Sub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).MiningXP = MiningXP

End Sub

Sub SetPlayerFishingXP(ByVal Index As Long, ByVal FishingXP As Long)

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).FishingXP = FishingXP

End 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: 0

Double click on scrlReward and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblRewardXP.Caption = "XP Rewarded: " & scrlRewardXP.Value

Resource(EditorIndex).RewardXP = scrlRewardXP.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlRewardXP_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on scrlWoodcutting and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblWoodcutting.Caption = "Woodcutting: " & scrlWoodcutting.Value

Resource(EditorIndex).WcReq = scrlWoodcutting.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlWoodcutting_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on scrlFishing and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblFishing.Caption = "Fishing: " & scrlFishing.Value

Resource(EditorIndex).FReq = scrlFishing.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlFishing_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on scrlMining and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblMining.Caption = "Mining: " & scrlMining.Value

Resource(EditorIndex).MReq = scrlMining.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlMining_Change", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit 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 out

If Options.Debug = 1 Then On Error GoTo errorhandler

If chkWcXP.Value = 0 Then

Resource(EditorIndex).WcXP = False

Else

Resource(EditorIndex).WcXP = True

End If

' Error handler

Exit Sub

errorhandler:

HandleError "chkWcXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on chkFXP and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If chkFXP.Value = 0 Then

Resource(EditorIndex).FXP = False

Else

Resource(EditorIndex).FXP = True

End If

' Error handler

Exit Sub

errorhandler:

HandleError "chkFXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on chkMXP and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If chkMXP.Value = 0 Then

Resource(EditorIndex).MXP = False

Else

Resource(EditorIndex).MXP = True

End If

' Error handler

Exit Sub

errorhandler:

HandleError "chkMXP", "frmEditor_Resource", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Now, on to frmEditor_Item

Make 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 out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblWoodcutting.Caption = "Woodcuting: " & scrlWoodcutting.Value

Item(EditorIndex).WcXP = scrlWoodcutting.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlWoodcutting_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on scrlFishing and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblFishing.Caption = "Fishing: " & scrlFishing.Value

Item(EditorIndex).FXP = scrlFishing.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlFishing_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

```

Double click on scrlMining and put there

```

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

lblMining.Caption = "Mining: " & scrlMining.Value

Item(EditorIndex).MXP = scrlMining.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlMining_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit 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

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

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

  • 1 month later...
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 Sub

Player(Index).WoodcuttingXP = WoodcuttingXP

End SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).MiningXP = MiningXP

End SubSub SetPlayerFishingXP(ByVal Index As Long, ByVal FishingXP As Long)

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).FishingXP = FishingXP

End Sub

UPDATE: Turns out theres a typo in the tutorial:

End SubSub SetPlayerMiningXP(ByVal Index As Long, ByVal MiningXP As Long)

for example should be

End Sub

Sub 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

  • 5 weeks later...
  • 2 months later...
> 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...