help with looting in my modified hunter script

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

Bio_War
a lesser mummy
a lesser mummy
Posts: 36
Joined: Sun Sep 29, 2002 1:03 pm

help with looting in my modified hunter script

Post by Bio_War » Wed Jan 14, 2004 10:14 pm

ok, this is from GJ hunter script just modified a bit, what i am trying to do, is in the loot section, first it checks to see if it is a certian mob, if not it aquires a new target, if it is rigt, it opens the loot window, then it checks to see if the loot in the loot windows is what i want to keep --- here is where i am having problems, it will find 1 item, but not 2, any ideas?

Bio

Code: Select all

| hunter.mac
| v3.1
| Hunt script with loot for new loot parser.
| As always much of this script is inspired or taken directly from
| pieces of macro's found at macroquest2.com's macro depot
| Thank you to all the people who have donated their scripts which
| made this possible.  And thank you to the MQ developers.
|
| Edit  /varset MainArray(1,0) "silk" and /varset MainArray(1,1) "skin"
| Also edit /varset MainArray(2,0) "widow" and /varset MainArray(2,1) "wolf"
| You can also make these arrays bigger.  If you want to search for
| wolfs, widows and orcs you would have this
| /varset MainArray(2,0) "widow"
| /varset MainArray(2,1) "wolf"
| /varset MainArray(2,2) "orc"
| /varset MobArraySize 3
| This picks a random number based on MobArraySize to pick which
| Type of mob it will chose from the array.
|
| What type of loot you want can be expanded in a similar way to
| the mobs you want to hunt.  Just add your array entry and update
| /varset LootTotal 2 to be /varset LootTotal [# of loot entries]
|
| Another thing, for the code to actualy destroy items you don't want to
| keep you must have fast item destroy turned on in the game.  I would
| test the script for a while on your machine before doing this.  It would
| really suck if it picks up your Eyepatch of Plunder and destroies it
| due to a bug.

|#turbo 90

#event HitsYou "YOU for"

Sub Main
	/declare MobToHunt global
	/declare MainArray array2
	/declare MyXLOC global
	/declare MyYLOC global
	/declare KSRadius global
	/declare NotSee global
	/declare TooFar global
	/declare MyTarget global
	/declare TargetDead global
	/declare HasTarget global
	/declare ObstCount global
	/declare LootSlot global
	/declare CheckLoot global
	/declare LootTotal global
	/declare MobArraySize global
	/declare RangeMax global
	/declare RangeMin global
	/declare FastRange global
	/declare WaitForAdds global
	/press esc
	/press esc
	/press esc
	/press esc
	/press alt
	/press shift
	/press ctrl
	/varset RangeMax 12
	/varset RangeMin 8
	/varset FastRange 14
	/varset LootSlot 0
	/varset CheckLoot 0
	/varset MainArray(1,0) "item 1"
	/varset MainArray(1,1) "item 2"
| Add as many of these  as you want but make sure you
| increase LootTotal
	/varset LootTotal 2
	/varset KSRadius 100
	/varset HasTarget 0
	/varset ObstCount 0
	/varset WaitForAdds 1
	:Start
	/call CheckBuffs
	/call SetAlerts
	/call GetTarget
	/if @HasTarget=="1" /call MoveToMob
	/if @HasTarget=="1" /call CombatSub
	/if @HasTarget=="1" /call MoveToMob
	/if @HasTarget=="1" /call LootMob
	/call ResetSub
	/goto :Start
/return


sub SetAlerts
/alert clear 1
/alert clear 2
|/alert clear 3
|/alert clear 4

| Rare (Most important)
/alert add 1 npc radius 600 nopcnear 60 "mob 1"
/alert add 1 npc radius 500 nopcnear 60 "mob 2"
/alert add 1 npc radius 500 nopcnear 60 "mob 3"
/alert add 1 npc radius 500 nopcnear 60 "mob 4"

| Uncomon (next most important)
| /alert add 2 npc radius 500 nopcnear 60 ""

| Common (every day stuff)
|/alert add 3 npc

| Scarry (Stay away from)
| /alert add 4 npc radius 10 corpse

/return


Sub MoveToMob
	/face nolook
	/if n $target(distance)>=@FastRange /call Fastmove
	/if n $target(distance)>@RangeMax {
		/press up
	}
	/if n $target(distance)<@RangeMin {
		/press down
	}
/return

sub GetTarget
	 :Aquire
/if "$alert(1)"=="TRUE" {
/target npc alert 1 nopcnear @KSRadius
} else /if "$alert(2)"=="TRUE" {
/target npc alert 2 nopcnear @KSRadius
} else {
/target npc alert 3 nopcnear @KSRadius
}
	/varset MyTarget $target(id)
	/varset TargetDead 0
	/if n $target(id)==0 /goto :Aquire
	/varset HasTarget 1
	/varset MobToHunt $target(name)

/return

Sub Fastmove
	/varset MyXLOC $char(x)
	/varset MyYLOC $char(y)
	/varset ObstCount 0
	:fastmoveloop
	/if $target()=="FALSE" {
		/sendkey up up
		/if $combat=="TRUE" {
			/attack off
			/return
		}
	}
	/face nolook
	/if n $target(distance)>@FastRange {
		/sendkey down up
	}
	/if n $target(distance)<=@FastRange {
		/sendkey up up
		/return
	}
	/varadd ObstCount 1
	/if n @ObstCount>=3 {
		/call CheckObst
	}
	/goto :fastmoveloop
/return

sub CombatSub
	/if $target()=="FALSE" {
		/varset HasTarget 0
		/return
	}
	| Check no PCs are in KSradius still
	/delay .5s
	/if n $searchspawn(pc,radius:100)!=0 /goto :WeKilledIt
	/attack on
	:combatloop
	/face nolook
	/if $char(class)==Ranger /call BackstabIt
	/call MoveToMob
	/face nolook
	/if n $target(id)==0 /varset TargetDead 1
	/if n @TargetDead!=1 /goto :combatloop
	/sendkey up up
	/delay .5s
	/attack off
	/target id @MyTarget
	/delay .5s
 :WeKilledIt
/return

[color=green]
sub LootMob
	/if "$target(name,clean)"!="mob 1" /goto :doneloot
	/loot
	/delay 1.5s
	/if $corpse(has,"@MainArray(1,@CheckLoot)")==false /goto :doneloot
	: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 .5s
		/echo Keeping $cursor(name)
		/autoinv
		|/delay .5s
		/varadd LootSlot 1
		/goto :lootloop
	}
	/varadd CheckLoot 1
	/if "$cursor()"=="TRUE" {
		/if n @CheckLoot<@LootTotal /goto :lootchecker
	}
	/if "$cursor()"=="TRUE" {
		|/delay .5s
		/echo Destroying $cursor(name)
		/destroy
		|/delay .5s
	}
	/varadd LootSlot 1
	/varset CheckLoot 0
	/goto :lootloop
    :doneloot
        /delay .5s
	/lootn never
	/varset LootSlot 0
