Author Topic: First Script, help appreciated!  (Read 3198 times)

0 Members and 1 Guest are viewing this topic.

Offline RnTopic starter

  • Full Member
  • ***
  • Posts: 177
  • Activity:
    0%
  • Reputation Power: 0
  • Rn has no influence.
  • Gender: Male
  • Respect: +15
  • Referrals: 0
    • View Profile
First Script, help appreciated!
« on: May 06, 2016, 04:47:11 PM »
0
OK, so my very first script from scratch (be gentle). I've played around with others and I'm basically using snippets from different ones and what I've learned doing so to get started. Any help appreciated!



First Goal:
Use secondary character to repeatedly area peacemake and bandage primary character while being able to manually interrupt the loop to discord on my command.

So far I have two separate scripts that work-ish, but I would like to combine the two to accomplish my goal.


#1. Constant peacing and manual disco

gosub Peace
gosub Discord


sub Peace
    {
     event macro 13 9    ;peacemaking
     target 5s
     event macro 23 0    ;tgt self
     wait 7s
     return
    }


sub Discord
     {
       scanjournal %i
       if You_must_wait in #journal       ;breaks peace loop
          {
           wait 7s                        ;provides time to use disco
           scanjournal %i
           if You_play in #journal   ;disco success
              {
               wait 7s                     ;wait for skill cooldown
              }
           scanjournal %i
           if You_attempt in #journal  ;disco fail
              {
               wait 4s          ;wait for skill cooldown
              }
          }
     }
;goes back to peace loop


Two questions. Does my second set of journal scans actually work like I think it does (only testing on easy things as I'm spending more time on the code than in-game)? Secondly, does the journal scan only scan the last line in the journal?



#2. Constant healing and manual discord

gosub Heal
gosub Disco




sub Heal
    {
       event macro 17           ;use last object (bandage) (have to manually use before starting)
       set #ltargetid KAYSSE   ;change this depending on primary char
       set #ltargetkind 1        ;is this line needed?
       target 5s
       event macro 22          ;last tgt (primary char)
       wait 3s                     ;wait for bandage heal
       return
     }
      
      
sub Disco
     {
       scanjournal %i
          if Choose in #journal     ;used disco
             {
              wait 10s              ;pause so bandage use doesn't cancel targeting
             }
     }




So I've tried to combine the two into one heal/peace/disco script but I keep shooting myself in the foot. Any pointers?




My LONG term goes is to be able to able to create something like:

heal primary when needed
constant peace loop
on primary character, through party chat - send monster ID to secondary character, break the heal/peace loop to disco the monster my primary is targeting

Offline savestheyday

  • Jr. Member
  • **
  • Posts: 20
  • Activity:
    0%
  • Reputation Power: 1
  • savestheyday has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: First Script, help appreciated!
« Reply #1 on: May 06, 2016, 09:00:41 PM »
0
Since you are planning on coordinating actions between two clients, I suggest learning about persistent variables by reading the easyuo documentation (http://wiki.easyuo.com/index.php?title=Variables).  It is hard to read an allies hp vs. your own or an enemies. Instead of using OCR, just tell the other client what the current hp is!  Go on test center where no one will bother you and have the second client say the current hp of the first every few seconds.  Play on the first client and damage yourself several times to test that it is working correctly.  You can press F7 to walk through each line in a script to find spots where it hangs up or behaves funny.  As you get basic parts keep building more and more complexity into the scripts.

Client 2:
Code: [Select]
main_loop:

repeat

if my allies *currenthp is less than his *maxhp
{
    msg My BFF has *currenthp HP $
    wait 30
    ; gosub healing
}
; gosub barding *enemyid

until #CharGhost = YES
while #CharGhost = YES
    msg you said you would protect me! $
    halt
GoTo main_loop

Client 1:
Code: [Select]
main_loop:

repeat

set my max hp to *maxhp ; in case of buff/debuff
set my current hp to *currenthp
wait 20

until #CharGhost = YES
while #CharGhost = YES
    msg nice healing, anusface $
    halt
GoTo main_loop

Once you get the above working modify it to display an enemy ID from the first client on the second.  You can then use that to auto target your bard skills.  I would use finditem in your backpack to look for bandages so you don't have to hardcode the ID each time.

To understand how to organize the flow of your script and use a wrapper/loop read (http://www.scriptuo.com/index.php?topic=976.0)

To pull useful information about your toons for passing info about your HP check out (http://wiki.easyuo.com/index.php?title=MaxHits)

You could consider adding some small waits in your subs for stability, and also using timers to figure out when you should use the next bard skill or bandaid (http://www.scriptuo.com/index.php?topic=12094.0)


I'm not great at scripting, but that's a start until the Wizards can explain more.

Tags: