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

[EO] Weapon Proficiencies/Skill Level


DJMaxus
 Share

Recommended Posts

This is a tutorial for Eclipse Origins v.2 Beta. It will allow your character to become skilled at using a certain type of weapon, do more damage the weapon type equipped, and have access to better weapons of the same type based on your skill level. I did a tutorial of this for MRDE but that is long gone from what I can see now. This is almost a direct copy of the tutorial tweaked a bit to work with EO.

This tutorial only shows you how to set up a weapon proficiency for one type of weapon, to add more types, simply follow the way the example is set up. Just as all tutorials should be, its not recommended to simply use this tutorial as it is. Modify it and tweak it to fit your game. Now, on to the tutorial.

_**How It Works:**_

It's pretty similar to what you'd find in Borderlands, or the Elder Scrolls IV. You will be adding variables that determine what type of item the player is using, their proficiency level, and how skilled at a certain weapon type the player must be in order to use the item. If a player lands an attack with a sword, they will gain experience in "Swords" usage, once they gain enough experience, their Swords level will increase and they will do more damage with all sword type weapons, some swords can only be used if their skill level is high enough however. This principle can be used for things like Axes and Polearms as well.

_**The Code:**_
=============
**Server Side**
=============
In **modConstants**

Find:
```
Public Const MAX_PARTY_MEMBERS As Long = 4
```
Underneath it, add:
```
' Proficiency
Public Const MAX_SKILL_LEVEL As Long = 99
```
* This is the max level a proficiency skill can reach.

In **modTypes**
Find : **Private Type PlayerRec**

Add this to the bottom of **Private Type PlayerRec** (before **End Type**)
```
    ' Proficiencies
    Swords As Byte
    SwordsExp As Long
```
Find : **Private Type ItemRec**

Add this to the bottom of **Private Type ItemRec** (before **End Type**)
```
' Proficiencies
    Sword As Long
    SwordsReq As Long
```
In **modPlayer**

Add This to the very bottom of **modPlayer**
```
' Check Proficiency Level Up
Sub SwordsLevelUp(ByVal Index As Long)
    Dim i As Long
    Dim expRollover As Long

        expRollover = GetPlayerSwordsExp(Index) - GetPlayerNextSwordsLevel(Index)

        If GetPlayerSwords(Index) >= MAX_SKILL_LEVEL Then Exit Sub

        ' Level up
        SetPlayerSwords Index, GetPlayerSwords(Index) + 1

        Call SetPlayerSwordsExp(Index, expRollover)

        SendPlayerData Index
        SendEXP Index

        ' Send messages
        PlayerMsg Index, "Your skill with Swords has increased!", BrightGreen
End Sub
```
Find : **Function GetPlayerNextLevel**

Underneath the whole function, add:
```
' Proficeicies
'***************************************
' Swords Skill Level
'***************************************
Function GetPlayerSwords(ByVal Index As Long) As Long
    If Index > MAX_PLAYERS Then Exit Function
    GetPlayerSwords = Player(Index).Swords
End Function
Function SetPlayerSwords(ByVal Index As Long, ByVal Swords As Long)
    SetPlayerSwords = False
    If Swords > MAX_SKILL_LEVEL Then Exit Function
    Player(Index).Swords = Swords
    SetPlayerSwords = True
End Function
Function GetPlayerSwordsExp(ByVal Index As Long) As Long
    GetPlayerSwordsExp = Player(Index).SwordsExp
End Function
Sub SetPlayerSwordsExp(ByVal Index As Long, ByVal SwordsExp As Long)
    Player(Index).SwordsExp = SwordsExp
    SendEXP Index
    If GetPlayerSwordsExp(Index) >= GetPlayerNextSwordsLevel(Index) Then SwordsLevelUp Index
End Sub

Public Function GetPlayerNextSwordsLevel(ByVal Index As Long) As Long
    GetPlayerNextSwordsLevel = (50 / 3) * ((GetPlayerSwords(Index) + 1) ^ 3 - (6 * (GetPlayerSwords(Index) + 1) ^ 2) + 17 * (GetPlayerSwords(Index) + 1) - 12)
End Function
```
Find : **Public Sub Use Item**

In this sub, find :

