Well... it's ugly but this is what I came up with.
Max Attribute is always 0 so don't need to generate a starting stat for it. This is to randomize the order stats get starting points rolled for so that it's not always biased in favor of the Index-order of the stats. I talked about it in chit-chat but now it's actual code.
This is just the part where I'm randomizing in the Indexes, not the rolling values for the stats part. This is what I was being vexxed by. It's orders of magnitude better than what I was doing but still probably absolutely the wrong way to do it.
What I'm trying to achieve is one and done rolling for stats (which calls this first).
It's returning 0 through 5 (MIN_ATTRIBUTE = 0, MAX_ATTRIBUTE - 1 = 5)
If someone can show me a better way I'd appreciate it.
Code:Public Function RandomizeAttributeIndexes() As Long() Dim m_Callstacker As New cCallStacker Dim nAttributeIndex(MIN_PLAYER_ATTRIBUTE To MAX_PLAYER_ATTRIBUTE - 1) As Long Dim fSuccess As Boolean Dim nRnd As Long Dim n As Long Dim m As Long ' Does not include Development which always starts at 0. m_Callstacker.Add NAME & ".RandomizeAttributeIndexes(Public Function)" For n = LBound(nAttributeIndex) To UBound(nAttributeIndex) nAttributeIndex(n) = -1 Next n Do fSuccess = True For n = LBound(nAttributeIndex) To UBound(nAttributeIndex) nRnd = RollDie(MAX_PLAYER_ATTRIBUTE - MIN_PLAYER_ATTRIBUTE) - 1 If nAttributeIndex(n) = -1 Then For m = LBound(nAttributeIndex) To UBound(nAttributeIndex) If nAttributeIndex(m) = nRnd Then fSuccess = False Exit For End If Next m If fSuccess Then nAttributeIndex(n) = nRnd End If Next n Loop Until fSuccess For n = LBound(nAttributeIndex) To UBound(nAttributeIndex) Debug.Print "nAttributeIndex(" & n & ") = " & nAttributeIndex(n) Next n RandomizeAttributeIndexes = nAttributeIndex Stop End Function




Reply With Quote