This routine lets you determine an item stat just by requesting the item stat by name. The returned value should be the stat in question. You will need to open whatever container you are searching.
The arguments are as follows:
%1 = attibute text to search for
%2 = container to search in
%3 = #TRUE to sum all of this stat (computes FCR, FC, Armor values on your paperdoll)
gosub TM_FindAttrib lower , #SPC , reagent , #spc , cost #CHARID #TRUE
gosub TM_FindAttrib mage , #SPC , weapon #CHARID #FALSE
display ok #RESULT
stop
sub TM_FindAttrib
namespace push
namespace local FA
set !temp_lpc #LPC
set !#LPC 1000
set !attibute %1
set !container %2
set !sum %3
finditem * C_ , !container
if #FINDCNT > 0
{
set !summed_value 0
set !findid
for #FINDINDEX 1 #FINDCNT
{
event property #FINDID
str count #PROPERTY !attibute
if #STRRES > 0
{
set !findid !findid , _ , #FINDID
str pos #PROPERTY !attibute #STRRES
set %start #STRRES
str len !attibute
set %start %start + #STRRES
str del #PROPERTY 1 %start
set %string #STRRES
str pos %string $ 1
str left %string #STRRES
gosub TM_TrimString #STRRES
set !summed_value !summed_value + #RESULT
if !sum = #FALSE
break
}
}
}
set #RESULT !summed_value
set #LPC !temp_lpc
namespace pop
return #RESULT
sub TM_GetFindID
namespace push
namespace local FA
set #RESULT !findid
namespace pop
return #RESULT
sub TM_TrimString
namespace push
namespace local TS
set !string %1
str len !string
set !len #STRRES
set !start 1
set !end !len
set !result
for !i 1 !len
{
str mid !string !i 1
if #STRRES in 0_1_2_3_4_5_6_7_8_9_0_-
set !result !result , #STRRES
}
set #RESULT !result
namespace pop
return #RESULT
Note this will only work on normal armor/items. If items are part of a "set", the numbers returned won't be accurate.