```
Case ITEM_TYPE_WEAPON
```
Add this underneth it:
```
' Proficiency Requirements

                ' Swords
                If Item(ItemNum).SwordsReq > 0 Then
                    If GetPlayerSwords(Index) < Item(ItemNum).SwordsReq Then
                        PlayerMsg Index, "You are not skilled enough with Swords to use this weapon.", BrightRed
                        Exit Sub
                    End If
                End If
```
In **modCombat**

Find **Function GetPlayerDamage**

Change that entire function to:
```
Function GetPlayerDamage(ByVal index As Long) As Long
    Dim weaponNum As Long

    GetPlayerDamage = 0

    ' Check for subscript out of range
    If IsPlaying(index) = False Or index <= 0 Or index > MAX_PLAYERS Then
        Exit Function
    End If
    If GetPlayerEquipment(index, Weapon) > 0 Then
        weaponNum = GetPlayerEquipment(index, Weapon)
        ' Proficiency damage bonus calculation
        If Item(weaponNum).Sword > 0 Then
            GetPlayerDamage = 0.085 * 5 * GetPlayerStat(index, Strength) * Item(weaponNum).Data2 + (GetPlayerLevel(index) / 5) + (GetPlayerSwords(index) / 5)
        Else
            GetPlayerDamage = 0.085 * 5 * GetPlayerStat(index, Strength) * Item(weaponNum).Data2 + (GetPlayerLevel(index) / 5)
        End If
    Else
        GetPlayerDamage = 0.085 * 5 * GetPlayerStat(index, Strength) + (GetPlayerLevel(index) / 5)
    End If

End Function
```
In **Public Sub PlayerAttackNpc** & **Public Sub PlayerAttackPlayer**
(You do the exact same thing for both of these subs)

Under: **Dim Buffer As clsBuffer**

Add:
```
' Proficiencies
    Dim SW As Long
    Dim ItemNum As Long
```
In the same sub, find:
```
If Damage >= MapNpc(mapNum).Npc(mapNpcNum).Vital(Vitals.HP) Then
```**(When editing **Public Sub PlayerAttackPlayer**, the line is as follows)**
```
If Damage >= GetPlayerVital(victim, Vitals.HP) Then
```
Add this below it:
```
        ' If the player has a weapon, determine what type it is...
        ' Then calculate the weapon exp
        ItemNum = GetPlayerEquipment(attacker, weapon)
        If ItemNum > 0 Then
        SW = Item(ItemNum).Sword
            If SW > 0 Then
                SetPlayerSwordsExp attacker, GetPlayerSwordsExp(attacker) + GetPlayerSwords(attacker) * 2 + 5
                SendEXP attacker
            End If
        End If
```
In **modDatabase**

Find **Sub AddChar**

Find the line:
```
        Player(Index).Level = 1
```
Add this below it:
```
' Starting Proficiency Levels
        Player(Index).Swords = 1
```
In **modServerTCP**

Find : **Function PlayerData**

Find the line:
```
Buffer.WriteLong GetPlayerPK(Index)
```
Add this underneath it:
```
Buffer.WriteLong GetPlayerSwords(Index)
```
Find : **Sub SendEXP**

