This is brill, just using this code for my bot and did some housekeeping and thought I'd give some feedback.
Most of the 20% mods that are for an attribute use the hex code of the attribute in the modstring. Heres an example that I quickly edited from your IsPerfectStaff function:
Code:
Func IsPerfectStaff($aItem)
Local $A = GetItemAttribute($aItem), $ModStruct = GetModStruct($aItem)
Switch $A
Case 12 ; Energy Storage - search for 08, 09, 0A, 0B, or 0C attributes
Return StringRegExp($ModStruct,"0[89ABC]141822")
Case 16 ; Divine - search for 0D, 0E, or 0F attributes
Return StringRegExp($ModStruct,"0[DEF]141822")
Case Else ; Everything else - search explicitly for the hex value of this attribute.
Return StringInStr($ModStruct,Hex($A,2)&"141822")
EndSwitch
EndFunc
Does make it a bit harder to figure out whats going on here, but cuts a lot of the cruft out.