Author Topic: ENs - "Snippets of Code" - 35+ subs.  (Read 64890 times)

0 Members and 4 Guests are viewing this topic.

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #15 on: September 23, 2010, 07:03:46 PM »
+2
GENERIC MOVE ITEM/S TO CONTAINER

Eg
Code: [Select]
gosub ENs_MoveToContainer  !myItemID #backpackid  

Code: [Select]
Sub ENs_MoveToContainor ; 3/31/08 - %1 Item %2 Containor %3 stack (Optional) %4 Wait (optional)
  set !DragDropWait %4
  if %0 < 4
    set !DragDropWait 15
  wait !DragDropWait
  ExEvent drag %1 %3
  ExEvent DropC %2
  wait !DragDropWait
Return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #16 on: April 19, 2011, 06:27:18 PM »
+2
ENs Siege Perilous ROT TIMER Sub

This work is based off Paulonius original Work Located Here

Use this to wait the min amount of time until next gain in any of the tracked skills.
IE for training taming on seige you are actually gaining in taming and animal lore... thierfor I only want it to wait if both skill are in ROT (and not at skill cap) and then only wait the min time for one skill to come out of ROT.

This sub uses a number of other EN Subs and var settings (ENs_Hide, ENs_AntiIdle, ENs_CastSpellOn can be found in this thread). Sub GLOBALSetStatus is a standard sub i use in my scripts to set the 'text' of a menu item labeled status. Checkprogressmenu - checks the menu that is displayed for user actions.

Code: [Select]
   goSub ENs_RoTTimer Tame Anil
Code: [Select]
;==========================================================
; ENs Siege Perilous ROT TIMER Subs
;==========================================================
Sub ENs_RoTTimer  ; Based off of Paulonius Rot Time .. many thanks
                  ; Checks and waits for ROT Timer On Seige.
                  ; Pass As Many Skills as you need to track
                  ; ie ENs_RoTTimer Tame Anim Veti
  If #Shard = Siege , #Spc , Perilous && ( %0 <> N/A || %EN_ROTSkillsCount <> N/A )
    {
    If %0 <> %EN_ROTSkillsCount ; setup first run.
      {
      set %EN_ROTSkillsCount %0
      For !x 1 %EN_ROTSkillsCount
        {
        set %EN_ROTSkillName . !x % . !x
        Chooseskill % . !x Real
        set %EN_ROTSkillLast . !x % . !x
        set %EN_ROTSKillTime . !x #scnt - 1
        }
      Chooseskill Mage Real
      set %EN_ROTMagery #skill > 0
      Chooseskill hidi Real
      set %EN_ROTHiding #skill > 0
      if %Invispell = N/A
        set %Invispell 43
      }

   ; Find Lowest time to continue
   set !RotTimer 0
   set !RotMax   0
   for !x 1 %EN_ROTSkillsCount
     {
     Chooseskill %EN_ROTSkillName . !x Real
     set !y 0
     if %EN_ROTSKillTime . !x > #scnt   ; time left on clock from last gain.
       set !y %EN_ROTSKillTime . !x - #scnt
     if #skill > 699 && #skill > %EN_ROTSkillLast . !x &&  #skill < #skillcap
       {
       If #Skill < 800                        ; 5 Minute Interval
         Set !y #SCNT + 300
       If #Skill >= 800 && #Skill < 900       ; 8 Minute Interval
         Set !y  #SCNT + 480
       If #Skill >= 900 && #Skill < 1000      ; 12 Minute Interval
         Set !y  #SCNT + 720
       If #Skill >= 1000 && #Skill < 1200     ; 15 Minute Interval
         Set !y  #SCNT + 900
       set %EN_ROTSkillLast . !x #skill
       set %EN_ROTSKillTime . !x #scnt + !y
       }
     if !y < !RotTimer
       set !RotTimer !y
     if !y > !RotMax
       set !RotMax !y
     }

   if !RotTimer > 0
     {
     set !RotSkillEscape !RotTimer
     Repeat
       set !x !RotTimer - #scnt
       goSub GLOBALSetStatus ROT-Timer Countdown: !x
       set !RotSkillEscape !RotSkillEscape - 1
       if H notin #CharStatus && ( %EN_ROTHiding || %EN_DoHiding ) && ( %EN_HideTimer <= #Scnt || %EN_HideTimer = N/A )
          gosub ENs_Hide 1
       If H notin #CharStatus && %EN_ROTMagery
          Gosub ENs_CastSpellOn %Invispell #CharID
       gosub ENs_AntiIdle 7
       if %EN_RegisteredProgressMenu
         goSub CheckProgressMenu
       wait 1
     Until #SCNT >= !RotTimer || !RotSkillEscape < 1
     }
  }