Find the line:
```
    Buffer.WriteLong GetPlayerNextLevel(Index)

Add this underneath it:
[code]    ' Proficiencies
    Buffer.WriteLong GetPlayerSwordsExp(Index)
    Buffer.WriteLong GetPlayerNextSwordsLevel(Index)[/code]
=============
[b]Client Side[/b]
=============

In [b]modTypes[/b]
Find : [b]Private Type PlayerRec[/b]

Add this to the bottom of [b]Private Type PlayerRec[/b] (before [b]End Type[/b])
[code]    ' Proficiencies
    Swords As Byte
    SwordsExp As Long[/code]
Find : [b]Private Type ItemRec[/b]

Add this to the bottom of [b]Private Type ItemRec[/b] (before [b]End Type[/b])
[code]' Proficiencies
    Sword As Long
    SwordsReq As Long[/code]
In [b]modDatabase[/b]

Find : [b]Sub SetPlayerExp[/b]

Underneath the entire sub, add:
[code]Function GetPlayerSwords(ByVal Index As Long) As Long
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If Index > MAX_PLAYERS Then Exit Function
    GetPlayerSwords = Player(Index).Swords

    ' Error handler
    Exit Function
errorhandler:
    HandleError "GetPlayerSwords", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Function
End Function

Sub SetPlayerSwords(ByVal Index As Long, ByVal Swords As Long)
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If Index > MAX_PLAYERS Then Exit Sub
    Player(Index).Swords = Swords

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SetPlayerSwords", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

Function GetPlayerSwordsExp(ByVal Index As Long) As Long
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If Index > MAX_PLAYERS Then Exit Function
    GetPlayerSwordsExp = Player(Index).SwordsExp

    ' Error handler
    Exit Function
errorhandler:
    HandleError "GetPlayerSwordsExp", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Function
End Function

Sub SetPlayerSwordsExp(ByVal Index As Long, ByVal SwordsExp As Long)
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If Index > MAX_PLAYERS Then Exit Sub
    Player(Index).SwordsExp = SwordsExp

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "SetPlayerSwordsExp", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub[/code]
In [b]modGameEditors[/b]

Find : [b]Sub ItemEditorInit[/b]

Find the line:
[code]frmEditor_Item.scrlLevelReq.Value = .LevelReq[/code]
Underneath it, add:
[code]        ' Proficiencies
        frmEditor_Item.scrlSwordReq.Value = .SwordsReq
        frmEditor_Item.chkSW = .Sword[/code]
In [b]modHandleData[/b]

Find : [b]Private Sub HandlePlayerExp[/b]

In the sub find:
[code]Dim TNL As Long[/code]
Underneath it, add:
[code]Dim TNSW As Long[/code]
In the same sub, find this line:
[code]    frmMain.imgEXPBar.width = ((GetPlayerExp(MyIndex) / EXPBar_Width) / (TNL / EXPBar_Width)) * EXPBar_Width[/code]
Underneath it add:
[code]    ' Proficiencies
    SetPlayerSwordsExp Index, Buffer.ReadLong
    TNSW = Buffer.ReadLong
    frmMain.lblSwordsExp.Caption = GetPlayerSwordsExp(Index) & "/" & TNSW[/code]
Find : [b]Private Sub HandlePlayerData[/b]

Within the sub, find this line:
[code]    Call SetPlayerPK(i, Buffer.ReadLong)[/code]
Underneath it, add:
[code]    Call SetPlayerSwords(i, Buffer.ReadLong)[/code]
In the same sub, find:
[code]frmMain.lblCharName = GetPlayerName(MyIndex) & " - Level " & GetPlayerLevel(MyIndex)[/code]
Underneath it, add:
[code]frmMain.lblSwords = "Swords Level: " & GetPlayerSwords(MyIndex)[/code]
[size][b][i]Form Work:[/i][/b][/size]

Open up [b]frmEditor_Item[/b]
Add the following items to it: (You may have to extend the form and make room)

1\. A Check Box, call it [b]chkSW[/b]
2\. A Label, call it [b]lblSwords[/b]
3\. A Scroll Bar, call it [b]scrlSwordReq[/b]

Double click [b]scrlSwordReq[/b] and paste this:
[code]    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub
    lblSwords.Caption = "SW: " & scrlSwordReq
    Item(EditorIndex).SwordsReq = scrlSwordReq.Value

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "scrlSwordReq_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub[/code]
Double click [b]chkSW[/b] and paste this:
[code]    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub
    Item(EditorIndex).Sword = chkSW.Value

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "chkSW_Click", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub[/code]
Open up [b]frmMain[/b]
Add the following items to it:

1\. A Label, call it [b]lblSwords[/b]
2\. A Label, call it [b]lblSwordsExp[/b]

These two labels will display your current skill level with the weapon, and your experience points to the next skill level.

That should be it. Hope this tutorial can help you further your project. If I missed something or you have a problem, don't hesitate to post your errors and questions and I'll help you get it working. Enjoy the tutorial. Feels good to post one of these again after a bit of an absence.
```
Link to comment
Share on other sites

  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

@aℓνιη:

> Edit:
>
> I have "0" in Character panel, in lblswords
>
> Help!

Server side **Function PlayerData** and Client side **Private Sub Handle PlayerData** must have their variables listed in the same order or they will return the wrong values. Make sure you've added the Swords code _after_ the line where it handles a player's PK (player killing) both client side and server side.

@Apple:

> Can you add a picture of the form work so we won't get confused or something?

No need to really. You can add the labels, scroll bar, and check box anywhere you want, as long as you have them in the right form. There's no specific place they need to be, but you can arrange them to make things look nicer.
Link to comment
Share on other sites

