Druid Kiter Mac

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

Crun
orc pawn
orc pawn
Posts: 12
Joined: Wed Dec 03, 2003 12:16 am

Druid Kiter Mac

Post by Crun » Fri Mar 19, 2004 11:39 pm

Ok, I've tried a couple minor mac's, and have done a lot of reading. Admitedly this is mostly slash and burn rape and pillage put on the bandaids and see if it works style macroing..... however for once I understand most of what I put in here, and even made some relatively intelligent additions. I however am left with some gaping holes, in a somewhat messy script and some more gaping holes in a somewhat messy brain..... (I'm kinda like the cat that just realized the ball of yarn can be as dangerous as it can be fun :) )

Here is the code, if you'd like to help I'd be forever grateful, the basic idea at this point is to be able to take a 30 druid from a point on the zonewall in OT.... find a target, preferably not too far from the zonewall, root it, snare it, dot, dot, dot it, and recast any that wear off..... only self buff I care about at this point is sow. In addition if you could help me clear out some of the stuff I don't need.... I've been kind of afraid of removing something that I don't know I need =)

TYVM for your assistance
Crun

Code: Select all

|Crun's Druid Kiter
|Mostly an adaptation of Hunter.mac by Grimjack
|Large sections stolen ruthelessly from XPBeast.mac by Tuna
|Current state.... Almost working.... I think =)


