Official ScriptUO EasyUO Scripts > Script Debug

pet attack with location error

(1/1)

Man7dowN:
hello all, having trouble getting my pet attack sub working correctly.

what im trying to do is this

check for closest enemy
{
if find enemy found
{
set pet current location
{
killloop:
have pet attack nearest target
{
check pets location, if pet is in same location return to kill loop
{
if pet location changed halt



what i wrote is not working correctly, looking for any help i can get


--- Code: --- set %monstertype ZC_WE_IJB_
set %petid PDZR
set %scanpk



for %searchDistance 1 10
{
  finditem %monstertype G_ , %searchdistance
  if #findcnt > 0
  {
  finditem %petid
    wait 5
    set %petidx #findx
    set %petidy #findy
    }
    killloop:
    finditem %monstertype G_ , %searchdistance
     if #findcnt > 0
     {
       set #ltargetid #findid
       msg all kill$
       wait 5
       target
       event macro 22 0
       }
       finditem %petid
        if %petid = %petidx || %petid = %petidy
          {
           event sysmessage attack again
           goto killloop
        if %petid <> %petidx || %petid <> %petidy
           {
            event sysmessage pet moving
            halt
            }
           }
--- End code ---

sumsum:
Up to you but I would build the loop around enemy hits VS pet x y. I haven't had much luck getting a x y to compare its self to a set x y on my scripts. I'm sure it can be done.. But it it does work and your monster runs off at 5% as they do... Your going to loop as your pet chases. Just an idea.

Man7dowN:

--- Quote from: sumsum on March 01, 2019, 03:41:48 PM ---Up to you but I would build the loop around enemy hits VS pet x y. I haven't had much luck getting a x y to compare its self to a set x y on my scripts. I'm sure it can be done.. But it it does work and your monster runs off at 5% as they do... Your going to loop as your pet chases. Just an idea.

--- End quote ---

i have been messing around with #finddist but i havnt been able to get it to work right yet, seems like it would be easier than setting multiple x ,y and comparing.

im just trying to get in to say hey i found enemy, set my pet current location, have pet attack enemy, then recheck pets current location, if pet location changes halt, if pet location unchanged use all attack loop again

but if i can get it going i will gladly share the little loop here, this is what i have so far but it fails



--- Code: --- set %monstertype ZC_WE_IJB_
set %petid PDZR
set %scanpk



for %searchDistance 1 10
{
  finditem %monstertype G_ , %searchdistance
  if #findcnt > 0
  {
  finditem %petid
    wait 5
    set %petdist #finddist
    }
    killloop:
    finditem %monstertype G_ , %searchdistance
     if #findcnt > 0
     {
       set #ltargetid #findid
       msg all kill$
       wait 5
       target
       event macro 22 0
       wait 10
       }
       finditem %petid
        if %petid = %petdist
          {
           event sysmessage attack again
           goto killloop
        if %petid <> %petdist
           {
            event sysmessage pet moving
            halt
            }
           }
--- End code ---

sumsum:
Here's how I find target types in my scripts:

set %TargetTypes TC_QE_XU_IKPC_TC_JD
Finditem %TargetTypes G_6
  If #findcnt > 0
    {
    set %TargetsFound %TargetsFound + 1



I never really used find dist...I just use finditem on ground within the dist im looking for it in... like this

FINDITEM PBN G_17


sorry I cant be of more help!

Man7dowN:
i think i got it
if anyone would like to test or look at this for errors that be great.

it should set closest enemy , set pet location , attack target , then check to see if pet has moved, if pet doesnt move attack target again


--- Code: ---  set %monstertype ZC_WE_IJB_ID_Q_V_UD_ED_RI_SI_EJ_QD_BE_WE_R_S_VI_FD_
set %petid WZXQ
set %scanpk
 
 
for %searchDistance 1 10
{
  finditem %monstertype G_ , %searchdistance
  if #findcnt > 0
   {
    set %targetkill #ltargetid
    event sysmessage monster set
    finditem %petid G_ , %searchdistance
     if #findcnt > 0
      {
       event sysmessage pet distance is at #finddist
       set %petdist1 #finddist
       killloop:
       set #ltargetid %targetkill
       msg all kill$
       wait 10
       target
       event macro 22 0
       wait 10
        {
         finditem %petid G_ , %searchdistance
            if #finddist <> %petdist1
             {
              event sysmessage MOVED
              halt
            if #finddist = %petdist1
              {
               event sysmessage STAYED
               goto killloop
               }
              }
             }
            }
           }
   if #findcnt = 0
     event sysmessage NO MOB
     wait 30
     return
--- End code ---

Navigation

[0] Message Index

Go to full version