Okay so this is my first source tutorial and I’m sure there is a better way to do this so if there is please feel free to touch it up. What this will do is create a button that generators numbers for all stats, HP, damage, and experience based off of the NPC’s level. I have even included a way to check and see if the NPC is a boss so the stats generated are higher then a normal NPC. Please be aware that the numbers generated are not to be used as is. I just kind of came up with the equations as I made this system so tweaking will most likely need to be done.

Alright this is all client side.

First, open up frmEditor_NPC. Anywhere in the code add this:

``````
Public Function RandomNumber(ByVal MaxValue As Long, Optional _
ByVal MinValue As Long = 0)

On Error Resume Next
Randomize Timer
RandomNumber = Int((MaxValue - MinValue + 1) * Rnd) + MinValue

End Function
``````

This makes it so we can use RandomNubmer(High, Low).

Next make a button on frmEditor_NPC, it can be anywhere but I put it next to the stat selection area. Name it Genstats and set the caption to something like Generate Stats. After that make a checkbox and name it chkBossName, then set the caption to something like Boss. Once all that is taken care of go back to object view and click on the Generate Stats button you made a bit ago and insert this:

``````
Private Sub Genstats_Click()
Dim High As Long
Dim Low As Long
Dim HighExp
Dim LowExp
Dim HighHP
Dim LowHP
Dim HighDam
Dim LowDam

'If not a Boss set stats as normal. This is where you change the equations for stats.
If chkBossName.Value = 0 Then
High = (txtLevel + 4)
Low = (txtLevel - 4)
HighExp = (txtLevel * 5 + 2)
LowExp = (txtLevel * 5 - 2)
HighHP = (txtLevel * 10 + 3)
LowHP = (txtLevel * 10 - 3)
HighDam = (txtLevel + 4)
LowDam = (txtLevel - 4)
End If

' Is a Boss set stats a bit higher then normal. This is where you change the equations for stats.
If chkBossName.Value = 1 Then
High = (txtLevel + 10)
Low = (txtLevel + 4)
HighExp = (txtLevel * 8 + 6)
LowExp = (txtLevel * 8 + 2)
HighHP = (txtLevel * 15 + 3)
LowHP = (txtLevel * 15 - 3)
HighDam = (txtLevel + 4)
LowDam = (txtLevel - 4)
End If

' Check so there are no stats below 0\. Then sets stats based on NPC Level.
If Low <= 0 Then
scrlStat(1).Value = RandomNumber(High, 0)
scrlStat(2).Value = RandomNumber(High, 0)
scrlStat(3).Value = RandomNumber(High, 0)
scrlStat(4).Value = RandomNumber(High, 0)
scrlStat(5).Value = RandomNumber(High, 0)
txtEXP.text = RandomNumber(HighExp, LowExp)
txtHP.text = RandomNumber(HighHP, LowHP)
txtDamage.text = RandomNumber(HighDam, 2)
End If

' Sets stats based on NPC Level.
If Low >= 0 Then
scrlStat(1).Value = RandomNumber(High, Low)
scrlStat(2).Value = RandomNumber(High, Low)
scrlStat(3).Value = RandomNumber(High, Low)
scrlStat(4).Value = RandomNumber(High, Low)
scrlStat(5).Value = RandomNumber(High, Low)
txtEXP.text = RandomNumber(HighExp, LowExp)
txtHP.text = RandomNumber(HighHP, LowHP)
txtDamage.text = RandomNumber(HighDam, LowDam)
End If

End Sub
``````

After that just save and compile. I think this should work on just about all versions of Eclipse and like I said, if there is a better way to do this just post it here. I’m always happy to learn more. I feel like I explained pretty well how everything works but if anyone has any questions just post them.