| hunter.mac 
| v3.1.c4f (adapted from grimjack's) 
| 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 Loot(0) "silk" and /varset Loot(1) "skin" 
| Also edit /varset Mob(0) "widow" and /varset Mob(1) "wolf" 
| You can also make these arrays bigger.  If you want to search for 
| wolfs, widows and orcs you would have this 
| /varset Mob(0) "widow" 
| /varset Mob(1) "wolf" 
| /varset Mob(2) "orc" 
| 
| What type of loot you want can be expanded in a similar way to 
| the mobs you want to hunt.  
| 
| C4F Modifications: 
| -tweaked search pattern (and as a bonus has 'priority' as a side effect) to 
|  look in ever increasing radius til it finds a suitable target 
| -changed/added special attacks during combat sub 
| -added respawn timeout wait timer, so if nothings found, it'll wait a bit 
|  before searching again 
| -paranoia random delay after each kill 
| -automatic array size calculation 
| -kill nearby, hostile "adds" (seems to work, let me know) 
| -/autoinventory for keepers, and drops items on the ground otherwise. 
| -NOTE: cause i'm paranoid about my hard earned gear, this script won't farm 
|  NO-DROP items for ya (yet, i might get around to tweaking the code to do so) 

DEBUG

#turbo 90 
#event AFKTell "AFK Message:" 
#event InvFull "no room to put that!" 
#event Died "you have entered" 
#event Hostile "scowls at you, ready to attack" 
#event Reroot "your Ensaring Roots spell has worn off."
#event Resnare "your Ensnare spell has worn off."
#event Redot1 "your Immolate spell has worn off."
#event Redot2 "your Creeping Crud spell has worn off."
#event Redot3 "your Stinging Swarm spell has worn off."
#event Resroot "your target resisted the Ensnaring Roots spell."
#event Ressnare "your target resisted the Ensnare spell."
#event Resdot1 "your target resisted the Immolate spell."
#event Resdot2 "your target resisted the Creeping Crud spell."
#event Resdot3 "your target resisted the Stinging Swarm spell."

Sub Main 
   /echo $time() Starting $macro 
   /declare MobToHunt global 
   /declare Loot array 
   /declare Mob array 
   /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 Spellstotal global 
   /declare MobArraySize global 
   /declare RangeMax global 
   /declare RangeMin global 
   /declare FastRange global
   /declare Spells array 
   /declare arX array
   /declare arY array

   /varset arX(0) 3900
   /varset arY(0) 750

   /declare FailMax global 
   /declare FailCounter global 
   /declare RandomDelay global 
   /declare CurrentTarget global 
   /declare TargetSub global 
   /declare SpellSub global
   /declare CurrentRadius global 
   /declare MaxRadius global 
   /declare CombatClickie global 
   /declare HostileNPC global 

   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 

   /alert add 1 npc radius 20 

   /varset FailMax 3 
   /varset FailCounter 0 
|set the max radius to hunt per cycle 
   /varset MaxRadius 1000 
| if you have a combat clickie you'd like to use, put the item name here 
|   /varset CombatClickie "Celestial Fists" 

   /varset RangeMax 80
   /varset RangeMin 35 
   /varset FastRange 11 
   /varset LootSlot 0 
   /varset CheckLoot 0 

| Combat spells to cast
   /varset Spells(0) "Ensnare"
   /varset Spells(1) "Ensnaring Roots
   /varset Spells(2) "Immolate"
   /varset Spells(3) "Creeping Crud"
   /varset Spells(4) "Stinging Swarm"

| Items to Loot 
|   /varset Loot(0) "silk" 
|   /varset Loot(1) "quality" 
|   /varset Loot(2) "snake egg" 
|  /varset Loot(3) "" 
|  /varset Loot(4) "" 
|  /varset Loot(5) "" 
|  /varset Loot(6) "" 
|  /varset Loot(7) "" 
|  /varset Loot(8) "" 
|  /varset Loot(9) "" 
|  /varset Loot(10) "" 
| 
| Targets to hunt - the lower subscript, the higher priority 
   /varset Mob(0) "cockatrice" 
   /varset Mob(1) "berzerker" 
   /varset Mob(2) "tigress" 
   /varset Mob(3) "succulent" 
   /varset Mob(4) "rhino" 
|   /varset Mob(5) "" 
|   /varset Mob(6) "" 
|   /varset Mob(7) "" 
|   /varset Mob(8) "" 
|  /varset Mob(9) "" 
|  /varset Mob(10) "" 

   /varset KSRadius 100 
   /varset HasTarget 0 
   /varset ObstCount 0 

| finding size of Spells array 
   /call ArraySize Spells 
   /varset Spellstotal $return 
   /if SpellsTotal<0 { 
    /echo No Spells defined for combat.... I hope you can fight.
   } 
   /echo Spell pool size $calc(@Spellstotal+1) 

| finding size of Loot array 
   /call ArraySize Loot 
   /varset LootTotal $return 
   /if LootTotal<0 { 
    /echo Nothing specified to loot! Just hunting specified mobs. 
   } 
   /echo Loot pool size $calc(@LootTotal+1) 

| finding size of mob array 
   /call ArraySize Mob 
   /varset MobArraySize $return 
   /if MobArraySize<0 { 
    /echo Nothing specified to hunt! (you do know what this script is supposed to do, right?) 
    /endmacro 
   } 
   /echo Mob list has $calc(@MobArraySize+1) entries 

   :Start 
   /doevents 
   /call GetTarget 

:KillAdds 
   /if @HasTarget=="1" /call MoveToMob 
   /if @HasTarget=="1" /call CombatSub 
   /if @HasTarget=="1" /call MoveToMob 
   /if (@HasTarget=="1" && @LootTotal>=0) /call LootMob 
   /call ResetSub 

   /if $alert(1)==TRUE { 
    /echo Looks like we have adds... 
    /target npc radius 20 
    /if $target(type)=="npc" { 
     /varset MyTarget $target(id) 
     /varset TargetDead 0 
     /varset HasTarget 1 
     /varset MobToHunt $target(name) 
     /consider 
     /delay 2 
     /doevents 
     /if @HostileNPC=="TRUE" { 
      /echo time to die $target(name,clean) 
      /goto :KillAdds 
     } else { 
      /echo False Alarm 
      /call ResetSub 
     } 
    }    
   } 
| Random wait after kill (up to 5 seconds) 
   /varset RandomDelay $rand(5) 
   /varcat RandomDelay "s" 
   /echo Paranoia - Waiting @RandomDelay before resuming 
   /delay @RandomDelay 

   /goto :Start 
/return 



sub GetTarget

   /stand
   /call AutoRunToLoc @arX(0) @arY(0) "STOPATDEST" "CAREFUL"
   /face heading 143
   /press esc
   /press Home
   /sit on

   /if "$gm"=="TRUE" { 
      /delay 5
      /goto :Start
   }
   /if n $char(mana,pct)<90 {
      /goto :Start
   }

   :Acquire 
   /for CurrentRadius 100 to @MaxRadius step 100 { 
    /for TargetSub 0 to @MobArraySize { 
     /target radius @CurrentRadius nopcnear @KSRadius npc "@Mob(@TargetSub)" 
     /varset MyTarget $target(id) 
     /varset TargetDead 0 
     /if n $target(id)!=0 { 
      /varset HasTarget 1 
      /varset MobToHunt $target(name) 
      /echo Acquired $target(name,clean) at range $target(distance) heading $target(direction) 
      /call CombatSub
     } 
     /next TargetSub 
    } 
   /delay 2 
   /next CurrentRadius 
   } 

   /if n $target(id)==0 { 
    /delay 2s 
    /varadd FailCounter 1 
    /echo Failed to Acquire Target in range @MaxRadius @FailCounter times 
    /if n @FailCounter>=@FailMax { 
     /echo waiting for respawns, resetting failure count. 
     /delay 60s 
     /varset FailCounter 0 
     } 
    /goto :Acquire 
   } 
   /varset HasTarget 1 
   /varset MobToHunt $target(name) 
/return 


Sub MoveToMob 
   /stand
   /face fast 
   /if n $target(distance)>@RangeMax { 
      /keypress autorun
   } 
   /if n $target(distance)<@RangeMin { 
      /keypress autorun
   } 
/return 


Sub CombatSub 
   /if $target()=="FALSE" { 
      /varset HasTarget 0 
      /return 
   }
   :combatloop 
   /face fast 
|   /call SpecialIt 
   /call MoveToMob 
   /face fast
   /for SpellSub 0 to @Spellstotal {
     /if n $target(distance)<@RangeMax {
       /if $char(casting)=="FALSE"
		}
	}
     /cast @Spells
   /next Spellsub
   /if n $target(id)==0 /varset TargetDead 1 
   /if n @TargetDead!=1 /goto :combatloop 
   /sendkey up up 
   /delay 1s 
   /target corpse 
/return 


sub LootMob 
   /fastdrop on 
   /lootn always 
   /delay 2s 
   /loot 
   /look 128 
   /delay 2s 
| check and see if corpse is empty 
   /if $corpse(empty)=="TRUE" { /echo empty corpse /goto :doneloot } 
   :lootloop 
   /if n @LootSlot>=9 /goto :doneloot 
   /click left corpse @LootSlot 
   /delay 1s 
   /if "$cursor()"!="TRUE" /goto :doneloot 
   :lootChecker 
   /if "$cursor(name)"~~"@Loot(@CheckLoot)" { 
      /delay 1s 
      /echo Saving "$cursor(name)" 
      /autoinventory 
      /delay 1s 
      /varadd LootSlot 1 
      /goto :lootloop 
   } 
   /varadd CheckLoot 1 
   /if "$cursor()"=="TRUE" { 
      /if n @CheckLoot<=@LootTotal /goto :lootchecker 
   } 
   /if "$cursor()"=="TRUE" { 
      /delay 1s 
      /echo Attempting to Drop "$cursor(name)" 
      /click left 0 0 
      /delay 1s 
      /if "$cursor()"=="TRUE" { 
       /beep 
       /echo could not drop "$cursor(name)" putting into inventory 
       /autoinventory 
      } 
   } 
   /varadd LootSlot 1 
   /varset CheckLoot 0 
   /goto :lootloop 
   :doneloot 
   /fastdrop off 
   /look 0 
   /varset LootSlot 0 
| check for adds 
   /target npc radius 10 
   /if $target(type)=="npc" :goto KillAdds 
/return 


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 
   /varset HostileNPC FALSE 
   /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 2s 
      /sendkey up up 
   } else { 
      /delay 1s 
      /sendkey up down 
      /sendkey down left 
      /delay @Param0 
      /sendkey up left 
      /sendkey down up 
      /delay 2s 
      /sendkey up up        
   } 
   /sendkey up down 
   /sendkey up Right 
   /sendkey up Left 
   /sendkey down up 
