Heh... I was looking for an old thread, and found this one. Thought I would post some of my script:
Const vbsTrue = 1
Const vbsFalse = 0
Dim SS_HB, SD_HB, SC_HB
Dim SS_MB, SD_MB, SC_MB
Dim SS_BC, SD_BC, SC_BC
Dim SS_GS, SD_GS, SC_GS
Dim SS_AOR, SD_AOR, SC_AOR
Dim SS_Berserk, SD_Berserk, SC_Berserk
Function TimeDiff (StartTime, EndTime)
Dim Hours, Minutes, Seconds
Seconds = DateDiff("s", StartTime, EndTime)
If Seconds > 90000 Then Seconds = 90000
If Seconds < 0 Then Seconds = 0
Minutes = Seconds / 60
Minutes = Fix(Minutes)
Seconds = Seconds - (Minutes * 60)
Hours = Minutes / 60
Hours = Fix(Hours)
Minutes = Minutes - (Hours * 60)
Seconds = CStr(Seconds)
Minutes = CStr(Minutes)
Hours = CStr(Hours)
If Len(Seconds) = 1 Then Seconds = "0" + Seconds
If Len(Minutes) = 1 Then Minutes = "0" + Minutes
If Len(Hours) = 1 Then Hours = "0" + Hours
TimeDiff = Hours & ":" & Minutes & ":" & Seconds
End Function
Sub Grab_BodyClock (thename, theoutput, arrWildcards)
SS_BC = Now()
SC_BC = arrWildcards(2)
End Sub
Sub Display_End_BodyClock (thename, theoutput, arrWildcards)
Dim TimeStamp
If SS_BC <> Empty Then
SD_BC = TimeDiff(SS_BC, Now())
TimeStamp = " (" & SD_BC & " - " & SC_BC & ")."
End If
If World.GetVariable("InParty") Then
World.EchoInput = vbsFalse
World.Send "party emote no longer has a fastened body clock." & TimeStamp
Else
World.Note "END: Body Clock" & TimeStamp
End If
SS_BC = Empty
World.EchoInput = vbsTrue
End Sub
Sub Grab_GodShield (thename, theoutput, arrWildcards)
SS_GS = Now()
SC_GS = arrWildcards(2)
End Sub
Sub Display_End_Godshield (thename, theoutput, arrWildcards)
Dim TimeStamp
If SS_GS <> Empty Then
SD_GS = TimeDiff(SS_GS, Now())
TimeStamp = " (" & SD_GS & " - " & SC_GS & ")."
End If
If World.GetVariable("InParty") Then
World.EchoInput = vbsFalse
World.Send "party emote no longer has a Godshield." & TimeStamp
Else
World.Note "END: GodShield" & TimeStamp
End If
SS_GS = Empty
World.EchoInput = vbsTrue
End Sub
Sub Grab_HealthBlessing (thename, theoutput, arrWildcards)
Dim Minutes
SS_HB = Now()
SC_HB = arrWildcards(2)
If SD_HB <> Empty Then
Minutes = Mid(SD_HB, 4, 2)
Minutes = CInt(Minutes) - 3
World.AddTimer "Warning_HB_Timer", 0, Minutes, 0, "", 5, "Display_HealthBlessing_Warning"
End If
End Sub
Sub Display_End_HealthBlessing (thename, theoutput, arrWildcards)
Dim TimeStamp
FleeNow "Display_End_HealthBlessing", theoutput, arrWildcards
If SS_HB <> Empty Then
SD_HB = TimeDiff(SS_HB, Now())
TimeStamp = " (" & SD_HB & " - " & SC_HB & ")."
End If
If World.GetVariable("InParty") Then
World.EchoInput = vbsFalse
World.Send "party emote no longer has blessed health." & TimeStamp
Else
World.Note "END: Health Blessing" & TimeStamp
End If
SS_HB = Empty
World.EchoInput = vbsTrue
End Sub
Sub Display_HealthBlessing_Warning (TimerName)
If World.GetVariable("InParty") Then
World.EchoInput = vbsFalse
World.Send "party emote expects Health Blessing will drop within 3 minutes."
Else
World.Note "WARNING: Health Blessing will drop within 3 minutes."
End If
End Sub
I created the "TimeDiff" function, because I prefer to see an output of "hh:mm:ss", rather that just a count of seconds. Some spells last 30 minutes, and I don't want to be informed of it's length in seconds!
In my example, I use "SS_" for the Spell Start time, "SC_" for the Spell Caster name, and "SD_" for the Spell Done time.
The Health Blessing spell is special. It greatly increases your hit points. If it drops in battle, it can be lethal, so I call a "Fleenow" subroutine, which makes me leave the area if I was in combat. I also set up a timer, to fire 3 minutes before the spell will expire, as a warning World.Note. The script doesn't know how long the spell will last, it looks at "SD_HB", which is how long it lasted the last time the spell was cast. The variable gets reset everytime I load mushclient, so on the very first health blessing, I don't get a 3 minute warning, since "SD_HB" is empty that first time. Mostly, this is handy for killing a very large mob (that takes hours to kill), since the Health Blessing will usually come from the same healer, and thus the length of the cast is usually about the same.
My script sends the message to the party, IF I am in a party ("InParty"), otherwise, it just sends me a World.Note. "Inparty" in managed with other script, not posted here.
Hopefully, this example will give you some ideas on how to track time, and some of the fancier things you can do with that information. :) |