Return
« Last Edit: April 20, 2011, 08:38:03 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #17 on: April 20, 2011, 06:28:01 AM »
+2
ENs Hide Sub

Code: [Select]
gosub ENs_hide
gosub ENs_hide 1 ; the number of hide attempts - if nothing passed defaults to 1
Code: [Select]
;===========================================
; ~~ Hide
;===========================================
Sub ENs_Hide
  IF %EN_HideTimer = N/A
    set %En_hideTimer #scnt - 20
  If %0 < 1 || %0 = N/A
     Set %1 1
  Set !MaxAttempts %1
  If H In #CharStatus
     {
     goSub GLOBALSetStatus No need to Hide your Hidden
     }
  ELSE
    {
     goSub GLOBALSetStatus Attempting To Hide
     FOR !Hide_Attempts 1 !MaxAttempts
       {
       If !Hide_Attempts > 1
         {
          For !Count 12 1
            {
            goSub GLOBALSetStatus Hide Attempt , #Spc , !Hide_attempts , #Spc , of , #spc , !MaxAttempts , #spc , -- In: , #Spc , !Count
            Wait 1s
            }
          }
          goSub GLOBALSetStatus Attempting To Hide !Hide_attempts , #Spc , of , #spc , !MaxAttempts
       EVENT macro 13 21
       set %EN_HideTimer #Scnt + 12
       wait 10
       If H In #CharStatus
         {
          goSub GLOBALSetStatus Successfully Hiden.
          Set !Hide_Attempts !MaxAttempts
         }
       }
     If H NotIn #CharStatus
       goSub GLOBALSetStatus Hide Attempt Failed.
    }
return
« Last Edit: April 20, 2011, 06:35:45 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #18 on: April 20, 2011, 06:41:20 AM »
+2
ENs Event Macro Gump Open

Ever wanted a stable way to open and position the paperdoll, backpack, statusbar or other event macro driven gump.

