radius hunter with loot

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

jcooler
a ghoul
a ghoul
Posts: 87
Joined: Wed Dec 31, 2003 7:38 pm

radius hunter with loot

Post by jcooler » Thu Jan 22, 2004 1:50 am

Hello I can not for the life of me make or figure out how to steal a looting code to loot the item i want and destory the rest



Code: Select all

goblin.mac

|This mac is a radius hunter that can loot (only ATM it can not loot )
|i have stolen code from other people will give crdit when macro is done
sub main


 /alert add 1 npc radius 100 "goblin"
 /alert add 2 npc radius 100 "corpse"
|----------------add ALERT mob here
 :Loop
 	/if $alert(1)==TRUE /call target
 	/if $alert(2)==TRUE /call targetcorpse
 /goto :loop
 /return

sub target

/target "goblin" radius 100
/delay 2
/if  n $target=="corpse" /call targetcorpse
/if  n $target=="goblin" /call Attack
/return

sub targetcorpse

/target "corpse" radius 100
/delay 2
/if  n $target=="corpse" /call corpse
/return


sub Attack 

  /declare MyXLOC global 
  /declare MyYLOC global 
  /declare ObstacleCount global 
  /declare targetarray array 
  
  /varset targetarray(0) "$target(name,clean)" 
  /varset targetarray(1) $target(level) 
  /varset targetarray(2) $target(name) 
  /varset targetarray(3) $target(id) 

  /echo Fighting a level @targetarray(1) @targetarray(0) 
  /face  
  /call MovetoMob 

  :CloserAF 
    /if "$target(id)"!=@targetarray(3) /goto :EndAF 
    /if n $target(distance)>10 /press up 
    /if n $target(distance)<10 /press down 
    /if n $target(distance)<15 /attack on 
    /if n $target(distance)>15 /attack off 
    /if n $target(distance)>15 /call MovetoMob 
    /face fast 
    /if n $target(distance)<11 /if n $char(ability,"taunt")>0 /doability "taunt" 
    /if n $target(distance)<11 /if n $char(ability,"Kick")>0 /doability "Kick" 
    /if n $target(distance)<11 /if n $char(ability,"Disarm")>0 /doability "Disarm" 
    /goto :CloserAF 

  :EndAF 
    /echo The level @targetarray(1) @targetarray(0) is dead... 
    /sendkey up up 
    /sendkey up down 
    /attack off 
    /varset targetarray(3) 0  
    [b]/call MoveToLoc -843.35 3733.87[/b]
|move to loc is to set a home point for the kill/loot radius
/return 

sub MoveToMob 

  /varset MyXLOC $char(x) 
  /varset MyYLOC $char(y) 
  /varset ObstacleCount 0 

  /if n $target(distance)<=15 { 
    /face 
    /return 
  } 
  /sendkey down up 

  :Movementloop 
    /varadd ObstacleCount 1 
    /if $target()=="FALSE" /return 
    /face  
    /if n $target(distance)<=10 { 
      /face 
      /sendkey up up 
      /return 
    } 
    /if @ObstacleCount>=3 { 
      /call CheckObstacle 
      /goto :Movementloop 
    } 
    /if n $target(distance)>10 /goto :MovementLoop 
/return 

sub CheckObstacle 
  /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObstacle 
  /varset MyXLOC $char(x) 
  /varset MyYLOC $char(y) 
  /varset ObstacleCount 0 
/return 

sub HitObstacle 
  /sendkey up up 
  /sendkey down down 
  /delay 3 
  /sendkey up down 
  /sendkey down ctrl 
  /if n $rand(99)>50 { 
    /sendkey down right 
  } else { 
    /sendkey down left 
  } 
  /delay 5 
  /sendkey up right 
  /sendkey up left 
  /sendkey up ctrl 
  /sendkey down up 
/return 

[b]sub corpse

/loot[/b]
CAN not for the life of me figure out how to loot a mob or incorerate others loot code into my macro



Sub MoveToLoc 
    /if "$defined(Param0)"=="FALSE" /return 
    /if "$defined(Param1)"=="FALSE" /return 
    :LocMoveLoop 
    /if "$char(state)"=="SIT" /stand 
    /face nolook loc @Param0,@Param1 
    /if n $distance(@Param0,@Param1)>5 /sendkey down up 
    /if n $distance(@Param0,@Param1)<=5 { 
       /sendkey up up 
       /if "$char(state)"=="SIT" /stand 
       /return 
    } 
    /goto :LocMoveLoop 
/return

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Thu Jan 22, 2004 9:24 am

Code: Select all

/loot
/varset lootslot 0
:lootloop
/click left corpse @lootslot
/if $cursor()==TRUE {
     /autoinventory
     /varadd lootslot 1
     /if n @lootslot > 10 {
          /click left corpse done 
          /return
          }
     /goto :lootloop
     }
/click left corpse done
/return
Something along those lines. You'll need to declare the lootslot variable, and change the 10 to however many slots you want to look for loot in.

I'm hammering that out on the fly so expect syntax errors :) Afraid I don't write many macros actually.

jcooler
a ghoul
a ghoul
Posts: 87
Joined: Wed Dec 31, 2003 7:38 pm

Post by jcooler » Thu Jan 22, 2004 12:55 pm

guess i needa read up on what a syntax is =p

jcooler
a ghoul
a ghoul
Posts: 87
Joined: Wed Dec 31, 2003 7:38 pm

Post by jcooler » Fri Jan 23, 2004 5:05 am

OK so i went in and riped off some of hunter mac =p
i got this to work but i just changes a few things that would make it easyer for other people use use the macro (still a work in progress) just wondering what u guys think if of how i could clean up some of the code =p

