ScriptUO

Official ScriptUO EasyUO Scripts => Site Scripter Libraries => 12TimesOvers' Script Library => Topic started by: 12TimesOver on September 23, 2010, 06:02:57 AM

Title: XIIxOveR's Standard Subs
Post by: 12TimesOver on September 23, 2010, 06:02:57 AM
Just a thread for various subs I've written which I use regularly. These are probably the same or similar to what many other people use and probably already have in their libraries but I thought "Why Not".

XII
Title: SUB ClickNWait
Post by: 12TimesOver on September 23, 2010, 06:04:22 AM
Code: [Select]
;#######################
;SUB XIIxClickNWait
;#######################
; %1 = Required: Xoffset
; %2 = Required: Yoffset
; %3 = Required: #TRUE to wait for gump, any other value to return after click
; %4 = Required if %3 is #TRUE: Gump_Name
; %5 = Required if %3 is #TRUE: Gump_Size
sub XIIxClickNWait
   namespace push
   namespace local nsXIIxClickNWait
   set !clickx #contposx + %1
   set !clicky #contposy + %2
   set !gName1 %4
   set !gName2 %4
   set !gSize %5
   click !clickx !clicky
   if %3 <> #TRUE
      {
      namespace pop
      return
      }
   if %0 > 3
      gosub GumpWait !gName1 !gName2 !gSize
   namespace pop   
