15-07-2008, 06:59 PM
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:
In the PlayerRec: Setup our array of stats and delete the old stat variables
Delete GetPlayerSTR, GetPlayerDEF, GetPlayerSpeed, GetPlayerMAGI and add the following
You pass in what stat you want and it returns it's value
Example of use:
Delete SetPlayerSTR, SetPlayerDEF, SetPlayerSpeed, SetPlayerMAGI and add the following
You pass in what stat to set the value to.
Example of use
LoadPlayer:
SavePlayer:
ClearChar
ClearPlayer
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 ?
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 ?