ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: razeial on July 30, 2012, 08:51:36 PM
-
Hey all. I wrote this script and posted it a few weeks ago, but a bug was reported to me that I can't seem to find a work around for. What's happening is if the lightning strike is not successfully delivered (as happens when either the weapon skill or bushido skill is at low level) , the script wont retoggle lightning strike until the lightning strike is successful. Can anyone please help me out??
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; Script Name: Raz's Full-Auto Bushido Trainer
; Author: Razeial
; Version: 1.1
; Purpose: Will train bushido to 120 using Lightning Strike on a horse
; (or llama, ostard, etc..}. It will also scan your paperdoll to see if you still have a
; weapon in your hand (ie your previous weapon breaks) and will automatically pull another
; weapon from your backpack and rearm it.
;
; Credits: TrailMyx for his Journal Scanner sub
;
; A VERY special thanks to JustAnotherFace (JAF). Without him, this script would not have
; come together. He took quite a bit of time to review the script, help me edit it, teach
; me along the way, and made more efficient suggestions!
;
;Instructions: The script is set up so that you must have a HORSE to train on.
; If you want to train on a cat, dog, llama, etc, you need to change the %mount
; with the corresponding itemtype. If you aren't using Mace Fighting, then you
; need to change the %weapon to the proper itemtype of whatever weapon you'll be
; using to train with. You will also need a good deal of that particular weapon
; in your backpack. I suggest 30 or 40 at a time. You can either craft them or
; buy them from a blacksmith shop. I also recommend wearing a high Mana Ren and
; Lower Mana Cost suit (wouldn't hurt to have Mana Inc on it also).
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;===========================================================================================
; SET UP
;===========================================================================================
set %weapon YSF_QOH_ ; ID's the types of weapons - Mace ---- Modify this to whatever weapon type
; you'll be using to train with
set %ShortDelay 10
set %mount SF_OF_; ID's the types of mounts/animals - Horse ---- Modify this to whatever animal
; type you'll be using to train with
;============================================================================================
;DO NOT EDIT BELOW THIS LINE
;============================================================================================
;
;
; Start Program
gosub showEUOMEnu1
set #menubutton N/a
MenuLoop:
if #MenuButton = cmdExit
{
menu hide
halt
}
if #MenuButton = cmdOK
{
menu hide
goto start
}
goto menuloop
start:
menu hideEUO
menu hide
if %setup <> #true
{
continue
}
finditem %mount G_ , 5
wait 10
if #findcnt < 1
{
sound
wait 5
Display You do not have an animal to train with dummy! Go get one!
halt
}
event macro 6 0
event macro 3 0 All follow me
event macro 3 0 All kill
target
event macro 23 0
;
mainloop:
repeat
gosub TM_AdvJournalSync lightning 100
finditem %weapon C_ , #charid
wait 1
if #findcnt < 1
gosub rearmwep
wait 5
if %spellsetup <> #true
gosub ChooseBushidoSpell
wait 5
gosub TrainBushido
until #skill = 1200
if #skillcap = #skill
{
sound
wait 5
Display CONGRADULATIONS! You've reached your skill cap! Now go kick some ass! :D
halt
}
;===================================================================
; REARM WEAPON SUB
;===================================================================
SUB RearmWep
finditem %weapon C_ , #backpackid
if #FINDcnt < 1
{
sound
wait 5
Display You are out of weapons! Go get some more and restart the script!
halt
}
set #RHANDID #findid ; Modify this based on one or two handed weapon
wait %ShortDelay
event macro 24 2 ; This is for arming a right handed weapon, if you want to arm a left handed weapon its 24 1
wait 1s
return
;====================================================================
; BUSHIDO SUBS
;====================================================================
SUB ChooseBushidoSpell
chooseskill bush
if #skill < 500
{
display Your Bushido skill is not high enough dummy! Go buy it up to 50!
halt
}
if #skill > 500
{
set %special 149 ; Lightning Strike
return
}
set %spellsetup #true
set %setup #true
return
;
SUB TrainBushido
gosub WaitForMana
Event Macro 15 %special ; Uses Lightning Strike
repeat
gosub TM_AdvJournalScan lightning VALID You_attack_with_lightning_precision
until #RESULT = #TRUE
event macro 8 7 ; This opens your backpack to prevent logging out
;
SUB WaitForMana
if #mana < 6 ; Modify this if you dont have 40% LMC and need more than 6 mana to cast Lightning Strike
{
repeat
wait 0
until #mana > 6 ; Modify this if you dont have 40% LMC and need more than 6 mana to cast Lightning Strike
}
return
;=================================================================
; Script Name: TrailMyx's Advanced Journal Scanner
; Author: TrailMyx
; Version: 1.2
; 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_AdvJournalGetTrigger - retrieve the triggering string (#FALSE for no trigger)
; TM_AdvJournalSync - Must call this in initialzation
; TM_AdvJournalScan - see header for details....
;
; Release history:
; v1.0 - Initial release.
; v1.1 - debug code added, fixed small possibility to miss an incoming journal entry
;
; Requirements:
; Nothing special
;
; Credit:
; If you use these subs, please leave credit for me somewhere in your script header.
;=================================================================
;------------------------ Call interface -----------------------
;=================================================================
;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
namespace push
namespace local TM_AdvJS_ , %1
set #RESULT !trigger
namespace pop
set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
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
set TM_AdvJournalGetTrigger #FALSE
namespace pop
set !TM_FunctionCalled #TRUE
return #FALSE
;--------- EasyUO Menu Designer Code Begin ---------
sub showEUOMenu1
menu Clear
menu Window Title Raz's Full-Auto Bushido Trainer
menu Window Color black
menu Window Size 300 250
menu Font Transparent #true
menu Font Align Left
menu Font Name MS Sans Serif
menu Font Size 8
menu Font Style b
menu Font Color Yellow
menu Font Transparent #true
menu Font Align Center
menu Text EUOLabel0 36 6 **************IMPORTANT**************
menu Text EUOLabel1 36 20 --You will need an animal to train with.
menu Text EUOLabel8 36 33 --You will need a bunch of weps in your pack
menu Text EUOLabel2 36 47 --You should also use a MR/LMC suit.
menu Text EUOLabel3 36 60 --Read the instructions in the script header
menu Text EUOLabel4 36 76 before you begin!
menu Text EUOLabel5 36 90 --IF YOU DONT THIS SCRIPT MAY NOT
menu Text EUOLabel6 36 105 WORK FOR YOU!!!!
menu Text EUOLabel7 36 160 Press OK to begin
menu Font Color Black
menu Button cmdOK 160 190 65 30 &OK
menu Button cmdExit 60 190 65 30 E&xit
menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------
-
The problem to me sounds like (And I am stating this without even looking at the code) you are utilizing a journal scanner to check for successful hits (IE: The message stating you perform a good strike, "You strike your opponent at lightning speed" or w/e it is.). Which means that when you miss (and there is no miss phrase for this) the script will continue to wait for the message of a successful hit.
A fix to this would be to set up the script with the cmppix feature. Set it up to scan the spell icon of Lightning strike for a change, and when it is false, it performs the action again, aka re-queues LS. You can see an example of this in my script LAME http://www.scriptuo.com/index.php?topic=7538.
You could get really creative however, and do something like this:
cmppix 1 f
{
if whateverMessage notin whateverJournalScanner
event macro 15 149
wait 5
}
return
Basically what this very crude and pseudo code states, is that if the icon for LS changes (From on to off/red to white) and the journal didn't see the "You strike with lightning blah blah" then to re-queue it because obviously it used the ability and missed.
However thinking about it again I realize that the journal scan would be redundant in this operation and that you can implement a feature to check the mana and compare it the the lowest value in which you are capable of performing the action with. (IIRC 6 or 8 is lowest with max LMC)
I now reflect upon my desire to implement a fail check and a mana consumption check feature that would basically check how many uses of LS there were in order to cut down on the mana cost of LS... Which I guess could be achieved via some sort of sentinel variable or accumulative variable check... Hmmm
Anyways, I'm rambling... Have at LAME, see if you find anything useful in there. :>
-
Holy *bleep*, I wrote a wall of text... Forgive me... I ramble :(
-
LOLOLOL TYTYTYTY!
I looked at your lame script and borrowed this:
sub setpixel-ls
event macro 15 149
display Move the mouse to Lightning Strike Button. You have 3 seconds
wait 3s
savePix #CURSORX #CURSORY 1
wait 5
return
and this from what you posted above:
cmppix 1 f
{
if attack_with_lightning_precision notin #journal
event macro 15 149
wait 5
}
return
and combined it to replace this:
SUB TrainBushido
gosub WaitForMana
Event Macro 15 %special ; Uses Lightning Strike
repeat
gosub TM_AdvJournalScan lightning VALID You_attack_with_lightning_precision
until #RESULT = #TRUE
event macro 8 7 ; This opens your backpack to prevent logging out
with this:
SUB TrainBushido
gosub WaitForMana
scanjournal 10
cmppix 1 f
{
if attack_with_lightning_precision notin #journal
event macro 15 149
wait 5
}
return
event macro 8 7 ; This opens your backpack to prevent logging out
And it freaking works like a charm! Thanks SOOOO much, will be updating the version number and adding you to the credits list :D
-
Anytime :>
-
Well, that code certainly looks familiar ;)
-
Hee Hee, another option would be to just set a fail safe timer, that if the journal event doesn't trigger within say... 6 seconds, it retoggles it.
Scanning Pixels requires it to be front screen, or at least "On Screen" With certain OS, which eats up CPU usage.
Mahna Mahna
-
Well, that code certainly looks familiar ;)
Haha! Thanks for your input on my first debug thread regarding this script! It runs like a champ now! I love learning this stuff. Now I just need to wait for an idea for a new script to pop in my head!