return
Title: SUB Gumpwait
Post by: 12TimesOver on September 23, 2010, 06:04:50 AM
Code: [Select]
;#######################
;SUB XIIxGumpWait
;#######################
; %1 = Required: Gumpname 1
; %2 = Required only if using Gumpsize: Gumpname 2
; %3 = Optional: Gumpsize
; Returns #TRUE if gump occured before timeout, #FALSE if timeout occured
sub XIIxGumpWait
   namespace push
   namespace local nsXIIxGumpWait
   wait 10
   set !gName1 %1
   set !gName2 %2
   set !gSize %3
   set !_time #SCNT
   while #SCNT <= !_time + 5
      {
      if %0 > 2
         {
         if ( #CONTNAME = !gName1 && #CONTSIZE = !gSize ) || ( #CONTNAME = !gName2 && #CONTSIZE = !gSize )
            {
            namespace pop
            return #TRUE
            }
         }
      else
         {
         if #CONTNAME = !gName1 || #CONTNAME = !gName2
            {
            namespace pop
            return #TRUE
            }
         }
      }
   namespace pop
return #FALSE
Title: SUB Maxweight
Post by: 12TimesOver on September 23, 2010, 06:05:18 AM
Code: [Select]
;####################
;SUB XIIxMaxWeight
;####################
; %1 = Maxweight offset
sub XIIxMaxWeight
   Namespace Push
   Namespace Local nsXIIxMaxWeight
   set !offset %1
   If #maxweight = N/A
      {
      event macro 8 2
      wait 5
      event macro 10 2
      }

   set !MaxWeight #MaxWeight

   finditem #CHARID
   if #findtype NOTIN AV_XU_OCB_NCB ;char is human
      set !MaxWeight !MaxWeight + 60
      
   if !MaxWeight > 550
      set !MaxWeight 550 ;Backpack maximum

   set !MaxWeight !MaxWeight - !offset ;Adjust as see fit for overfull buffer
   set #RESULT !MaxWeight
   Namespace pop
Return #RESULT
Title: SUB Pause
Post by: 12TimesOver on September 23, 2010, 06:05:48 AM
Code: [Select]
;#######################
;SUB XIIxPause
;#######################
; %1 = Button position 1
; %2 = Button position 2
; %3 = Button position 3
; %4 = Button position 4
; %5 = Button Name
; e.g. "gosub pause 340 92 40 25 Pause"
Sub XIIxPause
   namespace push
   namespace local XIIxPause
   set !1 %1
   set !2 %2
   set !3 %3
   set !4 %4
   set !5 %5
   menu set Status Status: Paused
   menu delete !5
   menu Font BGColor BtnFace
   menu Font Color WindowText
   menu button resume !1 !2 !3 !4 Resume
   set #menubutton N/A
   while #menubutton <> Resume
      wait 1
   menu delete resume
   menu Font BGColor BtnFace
   menu Font Color WindowText
   menu Button !5 !1 !2 !3 !4 !5
   menu set Status Status: Working...
   namespace pop
Return
Title: SUB RoT Timer with accompanying Skillcheck
Post by: 12TimesOver on May 06, 2011, 02:33:42 AM
Notes - this code assumes that you are also updating a Skill Gained display menu, if not you do not need to use the Whole2Dec sub and can comment out the menu lines in the Skillcheck sub. I left them there for reference.

RoT Timer not fully tested.

Code: [Select]
;####################
;SUB XIIxSkillCheck
;####################
; Checks skill, updates menu, and engages RoT Timer if applicable
; %1 Required = Skill to check
; %2 Required = Skill last time visited sub, used to determine if RoT (!LastSkill)
; %3 Required = #TRUE/#FALSE to update menu
; %4 Required if %3 is #TRUE = Starting skill level, used to update Menu (!StartSkill)
; Returns Skill Level
sub XIIxSkillCheck
   Namespace Push
   NameSpace Local nsXIIxSkillCheck
   set !SkillName %1
   set !LastSkill %2
   set !ToMenu %3
   set !StartSkill %4
   set !RoTShards Siege_Perilous_Mugen_
  
   chooseskill !SkillName
   set !CurrentSkill #skill

   if !ToMenu = #TRUE
      {
      set !GainedSkill !CurrentSkill - !StartSkill
      gosub XIIxWhole2Dec !CurrentSkill
      Menu set M_Skill_Current #RESULT
      gosub XIIxWhole2Dec !GainedSkill
      Menu set M_Skill_Gained #RESULT
      }

   if #Shard in !RoTShards && !CurrentSkill >= 700 && !CurrentSkill > !LastSkill
      gosub XIIxRoTimer !CurrentSkill

   set #RESULT !CurrentSkill
   namespace clear
   namespace Pop
return #RESULT

Code: [Select]
;####################
;SUB XIIxRoTimer
;####################
; %1 Skill Level
Sub XIIxRoTimer
   Namespace Push
   Namespace Local nsXIIxRoTimer
   set !Skill %1

   If !Skill > 699 && !Skill < 800
      Set !Timer #SCNT + 300
   If !Skill > 799 && !Skill < 900
      Set !Timer #SCNT + 480
   If !Skill > 899 && !Skill < 1000
      Set !Timer #SCNT + 720
   If !Skill > 999 && !Skill < 1200
      Set !Timer #SCNT + 900

   Repeat
      wait 1220
      Set #LobjectID #BackpackID
      Event Macro 17 0
   Until #SCNT >= !Timer

   Namespace Pop
Return

Code: [Select]
;#######################
;SUB XIIxWhole2Dec
;#######################
; %1 Whole number value to convert to Decimal form
; Returns Decimal value
sub XIIxWhole2Dec
   Namespace Push
   Namespace Local nsXIIxWhole2Dec
   set !Int %1 / 10
   set !Dec %1 % 10
   set #RESULT !Int , #dot , !Dec
   Namespace Pop
return #RESULT
Title: SUB MoveStuff
Post by: 12TimesOver on October 27, 2011, 04:51:03 AM
Code: [Select]
;#######################
;SUB XIIxMoveStuff
;#######################
; %1 ItemType or ID to move
; %2 Color or #FALSE if color doesn't matter
; %3 Container to move from
; %4 Number of items to move
; %5 Container to move to
; Returns #FALSE if item to move is not found or #TRUE if successful
sub XIIxMoveStuff
   Namespace Push
   Namespace Local nsXIIxMoveStuff
   set !Item2Move %1
   set !Color %2
   set !SourceContainer %3
   set !Amount2Move %4
   set !TargetContainer %5
   set !sWait 10
   
   finditem !Item2Move C_ , !SourceContainer
   if #findkind = -1
      {
      namespace clear
      NameSpace Pop
      Return #FALSE
      }
   else
      {
      if !Color <> #FALSE && #findcol <> !Color
         {
         ignoreitem #findid
         namespace clear
         namespace pop
         return #TRUE
         }
      else
         {
         if #findstack < !Amount2Move
            set !Amount2Move #findstack
         exevent drag #findid !Amount2Move
         wait !sWait
         exevent dropc !TargetContainer
         wait !sWait
         }
      }
   namespace clear
   Namespace Pop
return #TRUE