Author Topic: TrailMyx's Find Item Stat Sub  (Read 9302 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
TrailMyx's Find Item Stat Sub
« on: July 21, 2008, 08:12:48 AM »
0
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)

Code: easyuo
  1. gosub TM_FindAttrib lower , #SPC , reagent , #spc , cost #CHARID #TRUE
  2. gosub TM_FindAttrib mage , #SPC , weapon #CHARID #FALSE
  3. display ok #RESULT
  4. stop
  5.  
  6. sub TM_FindAttrib
  7.   namespace push
  8.   namespace local FA
  9.   set !temp_lpc #LPC
  10.   set !#LPC 1000
  11.   set !attibute %1
  12.   set !container %2
  13.   set !sum %3
  14.   finditem * C_ , !container
  15.   if #FINDCNT > 0
  16.   {
  17.     set !summed_value 0
  18.     set !findid
  19.     for #FINDINDEX 1 #FINDCNT
  20.     {
  21.       event property #FINDID
  22.       str count #PROPERTY !attibute
  23.       if #STRRES > 0
  24.       {
  25.         set !findid !findid , _ , #FINDID
  26.         str pos #PROPERTY !attibute #STRRES
  27.         set %start #STRRES
  28.         str len !attibute
  29.         set %start %start + #STRRES
  30.         str del #PROPERTY 1 %start
  31.         set %string #STRRES
  32.         str pos %string $ 1
  33.         str left %string #STRRES
  34.         gosub TM_TrimString #STRRES
  35.         set !summed_value !summed_value + #RESULT
  36.         if !sum = #FALSE
  37.           break
  38.       }
  39.     }
  40.   }
  41.   set #RESULT !summed_value
  42.   set #LPC !temp_lpc
  43.   namespace pop
  44. return #RESULT
  45.  
  46. sub TM_GetFindID
  47.   namespace push
  48.   namespace local FA
  49.   set #RESULT !findid
  50.   namespace pop
  51. return #RESULT
  52.  
  53. sub TM_TrimString
  54.   namespace push
  55.   namespace local TS
  56.   set !string %1
  57.   str len !string
  58.   set !len #STRRES
  59.   set !start 1
  60.   set !end !len
  61.   set !result
  62.   for !i 1 !len
  63.   {
  64.     str mid !string !i 1
  65.     if #STRRES in 0_1_2_3_4_5_6_7_8_9_0_-
  66.       set !result !result , #STRRES
  67.   }
  68.   set #RESULT !result
  69.   namespace pop
  70. return #RESULT
  71.  

Note this will only work on normal armor/items.  If items are part of a "set", the numbers returned won't be accurate.
« Last Edit: May 05, 2017, 05:05:46 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!