ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Coragin on January 08, 2014, 05:23:48 AM
-
Hiya! Me again.
Spliced together and changed some stuff in a few scripts to make something new.
First my problem was, it would not wait till mob was dead and completely keep saying "all kill" over and over and over. I got that fixed, but now it works fine for first mob, then dont do anything else :(
(Spliced from C2 Ilsh Spawner and Cervs Auto Honor, Left out the TM Journal subs as they work perfect and too long to post ;) )
I am assuming I have to reset the #find, but its been so long. :(
set %spawn NB_XI_EF_WF_XZ_
start:
gosub disco
gosub wait
goto start:
sub wait
if #findkind = -1
return
msg all kill $
target 5s
set #ltargetid %spawn
set #ltargetkind 1
event macro 22 0
wait 10
event macro 3 0 all kill
target 5s
event macro 22
KeepWaiting:
Repeat
if #findkind = 1
goto KeepWaiting:
until #findCnt = 0
Return
sub disco
set %DiscoAttempts 0
repeat
if %DiscoAttempts > 0
wait 10s
finditem %spawn G_10
if #findkind = -1
return
set %spawn #findid
event macro 13 15 ;disco
target 5s
set #ltargetid %spawn
set #ltargetkind 1
event macro 22 0
wait 1s
gosub TM_AdvJournalScan disco NONE jarring already
set %DiscoAttempts ( %DiscoAttempts + 1 )
until #result = #true
gosub TM_AdvJournalSync disco 100
return
-
I think I figured it out, will find out next Navrey...
KeepWaiting:
Repeat
;if #findkind = 1
;goto KeepWaiting:
until #findCnt = 0
Return
Conflicting code...
-
Well that didnt work...changing that area to....
Repeat
until #findCnt = -1
-
I dont get it, its not working :( Gets stuck right in that loop
-
Dont' get #findkind & #findcnt mixed up. #Findcnt will = ZERO if there's nothing to be found. I always use #findcnt and NEVER #findkind.
-
Findkind has to do with whether what was found was on the ground or in a container. So using findkind can get you in trouble. Findcnt as Alpha has said is the better way to find whether there is something there or not. (MWinc is the one who taught me that one) :)
-
I use #findkind all of the time but I typically just use it as an either yes found or no not found:
if #findkind <> -1 <--- Item is found
if #findkind= -1 <--- Item is not found
This is fine to use.
I tend to use #findcnt when I expect to find or need to loop through multiple items.
The only reason #findcnt is recommended over #findkind is that it's "easier for humans to debug" (according to the EasyUO wiki). Use whichever is less confusing for you, and as Tidus points out, the #findcnt is typicall less confusing because #findkind has multiple potential values:
-1 No objects found.
0 Object is in a container.
1 Object is on the ground.
X
-
Yep.. 12X that about sums it up. You will all probably smile but for the longest time I couldn't remember what #TRUE & #FALSE evaluated to as integers.. I'd alway get the 0 and -1 mixed up until I simply thought about -1 basically being a "T" tipped over on it's side and thus #TRUE. LoL YES... that's actually how I think about it heh.
-
Hah nice!! Now I'll be able to remember too, thanks for the tip! :P
-
Well that didnt work...changing that area to....
Repeat
until #findCnt = -1
Needs to be
Repeat
until #findCnt = 0
you will never find a negative in a count :)
-
EDIT: Well poop, colors dont work in code. Gonna try converting to a quote, if it is not too messy, I will leave it and this note. :)
Okay here is what I got guys, the whole script. Its a start of me getting back into things and making bigger scripts like I used to. Remember my imbuing training and make armor/imbue/enhance? This is gonna be a stand alone Bard/Tamer/Mage bot for doing things that need disco.
Anyways, can someone please edit it so it works correctly so I can see what is wrong? It runs one spawn perfect, then hangs.
Also this is getting going on most things that are the core, Turn on Perserverence BEFORE discord and off when Mob dies (See purple note)
As well as I intend to add healing, at minimum for pet, first just by baindaids, then by magery if its a mob Tamer cannot get close to.
Healing for emergencies on Tank will also come if it is not too much for me. Doubtful, just slow getting back in to things and remembering :D
I also want to have the toon stay within 10 tiles of Tank no matter where tank goes. Thinking of using party chat so bot can communicate with main what its doing. Also scanning party chat to do certain things...
Anyways, thanks for listening. :)
I will mark in RED where its hanging. Please, thank you, :)
set %spawn XZ_HS_IJ_FJ_
set %scanbuffbar C:\EUO\
start:
gosub disco
gosub wait
;gosub bardoff ;<------Will eventually turn off Bard Mastery Perserverence
goto start:
sub wait
if #findkind = -1
return
msg all kill $ ;duh
target 5s
set #ltargetid %spawn
set #ltargetkind 1
event macro 22 0 ;last target
wait 10
event macro 3 0 all kill ;duh
target 5s
event macro 22 ;last target
KeepWaiting:
Repeat
until #findCnt = 0 ;<---------Hangs up here!
Return
sub bardoff
if #findkind = 1
return
Call ScanBuffBar
if _Preservance_ in %BuffBarIconNames
{
event macro 15 704 ;Cast Perserverence (off) <-----This will turn OFF Perserverence
wait 5s
}
Return
sub castbard
if _Preservance_ in %BuffBarIconNames
Return
event macro 15 704 ;Cast Perserverence (on) <-----This sub will turn ON Perserverence.
wait 5s
Return
sub disco
set %DiscoAttempts 0
repeat
if %DiscoAttempts > 0
wait 10s
finditem %spawn G_10
if #findkind = -1
return
;event macro 15 704 ;Cast Perserverence (on)<-----For now, this turns Perserverence on (but toggles it on off on off)
wait 90
set %spawn #findid
event macro 13 15 ;disco
target 5s
set #ltargetid %spawn
set #ltargetkind 1
event macro 22 0
wait 1s
gosub TM_AdvJournalScan disco NONE jarring already
set %DiscoAttempts ( %DiscoAttempts + 1 )
until #result = #true
gosub TM_AdvJournalSync disco 100
return
;------------------------------Journal tool---------------------
;=================================================================
; Script Name: TrailMyx's Advanced Journal Scanner
; Author: TrailMyx
; Version: 1.0
; Shard OSI / FS: OSI / FS?
; Revision Date: 10/20/2007
; Purpose:
; Use these subs to quickly find text in your #journal entries. These subs
; use #jindex for flawless journal scanning and is much more reliable than using
; standard indexing of #journal and #SYSMSG.
;
; Now it is possible to manage separate journals based on unrelated text. It's now possible
; to monitor spellcasting, bandaging, stealing, or anything else without a TM_AdvJournalSync
; potentially removing text needed for another UO funciton.
;
; New is the ability to either gosub or call these functions without the need to change the
; header! When calling, a limit of 10 arguments is allowed, but more can be added by editing the
; call interface section.
;
; Examples:
; gosub TM_AdvJournalSync speech 100 ; sync "speech" journal space, set #LPC to 100 from default of 1000
; gosub TM_AdvJournalScan speech VALID Find_this_text and_find_this_too ; will not advance copy of #jindex
; gosub TM_AdvJournalScan heal VALID_ADVANCE you_heal_what that_patient_is_not ; advances pointer after scan
; gosub TM_AdvJournalScan spellcast NONE fizzle ; no spam checking and doesn't advance #jindex copy automatically
;
; Subs included:
; TM_AdvJournalSync - Must call this in initialzation
; TM_AdvJournalScan - see header for details....
;
; Release history:
; v1.0 - Initial release.
;
; Requirements:
; Nothing special
;
; Credit:
; If you use these subs, please leave credit for me somewhere in your script header.
;=================================================================
;------------------------ Call interface -----------------------
;=================================================================
set !TM_FunctionCalled #FALSE
if %0 = 1
gosub %1
if %0 = 2
gosub %1 %2
if %0 = 3
gosub %1 %2 %3
if %0 = 4
gosub %1 %2 %3 %4
if %0 = 5
gosub %1 %2 %3 %4 %5
if %0 = 6
gosub %1 %2 %3 %4 %5 %6
if %0 = 7
gosub %1 %2 %3 %4 %5 %6 %7
if %0 = 8
gosub %1 %2 %3 %4 %5 %6 %7 %8
if %0 = 9
gosub %1 %2 %3 %4 %5 %6 %7 %8 %9
if %0 = 10
gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10
if %0 = 11
gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11
if %0 > 11
{
display ok Too many arguments for "call", edit file.
stop
}
if !TM_FunctionCalled = #TRUE
exit
if %0 = N/A
display ok You may not run this script directly.
else
display ok Function " , %1 , " not found.
stop
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; %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
if !_jindex = N/A
set !_jindex #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 <= #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 #LPC !temp_lpc
namespace pop
set !TM_FunctionCalled #TRUE
return #FALSE
-
Well i think the reason you are hanging at that part is because it is no longer doing a find. So maybe if you do a finditem inside your repeat... that is my only thought of why it would hang there...
-
Well i think the reason you are hanging at that part is because it is no longer doing a find. So maybe if you do a finditem inside your repeat... that is my only thought of why it would hang there...
Ditto .. #findcnt only updates its value when you do a new finditem command. Therefor the results of a finditem are not valid for very long when dealing with moving/movable/consumable items such as players/npcs/mobs or potions !!!.
When creating loops I am always very careful to give an error way out generally but move time than expected passing. In most of my code I give multiple exits from loops such as pseudo code below
set !endtime #systime + 60 ; one min
repeat
-- code
until loggedin = #false || #charghost = #true || !endtime > #systime || TheActualRealConditionIWantedToTestFor