ScriptUO

Official ScriptUO EasyUO Scripts => Site Scripter Libraries => Endless Nights' Script Library => Topic started by: Endless Night on August 28, 2009, 05:13:59 AM

Title: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on August 28, 2009, 05:13:59 AM
Endless Nights Code Snippet Library

All Code in this thread is posted without any license, warranty, etc etc .  Do with it as you will, copy paste modify etc etc.

Be super nice if you posted a credit note.  Inspired by, Using ENS ?? , etc, etc .. not neccessary but nice.   Would be even nicer if you posted any  sweet addons or changes you made Here. (http://www.scriptuo.com/index.php?topic=7476.0).. Credits will be posted if used.

Enjoy but please dont post in this thread it will only get deleted.  If you wish to post a thank you note, comment, hatemail, review, notes, updates or anything else with reguards to these subs or EN in general please post it here..    (http://www.scriptuo.com/index.php?topic=7476.0)


LIST of Subs in this thread in order of posting
CLIENT SWAPPING
FINDING NEW MACROS
Find and Enter An Ant Hole
FIND ANT QUEEN
NEW TARGET SYSTEM ON /OFF
QUEST ITEM TOGGLING
Drop Item on the Ground Around you  (non stacking)
Plants  - Unlock Decorative plants and pickup plant from the ground
Generic Pickup Item/ Type From the ground
COUNT ITEMS IN YOUR BACKPACK/ANY BAG
String Formatting
JOURNAL STRINGS
HIT TRAINING DUMMY
ANTI-IDLE SUB
GENERIC MOVE ITEM/S TO CONTAINER
ENs Siege Perilous ROT TIMER Sub
Ens Hide
ENs Event Macro Gump Open
ENs Get Formatted Date Time
ENs GumpClick
CalculateOverLoadWeight
ENs PadWithSpaces
ENs Type A String
ENs Make a string with spaces
ENs SetVar To String With Spaces
ENs Fill Pitchers From Water Trough
ENs Open Bag / Containor
ENs GetITemWeight
ENs CastSpellOn
ENs FindBag
ENs USeSalvageBag
ENs MoveToContainor
ENs_TrimLeadingAndTrailingSpaces
ENs_DeleteString
Auto Mount When Dismounted Script
ENs -EasyDressing - Equip and Unequip Items from paperdoll
ENs - Load and save data to a file
ENs_FindClosestType
ENs_ReplaceString
save load vars to/from file
ENs_8x8Calculator
ENs_RandomWait
ENs_WhereAmI
ENs_WhatFacetAmIOn
ENs_WhatLandMassAmIOn
ENs_WhereIsThis
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on September 01, 2009, 06:54:40 AM
CLIENT SWAPPING

This is the simple but effective sub ive always used for Swapping clients.  (This way you can have more than 2 open and it will still find the rigth client.  Its Pretty fun stuff

Code: [Select]
Sub SwapTo  ; CharID
 While #Charid <> %1
   {
   UOXL Swap
   wait 10
   }
Return

And heres a bit of code to set the Characters.. all ripped from my justice rezzor (its lacking Type checks so if you pick a box as your char it will accept it :) )
Code: [Select]
Gosub GetChar Red
set %Red #Result
Gosub GetChar Blue
set %BLue #Result

gosub SwapTo %Blue
halt

Sub GetChar
  display OK Target your %1 Character now
  set #targCurs 1
  while #targCurs = 1
    wait 0
Return #ltargetID
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on October 02, 2009, 08:18:12 AM
FINDING NEW MACROS

IF Skill... look at macro list and find last known number used for a macros.. then scan numbers following until you find it.


If spell .. do simular heres some code to help out

Code: [Select]
; Find Spell Macros
set %X 600   ; Set x to some starting number
set %xend    ; set ending number
Repeat
  setuotitle %x
  Event macro 15  %x
  wait 1
  If A in #charStatus
     {
     display ok Got a spell: %x
     wait 10
     }
  set %x %x + 1
Until %x = %Xend
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on October 16, 2009, 04:54:24 PM
Find and Enter An Ant Hole

When next to an anthole --> gosub Ens_EnterAntHole

Code: [Select]
Sub ENs_EnterAntHole
   set !oldCharposx #CharPosX
   set !OldCharPosy #CharPosY
   set !EnterHoleTries 5
   If %Antholetypes = N/A
      set %AntHoleTypes PUI_SUI_RVB
   Finditem %AntHoleTypes G_3
   If #Findcnt >= 1
     {
     set #lObjectID #findid
     Repeat
       set !EnterHoleTries !EnterHoleTries - 1
       event Macro 17 0
       Wait 4
     Until #charposx <> !Oldcharposx || #Charposy <> !oldCharposy || !EnterHoleTries <= 0
     }
Return ( #charposx <> !Oldcharposx || #Charposy <> !oldCharposy  )
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on October 16, 2009, 09:09:28 PM
FIND ANT QUEEN

Starting in lower Rigth corner .. this will run around until it finds the queen

Code: [Select]
gosub ENs_findAntQueen
halt

sub ENs_FindAntQueen
  If %QueenLoopValueMax = N/A
    gosub SetupQueenLoopValues
  set !queenfound #False
  set !Loopvalue 0
  repeat
    gosub queenmove !loopvalue
    gosub findqueen
  until #result   ; queen found
  wait 5
Return

sub FindQueen
  set #result #false
  finditem OHB G_7
  If #Findcnt > 0
    {
    set !exit 15
    Repeat
      finditem OHB G_7
      Event Pathfind #findx #findy #findz  ; the queen
      wait 1
      set !exit !exit -1
      finditem OHB G_2
    Until !exit < 1 || #findcnt > 0
    set #result #findcnt > 0
    }
Return #Result

Sub QueenMove
    set !x %QueenLoopValuex . %1
    set !y %QueenLoopValuey . %1
    set !z %QueenLoopValuez . %1
    set !Exit 20
    Repeat
      set !Exit !exit - 1
      event pathfind !x !y !z
      wait 1
    Until ( #Charposx = !x && #charposy = !y ) || !exit < 1
    set !loopvalue !loopValue + 1
    If !loopvalue >= %QueenLoopValueMAx
      set !LoopValue 1
REturn

sub SetupQueenLoopValues
  gosub AddQueenloopvalue 5805 1908 3
  gosub AddQueenloopvalue 5803 1896 2
  gosub AddQueenloopvalue 5796 1889 2
  gosub AddQueenloopvalue 5788 1881 2
  gosub AddQueenloopvalue 5779 1872 0
  gosub AddQueenloopvalue 5770 1872 1
  gosub AddQueenloopvalue 5761 1876 0
  gosub AddQueenloopvalue 5755 1885 0
  gosub AddQueenloopvalue 5752 1895 2
  gosub AddQueenloopvalue 5756 1905 2
  gosub AddQueenloopvalue 5759 1910 5
  gosub AddQueenloopvalue 5769 1919 1
  gosub AddQueenloopvalue 5776 1924 3
  gosub AddQueenloopvalue 5780 1931 1
  gosub AddQueenloopvalue 5788 1933 4
  gosub AddQueenloopvalue 5796 1925 2
  gosub AddQueenloopvalue 5805 1915 3
  gosub AddQueenloopvalue 5810 1918 1
  gosub AddQueenloopvalue 5806 1925 3
  gosub AddQueenloopvalue 5799 1930 2
  gosub AddQueenloopvalue 5794 1926 4
  gosub AddQueenloopvalue 5797 1918 3
  gosub AddQueenloopvalue 5790 1913 3
  gosub AddQueenloopvalue 5781 1907 2
  gosub AddQueenloopvalue 5772 1904 1
  gosub AddQueenloopvalue 5764 1897 3
  gosub AddQueenloopvalue 5769 1889 1
  gosub AddQueenloopvalue 5775 1887 4
  gosub AddQueenloopvalue 5782 1894 1
  gosub AddQueenloopvalue 5777 1899 20
  gosub AddQueenloopvalue 5784 1900 0
  gosub AddQueenloopvalue 5789 1906 0
  gosub AddQueenloopvalue 5795 1912 4
  gosub AddQueenloopvalue 5801 1918 2
  gosub AddQueenloopvalue 5803 1916 5
  gosub AddQueenloopvalue 5807 1911 3
Return

sub AddQueenLoopValue
  if %QueenLoopValueMAx = N/A
     set %QueenLoopValueMax 0
  set %QueenLoopValueMAx %QueenLoopValueMax + 1
  set %QueenLoopValuex . %QueenLoopValueMax   %1
  set %QueenLoopValuey . %QueenLoopValueMax   %2
  set %QueenLoopValuez . %QueenLoopValueMax   %3
Return

Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on December 09, 2009, 10:02:39 AM
NEW TARGET SYSTEM ON /OFF

Below allows you to set it on or off and has inbult timeouts so if the client hangs or other the code doesnt get stuck.  Returns if it was succesfful in setting the desired on /off status

Code: [Select]
sub Ens_SetNewTargetSystem
  ; %1-On/off  %2-MaxAttampts %3-Waittime
  ; If nothing passed Default ON 6 20
  set !Status ON
  set !MaxAttempts 6
  set !MaxWaitTime 8
  If %0 > 0 && %1 <> N/A
     set !Status %1
  If %0 >= 2 && %2 <> N/A
    set !MaxAttempts %2
  If %0 >= 3 && %3 <> N/A
    set !MaxWaitTime %3
  set !StatusNo OFF
  If !status = OFF
     set !StatusNO ON
  set !YESString  New_Targeting_System_ , !Status
  set !NOString  New_Targeting_System_ , !StatusNo

  set !TargetOn #false
  repeat
    set !MaxAttempts !MaxAttempts - 1
    set !JOurnalOn #jindex + 1
    event macro 56
    set !Waittime !MaxWaitTime
    Repeat
      wait 1
      set !WaitTime !WaitTime - 1
      while #jindex >= !JournalOn
         {
         scanJournal !JOurnalOn
         IF !YESString = #journal
            set !Targeton #true
         IF !NOString = #journal
            set !Targeton #False
         set !JOurnalOn !JOurnalOn + 1
         }
    Until !WaitTime <= 0 || !TargetOn
  until !TargetOn  || !MaxAttempts <= 0
Return !TargetOn
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on December 09, 2009, 10:03:29 AM
QUEST ITEM TOGGLING

How to Make an item a quest item

Code: [Select]
set %ToggleQuestITemMenuLocation 6
gosub ENs_ToggleQuestITem   <item id>

Sub ENs_ToggleQuestITem ; %1
  exevent popup #charid
  wait 10
  set %Clicky 18 * %ToggleQuestITemMenuLocation
  set %Clicky %clicky + 2
  click 66 %clicky
  wait 10
  set #ltargetid %1
  set #ltargetkind 1
  event macro 22 0
  wait 10
  Key ESC   ; cancel toggle
  wait 10
Return

This only targets 1 item but you could mod it to target as many as you want.  TM has an additional sophistication in his script that READS the context menu to determine the postion of the Toggle Questitem selection.
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on January 15, 2010, 07:44:58 PM
Drop Item on the Ground Around you  (non stacking)

Returns true or false for success or fail.  trys every spot around your character

Code: [Select]
Sub ENs_DropOnGround ; %itemid %BagFrom %DropRadius
  set %Item %1
  IF %0 <= 1
    set %2
  set %BagFrom %2
  IF %0 <= 2
    set %3 2
  set %DropRadius %3
 
  Set %XPos ( #CharPosX - %DropRadius )
  Set %YPos ( #CharPosY - %DropRadius )
  Set %DropExit #False
  Repeat
    wait 10
    FindItem %item C_ , %BagFrom
    wait 3
    If #FindKind = -1
      Set %DropExit #True
    IF %DropExit = #False
      {
      ;event ExMsg #charID 3 0 trying %xpos %ypos
      ExEvent Drag #findid #Findstack
      Wait 12
      ExEvent DropG %Xpos %YPos
   
      ; Increment Position
      Set %XPos ( %XPos + 1 )
      If %Xpos > ( #CharPosX + %DropRadius )
        {
        Set %YPos ( %YPos + 1 )
        Set %XPos ( #CharPosX - %DropRadius )
        }
      }
  Until %DropExit || %YPos > ( #CharPosY + %DropRadius )
Return %DropExit
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on January 16, 2010, 06:29:02 AM
Plants  - Unlock Decorative plants and pickup plant from the ground

Code: [Select]
set %MySecureID #backpackid   ; Setit

set %plantTypes OLI_BCF_VWE_BWE_UAF_JWE_IWE_EXE_UWE_ICF_BXE_YVE_CCF_NWE_MWE_DXE_TCF_NXE_BKP_ZJP_MKP_AKP_CKP_OKP_NKP_LKP_TXE_ZBF_AIF_GWE_VWE_WTE_ZBF_BWE_BCF_CCF_SVE_IWE_MWE_YVE_REK_QVE_BFK_WTE_FWE_NXE_CYE_JDF_

Finditem %Planttypes g_2
If #findcnt > 0
  {
  For #findindex 1 #findcnt
     {
      event property #findid
      wait 5   ; wiat for property to be set
      if  Decorative in #property
             {
              msg i wish to unlock this $
              target 3s
              set #ltargetid #findid
              event macro 22 0
              wait 5
             exevent drag #findid
             exevent dropc %Mysecureid
             wait 20
              }
     }
  }
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on January 16, 2010, 06:34:15 AM
Generic Pickup Item/ Type From the ground

Returns the count of items dragged.

Code: [Select]
Gosub En_PickupfromGround  %DaggerType 2 #backpackid
Code: [Select]
Sub En_Pickupfromground ; %1-item/type %2-radius %3-put in bag  %4 - optional drop delay (defaults 20)
  If %0 < 4
      set %4 20
  finditem %1 G_ , %2
  If #findcnt > 0
      {
       for #findindex 1 #findcnt
            {
            exevent drag #findid
            exevent drop %3
            wait %4
            }
      }
Return #findcnt
Title: Re: Misc. "Snippets of Code" / Subfull Subs. - Do not post.
Post by: Endless Night on February 08, 2010, 09:51:49 AM
COUNT ITEMS IN YOUR BACKPACK/ANY BAG

The easist and fastest way to get the exact number of items in your backpack and subpacks is to left UO do the work.
If you open your paperdoll and move mouse over the packpack you will notice that the property of your backpack contains this information all you have to do is extract it via string commands.

Below is a sub that Should work for anypack, Just pass the pack id to the sub the item count is returned in #Result.
Code: [Select]
gosub ENs_GetPackItemCount #BackPackID
display ok You have #result items in that Pack
halt

Code: [Select]
Sub ENs_GetPackItemCount  ; %1 ID Of Pack.
  event property %1
  str Pos #property contents:   1
  set %leftChar #strRes + 10
  str Pos #property /125 1
  set %CharCount #strRes - %LeftChar
  str Mid #Property %leftChar %Charcount
Return #strres
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on February 19, 2010, 06:02:10 AM
String Formatting

Adds spaces either to left of right of string to make string = Lenght

Code: [Select]
Sub ENs_PadWithSpaces ; %1=LEFT/RIGHT %2= finshed string LENGHT
  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



Below Sub makes a string with spaces..  ie pass: this is a test ..  you will get returned a string 'this is a test'

Code: [Select]
sub ENs_MakeStringWithSpaces
  If %0 > 0 && %0 <> N/A
    {
    Set !FormatResult
    For !Count 1 %0
      Set !FormatResult !FormatResult , #spc , % . !Count
    }
return !FormatResult
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on September 11, 2010, 06:18:19 PM
JOURNAL STRINGS

Below sub will convert a regular string 'this is a test' into journal format 'this_is_a_test'

Code: [Select]
sub ENs_MakeJournalString
  While #Spc in %1
    {
    str Pos %1 #spc
    set %Pos #strres
    str del %1 %Pos 1
    str Ins #StrRes _ %pos
    set %1 #StrRes
    }
Return %1

Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on September 20, 2010, 05:26:14 PM
HIT TRAINING DUMMY

Sometimes i find really old chars that have min strenght .. i think from when i was testing advanced features of my character toolbox script... anyways instead of deleting char and starting over .. its easy enough to use a training dummy.

Code: [Select]
repeat
  gosub hitdummy
  wait 10
until #str = 20
halt

sub hitdummy
   finditem SDG G_1
   IF #findcnt > 0
      {
      set #lobject #findid
      event macro 17 0
      wait 1
      }
return
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on September 23, 2010, 04:38:50 AM
ANTI-IDLE SUB

A sub that will stop you from timing out.  Either pass random or 1-7, the sub will activate after being called >333 times
1= turn , and turn back
2= attempt to hide
3= Toggle war then peace or peace then war
4= open close chat
5= Bow
6= Salute
7= OpenBackpack
Random = Randomly selected 1-7

Code: [Select]
;===========================================
; ~~ Anti Idle Subs
;===========================================
Sub ENs_AntiIdle  ; %1 = 1-7 or Random
  If %ENs_Idletime = N/A
     Set %ENs_Idletime 0
  set %ENs_idletime %ENs_Idletime + 1
  If %ENs_idletime < 333
     Return
  set %ENs_idletime 0
  If %1 = Random || %1 = N/A
      Set %1  ( ( #random % 69 ) / 10 ) + 1
  set %AntiIdleType %1
  If %AntiIdleType = 1  ; Turn
    {
     If #CHARDIR = 7
       {
       event Macro 5 4
       wait 1s
       }
     event Macro 5 0
     wait 1s
     event Macro 5 4
     wait 1s
    }
  If %AntiIdleType = 2  ; Hide
    {
    event macro 13 21 ; Hiding
    wait 12s
    }
  If %AntiIdleType = 3  ; War & Peace
    {
     event Macro 6 0
     wait 1s
     event Macro 6 0
     wait 1s
    }
  If %AntiIdleType = 4  ; OpenClose Chat
    {
     event Macro 8 6
     wait 1s
     event macro 9 6
     wait 1s
    }
  If %AntiIdleType = 5  ; Bow
    {
     event Macro 18 0
     wait 1s
    }
  If %AntiIdleType = 6  ; Salute
    {
     event Macro 19 0
     wait 1s
    }
  If %AntiIdleType = 7  ; Open Backpack
    {
     event Macro 8 7
     wait 1s
    }

;  If %AntiIdleType = NEVERCALLED  ; InvokeVirtue
;    {
;     event macro 49 1 ; Invoke Honor Virtue
;     event macro 49 2 ; Invoke Sacrifice Virtue
;     event macro 49 3 ; Invoke Valor Virtue
;     wait 1s
;    }
Return
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on September 23, 2010, 07:03:46 PM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 19, 2011, 06:27:18 PM
ENs Siege Perilous ROT TIMER Sub

This work is based off Paulonius original Work Located Here (http://www.scriptuo.com/index.php?topic=6151.msg52106#msg52106)

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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 06:28:01 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 06:41:20 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 06:46:41 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 06:52:48 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 06:56:21 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:00:32 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:02:48 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:05:02 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:10:35 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:14:04 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 07:16:10 AM
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
Title: Re: ENs - Misc. "Snippets of Code" / usefull Subs.
Post by: Endless Night on April 20, 2011, 08:35:09 AM
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
Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on April 30, 2011, 10:36:45 AM
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

Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on April 30, 2011, 10:40:57 AM
ENs Use Salvage Bag

Code: [Select]
gosub ENs_UseSalvageBag %SalvageBagID 1  ; popup option 1-3, 1=all, 2=ingots, 3=cloth
gosub ENs_UseSalvageBag %SalvageBagID     ; same as if 1 was passed

Code: [Select]
Sub ENs_UseSalvageBag ; Bagid Option= 1 2 3 if option not passed defaults as 1
  set !BagID %1
  set !Option %2
  if %0 = 1
     set !Option 1
  set !Escape 10
  Repeat
    exevent popup !BagId
    wait 5
    set !Escape !Escape - 1
  Until !Escape <= 0 || ( #Contname = Normal_gump && #ContSize = 106_78 )
  set !PopupContKind #ContKind
  If !Escape > 0
    {
    contpos 0 100
    wait 4
    set !x #contposx + 50
    set !y #contposy + ( !Option * 20 )
    set !Escape 5
    Repeat
      Click !x !Y DMC
      wait 3
      set !Escape !Escape - 1
    Until !Escape <= 0 || #Contkind <> !PopupContKind
    }
Return
Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on August 18, 2011, 01:52:39 PM
ENs MoveToContainor

Move ONE item or one stack of items to a container.

Code: [Select]
finditem POF G_2  ; find gold on ground radius 2
gosub ENs_MoveToContainor  #findid #Backpackid #findstack  ; move gold to backpack

Code: [Select]
Sub ENs_MoveToContainor ; 3/31/08 - %1 Item %2 Containor %3 stack %4 Wait (Optional, defaults to 12)
  set !DragDropWait %4
  if %0 < 4
    set !DragDropWait 12
  wait !DragDropWait
  ExEvent drag %1 %3
  ExEvent DropC %2
  wait !DragDropWait
Return
Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on August 30, 2011, 07:30:06 PM
ENs_TrimLeadingAndTrailingSpaces
Removes all leading and trailing spaces in a string .. ie '    this is a test    '  returns as 'this is a test'

Code: [Select]
event property <someitemID>
gosub ENs_TrimLeadingAndTrailingSpaces #property
display ok #result


Code: [Select]
sub ENs_TrimLeadingAndTrailingSpaces %1
  repeat ; Remove Leading
    Str Left %1 1
    set !Char #Strres
    if !Char = #Spc
       {
        str Len %1
        set !trim #Strres - 1
        str Right %1 !Trim
        set %1 #strres
        }
  until !Char <> #spc
 
  repeat ; Remove Trailing
    Str Right %1 1
    set !Char #Strres
    if !Char = #Spc
       {
        str Len %1
        set !trim #Strres - 1
        str Left %1 !Trim
        set %1 #strres
        }
  until !Char <> #spc
return %1
Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on August 30, 2011, 07:32:05 PM
ENs_DeleteString
Deletes all occurances of a string in another string  ie #spc 'this is a test'  returns 'thisisatest'

Code: [Select]
gosub  ENs_DeleteString  _ this_is_a_test   ; DeleteString OriginalString
display ok #Result   ; = thisisatest
gosub  ENs_DeleteString  test this_is_a_test
display ok #Result  ; = this_is_a_

Code: [Select]
sub ENs_DeleteString ; %1-delete %2 String
  str len %1
  set !Len #Strres
  While %1 in %2
    {
    str Pos %2 %1
    str del %2 #strres !Len
    set %2 #StrRes
    }
Return %2
Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on August 31, 2011, 04:40:56 AM
Auto Mount When Dismounted Script
Bit of dumb code that remounts you if your dismounted.

Code: [Select]
set %waittime 30
display ok Please Dismount
wait 30
display ok Please target your mount
set #targcurs 1
While #targcurs = 1
  wait 1
set %mount #ltargetid

set %ExitScript #False
repeat
  wait 2
  findItem %mount G
  if #findBagID <> #charID && #Findcnt > 0
    {
    msg All Follow Me $
    wait %Waittime
    set #lObjectID %mount
    event Macro 17
    wait 2s
    }
   while #Charghost = YES
     wait 1
Until %ExitScript = #true
halt
Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on April 02, 2012, 08:56:34 AM
ENs - Easy Dressing
Version 2.0

Easily unequip and reequip your paper-doll using the exevent equip 24 command.   Userful for if you die alot.   You may take apart the attached script and use the subs you require...

Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on November 19, 2012, 06:30:28 PM
LOAD and Save data to a file  

; Example Code
Code: [Select]
goSub ENs_SetupCommandLine  ; initialize save/load enviroment
SET %TestVar 1
set %testvar2 test
set %Filename C:\easyuo\en-test.txt
display ok saveing a test value of %testvar - %testvar2
goSub ENs_ClearFile %filename
gosub ENs_SaveData %filename TestVar TestVar2
; ~~~~~~~~~~~~~~~~~~~
set %testvar 2
set %testvar2 boo
display ok resting testvalue to %testvar : %testvar2
; ~~~~~~~~~~~~~~~~~~~
gosub ENs_LoadData %fileName
display ok TestValue = %testvar : %testvar2 $ (should be 1 : test what was saved in file)
halt


; Subs
Code: [Select]
sub ENs_SaveData ; <%Filename> 1..z of <Varname to save without the % Sign>
  set !SDFileName %1
  set !SDBufferText
  set !SDFile  #spc , >> , #spc , !SDFileName
  set !SDAnd  #spc , && , #spc
  set !SDEcho Echo , #spc , Set , #spc
  set !SDVarName %2
  set !SdValue % . !SDVarName
  set !SDBufferText !SdEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
  if %0 > 2
    {
    for !x 3 %0
      {
      set !SDVarName % . !x
      set !SdValue % . !SDVarName
      set !SDBufferText !SDBufferText , !SDAnd , !SDEcho , %ENs_PercentSign , !SdVarName , #spc , !SDValue , !SDFile
      }
    }
  if %ENs_Cmd = N/A
    gosub ENs_SetupCommandLine
  Execute %ENs_Cmd /c !SDBufferText
Return

sub ENs_LoadData ; %filename
  call %1
return

Sub ENs_ClearFile
  set !SDFileName %1
  if %ENs_Cmd = N/A
    gosub ENs_SetupCommandLine
  set !clOutput #SMC , #spc , ENs , #spc , Var , #spc , Save
  Execute %ENs_Cmd /c Echo !clOutput > !SDFileName
Return

Sub ENs_SetupCommandLine
  Set %ENs_Cmd cmd.exe
  Str Left #OSVer 1
  If #StrRes = 1
      Set %ENs_Cmd command.com
  If #StrRes = 2
      Set %ENs_Cmd cmd.exe
  set %ENs_PercentSign %
Return

Title: Re: ENs - "Snippets of Code" - 25+ subs.
Post by: Endless Night on January 21, 2013, 07:55:51 AM
ENs Find Closest Type

Finds the closest item/monster player on the ground (pass the type list)


Code: [Select]
set %monster IS
gosub ENs_FindClosestType %Monster
display ok Closest monster id = #result
halt

Code: [Select]
sub ENs_FindClosestType
  set !dist 100000000
  set #result N/A
  findItem %1 G_20
  if #findcnt > 0
    {
    for #findindex 1 #findcnt
       {
        if #finddist < !dist
            {
            set !dist #finddist
            set #result #findid
            }
       }
    }
return #result
Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on October 13, 2013, 06:00:41 AM
ENs_ReplaceString

Searches Source string for occurrences of "ReplaceString", removes them and replaces with the contents of "WithString",

Code: [Select]
gosub ENs_ReplaceString  I___wish___these___were___a___single___space    ___    #spc
display ok #result

Code: [Select]
sub ENs_ReplaceString ; SourceString ReplaceString WithString
  str count %1 %2
  set %5 #strres
  Str len %2
  set %4 #strres
  While %5 > 0
    {
    str Pos %1 %2 %5
    set %6 #strres
    str del %1 %6 %4
    str Ins #StrRes %3 %6
    set %1 #StrRes
    set %5 %5 - 1
    }
Return %1
Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on April 05, 2015, 12:06:23 PM
ENs_8x8Calculator

Maintains an array to determine if you have depleted the resource in that grid already.  Can be used for fishing, mining, lumberjacking or any other 8x8 resource.

How to use:  Upon starting at a new location RESET the grid, then when you located a resource spot check to see if the 8x8 grid that spot is in is already depleted  if not depleted, deplete it and add to the grid,  when you detect the next spot  check again continue until no more resource spots found.

Example pseudo code
Code: [Select]
goSub ENs_8x8Calculator RESET     ; Arrived at new location reset grid results
Repeat ; Starting resource gathering loop
    ; found a spot check it
    goSub  ENs_8x8Calculator %resoucex %resoucey
    IF #Result
       {  ; Area not depleted yet ... deplete the resource...
        If  %resource_depleted
             goSub  ENs_8x8Calculator %resoucex %resoucey ADD    ; add as depleted spot when resource depleted
        }
until <no more resouce spots found>

Code: [Select]
Sub ENs_8x8Calculator ; RESET OR  %x , %y OR %x %y ADD
  set #Result #False
  IF %1 = RESET || %EN_8x8ResourceSquare = N/A
     set %EN_8x8ResourceSquare
  If %0 >= 2 && %1 <> RESET
    {
    set !8x %1 / 8
    set !8y %2 / 8
    set !8x8pos _ , !8x , x , !8y
    set #Result !8x8pos notin %EN_8x8ResourceSquare
    IF %0 = 3 && %3 = ADD && #Result
      set %EN_8x8ResourceSquare %EN_8x8ResourceSquare , !8x8Pos
    }
Return #Result
Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on April 09, 2015, 06:28:39 AM
ENs_RandomWait

Wait a random amount of time between the min and max values passed.

Code: [Select]
gosub ENs_RandomWait  20 150
Code: [Select]
sub ENs_RandomWait  ; %1=Min wait,  %2=Max Wait in MS
   set !EN_Time %1 + ( #Random % ( %2 - %1 + 1 ) )
   wait !EN_Time
return
Title: Re: ENs - "Snippets of Code" - 35+ subs.
Post by: Endless Night on February 12, 2020, 08:27:37 AM
Dont know where you are in the world ...  ??   Maybe this will help.

Example Usage
Code: [Select]
gosub ENs_WhatFacetAmIOn
  display ok #result
gosub ENs_WhatLandMassAmIOn
  display ok #result
gosub ENs_WhereAmI
  display ok #result
halt

Helper Subs
Code: [Select]
sub ENs_WhereAmI
  gosub ENs_WhereIsThis #CURSKIND #CHARPOSX #CHARPOSY
  set #result %EN_Location_Facet , #spc , - , #spc , %EN_Location_LandMass
  set !Blank
  if %EN_Location_Landmass = !Blank
     set #result %EN_Location_Facet
return  #result

sub ENs_WhatFacetAmIOn
  gosub ENs_WhereIsThis
  set #result %EN_Location_Facet
return #result

sub ENs_WhatLandMassAmIOn
  gosub ENs_WhereIsThis
  set #result %EN_Location_LandMass
  set !Blank
  if #result = !Blank
    set #result %EN_Location_Facet
return #result

Main Sub
Code: [Select]
sub ENs_WhereIsThis  ; %1..3  curskind x y
  set !Facet %1
  set !x %2
  set !y %3
  if %0 = 0
    {
    set !Facet #CursKind
    set !x       #CharPosX
    set !y       #CharPosY
    }
  set %EN_Location_Facet
  set %EN_Location_LandMass
  if !Facet = 0
    {
    set %EN_Location_Facet    Felucca
    set %EN_Location_LandMass Britannia
    IF ( #CHARPOSX >= 5120  && #CHARPOSX <= 6143 ) && ( #CHARPOSY >= 2300 && #CHARPOSY <= 4095 )
        set %EN_Location_LandMass  T2A
    }
  if !Facet = 1
    {
    %EN_Location_Facet Trammel
    IF ( #CHARPOSX >= 5120  && #CHARPOSX <= 6143 ) && ( #CHARPOSY >= 2300 && #CHARPOSY <= 4095 )
        set %EN_Location_LandMass T2A
    }
  if !Facet = 2
    set %EN_Location_Facet Ilshenar
  if !Facet = 3
    set %EN_Location_Facet Malas
  if !Facet = 4
    set %EN_Location_Facet Tokuno
  if !Facet = 5
    {
    set %EN_Location_Facet  Ter , #spc , Mur
    IF ( #CHARPOSX >= 85 && #CHARPOSX <= 770 ) && ( #CHARPOSY >= 1348 && #CHARPOSY <= 1979 )
        set %EN_Location_LandMass  Eodon , #Spc , NW
    IF ( #CHARPOSX >= 593 && #CHARPOSX <= 946 ) && ( #CHARPOSY >= 1940 && #CHARPOSY <= 2178 )
        set %EN_Location_LandMass  Eodon , #spc , SE
    }
return