Code: [Select]
;gosub EventMacroGumpOpen posX posY gumpnumber gumpnumber2  gumpname
gosub EventMacroGumpOpen 775 0 8 1 paperdoll_gump
Code: [Select]
Sub ENs_EventMacroGumpOpen  ; v3 9/13/07
  If %1 <> N/A && %2 <> N/A
    NextCpos %1 %2
  set %EventMacroGumpOpenTimeout #scnt + 7
  Repeat
    event macro %3 %4
    wait 5
  Until #contname = %5 || #scnt > %EventMacroGumpOpenTimeout
  If ( #Contposx <> %1 || #contposy <> %2 ) && %1 <> N/A && %2 <> N/A
    contpos %1 %2
Return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #19 on: April 20, 2011, 06:46:41 AM »
+2
ENs Get Formatted Date Time

Code: [Select]
gosub ENs_GetFormatDateTime
display ok the Date and time is: %FormattedDate - %FormattedTime
Code: [Select]
Sub ENs_GetFormattedDateTime
 str left #date 2
 set %FormattedDate #date , / ,  #Strres
 str RIGHT %FormattedDate 7
 Str Ins #Strres / 3
 set %FormattedDate #strres
 Str Ins #Time : 3
 str Ins #Strres : 6
 set %FormattedTime #strres
Return %FormattedTime
« Last Edit: April 20, 2011, 06:49:05 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #20 on: April 20, 2011, 06:52:48 AM »
+2
ENs GumpClick

Click on a gump at position x,y  of gump, sub automatically offsets for gump position on the screen. Pass as many click adjusters as needed (as per click command)

Code: [Select]
gosub ENs_Gumpclick 10 10  ; clicks 10,10 of gump
gosub ENs_Gumpclick 10 10 f x500  ; clicks 10 10 of gump fast 500 times

Code: [Select]
sub ENs_gumpclick  ; %1 offset x  offset y  Attibute  9/6/07
  set %clickx #contposx + %1
  set %clicky #contposy + %2
  set %0 %0 + 1
  For %Gumpclickcount %0 10
    set % . %GumpclickCount
  click %clickx %clicky %3 %4 %5 %6 %7 %8 %9 %10
Return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #21 on: April 20, 2011, 06:56:21 AM »
+2
CalculateOverLoadWeight

Code: [Select]
sub CalculateOverLoadWeight
  set #Result #MaxWeight - #Weight
  finditem #charid
  if #findtype in HS_IS ; Human
    set #Result #Result + 60
  if #maxweight > 597
    set #Result 597 - #weight
return #Result
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #22 on: April 20, 2011, 07:00:32 AM »
+2
ENs PadWithSpaces

Formats a string to a certain length by either padding spaces to the left or right or the passed string as selected.
eg  gosub ENs_PadWithSpaces LEFT 10 Hello
     #result will equal  '     Hello'  (without quotes of course)

Code: [Select]
Sub ENs_PadWithSpaces ; LEFT/RIGHT LENGHT STring
  str len %3
  Set !Add %2 - #strres
  If !Add > 0
    For !Count 1 !Add
       {
        If %1 = LEFT
          set %3  #spc , %3
        ELSE
          SET %3 %3 , #SPC
       }
Return %3
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #23 on: April 20, 2011, 07:02:48 AM »
+2
ENs Type A String

Use it to enter a password or just type each letter in a string individually

Code: [Select]
sub ENs_TypeString  
  str Len %1
  set !CharCount #strRes
  for %i 1 !CharCount
   {
   str Mid %1 %i 1
   IF #Strres = #Spc
       Key Space
    ELSE
       key #strRes
   wait 1
   }
return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #24 on: April 20, 2011, 07:05:02 AM »
+2
ENs Make a string with spaces

Code: [Select]
gosub ENs_MAkeStringWithSpaces  This is a test .. this is only a test, i can type what ever here and it gets formatted $ sweet
display ok #result

Code: [Select]
sub ENs_MakeStringWithSpaces
  If %0 > 0 && %0 <> N/A
    {
    Set !FormatResult
    For !Count 1 %0
      Set !FormatResult !FormatResult , #spc , % . !Count
    }
return !FormatResult



ENs_SetVarToStringWithSpaces

Code: [Select]
gosub ENs_SetVarToStringWithSpaces TestVar  This is a test .. this is only a test, i can type what ever here and it gets formatted $ sweet
display ok %testVar

Code: [Select]
sub ENs_SetVarToStringWithSpaces
  Set  % . %1
  If %0 > 1 && %0 <> N/A
    {
    For !Count 2 %0
      set % . %1  % . %1 , #spc , % . !Count
    }
return
« Last Edit: October 13, 2013, 05:55:47 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #25 on: April 20, 2011, 07:10:35 AM »
+2
ENs Fill Pitchers From Water Trough

Code: [Select]
sub ENs_FillPitchersFromWaterTrough  ; %1= troughrange , defaults to 12 if nothing passed
 If %waterTroughTypes = N/A
  set %waterTroughTypes TEE_WEE_QEE_VEE
 IF  %emptypitcherTypes = N/A
    set %emptypitcher  WYF
 set %waterTroughRange %1
 If %0 <> 1
   set %waterTroughRange 12
 finditem %waterTroughTypes G_ , %waterTroughRange
 If #Findcnt = 0
     event exmsg #charid 3 0 ERROR No Water Trough Found
 IF #findcnt > 0
   {
   set %WaterTroughId #findid
   finditem %emptypitcher C_ , #backpackid
   if #findcnt > 0
     {
     For #findindex 1 #findcnt
       {
       set #lobjectid #findid
       event exmsg #charid 3 0 Empty pitchers found, filling! #findindex of #findcnt
       event macro 17
       target 5s
       set #Ltargetkind 1
       set #ltargetid %WaterTroughID
       event macro 22
       wait 20
       }
     }
   }
return
« Last Edit: July 31, 2015, 06:48:09 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #26 on: April 20, 2011, 07:14:04 AM »
+2
ENs Open Bag / Containor

Attempts to open bag 5 times

Code: [Select]
gosub ENs_OpenBag %BagID   
gosub ENs_OpenBag %BagID   50 50 ; x y position
Code: [Select]
Sub ENs_OpenBag ; modded 4/1/08
  If %0=3
    nextcpos %2 %3
  set #lObjectID %1
  set !OpenBagTries 5
  Repeat
    set !OpenBagTries !OpenBagTries - 1
    FindItem %1  ; C_ , #BackPackID
    If #Findcnt = 1
       event Macro 17 0
    Wait 10
  Until #ContID = %1 || !OpenBagTries < 1 || #Findcnt = 0
Return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #27 on: April 20, 2011, 07:16:10 AM »
+2
ENs GetITemWeight

Reads wait from the item property's. Returns results in #result

Code: [Select]
Sub ENs_GetItemWeight ; %1 PackId %2 Var to set
  set !b stone , #spc
  set !escape   3
  set !Escape2 10
  Repeat
     event Property %1
     repeat
;       wait 1
       set !Escape2 !Escape2 - 1
    Until !b in #property  || !Escape2 <= 0
    set !Escape !Escape - 1
  Until !b in #property  || !Escape <= 0
  wait 5
  str pos #property Weight:
  set !StartTemp #strres + 8
  str pos #property Stone
  set !EndTemp #Strres - 1
  set !count !EndTemp - !StartTemp
  str mid #property !StartTemp !Count
  If %0 > 1
    Set % . %2 #Strres
Return #Strres
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - Misc. "Snippets of Code" / usefull Subs.
« Reply #28 on: April 20, 2011, 08:35:09 AM »
+2
ENs Cast Spell On

Built in failure detection and retry

Code: [Select]
gosub ENs_CastSpellOn %TheSpell %TheTarget
Code: [Select]
Sub ENs_CastSpellOn  ; 3/1/08
  If %1 = N/A || %1 = 0
     Return
  Set %The_Spell %1
  Set %The_Target %2
  if %Invispell = N/A
      set %Invispell 43 
  If %The_Spell = %Invispell && %The_Target = #charID && H In #CharStatus
     Return  ; caston self already hidden ?

  set %CastSpellOnTimeout #Scnt + 7
  set !EscapeCount 60
  Repeat
    set !EscapeCount !EscapeCount - 1
    gosub CheckProgressMenu
    set !Jstart #Jindex + 1
    event Macro 15 %The_Spell
    set %wait #scnt + 5
    Set %CastSpellAgain NO
    Repeat
      Wait 1
    Until #targcurs <> 0 || #Scnt > %Wait || %DontStop = #False || #CliLogged = 0 || #CharGhost = YES


    if #scnt > %wait
      Set %CastSpellAgain %DontStop ; ie TRUE

    If #Targcurs <> 0 && %DontStop = #True
      {
      If %The_Target = #CharID
        event macro 23
      If %The_Target <> #CharID
        {
        Set #LTargetID %The_Target
        set #LTargetKind 1
        event macro 22 0
        }
      wait 10
      For !JLoop !JStart #Jindex
        {
        scanjournal !JLoop
        if fizzles in #journal || already_performing in #journal || more_reagants in #journal || not_yet_recovered in #journal || your_concentration in #journal || insufficent_mana in #journal || not_yet_recovered in #journal
          Set %CastSpellAgain YES
        If You_cannot_perform_negative_acts_on_your_target. in #Journal
          set %CastSpellAgain NO
        }
      }
    If %CastSpellAgain = YES && %The_Spell = %Invispell && %The_Target = #charID && H In #CharStatus
      set %CastSpellAgain NO ; Already Hidden ??

    if %CastSpellAgain = YES
       wait 50
  Until %CastSpellAgain = NO ||  %DontStop = #False ||  #Scnt >= %CastSpellOnTimeout || #CliLogged = 0 || #CharGhost = YES || !EscapeCount < 1
Return
« Last Edit: April 20, 2011, 08:37:13 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: ENs - "Snippets of Code" - 25+ subs.
« Reply #29 on: April 30, 2011, 10:36:45 AM »
+2
ENs FindBag by Type and Name

Code: [Select]
set %TextSalvageBag  Salvage , #Spc , Bag
gosub ENs_FindBag #BackpackID CKF %TextSalvageBag SalvageBagID
Display ok Bagid: %SalvageBagID

Code: [Select]
Sub ENs_Findbag ; 1=IN 2=PropertyName 3=ReturnVar (minus the %)
  Finditem %2 C_ , %1
  Set % . %4 N/A
  If #Findcnt > 0
     {
     set #Findindex 0
     Repeat
       set #Findindex #Findindex + 1
       event Property #Findid
       If %3 in #Property
          Set % . %4 #Findid
     Until #Findindex >= #Findcnt || %3 in #Property
     }
Return

« Last Edit: April 30, 2011, 10:41:40 AM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Tags: