Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Different way to do stats
#1
I wanted to do stats differently then the default setup so here's what i came up with:

I created an enum for my stats:
Code:
Public Enum Stats
    Strength = 1
    Defense
    Speed
    Magic
    ' Make sure Stat_Count is below everything else
    Stat_Count
End Enum

In the PlayerRec: Setup our array of stats and delete the old stat variables
Code:
Stat(1 To Stats.Stat_Count - 1) As Long

Delete GetPlayerSTR, GetPlayerDEF, GetPlayerSpeed, GetPlayerMAGI and add the following
You pass in what stat you want and it returns it's value
Code:
Public Function GetPlayerStat(ByVal Index As Long, ByVal Stat As Stats) As Long
    GetPlayerStat = Player(Index).Char(Player(Index).CharNum).Stat(Stat)
End Function

Example of use:
Code:
GetPlayerStat(Index, Stats.Strength)

Delete SetPlayerSTR, SetPlayerDEF, SetPlayerSpeed, SetPlayerMAGI and add the following
You pass in what stat to set the value to.
Code:
Public Sub SetPlayerStat(ByVal Index As Long, ByVal Stat As Stats, ByVal Value As Long)
    Player(Index).Char(Player(Index).CharNum).Stat(Stat) = Value
End Sub

Example of use
Code:
Call SetPlayerStat(Index, Stats.Strength, GetPlayerStat(Index, Stats.Strength) + 1)

LoadPlayer:
Code:
For n = 1 To Stats.Stat_Count - 1
    Get #nFileNum, , Player(Index).Char(i).Stat(n)
Next n

SavePlayer:
Code:
For n = 1 To Stats.Stat_Count - 1
    Put #nFileNum, , Player(Index).Char(i).Stat(n)
Next n

ClearChar
Code:
For n = 1 To Stats.Stat_Count - 1
        Player(Index).Char(CharNum).Stat(n) = 0
    Next n

ClearPlayer
Code:
For n = 1 To Stats.Stat_Count - 1
            Player(Index).Char(i).Stat(n) = 0
        Next n


I figure with this new method it would be easier to add / remove stats for a game.

This can also be used in ClassRec and NpcRec.

Any thoughts / comments / questions ?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)