Author Topic: pet attack with location error  (Read 4238 times)

0 Members and 1 Guest are viewing this topic.

Offline Man7dowNTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • Man7dowN has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
pet attack with location error
« on: February 28, 2019, 10:41:05 AM »
0
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: [Select]
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
            }
           }


Offline sumsum

  • Jr. Member
  • **
  • Posts: 47
  • Activity:
    0%
  • Reputation Power: 1
  • sumsum has no influence.
  • Respect: +9
  • Referrals: 0
    • View Profile
Re: pet attack with location error
« Reply #1 on: March 01, 2019, 03:41:48 PM »
0
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.

Offline Man7dowNTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • Man7dowN has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: pet attack with location error
« Reply #2 on: March 03, 2019, 06:49:24 AM »
0
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.

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: [Select]
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
            }
           }

Offline sumsum

  • Jr. Member
  • **
  • Posts: 47
  • Activity:
    0%
  • Reputation Power: 1
  • sumsum has no influence.
  • Respect: +9
  • Referrals: 0
    • View Profile
Re: pet attack with location error
« Reply #3 on: March 03, 2019, 11:25:56 AM »
0
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!

Offline Man7dowNTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Activity:
    0%
  • Reputation Power: 0
  • Man7dowN has no influence.
  • Respect: +1
  • Referrals: 0
    • View Profile
Re: pet attack with location error
« Reply #4 on: March 04, 2019, 04:25:55 AM »
0
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: [Select]
  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

Tags: