First, I will admit I did not run this to reproduce your error. Once I looked at it out to satisfy my curiosity, I remembered having similar behavior in a script of my own. So I decided to go compare what I did there to see if possibly I did something different.
You said it recalls the first time to arrive at the bank and then it continues to cast. Now you are blocking yourself as you try to recall to the position where you are standing.
This means it completes the first pass through the routine, TM_NewCastSpell, successfully, then still hits an error condition, where #RESULT is #TRUE. #RESULT is set any time there is a return from a subroutine or it is specifically set in a script. In this loop where it is stuck, that is the gosub statements to TM_AdvJournalSync and TM_AdvJournalScan.
I looked at a script where I used the same Recall logic code and I have a difference, so maybe this could help your issue, too.
Here is the code in this mining script:
;####################
;SUB TM_NewCastSpell
;####################
; %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 100
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 NONE spell_fizzles 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
}
Here is the code in my script using these routines:
;-------------------------------------------------------------------------------
; %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
Pay particular attention to the TM_AdvJournalScan lines.
Both of mine use VALID in place of NONE (VALID means make sure other player's speech is not interfering with your results; NONE just accepts whatever is in the character's journal).
The first TM_AdvJournalScan I removed "spell_fizzles".
On a positive note, I do not believe what you are describing is a timing issue. I think this script's logic supports your description in this recall routine.
I looked at the few places that the code calls any of the TM_Travel routines and there is no code to try to rerun the travel routine - it is expecting a successful result. That gives more weight to the issue of recalling over an over is in the TM_Travel routines itself and that boils down to the code in TM_NewCastSpell.
Gaderian