/return 


Sub SpecialIt 
   /if ($char(class)==Rogue && n $char(ability,"Backstab")>0) { 
      /if $target()=="TRUE" { 
         /face fast 
         /doability "Backstab" 
      } 
   } 
   /if ($char(class)==Monk && n $char(ability,"Flying Kick")>0) { 
      /if $target()=="TRUE" { 
         /face fast 
         /doability "Flying Kick" 
      } 
   } 
   /if "@CombatClickie"!="" { 
      /cast item "@CombatClickie" 
   } 
/return 

sub AutoRunToLoc
    /if n $distance(@arY(0),@arX(0))<=15 /return
	/declare	l1	local
	/declare	l2	local
	/declare	distLastCheck local
        /declare	gThreshold local 
        /declare	doStopRunningWhenDone local 
	/declare	isCareful local
        /declare	t_StuckTimeout  local
 
    /varset gThreshold 14
	/varset l2 @Param0
	/varset l1 @Param1
	/varset doStopRunningWhenDone @Param2
	/varset isCareful @Param3
	/if n $distance(@l1,@l2)<@gThreshold /return
	/varset t_StuckTimeout	2s

    /face loc @l1, @l2 

	/if "$char(state)"!="STAND" /stand
    /call AutoRun 1 
	/echo Running to @l2 X, @l1 Y ( @doStopRunningWhenDone, @isCareful )
    
	/echo $distance(@l1,@l2) 
	/varset distLastCheck $distance(@l1,@l2) 
	
	:MainLoop2 
		/delay 1
		/face loc @l1, @l2 
		/doevents

		| Update loc every 3 seconds
