;==================================
; Script Name: Reaper's Brit Library Mace and Shield Donator
; Author: The Reaper
; Version: 2.0
; Client Tested with: 7.0.8.0
; EUO version tested with: 1.5.191
; Purpose: Donating to brit library for Mace and Shield Reading glasses
; Special thanks to TM for the journal scanner subs and save subs :D
;==================================
; Notes:-
; 1
; Rune to house must be within 2 tiles of your secure
; AND next to an anvil.
; 2
; Store all ingots in the top level of your secure
; 3
; DO NOT store valuable ingots in secure, as script does not discriminate
; 4
; Script will make 50 bucklers before turning them in, make sure you
; can carry 250 stones (this can be user defined under "Script Variables")
;==================================
; Update Log
; 1.0
; Initial Release
; 1.1 30/05/2011
; Changed way hammers are made to prevent making excessive tinker tools
; Minor bugs fixed
; 2.0 30/05/2011
; Added gate support and more reliable travelling
; Added a status window
;==================================
; Remove the ";" below to reset the script should you wish to change any of the setup
; gosub TM_NGFS_DeleteName TheReapers_Mace_and_Shield_Donator
; halt
;==================================
set %debug 0
;==================================
; Script Variables (Item types)
set %plain_ingots ENK
set %tinker_tools KTL
set %smiths_hammer TLH
set %buckler FIK
set %max_buckler_amount 55 ; set this to 49, if you want to make 50 etc
set %TR_make_first_hammer 0
set %TR_Status_bucklers 0
set %TR_Status_ingots 0
;==================================
gosub TM_NGFS_InitializeScript TheReapers_Mace_and_Shield_Donator
gosub TM_NGFS_LoadVariables TheReapers_Mace_and_Shield_Donator
gosub TM_AddUnderscore #CHARNAME
set %charname #RESULT
gosub TM_AdvJournalSync world 100
menu hideEUO
event Macro 8 2 ;open status bar
wait 10
set #contPosX 850
set #contPosY 325
event macro 8 7
wait 10
set #contPosX 850
set #contPosY 500
chooseskill tink
if #skill < 800
{
display ok You need 80.0 tinkering to make blacksmith's hammers efficiently.
halt
}
chooseskill blac
if #skill < 250
{
display ok You need to buy blacksmithing from the trainer in order to run this script.
halt
}
;==================================
; Skips setup if save file exists
if %TR_save = 2
{
goto Start
}
; Deletes save if previously used V1.0 of script
if %TR_save = 1
{
gosub TR_wipe_old_save
}
;==================================
; Determines whether or not to scan for world saves
display yesno Are you playing on an OSI/EA shard?
if #dispRes = Yes
{
set %TR_shard OSI
}
else
{
set %TR_shard free
}
;==================================
; Select travel method
display yesnocancel Do you want to use Magery or Chivalry for returning to the bank/secure? $ (Magery = Yes Chivalry = No Gate Travel = Cancel)
if #dispRes = Yes
{
set %TR_recallmethod RE
}
if #dispRes = No
{
set %TR_recallmethod SJ
}
if #dispRes = Cancel
{
set %TR_recallmethod GA
}
;==================================
; Get Runebook ID
display ok Target your runebook
set #targcurs 1
wait 5
repeat
wait 0
until #targcurs = 0
set %TR_runebook #ltargetID
set #lobjectID %TR_runebook
wait 5
event macro 17 0
wait 10
;==================================
; Get House rune number
menu clear
menu window title Rune #'s
menu window color btnface
menu window size 189 111
menu font Transparent #true
menu font align left
menu font name MS Sans Serif
menu font size 8
menu font style
menu font color WindowText
menu text ttext 5 5 What is the number of
menu text ttext2 5 25 your HOUSE rune?
menu edit TR_house_rune 36 50 121
menu button TR_ok 70 75 50 25 OK!
menu show
set #menubutton n/a
repeat
wait 0
until #menubutton <> n/a
menu get TR_house_rune
menu hide
if %debug = 1
{
display ok #menures
}
set %TR_House_Rune #menures
wait 5
;==================================
; Get Library rune number
menu clear
menu window title Rune #'s
menu window color btnface
menu window size 189 111
menu font Transparent #true
menu font align left
menu font name MS Sans Serif
menu font size 8
menu font style
menu font color WindowText
menu text ttext 5 5 What is the number of
menu text ttext2 5 25 your LIBRARY rune?
menu edit TR_library_rune 36 50 121
menu button TR_ok 70 75 50 25 OK!
menu show
menu hideEUO
set #menubutton n/a
repeat
wait 0
until #menubutton <> n/a
menu get TR_library_rune
menu hide
if %debug = 1
{
display ok #menures
}
set %TR_Library_Rune #menures
menu clear
wait 5
;==================================
; Get secure ID number
display ok Target your secure container.
set #targcurs 1
wait 5
repeat
wait 0
until #targcurs = 0
set %TR_secure #ltargetid
wait 5
;==================================
; Recall to Library to set the NPC's ID
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_Library_Rune %TR_Library_Rune %TR_runebook
if #result = #true
{
display ok There is a problem with your recall rune to the library, halting.
halt
}
display ok Target the Mace and Shield donation NPC.
set #targcurs 1
wait 5
repeat
wait 0
until #targcurs = 0
set %TR_Donation_NPC #ltargetID
wait 5
;==================================
; Save %var's
if %TR_save <> 2
{
set %TR_save 2
gosub TM_NGFS_RegisterVariables TheReapers_Mace_and_Shield_Donator std std TR_recallmethod TR_runebook TR_save TR_Donation_NPC TR_secure TR_Library_Rune TR_House_Rune TR_shard TR_Status_ingots TR_Status_bucklers
gosub TM_NGFS_SaveVariables TheReapers_Mace_and_Shield_Donator
}
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_House_Rune %TR_House_Rune %TR_runebook
Start:
;==================================
; Status window setup
menu clear
menu window title M&S Donator
menu window color btnface
menu window size 189 100
menu font Transparent #true
menu font align left
menu font name MS Sans Serif
menu font size 8
menu font style
menu font color WindowText
menu text tbucklers 5 5 Number of bucklers made:
menu text tingots 5 25 Number of ingots used:
menu text tpoints 5 45 Library points gained:
menu text tnbucklers 150 5 %TR_Status_bucklers
menu text tningots 150 25 %TR_Status_ingots
menu text tnpoints 150 45 ???
menu button TR_pause 5 75 75 25 PAUSE
menu button TR_close 85 75 100 25 SAVE , #spc , + , #spc , CLOSE
set #menubutton n/a
menu show
;==================================
;==================================
; Main Script Loop
repeat
gosub TR_open_secure
gosub TR_open_backpack
gosub TR_make_bucklers
gosub TR_check_weight
event macro 31 0
gosub TR_open_backpack
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_Library_Rune %TR_Library_Rune %TR_runebook
if #result = #true
{
repeat
wait 50
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_Library_Rune %TR_Library_Rune %TR_runebook
until #result = #false
}
if %TR_shard = free
{
gosub TM_AdvJournalScan world VALID_ADVANCE The_world_will_
if #result = #true
{
sound
wait 30s
if %debug = 2
{
display ok World save detected
}
}
}
gosub TR_Hand_in
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_House_Rune %TR_House_Rune %TR_runebook
if #result = #true
{
repeat
wait 50
gosub TM_TravelFromRunebook %TR_Recallmethod %TR_House_Rune %TR_House_Rune %TR_runebook
until #result = #false
}
event macro 31 0
until #charghost = yes
display ok Your dead, unlucky!
halt
;==================================
;==================================
; SUBS
;==================================
; Wipes out of date save
sub TR_wipe_old_save
gosub TM_NGFS_DeleteName TheReapers_Mace_and_Shield_Donator
return
;==================================
; Open status window and backpack
sub TR_open_backpack
event Macro 8 2 ;open status bar
wait 10
set #contPosX 850
set #contPosY 325
event macro 8 7
wait 10
set #contPosX 850
set #contPosY 500
wait 10
return
;==================================
; Makes bucklers
sub TR_make_bucklers
repeat
gosub TR_menu_button
if %TR_shard = free
{
gosub TM_AdvJournalScan world VALID_ADVANCE The_world_will_
if #result = #true
{
sound
wait 30s
if %debug = 2
{
display ok World save detected.
}
}
}
finditem %plain_ingots C_ , #backpackID
if #findkind = -1
{
gosub TR_get_ingots
}
else
{
if #findstack < 40
{
gosub TR_get_ingots
}
}
finditem %tinker_tools C_ , #backpackID
if #findkind = -1
{
display ok You need at least one tinkers tool in your backpack to run this script, halting!
halt
}
if #findcnt < 2
{
gosub TR_make_tinkers_tool
}
finditem %smiths_hammer C_ , #backpackID
if #findkind = -1
{
gosub TR_make_hammer
}
set #lobjectID #findID
wait 5
event macro 17 0
wait 5
set #contPosX 0
set #contPosY 0
wait 5
if %TR_make_first_buckler = 1
{
click 285 415 dmc
}
else
{
click 30 170 dmc
wait 5
set #contPosX 0
set #contPosY 0
wait 5
click 235 70 dmc
set %TR_make_first_buckler 1
}
gosub TR_waitfor_generic_gump
finditem %buckler C_ , #backpackID
until #findcnt > %max_buckler_amount
set %TR_no_bucklers #findcnt
return
;==================================
; Places ingots in backpack
sub TR_get_ingots
finditem %plain_ingots C_ , %TR_secure
if #findkind = -1
{
display ok You have run out of ingots, Halting!
halt
}
if #findstack < 1000
{
set %stack #findstack
}
else
{
set %stack 1000
}
exevent drag #findID %stack
wait 10
exevent dropc #backpackID
wait 15
set %TR_Status_ingots ( %TR_Status_ingots + %stack )
return
;==================================
; Makes tinker tools
sub TR_make_tinkers_tool
set #lobjectID #findID
event macro 17 0
wait 5
set #contPosX 0
set #contPosY 0
wait 5
click 30 110 dmc
wait 5
set #contPosX 0
set #contPosY 0
wait 5
click 230 130 dmc
gosub TR_waitfor_generic_gump
return
;==================================
; Makes makes smith's hammer
sub TR_make_hammer
finditem %tinker_tools C_ , #backpackID
set #lobjectID #findID
repeat
wait 5
event macro 17 0
gosub TR_waitfor_generic_gump
set #contPosX 0
set #contPosY 0
wait 5
click 30 110 dmc
gosub TR_waitfor_generic_gump
set #contPosX 0
set #contPosY 0
wait 5
click 385 270 dmc
gosub TR_waitfor_generic_gump
set #contPosX 0
set #contPosY 0
wait 5
click 230 130 dmc
gosub TR_waitfor_generic_gump
wait 10
finditem %smiths_hammer C_ , #backpackID
wait 5
until #findkind <> -1
return
;==================================
; Updates the status window
sub TR_update_status
set %Bpoints ( %TR_Status_bucklers * 9 )
menu delete tnbucklers
menu delete tningots
menu delete tnpoints
menu text tnbucklers 150 5 %TR_Status_bucklers
menu text tningots 150 25 %TR_Status_ingots
menu text tnpoints 150 45 %Bpoints
return
;==================================
; Determines menu button status
sub TR_menu_button
if #menubutton <> n/a
{
if #menubutton = TR_pause
{
menu delete TR_pause
menu button TR_resume 5 75 75 25 RESUME
set #menubutton n/a
repeat
wait 0
until #menubutton <> n/a
if #menubutton = TR_resume
{
menu delete TR_resume
menu button TR_pause 5 75 75 25 PAUSE
set #menubutton n/a
}
}
if #menubutton = TR_close
{
gosub TR_save_and_close
}
}
return
;==================================
; Saves %vars and quits script
sub TR_save_and_close
gosub TM_NGFS_RegisterVariables TheReapers_Mace_and_Shield_Donator std std TR_recallmethod TR_runebook TR_save TR_Donation_NPC TR_secure TR_Library_Rune TR_House_Rune TR_shard TR_Status_ingots TR_Status_bucklers
gosub TM_NGFS_SaveVariables TheReapers_Mace_and_Shield_Donator
menu hide
halt
;==================================
; Check weight + dump ingots to secure if overweight
sub TR_check_weight
if #weight < #maxweight
{
return
}
else
{
finditem %plain_ingots C_ , #backpackid
wait 5
exevent drag #findid #findstack
wait 10
exevent dropc %TR_secure
set %TR_Status_ingots ( %TR_Status_ingots - #findstack )
}
wait 20
if #weight > #maxweight
{
display ok You are overweight, halting.
halt
}
return
;==================================
; Hands in the bucklers
sub TR_Hand_in
set %TR_temp_weight #weight
repeat
set #lobjectID %TR_Donation_NPC
event macro 17 0
gosub TR_waitfor_generic_gump
set #contPosX 0
set #contPosY 0
wait 5
click 40 260 dmc
wait 10
msg %TR_no_bucklers $
wait 10
until #weight < %TR_temp_weight
set %TR_Status_bucklers ( %TR_Status_bucklers + %TR_no_bucklers )
set %TR_no_bucklers 0
gosub TR_update_status
return
;==================================
; Wait for hand-in gump
sub TR_waitfor_generic_gump
set %TR_time #scnt
repeat
if You_create_ in #sysmsg
{
break
}
if #scnt > ( %TR_time + 10 )
{
break
}
wait 0
until #contname = generic_gump
wait 5
return
;==================================
; Open house secure
sub TR_open_secure
set #lobjectid %TR_secure
wait 5
event macro 17 0
wait 5
set #contPosX 650
set #contPosY 500
return
;==================================
;-----END OF THE REAPERS SUBS------
;==================================
;--------------------------------------------------------------------
;------------------------ TM's SAVE SUBS ----------------------------
;--------------------------------------------------------------------
;--------------------- Base User Functions -------------------------
;--------------------------------------------------------------------
; TM_NGFS_InitializeScript
; %1 - ScriptName
; %2 = (opt) generic : add this tag to create a generic (non-character relative data set)
sub TM_NGFS_InitializeScript
namespace push
namespace local TM_NGFS , _ , %1
namespace clear
set !lpc #LPC
set #LPC 10000
if %0 = 0
{
display ok You must name your script, spaces will be converted to underscores.
stop
}
set !TM_FSSIZE 1000 ; do not change this!!
set !script_name %1
set !args %0
gosub AddUnderscore !script_name
set !script_name #RESULT
if !args = 1
{
gosub AddUnderscore #SHARD
set !slot #CHARID , _ , #RESULT , _ , !script_name , _vars
}
else
{
set !slot generic , _ , !script_name , _vars
}
set ! . !slot
set !varcnt 0
set !index 0
set !script_index N/A
while *TM_FS . !index <> N/A
{
if *TM_FS . !index = !slot
{
set !script_index !index
break
}
set !index !index + 1
}
if !script_index = N/A
{
set !script_index !index
set *TM_FS . !script_index !slot
}
set #LPC !lpc
namespace pop
set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
; TM_NGFS_RegisterVariables
; %1 - ScriptName
; %2 - NSType (local, global, std) --> std is a %var
; %3 - NSName (std) --> std is a %var
; %4, %5, %6, etc. variable names (don't include the % or ! - so %var becomes var, etc)
sub TM_NGFS_RegisterVariables
if %0 <= 3
{
display ok Not enough arguments
stop
}
namespace push
namespace local TM_NGFS , _ , %1
if !slot = N/A
{
display ok You must name your script and also run TM_NGFS_InitializeScript first.
stop
}
set !nstype %2
set !nsname %3
for !i 4 %0
{
set !var % . !i
if !nstype , , !nsname , , !var notin ! . !slot
{
set !newval ! . !slot
set ! . !slot !newval , !nstype , , !nsname , , !var ,
set !varcnt !varcnt + 1
}
}
namespace pop
set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
; TM_NGFS_SaveVariables
; %1 - ScriptName
; assuming you have registered the variables, then everything will be saved in one call
sub TM_NGFS_SaveVariables
if %0 = 0
{
display ok You must name your script, spaces will be converted to underscores.
stop
}
namespace push
namespace local TM_NGFS , _ , %1
if !TM_FSSIZE = N/A
{
display ok You must first call TM_NGFS_InitializeScript and have$registered variables with TM_NGFS_RegisterVariables - STOPPING.
stop
}
set !lpc #LPC
set #LPC 10000
set !outstring
set !start 1
set !sepcnt 1
set !line_count 0
set !temp_str ! . !slot
for !i 1 !varcnt
{
gosub ReadItem ! . !slot
set !nstype #RESULT
gosub ReadItem ! . !slot
set !nsname #RESULT
gosub ReadItem ! . !slot
set !var #RESULT
if std in !nstype
{
set !val % . !var
}
else
{
namespace copy !var from !nstype !nsname
set !val ! . !var
}
set !outstring !outstring , !nstype , , !nsname , , !var , , !val ,
str len !outstring
if #STRRES >= !TM_FSSIZE
{
set * . !slot , !line_count !outstring
set !outstring
set !line_count !line_count + 1
set !start !start - 1
str del ! . !slot 1 !start
set ! . !slot #STRRES
set !start 1
set !sepcnt 1
}
}
str len !outstring
if #STRRES > 0
{
set * . !slot , !line_count !outstring
set !line_count !line_count + 1
}
set * . !slot , !line_count N/A ; make sure there's nothing left at end of the list
set #LPC !lpc
set ! . !slot !temp_str
namespace pop
set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
; TM_NGFS_LoadVariables
; %1 - ScriptName
; note you have to call TM_NGFS_InitializeScript
sub TM_NGFS_LoadVariables
if %0 = 0
{
display ok You must name your script, spaces will be converted to underscores.
stop
}
namespace push
namespace local TM_NGFS , _ , %1
if !TM_FSSIZE = N/A
{
display ok You must first call TM_NGFS_InitializeScript - STOPPING.
stop
}
set !lpc #LPC
set #LPC 10000
set !start 1
set !sepcnt 1
set !line_count 0
set !temp !slot , !line_count
set !string * . !temp
set ! . !slot
set !varcnt 0
set !continue #TRUE
while !continue = #TRUE
{
gosub ReadItem !string
if !continue = #TRUE
{
set !nstype #RESULT
gosub ReadItem !string
set !nsname #RESULT
gosub ReadItem !string
set !var #RESULT
gosub ReadItem !string
set !val #RESULT
if std in !nstype
{
set % . !var !val
}
else
{
set ! . !var !val
namespace copy !var to !nstype !nsname
}
set !newval ! . !slot
set ! . !slot !newval , !nstype , , !nsname , , !var ,
set !varcnt !varcnt + 1
}
if !continue = #FALSE
{
set !line_count !line_count + 1
set !temp !slot , !line_count
set !string * . !temp
set !start 1
set !sepcnt 1
if !string <> N/A
set !continue #TRUE ; still more to process
}
}
set #LPC !lpc
namespace pop
set !TM_Function_found #TRUE
return
;--------------------------------------------------------------------
; Used internally
sub ReadItem
str pos %1 !sepcnt
if #STRRES <> 0
{
set !len #STRRES - !start
str mid %1 !start !len
set !start !start + !len + 1
set !sepcnt !sepcnt + 1
return #STRRES
}
set !continue #FALSE
return #TRUE
;--------------------------------------------------------------------
; Used internally
; %1 - string to mung
sub AddUnderscore
namespace push
namespace local AU
set !tempstring %1
AddUnderscore_loop1:
str pos !tempstring #SPC
if #STRRES <> 0
{
set !val #STRRES - 1
str left !tempstring !val
set !left #STRRES
set !val !val + 1
str del !tempstring 1 !val
set !tempstring !left , _ , #STRRES
goto AddUnderscore_loop1
}
set #RESULT !tempstring
namespace pop
return #RESULT
;--------------------------------------------------------------------
;---------------- Advanced File System Functions -------------------
;--------------------------------------------------------------------
; TM_NGFS_DoesSaveExist
; %1 - ScriptName
; #RESULT = #TRUE - exists, #FALSE - doesn't exist
; note: this is relative to the current character.
sub TM_NGFS_DoesSaveExist
namespace push
namespace local TM_NGFS , _ , %1
set !lpc #LPC
set #LPC 10000
set !script_name %1
set !args %0
gosub AddUnderscore !script_name
set !script_name #RESULT
if !args = 1
{
gosub AddUnderscore #SHARD
set !tempslot #CHARID , _ , #RESULT , _ , !script_name , _vars
}
else
{
set !tempslot generic , _ , !script_name , _vars
}
set !index 0
set #RESULT #FALSE
while *TM_FS . !index <> N/A
{
if *TM_FS . !index = !tempslot
{
set #RESULT #TRUE
break
}
set !index !index + 1
}
set #LPC !lpc
namespace pop
set !TM_Function_found #TRUE
return #RESULT
;--------------------------------------------------------------------
; TM_NGFS_DeleteName
; %1 = script name tag
; %2 = (opt) generic : add this tag to create a generic (non-character relative data set)
; note: this will also clean up the data stored within the data set
sub TM_NGFS_DeleteName
namespace push
namespace local TM_NGFS , _ , %1
set !lpc #LPC
set #LPC 10000
set !script_name %1
set !args %0
gosub AddUnderscore !script_name
set !script_name #RESULT
if !args = 1
{
gosub AddUnderscore #SHARD
set !tempslot #CHARID , _ , #RESULT , _ , !script_name , _vars
}
else
{
set !tempslot generic , _ , !script_name , _vars
}
set !index 0
set #RESULT #FALSE
set !start #FALSE
while *TM_FS . !index <> N/A
{
if *TM_FS . !index = !tempslot
set !start #TRUE
if !start = #TRUE
{
set !next !index + 1
set *TM_FS . !index *TM_FS . !next
}
set !index !index + 1
}
if !start = #TRUE
{
set !index 0
while !tempslot . !index <> N/A
{
set !tempslot . !index N/A
set !index !index + 1
}
}
set #LPC !lpc
namespace pop
set !TM_Function_found #TRUE
return #RESULT
;--------------------------------------------------------------------
; TM_NGFS_ForceDelete
; %1 = Force delete when entire *TM_FSn var value is known - (get from TM_NGFS_GetFSIndexVal)
; full names are made up like this: XXYYZZ_Shard_ScriptName_vars (XXYYZZ = CHARID, _vars is required)
; note: this will also clean up the data stored within the data set
sub TM_NGFS_ForceDelete
namespace push
namespace local TM_NGFS , _ , %1
set !lpc #LPC
set #LPC 10000
set !full_name %1
set !index 0
set #RESULT #FALSE
set !start #FALSE
while *TM_FS . !index <> N/A
{
if *TM_FS . !index = !full_name
set !start #TRUE
if !start = #TRUE
{
set !next !index + 1
set *TM_FS . !index *TM_FS . !next
}
set !index !index + 1
}
if !start = #TRUE
{
set !index 0
while !full_name . !index <> N/A
{
set !full_name . !index N/A
set !index !index + 1
}
}
set #LPC !lpc
namespace pop
set !TM_Function_found #TRUE
return #RESULT
;--------------------------------------------------------------------
; TM_NGFS_GetFSIndexVal
; %1 = retrieves the *TM_FSn value. This will be terminated by N/A at the end of the list
; index value is integer starting at 0 to n
sub TM_NGFS_GetFSIndexVal
namespace push
namespace local TM_NGFS , _ , %1
set #RESULT *TM_FS . %1
namespace pop
set !TM_Function_found #TRUE
return #RESULT
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; TM's Journal Scanning Subs
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - #LPC setting (optional)
; Brings !_jindex up to the most recent #journal entry
sub TM_AdvJournalSync
namespace push
namespace local TM_AdvJS_ , %1
set !_jindex #jindex + 1
if %0 > 1
set !lpc_set %2
namespace pop
set !TM_FunctionCalled #TRUE
return
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
; %3, %4, %5, etc strings to match
; returns #TRUE for match, #FALSE for no match
; Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
; Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
; About %2 arguments:
; NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
; ADVANCE: no spam checking, advances #jindex copy
; VALID: invokes SPAM filtering, no advance of #jindex copy
; VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
sub TM_AdvJournalScan
namespace push
namespace local TM_AdvJS_ , %1
set !args %2
set !temp_lpc #LPC
if !lpc_set = N/A
set #LPC 1000
else
set #LPC !lpc_set
set !num_args %0
set !first_arg 3
set !sampled_jindex #JINDEX
if !_jindex = N/A
set !_jindex !sampled_jindex
if !charname = N/A
{
set !charname #CHARNAME
AdvJournalScan_loop1:
str pos !charname #SPC
if #STRRES <> 0
{
set !val #STRRES - 1
str left !charname !val
set !left #STRRES
set !val !val + 1
str del !charname 1 !val
set !charname !left , _ , #STRRES
goto AdvJournalScan_loop1
}
}
set !index !first_arg
repeat
set !temp_jindex !_jindex
set !text % . !index
while !temp_jindex <= !sampled_jindex
{
scanjournal !temp_jindex
str pos #JOURNAL !charname 1
set !namepos #STRRES
str count #JOURNAL !charname
set !namecnt #STRRES
str pos #JOURNAL :_ 1
set !smcpos #STRRES
str pos #JOURNAL !text 1
set !textpos #STRRES
if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
set !pass #TRUE
else
set !pass #FALSE
if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
{
set !temp_jindex !temp_jindex + 1
if ADVANCE in !args
set !_jindex !temp_jindex
set #LPC !temp_lpc
namespace pop
set !TM_FunctionCalled #TRUE
return #TRUE
}
set !temp_jindex !temp_jindex + 1
}
set !index !index + 1
until !index - !first_arg > !num_args - !first_arg
set %10 !sampled_jindex - !_jindex
set %10 %1 , _ , %10 ; for debugging purposes
set #LPC !temp_lpc
namespace pop
set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; %1 = spell number
; %2 = #TARGETID or SELF or NONE
; %3 = retry count (-1 = cast until successful)
; %4 = cast delay
; %5 = recovery delay
sub TM_NewCastSpell
namespace push
namespace local NCS
set !lpc #LPC
set #LPC 100
set !whichspell %1
set !whichtarget %2
set !castretrymax %3
set !waitdelay %4
set !recovery_delay %5
set !castretry 0
set !temp_ltargetid #LTARGETID
set !temp_ltargetkind #LTARGETKIND
NewCastSpell_loop1:
if !castretrymax < 0
goto NewCastSpell_cont1
if !castretry > !castretrymax
goto NewCastSpell_end1
NewCastSpell_cont1:
gosub TM_AdvJournalSync SPELLCAST
set #LTARGETKIND 1
set #LTARGETID !whichtarget
set !tempmana #MANA
event macro 15 !whichspell ; cast the spell
wait !waitdelay
set !targettimeout #SCNT + 7
NewCastSpell_wait1:
gosub TM_AdvJournalScan SPELLCAST VALID you_have_not_yet mana your_spirit more_reagents
if #RESULT = #TRUE || #SCNT > !targettimeout
{
set !casttimeout #SCNT2 + !recovery_delay
repeat
until #SCNT2 > !casttimeout ; finish up cast delay
set !castretry !castretry + 1
goto NewCastSpell_loop1
}
if !whichtarget = NONE
goto NewCastSpell_skip1
if #TARGCURS = 1
goto NewCastSpell_targ1
goto NewCastSpell_wait1 ; wait for target cursor
NewCastSpell_targ1:
if !whichtarget = SELF
event macro 23
else
event macro 22
NewCastSpell_skip1:
wait 5
set !casttimeout #SCNT2 + !recovery_delay
NewCastSpell_skip2:
if !whichspell >= 0 && !whichspell <= 63 ; Magery
{
gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents
}
else
{
set !cont #FALSE ; Chivalry, Necromancy, etc
finditem !whichtarget *
if !whichtarget in SELF_NONE || #FINDKIND <> -1
set !cont #TRUE
if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
set #RESULT #TRUE
else
set #RESULT #FALSE
}
repeat
until #SCNT2 > !casttimeout ; finish up cast delay
if #RESULT = #TRUE
{
if !castretrymax > -1
{
set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
if !castretry > !castretrymax
goto NewCastSpell_end1
}
goto NewCastSpell_loop1
}
if #SCNT2 <= !casttimeout ; finish up cast delay
goto NewCastSpell_skip2
NewCastSpell_end1:
set #LTARGETID !temp_ltargetid
set #LTARGETKIND !temp_ltargetkind
set #LPC !lpc
namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
namespace push
namespace local RFR
set #LTARGETKIND 1
set !method %1
set !locindex %2
set !locindexend %3
set !rbook %4
finditem !rbook C_ , #BACKPACKID
if !method notin RE_GA_SJ || #FINDKIND = -1
{
namespace pop
return #TRUE
}
if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
TravelFromRunebook_loop1:
set #LOBJECTID !rbook
set #LTARGETKIND 1
event macro 17 0
gosub GumpWait generic_gump generic_gump
set !runeclickx 140 ; page 1, rune 1
set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
if !locindex > 8
{
set !runeclickx 310 ; page 2, rune 1
set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
}
set !runeclicky #CONTPOSY + 196
click !runeclickx !runeclicky
wait 5
set !runeclicky #CONTPOSY + 24
set !runeclickx #CONTPOSX + 164 ; page 1 set to default
if !locindex % 2 = 0
{
set !runeclickx #CONTPOSX + 305 ; page 2 set to default
}
click !runeclickx !runeclicky
wait 5
set !oldx #CHARPOSX
set !oldy #CHARPOSY
if !method = RE
gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
if !method = GA
{
gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
set !temp_cnt #SCNT + 10
repeat
finditem KEF_OTF_JEF G_0
until #FINDKIND <> -1 || #SCNT > !temp_cnt
if #FINDKIND <> -1
{
set #LOBJECTID #FINDID
wait 10
event macro 17 0
wait 20
if #CONTNAME = generic_gump && #CONTSIZE = 420_280
{
gosub TM_AdvJournalSync SPELLCAST
set !clickx #CONTPOSX + 26
set !clicky #CONTPOSY + 261
click !clickx !clicky ; click ok
}
}
}
if !method = SJ
gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful
wait 30
set !tempscnt #SCNT + 10
WaitforTravel_loop1:
gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks
if #RESULT = #TRUE
{
gosub TM_AdvJournalSync SPELLCAST
set !locindex !locindex + 1
if !locindex > !locindexend
{
namespace pop
return #TRUE
}
goto TravelFromRunebook_loop1
}
if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
goto WaitforTravel_loop1
if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
{
set !clickx #CONTPOSX + 120
set !clicky #CONTPOSY + 60
click !clickx !clicky mc r
wait 5
}
namespace pop
click 401 254 n
return #FALSE
;------------------------------------------------
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
namespace push
namespace local TFNR
set !method %1
set !start_index %2
set !end_index %3
set !runbook_name %4
if !method notin RE_GA_SJ
{
namespace pop
return #TRUE
}
if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
{
namespace pop
return #TRUE
}
locatenamedrunebook:
finditem ZBN C_ , #BACKPACKID
if #FINDKIND <> -1
{
event property #FINDID
if !runbook_name in #PROPERTY
{
gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
}
else
{
ignoreitem #FINDID rbook
goto locatenamedrunebook
}
}
else
{
display ok Cannot locate specified runebook named , #SPC , !runbook_name
stop
}
ignoreitem reset rbook
namespace pop
return
;-------------------------------------------------------------------------------
sub TM_RandomRunebookTravel
namespace push
namespace local RRT
set !travelmethod %1
set !rune1 %2
set !rune2 %3
set !runebook %4
if !rune1 > !rune2
{
set !temp !rune2
set !rune2 !rune1
set !rune1 !temp
}
RunebookTravel_loop1:
set !random #RANDOM
set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
if #RESULT = #TRUE
goto RunebookTravel_loop1
namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = Object Findid
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromObject
namespace push
namespace local RFR
set !method %1
set !object %2
finditem !object C_ , #BACKPACKID
if !method notin RE_GA_SJ || #FINDKIND = -1
{
namespace pop
return #TRUE
}
set !oldx #CHARPOSX
set !oldy #CHARPOSY
TravelFromObject_loop1:
if !method = RE
gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
if !method = GA
{
gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
set !temp_cnt #SCNT + 10
repeat
finditem KEF_OTF_JEF G_0
until #FINDKIND <> -1 || #SCNT > !temp_cnt
if #FINDKIND <> -1
{
set #LOBJECTID #FINDID
wait 10
event macro 17 0
wait 20
if #CONTNAME = generic_gump && #CONTSIZE = 420_280
{
gosub TM_AdvJournalSync SPELLCAST
set !clickx #CONTPOSX + 26
set !clicky #CONTPOSY + 261
click !clickx !clicky ; click ok
}
}
}
if !method = SJ
gosub TM_NewCastSpell 210 !object -1 10 30 ; sacred journey until successful
wait 30
set !tempscnt #SCNT + 10
WaitforTravel2_loop1:
gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking your_spirit_lacks
if #RESULT = #TRUE
{
gosub TM_AdvJournalSync SPELLCAST
set !locindex !locindex + 1
if !locindex > !locindexend
{
namespace pop
return #TRUE
}
goto TravelFromObject_loop1
}
if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
goto WaitforTravel2_loop1
namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
namespace push
namespace local GW
wait 10
set !timedelay #SCNT
while #SCNT <= !timedelay + 7
{
if #CONTNAME = %1 || #CONTNAME = %2
{
namespace pop
return #TRUE
}
}
namespace pop
return #FALSE