I also added there at the bottom an ADD checker, which all it does is target an NPC with in 20 eqfeet or whatever and killing and get rid of the corpse

NOW your might be wondering why don;t i just use hunter well because i find it slows my computer down way much when it can't find a mob =p and it really can not deal with ADDs

Code: Select all

goblin.mac



sub main

/declare mob1 global


/declare MainArray array2
/declare LootSlot global
/declare CheckLoot global 
/declare LootTotal global
/declare anchorX global
/declare anchorY global
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 
----------------------------------------------------------------------------------------------
|-----THIS IS WHERE U CHANGE MOB LOOT AND ANCHOR
/varset mob1 "goblin"
/varset mob2 "------"
/varset MainArray(1,0) "green" 
/varset anchorX "3337"
/varset anchorY "2879"
|-----THIS IS WHERE U CHANGE MOB LOOT AND ANCHOR

----------------------------------------------------------------------------------------------
/varset LootSlot 0 
/varset CheckLoot 0 
/varset LootTotal 1



 /alert clear alerts
 /alert add 1 npc radius 100 "@mob1"

 :Loop
 	/if $alert(1)==TRUE /call target
 	/if $alert(2)==TRUE /call target
 /goto :loop
 /return

sub target

/target "@mob1" radius 100
/delay 2
/if  n $target(hp,pct)=="0" /call corpse
/if  n $target(hp,pct)=>"1" /call attack


/return



sub Attack 

  /declare MyXLOC global 
  /declare MyYLOC global 
  /declare ObstacleCount global 
  /declare targetarray array 
  
  /varset targetarray(0) "$target(name,clean)" 
  /varset targetarray(1) $target(level) 
  /varset targetarray(2) $target(name) 
  /varset targetarray(3) $target(id) 

  /echo Fighting a level @targetarray(1) @targetarray(0) 
  /face  
  /call MovetoMob 

  :CloserAF 
    /if "$target(id)"!=@targetarray(3) /goto :EndAF 
    /if n $target(distance)>10 /press up 
    /if n $target(distance)<10 /press down 
    /if n $target(distance)<15 /attack on 
    /if n $target(distance)>15 /attack off 
    /if n $target(distance)>15 /call MovetoMob 
    /face fast 
    /if n $target(distance)<11 /if n $char(ability,"taunt")>0 /doability "taunt" 
    /if n $target(distance)<11 /if n $char(ability,"Kick")>0 /doability "Kick" 
    /if n $target(distance)<11 /if n $char(ability,"Disarm")>0 /doability "Disarm" 
    /goto :CloserAF 

  :EndAF 
    /echo The level @targetarray(1) @targetarray(0) is dead... 
    /sendkey up up 
    /sendkey up down 
    /attack off 
    /varset targetarray(3) 0  
    

/return 

sub MoveToMob 

  /varset MyXLOC $char(x) 
  /varset MyYLOC $char(y) 
  /varset ObstacleCount 0 

  /if n $target(distance)<=15 { 
    /face 
    /return 
  } 
  /sendkey down up 

  :Movementloop 
    /varadd ObstacleCount 1 
    /if $target()=="FALSE" /return 
    /face  
    /if n $target(distance)<=10 { 
      /face 
      /sendkey up up 
      /return 
    } 
    /if @ObstacleCount>=3 { 
      /call CheckObstacle 
      /goto :Movementloop 
    } 
    /if n $target(distance)>10 /goto :MovementLoop 
/return 

sub CheckObstacle 
  /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObstacle 
  /varset MyXLOC $char(x) 
  /varset MyYLOC $char(y) 
  /varset ObstacleCount 0 
/return 

sub HitObstacle 
  /sendkey up up 
  /sendkey down down 
  /delay 3 
  /sendkey up down 
  /sendkey down ctrl 
  /if n $rand(99)>50 { 
    /sendkey down right 
  } else { 
    /sendkey down left 
  } 
  /delay 5 
  /sendkey up right 
  /sendkey up left 
  /sendkey up ctrl 
  /sendkey down up 
/return 

sub corpse
/loot 
   /delay 2s 
   :lootloop 
   /if n @LootSlot>=9 /goto :doneloot 
   /click left corpse @LootSlot 
   /delay 1s 
   /if "$cursor()"!="TRUE" /goto :doneloot 
   :lootChecker 
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" { 
      /delay 1s 
      /click left auto 
      /delay 1s 
      /varadd LootSlot 1 
      /goto :lootloop 
   } 
   /varadd CheckLoot 1 
   /if "$cursor()"=="TRUE" { 
      /if n @CheckLoot<@LootTotal /goto :lootchecker 
   } 
   /if "$cursor()"=="TRUE" { 
      /delay 1s 
      /click left destroy 
      /delay 1s 
   } 
   /varadd LootSlot 1 
   /varset CheckLoot 0 
   /goto :lootloop 
   :doneloot 
   /lootn always 
   /varset LootSlot 0 
/press esc
/press esc
/press esc
/press esc
/call movetoloc @anchorX @anchorY
/return 




Sub MoveToLoc 
    /if "$defined(Param0)"=="FALSE" /return 
    /if "$defined(Param1)"=="FALSE" /return 
    :LocMoveLoop 
    /if "$char(state)"=="SIT" /stand 
    /face nolook loc @Param0,@Param1 
    /if n $distance(@Param0,@Param1)>5 /sendkey down up 
    /if n $distance(@Param0,@Param1)<=5 { 
       /sendkey up up 
       /if "$char(state)"=="SIT" /stand 
/call mobadd
       /return 
    } 
    /goto :LocMoveLoop 
/return

sub mobadd
/target npc radius 20
/delay 3
/if  n $target(hp,pct)=>"1" /call attack
/call main
/return