Need help with this loot code

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Need help with this loot code

Post by cww256 » Tue Aug 12, 2003 5:26 am

Code: Select all

Sub Main
/varset Pulled 0
/varset Pet 0
/varset Mob 0
/varset Dark 0
/varset Doted 0
/varset MobDead 0
/varset LootSlot 0  
  :Start
    /target id $Mob
    /if (n $spawn($Mob,hp,pct)<6 && $target(id)!=$Mob) /call TargetCorpse
    /if n $MobDead==1 /call Loot
  /goto :Start
/return

Sub TargetCorpse
  /echo TargetCorpse
  /target corpse
  /varset MobDead 1
  /echo Set
/return

Sub Loot
  /echo Loot
  /stand
  :GoToCorpse
    /if n $target(distance)>10 {
      /face
      /sendkey down up
      /goto :GoToCorpse
    }
  /press up
  /loot
  /delay 10
  /varset LootSlot 0
  :LootLoop
    /if $cursor(name)=="NULL" /goto :LootDone
    /click left corpse $LootSlot
    /delay 5
    /if $cursor(name)"~~""ItemIDontWant" {
      /click left destroy
    } else /click left auto
    /delay 4
    /varadd $LootSlot 1
  /goto :LootLoop
  :LootDone
    /delay 4
    /press ESC   
/return
Can anyone point out why this wil not hit "Sub Loot" after the mob reaches 0 HP and dies?

This isnt all the code but it is the only part that isnt working.

If I put in some debugint echos, it seems to get stuck looping between

Code: Select all

/if (n $spawn($Mob,hp,pct)<6 && $target(id)!=$Mob) /call TargetCorpse
and

Code: Select all

Sub TargetCorpse
  /echo TargetCorpse
  /target corpse
  /varset MobDead 1
  /echo Set
/return
I never see the /echo Loot line

Doodman
a ghoul
a ghoul
Posts: 124
Joined: Thu Jan 02, 2003 12:07 pm

Post by Doodman » Tue Aug 12, 2003 10:10 am

Try changing:

Code: Select all

/if n $MobDead==1 /call Loot
to:

Code: Select all

/if $MobDead==1 /call Loot
The n in there negates the test in the if..

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Tue Aug 12, 2003 11:08 am

Doodman wrote:Try changing:

Code: Select all

/if n $MobDead==1 /call Loot
to:

Code: Select all

/if $MobDead==1 /call Loot
The n in there negates the test in the if..
The n in the /if tells MQ to make a numeric comparison and there is nothing wrong with it.

Try changing

Code: Select all

/if (n $spawn($Mob,hp,pct)<6 && $target(id)!=$Mob) /call TargetCorpse 
to

Code: Select all

/if n $spawn($Mob,hp,pct)<6 {
    /if n $target(id)!=$Mob) {
        /call TargetCorpse
    }
}
After that I would look at the logic... I'm not sure if the call will occur the way it is.

If $spawn has all functions working maybe you could use

Code: Select all

/if "$spawn($Mob,state)"=="DEAD" {
    /call TargetCorpse
}

User avatar
L124RD
Site Admin
Site Admin
Posts: 1343
Joined: Fri Jun 14, 2002 12:15 am
Location: Cyberspace
Contact:

Post by L124RD » Tue Aug 12, 2003 11:40 am

Salutations,
Following Wassups changes will result in the fixing of this macro. The line that (in my mind) seems to be failing is the one that states:

Code: Select all

/if (n $spawn($Mob,hp,pct)<6 && $target(id)!=$Mob) /call TargetCorpse
Simply because the n is inside hte brackets. If you follow Wassups changes for this line you will be in the cool.

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Post by cww256 » Tue Aug 12, 2003 11:48 pm

But this works fine...

Code: Select all

Sub Main
/if (n $char(id)==1560 && n $target(id)==1577) {
  /echo CharacterAndPet
} else /echo NotCharacterAndPet
/return
Assuming that your character id is 1560 and your pet id is 1577 and you have your pet targeted it returns CharacterAndPet

I like the "$spawn($Mob,state)"=="DEAD" thing but you say "If the functions are working..." Other than just coding it in and testing live how can I tell what functions are working since the documentation is rather outdated. :roll:

EDIT: Tested $spawn($Mob,state)"=="DEAD works well, but still would like to know how to find this function because I did not see it in documentation.

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Re: Need help with this loot code

Post by dont_know_at_all » Wed Aug 13, 2003 12:18 am

cww256 wrote:

Code: Select all

/if (n $spawn($Mob,hp,pct)<6 && $target(id)!=$Mob) /call TargetCorpse
if the mob I was beating on has less than %6 hp left
and I am no longer targeting that mob


Is that really what you meant? The live mob and the dead mob have the same id, I believe.

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Post by cww256 » Wed Aug 13, 2003 4:53 am

if the mob I was beating on has less than %6 hp left
and I am no longer targeting that mob
Yes thats exactly what I was checking.
The live mob and the dead mob have the same id, I believe.
Yes they have the same id but when the mob dies you loose target of it. So if you have something targeted and it dies and you dont send any new targeting commands
$target(id) will not equal the mobs id.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Wed Aug 13, 2003 8:10 am

so... set $target(id) to a var when you start fighting it, and when you lose target, check $spawn($vWhatever,state)... how hard is that?

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Wed Aug 13, 2003 12:44 pm

Try using Edit/Find(on this page), then insert $spawn and hit the enter key.

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Post by cww256 » Wed Aug 13, 2003 1:32 pm

so... set $target(id) to a var when you start fighting it, and when you lose target, check $spawn($vWhatever,state)... how hard is that?
If you would have actually bothered reading the whole thread you would have realized I already did that and posted that it worked.