@Piteq:

> So… if i want add this but not only sword, i need to copy that yes?

Yes, follow the tutorial again except everywhere you used the name "Swords", replace it with something else like "Axes" or "Daggers"

Doing it for Daggers, you're going to want to have things like **Daggers as Byte**, and **GetPlayerDaggers** this time around.
Link to comment
Share on other sites

@gdog12356:

> when i add this to a new frm, it works. But then if i close that frm, and reopen it via a button, it shows label_16\. Is there anyway to fix this?

What is label 16 supposed to be? Is the editor initializing? If you created a new form to serve as an editor, you'll need to treat it as such.
Link to comment
Share on other sites

  • 2 weeks later...
so i was able to gain 1 level of swords, but then the to next level stays at 0 and i cant go to swords lvl 2.  not entirely sure i did everything right, but other then that it works for me. 

edit, *after much attacking, it finnaly went to level 2, so i realize now its the lable not showing the counting up to next level.  i can fix that myself, and it was probly caused by me in the first place.  so all is well.  :)

so that darn auto fill vb6 does got me!  it put that sub end in before the rest of the stuff when i hit enter when putting it in.  lols.

so this morning i edited it like said and now it works for all my weapons.  this this is amazing!  gonna have to move it onto crafting things now.  so many things this can do, so many.
Link to comment
Share on other sites

  • 2 weeks later...
Great tuto' ^^ but I have a small problem:

>! [![](http://s3.noelshack.com/uploads/images/20127347923914_sword.png)](http://s3.noelshack.com/upload/20127347923914_sword.png)

When I equip this sword configured so:

>! [![](http://s3.noelshack.com/uploads/images/10984876942446_swoerd.png)](http://s3.noelshack.com/upload/10984876942446_swoerd.png)
Exp of the sword is always on 0/0
Link to comment
Share on other sites

well your sword needs level 2 swords to be used.  that 1st problem.

2nd.  it will say level 1 on a new character corectly yes?  if so this is your problem.  set it to 0 or 1 and use it then it should level you up.  you may have to equip/unequip the item for the changes to take place.

as for the scaling you have to set that yourself if you dont like the rates it goes as.
Link to comment
Share on other sites

@sotvotkong:

> well your sword needs level 2 swords to be used.  that 1st problem.

aa.. Ok I understood ^^I rectify now but
Now the experience Do not increase :/ He always stays in 0/100.. :s

@sotvotkong:

> as for the scaling you have to set that yourself if you dont like the rates it goes as.

:confused: I don't understand sorry I'm French
Link to comment
Share on other sites

  • 1 month later...
OK does anyone know whats going wrong? I added 4 different weapon types. Everything seemed to be going good but i tested it and im having a problem. Weapon Type #2 works just fine levels up like its suppose to. Weapon Type #1 levels up normally but it also gives exp for Weapon Types 3 & 4\. And when i check the box for either weapon type 3 or 4 it gives no exp for any weapon type?

Edit: When I attack with Weapon Type #1 it seems to hit the npc 3 times in a row one for type 1, 3, &4

I have gone threw and done the tutorial 3 times now with the same result. I will attempt to try again but if anyone knows what is causing this will they please let me know :)

NVM I GOT IT… This tutorial is great im just a dumb ass
Link to comment
Share on other sites

  • 2 weeks later...
@Domino_:

> Hmm I found a bug.. maybe… dunno xD umm Everything is set good I edit dmg in frmEditor_item ingame to 100 but dmg is the same 1-2 ... wtf and why? :D

Your ItemRec is probably out of order, make sure that the variables in the tutorial are at the bottom of your ItemRec, before End Type.
Link to comment
Share on other sites

@DJMaxus:

> Your ItemRec is probably out of order, make sure that the variables in the tutorial are at the bottom of your ItemRec, before End Type.

I have more than one weapon leveling added but they are in both sides similar and in order

Both sides
```
    Swords As Byte
    SwordsExp As Long
    Axes As Byte
    AxesExp As Long
    Staffs As Byte
    StaffsExp As Long
    Daggers As Byte
    DaggersExp As Long
    Maces As Byte
    MacesExp As Long

```
Link to comment
Share on other sites

Not too sure about that one then. All I could suggest is retracing your steps, or checking to see what the "Damage" variable returns in Sub PlayerAttackNpc. From there you should be able to find out why it's only 1-2.
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...