<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, November 06, 2002, 6:28 PM -->
<!-- MuClient version 3.30 -->

<!-- Plugin "EQHit" generated by Plugin Wizard -->

<muclient>
<plugin
   name="EQHit"
   author="Poromenos"
   id="08d3ee119e16e3920c423b42"
   language="VBscript"
   purpose="Counts hits on your equipment and alerts you on demand"
   save_state="y"
   date_written="2002-11-06 18:26:31"
   requires="3.30"
   version="1.3"
   >
<description trim="y">
<![CDATA[
------------------============== Reference ==============------------------
SUMMARY:
EQHit is designed to help you minimize equipment loss from damages during
battle. It logs all damage to your eq and optionally notifies you when to
remove the piece of eq that is about to scrap. This plugin is designed for
the Realms of Despair MUD, but it can probably be customized for other MUDs
very easily.

HINTS & TIPS:
Sometimes, the plugin will produce errors. This will usually happen when
MUSHClient crashes or in some other special cases, where the script will no
longer load normally. You can try these steps to get it to work:
Type "EQHit:Reset"
"Reinstall" the plugin
Type "EQHit:Reset"
Type "EQHit:ReadEQ"
Type "EQHit:ShowReport"

If that works, you're done. If it doesn't, try the above steps again, but
this time type "EQHit:DeleteAll" before reinstalling the script. This will
delete all your data though, so use it only as a last resort.

Sometimes, the plugin will log eq whenever you look at other characters or
when you look at yourself. If this happens, use the "EQHit:ReadEQ" command
a few times until it is fixed. I do not know yet what causes this, as there
is no reason why this should happen.

COMMAND REFERENCE:
EQHit:AddItem <name>; <AC>; <Alarm>; <Hits>
    Adds an item to the list. Case does not matter, but make sure there are
    no spelling mistakes in the name. AC is the armor class of the object,
    Alarm is the number of hits you want the program to alert you on,
    (should be less than AC), and Hits is the current number of hits an
    item has. If the item exists it will be replaced.
EQHit:AlarmItem <Item #>; <AC>; <Alarm>
    Item # is the number of the item as shown in EQHit:ShowReport, AC is
    the AC, and Alarm is the alarm.
EQHit:DeleteAll
    Deletes the entire DB (the ForceSave and ForceLoad function DB). It has
    no effect on the current DB, and if you want to delete the entire DB
    you have to use EQHit:Reset after this command.
EQHit:EditItem <item #>; <AC>; <alarm>; <hits>; <total>; <repairs>; <gold>
    Item # is the number of the item as shown in EQHit:ShowReport, AC is
    the AC, Alarm, Hits, Total is the total number of hits the item has
    taken in its lifetime, Repairs is the number of times you repaired it,
    and Gold is the total amount of money you spent repairing it.
EQHit:ExportDB <filename>
    Exports the equipment database to a file (only name, AC and alarm), so
    that you can import it to other characters.
EQHit:ForceLoad
    Loads the database from the save space.
EQHit:ForceSave
    Saves the database to the save space (use after changes).
EQHit:ImportDB <filename>
    Imports item name, AC and alarm from a previously exported file.
EQHit:ReadEQ
    Reads the EQ you are currently wearing and saves it in the database.
EQHit:RemoveItem <item number>
    Removes the item under that number.
EQHit:RepairAll
    Sets all items' hits to 0.
EQHit:Reset
    Clears the database. The database will be restored when you reopen the
    world of when you use EQHit:ForceLoad, even if you use EQHit:ForceSave
    before loading. The only way to clear it permanently is to use
    EQHit:DeleteAll and EQHit:Reset
EQHit:ResetItem
    Clears an item's details, leaving only its AC and Alarm. Use this if you
    no longer use an item but still want to keep it in the database for use
    in the future.
EQHit:ShowAll
    Shows a comprehensive report of EQ damage, AC, Alarm, etc. The report
    is too big to fit on some screens, but unfortunately all the info in it
    is necessary.
EQHit:ShowReport
    Shows only items that have damage on them. Use EQHit:ShowAll to see the
    entire database.
EQHit:ShowDetails <item number>
    Shows an item's details in expanded form.
EQHit:ShowReportOld
    Shows the old-style report. No colors, use in the unlikely event that
    the normal report has a problem.

OPERATION:
  EQHit logs all damage to your eq and notifies you when the number of hits
is equal to or more than the number you have specified in the Alarm field.
When you repair your equipment, the plugin understands it and automatically
sets the item's hits to 0, increments the number of repairs by 1 and the
gold you have spent by the amount of gold the repairman charged you.
  If an item scraps, EQHit will recognize it and alert you, and it will
reset the item's Hits, Total hits, Repairs and Gold.

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.vbs"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="(type 'garb' for a list of all wear locations)"
   name="ProcessEnd"
   script="subChecking"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   keep_evaluating="y"
   match="&lt;*&gt; *"
   name="ProcessEQ"
   omit_from_output="y"
   script="subProcessEQ"
   sequence="1"
  >
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="* falls to the ground in scraps!"
   omit_from_output="y"
   match_text_colour="y"
   text_colour="10"
   script="subScrapEQ"
   send_to="5"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="n"
   keep_evaluating="y"
   match="*You are using:"
   name="ProcessStart"
   omit_from_output="y"
   match_text_colour="y"
   text_colour="9"
   script="subChecking"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="* charges you * gold piec* to repair *."
   script="subRepairItem"
   sequence="100"
  >
  </trigger>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="(* gets damaged)"
   omit_from_output="y"
   match_text_colour="y"
   text_colour="10"
   script="subAddDamage"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   script="subAddItem"
   match="^EQHit:AddItem[ ]+(.*?);[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)$"
   enabled="y"
   regexp="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subAlarmItem"
   match="^EQHit\:AlarmItem[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)$"
   enabled="y"
   regexp="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subDeleteAll"
   match="EQHit:DeleteAll"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subEditItem"
   match="^EQHit:EditItem[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)\;[ ]+(\d+)$"
   enabled="y"
   regexp="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subExportDB"
   match="EQHit:ExportDB *"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subForceLoad"
   match="EQHit:ForceLoad"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subForceSave"
   match="EQHit:ForceSave"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subImportDB"
   match="EQHit:ImportDB *"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subReadEQ"
   match="EQHit:ReadEQ"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subRemoveItem"
   match="^EQHit:RemoveItem[ ]+(\d+)$"
   regexp="y"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subRepairAll"
   match="EQHit:RepairAll"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subReset"
   match="EQHit:Reset"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subResetItem"
   match="^EQHit:ResetItem[ ]+(\d+)$"
   regexp="y"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subShowAll"
   match="EQHit:ShowAll"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subShowDetails"
   match="^EQHit:ShowDetails[ ]+(\d+)$"
   regexp="y"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subShowReport"
   match="EQHit:ShowReport"
   enabled="y"
   ignore_case="y"
  >
  </alias>
  <alias
   script="subShowReportOld"
   match="EQHit:ShowReportOld"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

' EQ Table Format:
' -----------------------------------------------------------------
' |  0   |  1   |    2    |   3    |    4    |     5     |   6    |
' -----------------------------------------------------------------
' | Name |  AC  |  Alarm  |  Hits  |  Total  |  Repairs  |  Cost  |
' -----------------------------------------------------------------



Dim strEQTable()
Const constTableItems = 7

Sub subRepairAll (strName, strLine, strWildcards)
    Dim intCounter

    For intCounter = 0 to UBound(strEQTable, 2)
        strEQTable(3, intCounter) = 0
    Next
    World.Note "EQHit: All items on the database were repaired."
End Sub

Sub subRepairItem (strName, strLine, strWildcards)
    Dim intNextSpot
    Dim intItemNumber

    intItemNumber = fnFindItem(strWildcards(4))
    If intItemNumber >= 0 Then
        strEQTable(3, intItemNumber) = 0
        strEQTable(5, intItemNumber) = Int(strEQTable(5, intItemNumber)) + 1
        strEQTable(6, intItemNumber) = Int(strEQTable(6, intItemNumber)) + Int(strWildcards(2))
    End If
End Sub

Sub subSaveArray
    Dim intCounter
    Dim strContents
    Dim intArrayCounter

    For intCounter = 0 to UBound(strEQTable, 2)
        strContents = strEQTable(0, intCounter)
        For intArrayCounter = 1 to constTableItems
            strContents = strContents & "|" & strEQTable(intArrayCounter, intCounter)
        Next
        world.SetVariable "EQHit_Item_" & intCounter, strContents
    Next
End Sub

Sub subDeleteAll (strName, strLine, strWildcards)
    Dim intCounter

    World.Note "EQHit: If you weren't sure about this, it's too late... Here goes..."
    intCounter = 0
    Do
        If World.DeleteVariable ("EQHit_Item_" & intCounter) = 30019 Then
            Exit Do
        Else
            intCounter = intCounter + 1
        End If
    Loop
    World.Note "EQHit: All items deleted from the database!"
End Sub

Sub OnPluginConnect
    If UBound(strEQTable, 2) = 0 And strEQTable(0, 0) = "" Then
        World.Note "EQHit: Adding player's equipment..."
        World.EnableTrigger "ProcessStart", True
        World.Send "equipment"
    End If
End Sub

Sub OnPluginInstall
    subLoadArray
End Sub

Sub OnPluginSaveState
    subSaveArray
End Sub

Sub subLoadArray
    Dim intCounter
    Dim strContents
    Dim intArrayCounter
    Dim intLetterCounter
    Dim intBackup

    Redim strEQTable(constTableItems, 0)
    intCounter = 0
    intBackup = 0
    Do
        intArrayCounter = 0
        intLetterCounter = 1
        strContents = World.GetVariable ("EQHit_Item_" & intCounter)
        If IsEmpty (strContents) Then Exit Do
        If Left(strContents, 1) = "|" Then
            intCounter = intCounter + 1
        ElseIf fnFindItem(Left(strContents, InStr(1, strContents, "|") - 1)) > -1 Then
            intCounter = intCounter + 1
        Else
            Redim Preserve strEQTable(constTableItems, intBackup)
            Do Until intArrayCounter = constTableItems
                If Mid(strContents, intLetterCounter, 1) <> "|" Then
                    strEQTable(intArrayCounter, intBackup) = strEQTable(intArrayCounter, intBackup) & Mid(strContents, intLetterCounter, 1)
                Else
                    intArrayCounter = intArrayCounter + 1
                End If
                intLetterCounter = intLetterCounter + 1
            Loop
            intCounter = intCounter + 1
            intBackup = intBackup + 1
        End If
    Loop
End Sub

Sub subAddDamage (strName, strLine, strWildcards)
    Dim intItemNumber
    Dim strColor

    World.InfoClear
    world.InfoColour "red"
    world.InfoFont "Arial", 10, 1

    intItemNumber = fnFindItem(strWildcards(1))
    If intItemNumber >= 0 Then
        strEQTable(3, intItemNumber) = strEQTable(3, intItemNumber) + 1
        strEQTable(4, intItemNumber) = strEQTable(4, intItemNumber) + 1
        If Int(strEQTable(2, intItemNumber)) = 0 Then
            World.ColourNote "chartreuse", "", "(" & strWildcards(1) & " gets damaged and has taken " & strEQTable(3, intItemNumber) & " hits)"
        ElseIf Int(strEQTable(3, intItemNumber)) >= Int(strEQTable(2, intItemNumber)) Then
            World.ColourNote "red", "", "(" & UCase(strWildcards(1)) & " IS ABOUT TO SCRAP!!! " & strEQTable(3, intItemNumber) & "/" & strEQTable(1, intItemNumber) & " HITS!!!)"
            World.Info UCase(strWildcards(1)) & " HAS TAKEN " & strEQTable(3, intItemNumber) & _
            " HITS OUT OF A MAXIMUM OF " & strEQTable(1, intItemNumber) & " AND IS ABOUT TO SCRAP!!!"
        Else
            World.ColourNote "chartreuse", "", "(" & strWildcards(1) & " gets damaged and has " & strEQTable(3, intItemNumber) & "/" & strEQTable(1, intItemNumber) & " hits)"
        End if
    Else
        world.note "Item does not exist, adding..."
        subAddEQ strWildcards(1), 0, 0, 1, 1
    End If
End Sub

Sub subScrapEQ (strName, strLine, strWildcards)
    Dim intItemNumber

    World.InfoClear
    world.InfoColour "red"
    world.InfoFont "Arial", 10, 1

    intItemNumber = fnFindItem(strWildcards(1))
    If intItemNumber >= 0 Then
        World.ColourNote "red", "", strWildcards(1) & " has taken " & Int(strEQTable(3, intItemNumber)) & " hits and falls to the ground in scraps!"
        World.Info strWildcards(1) & " has taken " & Int(strEQTable(3, intItemNumber)) & " hits and scrapped!"
        strEQTable(3, intItemNumber) = 0
        strEQTable(4, intItemNumber) = 0
        strEQTable(5, intItemNumber) = 0
        strEQTable(6, intItemNumber) = 0
    Else
        world.note "Item does not exist, adding..."
        subAddEQ strWildcards(1), 0, 0, 0, 0
    End If
End Sub

Sub subForceSave (strName, strLine, strWildcards)
    SaveState
    World.Note "Database saved..."
End Sub

Sub subForceLoad (strName, strLine, strWildcards)
    subLoadArray
    World.Note "Database loaded..."
End Sub

Sub subShowReportOld (strName, strLine, strWildcards)
    Dim intCounter
    Dim lngTotals(7)
    Dim intCounter2

    World.Note "-------------------------------==================== EQHit  Report ====================-------------------------------"
    World.Note "| ### | Name                                                         |  AC |  Al |  Hts |  Ttl  |  Rpr  | Total Cst |"
    World.Note "---------------------------------------------------------------------------------------------------------------------"

    For intCounter = 0 to UBound(strEQTable, 2)
        If Trim(strEQTable(0, intCounter)) <> "" Then
            World.note "| " & fnSpacePad(intCounter, 3, True) & " | " & fnSpacePad(strEQTable(0, intCounter), 60, False) & _
            " | " & fnSpacePad(strEQTable(1, intCounter), 3, True) & " | " & fnSpacePad(strEQTable(2, intCounter), 3, True) & _
            " | " & fnSpacePad(strEQTable(3, intCounter), 4, True) & " | " & fnSpacePad(strEQTable(4, intCounter), 5, True) & _
            " | " & fnSpacePad(strEQTable(5, intCounter), 5, True) & " | " & fnSpacePad(strEQTable(6, intCounter), 9, True) & " |"
        End If
        For intCounter2 = 3 to constTableItems
            lngTotals(intCounter2) = Int(lngTotals(intCounter2)) + Int(strEQTable(intCounter2, intCounter))
        Next
    Next
    World.Note "---------------------------------------------------------------------------------------------------------------------"
    World.Note "| Ttl |                                                              |     |     | " & _
         fnSpacePad(lngTotals(3), 4, True) & " | " & fnSpacePad(lngTotals(4), 5, True) & " | " & _
         fnSpacePad(lngTotals(5), 5, True) & " | " & fnSpacePad(lngTotals(6), 9, True) & " |"
    World.Note "---------------------------------------------------------------------------------------------------------------------"
End Sub

Sub subExportDB (strName, strLine, strWildcards)
    Dim objFileObject
    Dim hndFileHandle
    Dim intCounter
    Dim strContents
    Dim intArrayCounter

    Set objFileObject = CreateObject("Scripting.FileSystemObject")
    Set hndFileHandle = objFileObject.CreateTextFile(Trim(strWildcards(1)), True)

    For intCounter = 0 to UBound(strEQTable, 2)
        strContents = strEQTable(0, intCounter)
        For intArrayCounter = 1 to 2
            strContents = strContents & "|" & strEQTable(intArrayCounter, intCounter)
        Next
        hndFileHandle.WriteLine strContents & "|"
    Next

    hndFileHandle.Close
    World.Note "EQHit: Database successfully exported to " & Trim(strWildcards(1)) & "."
End Sub

Sub subImportDB (strName, strLine, strWildcards)
    On Error Resume Next

    Dim objFileObject
    Dim hndFileHandle
    Dim intCounter
    Dim strContents
    Dim intItemPos
    Dim intArrayCounter
    Dim intLetterCounter

    Set objFileObject = CreateObject("Scripting.FileSystemObject")
    Set hndFileHandle = objFileObject.OpenTextFile(Trim(strWildcards(1)), 1, False)

    If Err.Number <> 0 Then
        World.Note "EQHit: File not found!"
        Exit Sub
    End If

    intCounter = UBound(strEQTable, 2) + 1
    Do While hndFileHandle.AtEndOfStream <> True
        intArrayCounter = 0
        intItemPos = 0
        intLetterCounter = 1
        strContents = hndFileHandle.ReadLine
        If Trim(strContents) <> "" Then
            If Left(strContents, 1) <> "|" Then
                intItemPos = fnFindItem(Left(strContents, InStr(1, strContents, "|") - 1))
                If intItemPos < 0 Then
                    Redim Preserve strEQTable(constTableItems, intCounter)
                    Do Until intArrayCounter = 3
                        If Mid(strContents, intLetterCounter, 1) <> "|" Then
                            strEQTable(intArrayCounter, intCounter) = strEQTable(intArrayCounter, intCounter) & Mid(strContents, intLetterCounter, 1)
                        Else
                            intArrayCounter = intArrayCounter + 1
                        End If
                        intLetterCounter = intLetterCounter + 1
                    Loop
                    If strEQTable(3, intCounter) = "" Then strEQTable(3, intCounter) = 0
                    If strEQTable(4, intCounter) = "" Then strEQTable(4, intCounter) = 0
                    If strEQTable(5, intCounter) = "" Then strEQTable(5, intCounter) = 0
                    If strEQTable(6, intCounter) = "" Then strEQTable(6, intCounter) = 0                    
                    intCounter = intCounter + 1
                Else
                    strEQTable(0, intItemPos) = ""
                    strEQTable(1, intItemPos) = ""
                    strEQTable(2, intItemPos) = ""
                    Do
                        If Mid(strContents, intLetterCounter, 1) <> "|" Then
                            strEQTable(intArrayCounter, intItemPos) = strEQTable(intArrayCounter, intItemPos) & Mid(strContents, intLetterCounter, 1)
                        Else
                            intArrayCounter = intArrayCounter + 1
                        End If
                        intLetterCounter = intLetterCounter + 1
                    Loop Until intArrayCounter = 3
                    If strEQTable(3, intItemPos) = "" Then strEQTable(3, intItemPos) = 0
                    If strEQTable(4, intItemPos) = "" Then strEQTable(4, intItemPos) = 0
                    If strEQTable(5, intItemPos) = "" Then strEQTable(5, intItemPos) = 0
                    If strEQTable(6, intItemPos) = "" Then strEQTable(6, intItemPos) = 0
                End If
            End If
        End If
    Loop
    World.Note "EQHit: Database successfully imported from " & Trim(strWildcards(1)) & "."
    hndFileHandle.Close
End Sub

Sub subShowReport (strName, strLine, strWildcards)
    Dim intCounter
    Dim blnItemShown
    Dim lngTotals(7)
    Dim intCounter2
    Dim strColor

    World.Note "-------------------------------==================== EQHit  Report ====================-------------------------------"
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " ### "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " Name                                                         "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  AC "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Al "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Hts "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Ttl  "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Rpr  "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " Total Cst "
    World.ColourTell "silver", "", "|" & vbCrLf
    World.Note "---------------------------------------------------------------------------------------------------------------------"

    For intCounter = 0 to UBound(strEQTable, 2)
        If Trim(strEQTable(0, intCounter)) <> "" And Int(strEQTable(3, intCounter)) <> 0 Then

            If strEQTable(1, intCounter) <> 0 Then
                If Int(strEQTable(3, intCounter)) >= Int(strEQTable(2, intCounter)) Then
                    strColor = "red"
                ElseIf Int(strEQTable(3, intCounter)) > (Int(strEQTable(2, intCounter)) / 2) Then
                    strColor = "darkorange"
                ElseIf Int(strEQTable(3, intCounter)) > 0 Then
                    strColor = "yellow"
                Else
                    strColor = "chartreuse"
                End If
            Else
                strColor = "silver"
            End If

            blnItemShown = True

            World.ColourTell "silver", "", "| "
            World.ColourTell strColor, "", fnSpacePad(intCounter, 3, True)
            World.ColourTell "silver", "",  " | "
            World.Hyperlink "!!08d3ee119e16e3920c423b42:subCallDetails(" & CStr(intCounter) &")", strEQTable(0, intCounter), "Show item details on """ & strEQTable(0, intCounter) & """", strColor, "" , 0
            World.ColourTell strColor, "", fnSpaces(strEQTable(0, intCounter), 60)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(1, intCounter), 3, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(2, intCounter), 3, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(3, intCounter), 4, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(4, intCounter), 5, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(5, intCounter), 5, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(6, intCounter), 9, True)
            World.ColourTell "silver", "", " |" & vbCrLf
            For intCounter2 = 3 to constTableItems
                lngTotals(intCounter2) = Int(lngTotals(intCounter2)) + Int(strEQTable(intCounter2, intCounter))
            Next
        End If
    Next

    If blnItemShown Then
        World.Note "---------------------------------------------------------------------------------------------------------------------"
        World.ColourTell "silver", "", "| "
        World.ColourTell "chartreuse", "", "Ttl"
        World.ColourTell "silver", "", " |                                                              |     |     | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(3), 4, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(4), 5, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(5), 5, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(6), 9, True)
        World.ColourTell "silver", "", " |" & vbCrLf
        World.Note "---------------------------------------------------------------------------------------------------------------------"
    Else
        World.Note "|                                                                                                                   |"
        World.ColourTell "silver", "", "|                                "
        World.ColourTell "chartreuse", "",  "There are no damaged items to display at this time."
        World.ColourTell "silver", "", "                                |" & vbCrLf
        World.Note "|                                                                                                                   |"
        World.Note "---------------------------------------------------------------------------------------------------------------------"
    End If
End Sub

Sub subShowAll (strName, strLine, strWildcards)
    Dim intCounter
    Dim lngTotals(7)
    Dim intCounter2
    Dim strColor

    World.Note "-------------------------------==================== EQHit  Report ====================-------------------------------"
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " ### "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " Name                                                         "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  AC "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Al "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Hts "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Ttl  "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", "  Rpr  "
    World.ColourTell "silver", "", "|"
    World.ColourTell "chartreuse", "", " Total Cst "
    World.ColourTell "silver", "", "|" & vbCrLf
    World.Note "---------------------------------------------------------------------------------------------------------------------"

    For intCounter = 0 to UBound(strEQTable, 2)
        If Trim(strEQTable(0, intCounter)) <> "" Then

            If strEQTable(1, intCounter) <> 0 Then
                If Int(strEQTable(3, intCounter)) >= Int(strEQTable(2, intCounter)) Then
                    strColor = "red"
                ElseIf Int(strEQTable(3, intCounter)) > (Int(strEQTable(2, intCounter)) / 2) Then
                    strColor = "darkorange"
                ElseIf Int(strEQTable(3, intCounter)) > 0 Then
                    strColor = "yellow"
                Else
                    strColor = "chartreuse"
                End If
            Else
                strColor = "silver"
            End If

            World.ColourTell "silver", "", "| "
            World.ColourTell strColor, "", fnSpacePad(intCounter, 3, True)
            World.ColourTell "silver", "",  " | "
            World.Hyperlink "!!08d3ee119e16e3920c423b42:subCallDetails(" & CStr(intCounter) &")", strEQTable(0, intCounter), "Show item details on """ & strEQTable(0, intCounter) & """", strColor, "" , 0
            World.ColourTell strColor, "", fnSpaces(strEQTable(0, intCounter), 60)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(1, intCounter), 3, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(2, intCounter), 3, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(3, intCounter), 4, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(4, intCounter), 5, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(5, intCounter), 5, True)
            World.ColourTell "silver", "", " | "
            World.ColourTell strColor, "", fnSpacePad(strEQTable(6, intCounter), 9, True)
            World.ColourTell "silver", "", " |" & vbCrLf
            For intCounter2 = 3 to constTableItems
                lngTotals(intCounter2) = Int(lngTotals(intCounter2)) + Int(strEQTable(intCounter2, intCounter))
            Next
        End If
    Next
        World.Note "---------------------------------------------------------------------------------------------------------------------"
        World.ColourTell "silver", "", "| "
        World.ColourTell "chartreuse", "", "Ttl"
        World.ColourTell "silver", "", " |                                                              |     |     | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(3), 4, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(4), 5, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(5), 5, True)
        World.ColourTell "silver", "", " | "
        World.ColourTell "chartreuse", "", fnSpacePad(lngTotals(6), 9, True)
        World.ColourTell "silver", "", " |" & vbCrLf
        World.Note "---------------------------------------------------------------------------------------------------------------------"
End Sub

Function fnSpacePad (strWord, intSpaces, blnInBeginning)
    Dim intCounter

    If intSpaces - Len(strWord) < 1 Then
        fnSpacePad = strWord
        Exit Function
    End If

    If blnInBeginning Then
        fnSpacePad = String(intSpaces - Len(strWord), " ") & strWord
    Else
        fnSpacePad = strWord & String(intSpaces - Len(strWord), " ")
    End If
End Function

Function fnSpaces (strWord, intSpaces)
    Dim intCounter

    If intSpaces - Len(strWord) < 1 Then
        fnSpaces = ""
        Exit Function
    End If

    fnSpaces = String(intSpaces - Len(strWord), " ")
End Function

Sub subReset (strName, strLine, strWildcards)
    World.InfoClear
    World.InfoColour "red"
    World.InfoFont "Arial", 10, 1
    Redim strEQTable(constTableItems, 0)
    World.Note "EQHit: Database cleared, type 'EQHit:ForceLoad' to reload."
End Sub

Function fnFindItem (strItemName)
    Dim intCounter

    For intCounter = 0 to UBound(strEQTable, 2)
        If UCase(strEQTable(0, intCounter)) = UCase(strItemName) Then
            fnFindItem = intCounter
            Exit Function
        End IF
    Next
    fnFindItem = -1
End Function

Sub subChecking (strName, strLine, strWildcards)
    If UCase(strName) = "PROCESSSTART" Then
        World.EnableTrigger "ProcessEQ", True
    Else
        World.EnableTrigger "ProcessEQ", False
        World.EnableTrigger "ProcessStart", False
    End If
End Sub

Sub subAddEQ (strName, intAC, intAlarm, intHits, intTotal)
    Dim intNextSpot
    strName=Trim(strName)
    If Lcase(strName) = "something" then Exit Sub
    If fnFindItem(strName) > -1 Then
        World.Note "EQHit: Item Found in Database, skipping..."
    Else
        intNextSpot = fnFindNextSpot
        strEQTable(0, intNextSpot) = strName
        strEQTable(1, intNextSpot) = intAC
        strEQTable(2, intNextSpot) = intAlarm
        strEQTable(3, intNextSpot) = intHits
        strEQTable(4, intNextSpot) = intTotal
        strEQTable(5, intNextSpot) = 0
        strEQTable(6, intNextSpot) = 0
        World.Note "EQHit: Added EQ: " & strName & ", " & intAC & ", " & intAlarm & ", " & intHits & " to " & intNextSpot
    End If
End Sub

Sub subAddItem (strName, strOutput, strWildcards)
    Dim intNextSpot

    If Lcase(strWildcards(1)) = "something" then Exit Sub
    intNextSpot = fnFindItem(Trim(strWildcards(1)))
    If fnFindItem(Trim(strWildcards(1))) > -1 Then
        World.Note "EQHit: Item was found, changed properties."
        strEQTable(0, intNextSpot) = Trim(strWildcards(1))
        strEQTable(1, intNextSpot) = Int(Trim(strWildcards(2)))
        strEQTable(2, intNextSpot) = Int(Trim(strWildcards(3)))
        strEQTable(3, intNextSpot) = Int(Trim(strWildcards(4)))
        strEQTable(4, intNextSpot) = 0
        strEQTable(5, intNextSpot) = 0
        strEQTable(6, intNextSpot) = 0
    Else
        subAddEQ strWildcards(1), strWildcards(2), strWildcards(3), strWildcards(4), 0
    End If
End Sub

Sub subEditItem (strName, strOutput, strWildcards)
    If Int(strWildcards(1)) > UBound(strEQTable, 2) Or Int(strWildcards(1)) < 0 Or Trim(strEQTable(0, Int(strWildcards(1)))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        strEQTable(1, Int(strWildcards(1))) = Int(Trim(strWildcards(2)))
        strEQTable(2, Int(strWildcards(1))) = Int(Trim(strWildcards(3)))
        strEQTable(3, Int(strWildcards(1))) = Int(Trim(strWildcards(4)))
        strEQTable(4, Int(strWildcards(1))) = Int(Trim(strWildcards(5)))
        strEQTable(5, Int(strWildcards(1))) = Int(Trim(strWildcards(6)))
        strEQTable(6, Int(strWildcards(1))) = Int(Trim(strWildcards(7)))
        World.Note "EQHit: Item edited."
    End If
End Sub

Sub subResetItem (strName, strOutput, strWildcards)
    If Int(strWildcards(1)) > UBound(strEQTable, 2) Or Int(strWildcards(1)) < 0 Or Trim(strEQTable(0, Int(strWildcards(1)))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        strEQTable(3, Int(strWildcards(1))) = 0
        strEQTable(4, Int(strWildcards(1))) = 0
        strEQTable(5, Int(strWildcards(1))) = 0
        strEQTable(6, Int(strWildcards(1))) = 0
        World.Note "EQHit: Item reset."
    End If
End Sub

Sub subAlarmItem (strName, strOutput, strWildcards)
    If Int(strWildcards(1)) > UBound(strEQTable, 2) Or Int(strWildcards(1)) < 0 Or Trim(strEQTable(0, Int(strWildcards(1)))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        strEQTable(1, Int(strWildcards(1))) = Int(Trim(strWildcards(2)))
        strEQTable(2, Int(strWildcards(1))) = Int(Trim(strWildcards(3)))
        World.Note "EQHit: Item updated."
    End If
End Sub

Sub subRemoveItem (strName, strOutput, strWildcards)
    If Int(strWildcards(1)) > UBound(strEQTable, 2) Or Int(strWildcards(1)) < 0 Or Trim(strEQTable(0, Int(strWildcards(1)))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        strEQTable(0, Int(strWildcards(1))) = ""
        strEQTable(1, Int(strWildcards(1))) = ""
        strEQTable(2, Int(strWildcards(1))) = ""
        strEQTable(3, Int(strWildcards(1))) = ""
        strEQTable(4, Int(strWildcards(1))) = ""
        strEQTable(5, Int(strWildcards(1))) = ""
        strEQTable(6, Int(strWildcards(1))) = ""
        World.Note "EQHit: Item removed."
    End If
End Sub

Sub subCallDetails (strWildcards)
    If Int(strWildcards) > UBound(strEQTable, 2) Or Int(strWildcards) < 0 Or Trim(strEQTable(0, Int(strWildcards))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        World.Note "Item information:"
        World.Note "-----------------"
        World.Note "Item's number:      " & Int(strWildcards)
        World.Note "Item's name:        " & strEQTable(0, Int(strWildcards))
        World.Note "Item's Armor Class: " & strEQTable(1, Int(strWildcards))
        World.Note "Item's alarm value: " & strEQTable(2, Int(strWildcards))
        World.Note "Item's hits:        " & strEQTable(3, Int(strWildcards))
        World.Note "Item's total hits:  " & strEQTable(4, Int(strWildcards))
        World.Note "Times repaired:     " & strEQTable(5, Int(strWildcards))
        World.Note "Total repair cost:  " & strEQTable(6, Int(strWildcards))
        World.Note ""
    End If
End Sub

Sub subShowDetails (strName, strOutput, strWildcards)
    If Int(strWildcards(1)) > UBound(strEQTable, 2) Or Int(strWildcards(1)) < 0 Or Trim(strEQTable(0, Int(strWildcards(1)))) = "" Then
        World.Note "EQHit: This item does not exist!"
    Else
        World.Note "Item information:"
        World.Note "-----------------"
        World.Note "Item's number:        " & Int(strWildcards(1))
        World.Note "Item's name:          " & strEQTable(0, Int(strWildcards(1)))
        World.Note "Item's Armor Class:   " & strEQTable(1, Int(strWildcards(1)))
        World.Note "Item's alarm value:   " & strEQTable(2, Int(strWildcards(1)))
        World.Note "Item's hits:          " & strEQTable(3, Int(strWildcards(1)))
        World.Note "Item's total hits:    " & strEQTable(4, Int(strWildcards(1)))
        World.Note "Times repaired:       " & strEQTable(5, Int(strWildcards(1)))
        World.Note "Total repair cost:    " & strEQTable(6, Int(strWildcards(1)))
        World.Note ""
    End If
End Sub

Sub subReadEQ (strName, strOutput, strWildcards)
    World.Note "EQHit: Adding player's equipment..."
    World.EnableTrigger "ProcessStart", True
    World.Send "equipment"
End Sub

Function fnFindNextSpot
    Dim intCounter

    For intCounter = 0 To UBound(strEQTable, 2)
        If strEQTable(0, intCounter) = "" Then
            fnFindNextSpot = intCounter
            Exit Function
        End If
    Next
    fnFindNextSpot = Int(UBound(strEQTable, 2) + 1)
    Redim Preserve strEQTable(constTableItems, fnFindNextSpot)
End Function

Sub subProcessEQ (strName, strLine, strWildcards)
    subAddEQ fnTrimItem(strWildcards(2)), 0, 0, 0, 0
End Sub

Function fnTrimItem (strItemName)
    Dim strTemp
    Dim intCounter

    strTemp = Trim(strItemName)

    'If the item's first letter is not
    'a parenthese, we are safe.
    If Left(strTemp, 1) <> "(" Then
        fnTrimItem = strTemp
        Exit Function
    End If

    For intCounter = 1 To Len(strTemp)
        If Mid(strTemp, intCounter, 2) = ") " And Mid(strTemp, intCounter + 2, 1) <> "(" Then
            fnTrimItem = Right(strTemp, Len(strTemp) - intCounter - 1)
            Exit Function
        End If
    Next
End Function
]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="EQHit:Help"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>