/return
[/color]

sub ResetSub
	/sendkey up up
	/press esc
	/press esc
	/press esc
	/press esc
	/press alt
	/press shift
	/press ctrl
	/varset CheckLoot 0
	/varset HasTarget 0
	/varset ObstCount 0
	/delay 1s
/return

sub CheckObst
	/if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObst 5
	/varset MyXLOC $char(x)
	/varset MyYLOC $char(y)
	/varset ObstCount 0
/return

sub HitObst
	/sendkey up up
	/sendkey down down
	/if n $rand(99)>50 {
		/delay 1s
		/sendkey up down
		/sendkey down Right
		/delay @Param0
		/sendkey up Right
		/sendkey down up
		/delay 1s
		/sendkey up up
	} else {
		/delay 1s
		/sendkey up down
		/sendkey down left
		/delay @Param0
		/sendkey up left
		/sendkey down up
		/delay 1s
		/sendkey up up
	}
	/sendkey up down
	/sendkey up Right
	/sendkey up Left
	/sendkey down up
/return

Sub BackstabIt
	/if n $char(ability,"kick")!=-2 {
		/if $target()=="TRUE" {
			/face nolook
			/doability "kick"
		}
		}
	/if n $char(ability,"Begging")!=-2 {
	/attack off
	/doability "Begging"
	/attack on
	}
/return

Sub CheckBuffs

  /call SelfBuff "spirit of wolf"
  | /call SelfBuff "Shield of Brambles"
  | /call SelfBuff "Storm Strength"
  | /call SelfBuff "Spikecoat"
  | /call SelfBuff "Skin Like Steel"
  | /call SelfBuff "Strength of Nature"
  | /call SelfBuff "call of earth"
/return



Sub SelfBuff

  /if n $char(buff,"@Param0")==0 {
	 /target myself
	 /delay .5

	 /cast "@Param0"
	 /delay "$calc($spell("@Param0",casttime)+4.5)"s

	 /press esc
  }
/return

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

Post by dont_know_at_all » Wed Jan 14, 2004 11:39 pm

You don't reset CheckLoot often enough.

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 » Fri Jan 16, 2004 7:07 am

You can also make it simpler in this line:

Code: Select all

/if $corpse(has,"@MainArray(1,@CheckLoot)")==false /goto :doneloot

changed to

Code: Select all

/if $corpse(empty)==TRUE /goto :doneloot
If I understand that line correctly.