#1 Help Hotfoot Run SilCORE
Posted: Fri Jan 01, 2010 10:36 pm
Okay, so I want to be able to run SilCORE through screenmonkey, but my coding skills have regressed to the point of suck.
Now the board has a good code for rolling SilCORE D6, but screenmonkey does not, and I was wondering if anyone could help me turn the following script into a SilCORE roller for screenmonkey.
Anyone?
Now the board has a good code for rolling SilCORE D6, but screenmonkey does not, and I was wondering if anyone could help me turn the following script into a SilCORE roller for screenmonkey.
Code: Select all
'Star Wars D6 Roller by theMagius
'Contact: theMagius@gmail.com
'For usage instructions, type "/roll help" in the chat window.
'Please report errors to theMagius@gmail.com
#register /jedi StarWarsD6
#register /sw StarWarsD6 Star Wars D6 by theMagius. Type "/roll help" to view help information.
' The format for the die rolls in Star Wars D6 is: <number>D<+><pip(s)>
'
' If the wild die rolls a 1, capture the highest-rolled number in the batch
' If the wild die rolls a 6, keep rolling it
'
' The total roll is <wild die> + <all other dice> + <pip(s)> - <die penalty>
Sub StarWarsD6()
On Error Resume Next
' local variables
cs = GetChatSession()
ci = cs.GetLastItem()
os = GetCurrentSession()
pc = GetCurrentPlayer()
' get last entered command
ci.Text = LCase(Ci.Text)
RollAction = 0
' if first five characters are help, user is requesting text info
ActionCheck = Left(ci.Text, 5)
If ActionCheck = " help" Then
RollAction = 2
End If
If RollAction = 2 Then
' if user requested help info, show info
ci.PlayerTo = ci.PlayerFrom
ci.Action = "requested help information for /sw"
ci.Text = "<DD>All <B>/sw</b> commands can also be called with <B>/jedi</B>."
ci.Text = ci.Text + "The format is: <i>1D</i>, <i>2D</i>, <i>1D+1</i>, <i>2D+1</i>, etc."
ElseIf RollAction = 0 Then
' else, if rolling dice
' find the D character in the string
DInd = inStr(ci.Text, "d")
' if the command was not formatted correctly, tell user
If DInd = 0 Then
ci.PlayerTo = ci.PlayerFrom
ci.Action = "attempted to use the /sw command"
ci.Text = "Invalid command."
Else
' find the + character in the string
PlusInd = inStr(ci.Text, "+")
If PlusInd >< 0 Then
ModInd = PlusInd
ModType = "+"
End If
' find the - character in the string
MinInd = inStr(ci.Text, "-")
If MinInd >< 0 Then
ModInd = MinInd
ModType = "-"
End If
' get the number of dice being rolled
MidLen = DInd - 1
DiceNum = Mid(ci.Text, 1, MidLen)
If ModInd >< 0 Then
' if there's a + or - in the die roll
' get the number of characters for the die type
MidLen = ModInd - 1 - DInd
Else
' else, we're just rolling a plain number
' get the number of characters for the die type
MidLen = Len(ci.Text) - DInd
End If
If ModInd >< 0 Then
' if there's a + or -
' capture the + or - modifier
MidLen = Len(ci.Text) - ModInd
MidStart = ModInd + 1
ModNum = Mid(ci.Text, MidStart, MidLen)
Else
' else, there's no + or -
ModNum = "0"
End If
' now that we've captured all the + and - numbers, set up the expression
Dice = CInt(DiceNum - 1) ' ???
SingleDie = "1d6"
Sides = 6
Penalty = 0
Tame = 0
Highest = 0
Modifier = CInt(ModNum)
If ModNum = "0" Then
Expression = DiceNum + "D" + SidesNum
End If
If ModNum >< "0" Then
Expression = DiceNum + "D" + SidesNum + ModType + ModNum
End If
' start with a fresh roll result line
ci.Text = ""
' no matter what, we ALWAYS roll a wild die
RollNow = EvalDice(SingleDie)
If RollNow = 1 Then
Penalty = 1
End If
AddTimes = 1
BestRoll = AddTimes * Sides
' continue rolling the wild die if it was a 6
Do While RollNow = BestRoll
If RollNow = BestRoll Then
RollNew = EvalDice(SingleDie)
RollNow = RollNow + RollNew
End If
AddTimes = AddTimes + 1
BestRoll = AddTimes * Sides
Loop
' keep track of what we rolled on the wild die
Wild = RollNow
' loop until all dice are rolled
Do While Dice > 0
' roll a single die, without any modifiers
ci.Text = ci.Text + " "
RollNow = EvalDice(SingleDie)
' mark off that a single die was rolled
Dice = Dice - 1
' keep track of the highest roll (for penalty purposes)
If RollNow > Highest Then
Highest = RollNow
End If
' update the total roll result
Tame = Tame + RollNow
Loop
' apply penalty if we rolled a 1 on the wild die
If Penalty = 1 Then
Tame = Tame - Highest
End If
' now that all the dice have been rolled and tallied, +/- any modifiers
If ModType = "+" Then
RollTotal = Wild + Tame + Modifier
ElseIf ModType = "-" Then
RollTotal = Wild + Tame - Modifier
Else
RollTotal = Wild + Tame
End If
' in case we went negative (2d case with high tame die)
If RollTotal < 1 Then
RollTotal = 1
End If
' print the original roll expression to the screen
ci.Action = "rolls " + Expression
ci.Text = ci.Text
' format the output line
' ci.Text = ci.Text + "Wild is: " + CStr(Wild)
' ci.Text = ci.Text + ", Tame is: " + CStr(Tame)
' ci.Text = ci.Text + ", Modifier is: " + CStr(Modifier)
' ci.Text = ci.Text + ", Highest is: " + CStr(Highest)
' ci.Text = ci.Text + ", Total is: " + CStr(RollTotal)
ci.Text = ci.Text + "(<font color=red>" + Cstr(Wild) + "</font>"
If Tame >< 0 Then
ci.Text = ci.Text + "+" + CStr(Tame)
End If
If Modifier >< 0 Then
If ModType = "+" Then
ci.Text = ci.Text + "+" + Cstr(Modifier)
Else
ci.Text = ci.Text + "-" + Cstr(Modifier)
End If
End If
if pc.isGM = True Then
ci.Text = ci.Text + ") <b><font color=green>=> " + Cstr(RollTotal) + " <=</font></b>"
Else
ci.Text = ci.Text + ") => <b>" + Cstr(RollTotal) + "</b>"
End If
End If
End If
End Sub