Do...While loops are usually a no-no in MUSHclient scripts. They stall the client until the loop is complete. (Nothing else is processed). You must use triggers to repeat actions.
Alias: ^autocrack[ ]?(.*)$
Regular Expression: Checked
Label: Autocrack
Script: Autocrack
Sub Autocrack (AliasName, AliasLine, arrWildcards)
If IsNumeric(Trim(arrWildcards(1))) Then
World.AddTimer "CrackItTimer", 0, CInt(Trim(arrWildcards(1))), 0, "", 5, ""
Call AttemptCrack "AutoCrack", Empty, Empty
Else
World.DeleteTimer "CrackItTimer"
World.Note "Crack Timer Deleted."
End If
End Sub
Alias: ^crackit[ ]?(.*)$
Regular Expression: Checked
Label: crackit
Script: CrackIt
Sub CrackIt (AliasName, AliasLine, arrWildcards)
Dim Code
Code = Trim(ArrWildcards(1))
If (NOT IsNumeric(Code)) OR (Len(Code)) <> 3 Then
Code = World.GetVariable("CrackItCode")
If Code = Empty Then Code = "111"
End If
World.SetVariable "CrackItCode", Code
Call AttemptCrack "CrackIt", Empty, Empty
End Sub
Sub Attempt_Crack (Triggername, TriggerLine, ArrWildcards)
Dim A,B,C
Dim Code
Code = World.GetVariable("CrackItCode")
If Code = Empty Then Code = "111"
If (Triggername = "CrackIt") OR (World.IsTimer("CrackItTimer") Then
A = Mid(Code, 1, 1)
B = Mid(Code, 2, 1)
C = Mid(Code, 3, 1)
World.Note "Trying: " & A & B & C
World.Send "TURN 1 TO " & A
World.Send "TURN 2 TO " & B
World.Send "TURN 3 TO " & C
World.Send "open safe"
C = CInt(C) + 1
If C > 9 Then
C = 1
B = CInt(B) + 1
End If
If B > 9 Then
B = 1
A = CInt(A) + 1
End If
If A > 9 Then
A = 1
B = 1
C = 1
End If
World.SetVariable "CrackItCode", CStr(A) & CStr(B) & CStr(C)
End If
End Sub
Trigger: THE SAFE IS LOCKED
Label: CrackFail
Script: Attempt_Crack
Whew, all of that written here from scratch, with no easy means of testing it.
Use "autocrack" alias to set the timer, OR to turn it off. If you supply a number, the timer will be on for that many minutes. (Change the addtimer line if you want to make it seconds instead). If you don't supply an argument, or if it's an illegal argument, the timer will be deleted. The alias will also start the cycle by making an attempt.
Use "crackit" alias to make a single attempt. With no argument (or illegal argument), it will try and continue from where it left off. (If it can't, it will reset to "111"). OR, if you choose, supply a three digit number to reset the cracking to that number. For example "crackit 111" will start from the beginning.
Build a trigger to fire on the failure message. This will call the "Attempt_Crack" routine, which checks to see if the timer is active. if so, it tries again, if not, it does nothing.
As I said, I haven't tested this. I think it's impossible to write script in one go without bugs, so let me know what problems you have, and I will try to advise fixes. |