Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[General] Adding new Stats
#1
Just a basic overview of the stats.
You can also refrence http://web.miragesource.com/forums/viewt...f=5&t=3988
where i outline the original idea.

modEnumerations
Code:
' Stats used by Players, Npcs and Classes
Public Enum Stats
    Strength = 1
    Defense
    Speed
    Magic
    ' Make sure Stat_Count is below everything else
    Stat_Count
End Enum
The enum will automatically increment each item in the list. Starting at Strength = 1 so Stat_Count would equal 5.

When you add in a new stat make sure to add it is above this:
Quote:' Make sure Stat_Count is below everything else
If Stat_Count isn't the last in the enum, it will create problems for you.

The way the current stat system works , in the PlayerRec we have
Code:
' Stats
    Stat(1 To Stats.Stat_Count - 1) As Byte

So it will automatically setup how many stats you have.
If you have any accounts and edit the Stat Enums, you will have to delete your accounts or create a converter tool.

Now to access your stats we have:
Code:
Public Function GetPlayerStat(ByVal Index As Long, ByVal Stat As Stats) As Long
    GetPlayerStat = Player(Index).Char(TempPlayer(Index).CharNum).Stat(Stat)
End Function

This function can get any stat you have.
Code:
GetPlayerStat(Index, Stats.NewStat)

VB6 has a little bit of intellisense and should automatically show a list of the Stat enums for you.

To set a stat we have
Code:
Public Sub SetPlayerStat(ByVal Index As Long, ByVal Stat As Stats, ByVal Value As Long)
    Player(Index).Char(TempPlayer(Index).CharNum).Stat(Stat) = Value
End Sub

A common use:
Code:
SetPlayerStat(Index, Stats.NewStat, GetPlayerStat(Index, Stats.NewStat + 5))

Let me know if you don't understand anything, or if i left something out.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)