|		/call isRooted
		/if n $return==0 {
			/if n @t_StuckTimeout<=0 {
				/varset t_StuckTimeout 3s

				| -----------------
				| If we appear stuck, return.  Calling procedure
				| should pick a new spot and re-call.
				| Only do this if "careful" mode, though.
				| When in careless mode, just pick a random dir and
				| run there for a sec or two.
				| Careful = meant for running through dungeons and specific paths
				| Careless = meant for running through Dawnshroud and other
				| wide places where you might just be stuck on a rock, but in
				| general you don't care if you aggro extra mobs.
				| -----------------
				/if n $distance(@l1,@l2)==@distLastCheck {
					/if n @gPausingForAggro==0 {
						/if "@isCareful"=="CAREFUL" {
							/echo Appear to be stuck... facing random heading and returning!
							/face heading $rand(360)
							/return
						} else {
							/echo Appear to be stuck... being careful and just waiting.
							| @@TODO : Put the MineField Navigator code in here ^_^
						}
					}
				}
				/varset distLastCheck $distance(@l1,@l2)
			}
		} else {
			/echo I'm rooted... not bothering with safe/careful checking
		}

	| End mainLoop
	/if n $distance(@l1,@l2)>@gThreshold /goto :MainLoop2 

	/if "@doStopRunningWhenDone"=="STOPATDEST" {
		/call AutoRun 0 
		/echo Destination reached - stopping
	} else {
		/echo Destination reached - not stopping
	}
/return

Sub AutoRun 
   /if n @Param0==1 {
		/if n $char(speed)<=0 {
			/keypress autorun
		}
		/return
	}
	/if n @Param0==0 {
		/if n $char(speed)>0 {
			/keypress autorun
		}
		/return
	}
/return 

| returns the last valid subscript of an array, returns -1 for failure or no size 

Sub ArraySize(IncArray) 
/declare ArrSize local 
/declare ArrayCounter local 
/if $defined(IncArray)!=FALSE { 
  /varset ArrSize 0 
   /for ArrayCounter 0 to 1 step 0 { 
    /if "@@IncArray(@ArrSize)"=="UNDEFINED-ARRAY-ELEMENT" { 
     /return $calc(@ArrSize-1) 
    } 
    /varadd ArrSize 1 
   /next ArrayCounter 
   } 
} 
/return -1 



Sub Event_AFKTell 
/beep /delay 1s /beep 
/return 



Sub Event_InvFull 
/beep /delay 1s 
/beep /delay 2s 
/beep /delay 1s 
/beep 
/endmacro 
/return 

Sub Event_Hostile 
/varset HostileNPC "TRUE" 
/return 

Sub Event_Reroot
/cast "Ensnaring Roots"

Sub Event_Resroot
/cast "Ensnaring Roots"

Sub Event_Resnare
/cast "Ensnare"

Sub Event_Ressnare
/cast "Ensnare"

Sub Event_Redot1
/cast "Immolate"

Sub Event_Resdot1
/cast "Immolate"

Sub Event_Redot2
/cast "Creeping Death"

Sub Event_Resdot2
/cast "Creeping Death"

Sub Event_Redot3
/cast "Stinging Swarm"

Sub Event_Redot3
/cast "Stinging Swarm"

Sub Event_Resow
/target cran
/cast "Spirit of Wolf"
/target MobToHunt

Sub Event_Died 
/declare BeepCounter local 
/for BeepCounter 0 to 10 { 
/beep /delay 3 
/next BeepCounter 
} 
/endmacro 
/return