All pastes #443969 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-17 03:42 UTC
rendered paste body
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Original Author: steelx01 ;
; Current Author: Tenshi    ;
; tweaked by rummie	    ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Leave this define Intact. Its testing if this file is loaded or not.
#define ROUTINES

;;;Configuration options- Comment out to enable/disable

;#define PICK_POCKETS
;#define USE_VANISH
#define VANISH_HP_PCT 10
#define USE_EVASION
#define SINGLE_EVADE_HP 30		/* pop evasion under % hp when fighting 1 mob */
#define EVADE_AGGRO 1 	   		/* pop evasion if more than X mobs aggro'd AND..*/
#define MULTI_EVADE_HP  40 		/* MyHP less than this */
;#define USE_ADRENALINE
;#define ADRENALINE_HP_PCT 40
;#define SAVE_ADRENALINE_ADDS
;#define USE_FLURRY
;#define USE_GHOSTLY_STRIKE
;#define USE_HEMO
#define USE_BAND			/* Bandage post-combat? */
#define BAND_HP 37			/* % hp to bandage below */
#define BANDAGE_NAME Runecloth Bandage  /* explicit name of bandage, no quotes */
;#define GOUGE_BAND			/* enable gouge/bandage combo on single mob if hp below... */
;#define USE_GOUGE
;#define GOUGE_BAND_HP 50
#define BLIND_BAND			/* when fighting 1 mob, enable blind/bandage combo below... */
#define BLIND_BAND_HP 40                /* ...configurable HP percent ?? */
#define SINISTER_COST 45   		/* adjust to reflect talents */
#define EV_MULT 15 			/* combo points * multi = mob health % to FINISHING_MOVE */
#define FINISH_POINTS 4         	/* always FINISHING_MOVE at or above this many combo points */
#define FINISHING_MOVE Eviscerate     /* eviscerate, envenom, etc. no quotes. */
#define JUMP_CHANCE 90          	/* 100-JUMP_CHANCE = chance that char will jump while SS/Evisc */
#define USE_KICK			/* comment out to prevent frivolous kicking */
#define USE_SLICE			/* use slice and dice? */
#define SLICE_POINTS 2			/* slice and dice when combo points <= X and mob hp>50% */
#define RANGED_SPELL Throw		/* exact name of ranged spell, no quotes- Throw Shoot etc. */
;#define RANGED_PULL  			/* Open with Ranged?      ---{DO NOT DEFINE BOTH SIMULTANEOUSLY */
#define CS_PULL    			/* Open with CheapShot?   ---{THERE WILL BE PROBLEMS */
#define HEIGHT_DIFF 1000000             /* note - using CS_PULL, bot will still pull w/ ranged weapon if it exists and the target
					 * mob has a significantly different Z, ie. to avoid getting stuck on hills */

#define POISON_MAIN
#define POISON_OFF
#define MAINHAND_POISON "Deadly Poison IV"	/* explicit names necessary, */
#define OFFHAND_POISON  "Deadly Poison IV"        /* ie. Instant Poison, Deadly Poison III, etc. */
;#define PATROL_STEALTH			/* stealth on patrol? (CS_PULL defined will cause stealth on pull regardless */
#define STEALTH_PULL "Cheap Shot"		/* explicit name of stealth pull attack */



function RogueDebug(string Text)
{
	;echo [${Time.Time24}] ROGUEDEBUG: ${Text}
	;redirect -append roguedebug.txt echo [${Time.Time24}] ROGUEDEBUG: ${Text}
}

/* START ROAMPREP CODE */
function RoamPrep()
{

}

/* START ADVANCEPREP CODE */
function AdvancePrep()
{
 if ${MyMount(exists)} && !${Me.Mount(exists)} && !${Me.Buff[Ghost](exists)} && !${Me.Buff[Wisp](exists)}
      {
         move -stop
         wait 10
         if ${MountSpell}
         {
            cast "${MyMount}"
         }
         else
         {
            Item["${MyMount}"]:Use
         }
         wait 80 ${Me.Mount(exists)}
      }


} 

function CombatPrep()
{

call Dismount	
	/*#ifdef PATROL_STEALTH
	{
		call RogueDebug "Going into stealth"
		cast "Stealth"
	}
	#endif
	*/
	;Reset flag
	DoCombatPrep:Set[FALSE]
}

function Attack(string AttackGUID)
{
	
	
	declare diff float local
	declare SavX float local ${Me.X}
	declare SavY float local ${Me.Y}
	declare SavZ float local ${Me.Z}
	declare BailOut int local ${Math.Calc[${LavishScript.RunningTime}+(1000*${CombatBailout})]}
	declare EvMult int local 
	declare HavePulled bool local FALSE
	declare StuckCheck bool local FALSE
	declare ClosedToMelee bool local FALSE
	declare StuckCheckTime int local
	declare Aggros guidlist local
	declare ObstacleCheckTimer bool local TRUE
	declare PoisonOfChoice string
	declare jump_value int local
	
	EvMult:Set[EV_MULT]
	
	if ${AttackGUID.Equal[NULL]}||${AttackGUID.Equal[NOTARGET]}
	{
		call UpdateHudStatus "No target to attack"
	}
	
	call UpdateHudStatus "Attacking ${Object[${AttackGUID}].Name}" 
	
	call Dismount
	
	Do
	{
		;attempt to bailout on teleported mob
		if ${ClosedToMelee} && ${HavePulled} && ${Unit[${AttackGUID}].Distance}>20 && ${Unit[${AttackGUID}].PctHPs}>15
								
		{
			call UpdateHudStatus "I think mob was teleported, bailing. Verify?"
			TargetGUID:Set[NOTARGET]
			Return			
		}  
		
		
		SavX:Set[${Me.X}]
		SavY:Set[${Me.Y}]
		SavZ:Set[${Me.Z}]
		
		; Ensure we are still facing our target loc
		
		call ImpFacePrecision ${Unit[${AttackGUID}].X} ${Unit[${AttackGUID}].Y}
		call CheckFacing
		
		; Check we still have a valid target
		if !${Unit[${AttackGUID}](exists)}
		{
			call UpdateHudStatus "Target lost"
			TargetGUID:Set[NOTARGET]
			Return
		}
		
		; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return			
		}  

		; no swimmers
		if ${Target.Swimming} && !${Me.Swimming}
		{
			call UpdateHudStatus "I'd rather not drown thx"
			TargetGUID:Set[NOTARGET]
			Return			
		}  
		
		  if ${Unit[${AttackGUID}].FactionGroup.Equal[Alliance]} 
		   { 
		      ;add them to a blacklist or whatever here... 
		      call UpdateHudStatus "Target is an alliance member, don't bother attacking them" 
		      GUIDBlacklist:Set[${AttackGUID},AVOID] 
		      TargetGUID:Set[NOTARGET] 
		      Return 
   		   } 

		if ${Unit[${AttackGUID}].Faction.Equal[Cenarion Circle]} 
		   { 
		      ;add them to a blacklist or whatever here... 
		      call UpdateHudStatus "Target is an alliance member, don't bother attacking them" 
		      GUIDBlacklist:Set[${AttackGUID},AVOID] 
		      TargetGUID:Set[NOTARGET] 
		      Return 
   		   } 

		call CheckAggro
		
		; If we dont have our chosen unit targeted and were in range target it
		if !${Target.GUID.Equal[${AttackGUID}]}
		{
			#ifdef DEBUG
			call Debug "Targeting Unit ${Unit[${AttackGUID}].Distance}[${AttackGUID}]"
			#endif
			Target ${AttackGUID}
			waitframe
		}
		
		
		;if we are pulling and CS'ing and we aren't stealthed then do it
		#ifdef CS_PULL
		if ${Target.Distance}<18 && !${Me.InCombat} && !${Me.Buff[Stealth](exists)} && !${Spell[Stealth].Cooldown}
		{
		cast "Stealth"
		waitframe
		}
		#endif
		
		if ${Unit[${AttackGUID}].Tapped}
				{
					call UpdateHudStatus "Target already engaged"
					TargetGUID:Set[NOTARGET]
					Return			
		}  
		;jump_value:Set[${Math.Rand[100]}]
		;if (jump_value < JUMP_CHANCE)-1
		;		{
		;		wowpress Jump
		;}
		;jump_value:Clear
		
		if !${Me.Attacking}&&${Target(exists)}&&!${Me.Buff[Stealth](exists)}
		{
			WoWScript AttackTarget()
		}


; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return
		}
		; Check we havent picked up aggro
		Aggros:Search[-units,-nearest,-aggro,-alive,-range 0-20]
		if ${Aggros.Count}>0
		{
			#ifdef USE_VANISH
			if ${Aggros.Count}>3
			{
				RLG:Set[TRUE]
				call CastSpell "Vanish"
				return
			}
			#endif
			
			#ifdef USE_EVASION
			if ${Aggros.Count}>EVADE_AGGRO&&!${Spell[Evasion].Cooldown}&&${Me.PctHPs}<MULTI_EVADE_HP || ${Aggros.Count}&&!${Spell[Evasion].Cooldown}&&${Me.PctHPs}<SINGLE_EVADE_HP && ${Target.PctHPs}>25
			{
				Call CastSpell "Evasion"
			}
			#endif
			
			#ifdef USE_ADRENALINE
			if ${Aggros.Count}>1&&!${Spell[Adrenaline Rush].Cooldown}&&${Spell[Blade Flurry].Cooldown} && !${Me.Buff[Blade Flurry](exists)} || ${Me.PctHPs}<MULTI_EVADE_HP && ${Target.PctHPs}>30 && ${Spell[Evasion].Cooldown} && !${Spell[Adrenaline Rush].Cooldown} && !${Me.Buff[Evasion](exists)}&&${Spell[Blade Flurry].Cooldown}<110000
			{
				call CastSpell "Adrenaline Rush"
			}
			#endif
		}
		Aggros:Clear
	
	
	
	; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return
		}

/*
		;if ${Target.Distance} >= ${CombatMaxDist}
		if ${Target.Distance} >= ${PullingRange} && !${HavePulled}
		{
			call ImpFacePrecision ${Target.X} ${Target.Y}
			call CheckFacing
			move forward
			do
			{
        	
				call ImpFacePrecision ${Target.X} ${Target.Y}
				call CheckFacing
				move forward
				WaitFrame
			}
			while ${Target.Distance}>= ${PullingRange}

			move -stop forward

			;wait for half a second to give our pc a chance to move
			wait 5
		}
*/

;#ifdef CS_PULL
;HavePulled:Set[TRUE]
;#endif

;Check that we are not already there!
           if ${Target.Distance}>= ${CombatMaxDist} 
           ;&& ${HavePulled}
           {
              Do
              {
                 #ifdef CS_PULL
		 		if ${Target.Distance}<18 && !${Me.InCombat} && !${Me.Buff[Stealth](exists)} && !${Spell[Stealth].Cooldown}
		 		{
		 		cast "Stealth"
		 		waitframe
		 		}
		#endif
                 
                 
                 ;ensure we are still facing our target loc
                 call ImpFacePrecision ${Target.X} ${Target.Y}

                 ;press and hold the forward button
                 wowpress -hold moveforward

                 ;wait for half a second to give our pc a chance to move
                 wait 6

                 ;check to make sure we have moved if not then try and avoid the
                 ;obstacle thats in our path
                 if ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${SavX},${SavY},${SavZ}]}<1
                 {
                    call Obstacle2
                 }
                 ;store our current location for future checking
                 SavX:Set[${Me.X}]
                 SavY:Set[${Me.Y}]
                 SavZ:Set[${Me.Z}]
                 if ${Unit[${AttackGUID}].Tapped}
		 		{
		 			call UpdateHudStatus "Target already engaged"
		 			TargetGUID:Set[NOTARGET]
		 			Return			
		}  
                 
              }
              while (${Target.Distance} >= ${CombatMaxDist}&&(${LavishScript.RunningTime}<${BailOut})

              ;Made it to our target loc
              wowpress -release moveforward
           }
		
		;diff:Set[${Math.Calc[${Target.Z}-${Me.Z}]}]
		#ifdef CS_PULL
		{
			/*
			if ${Unit[${AttackGUID}].Distance}<30&&!${Me.InCombat} && !${HavePulled} && ${Me.Equip[ranged].Durability}>0 && ${Math.Abs[${diff}]}>=HEIGHT_DIFF
			{
			call UpdateHudStatus "Ranged pull b/c height difference ${Math.Calc[${Target.Z}-${Me.Z}]}"
			call CastSpell "RANGED_SPELL" ${Target.GUID}
			wait 60 ${Target.Distance}<10
			}
			*/	
			
			;else
			if !${Me.InCombat} && !${Me.Buff[Stealth](exists)} && !${Spell[Stealth].Cooldown} && ${Target.Distance}<18
			{
			cast "Stealth"
			HavePulled:Set[TRUE]
			}
			
			
		}
		
		#endif

; Check if we have pulled yet and if not do so.
		#ifdef RANGED_PULL
		if ${Unit[${AttackGUID}].Distance}<30&&!${Me.InCombat} && !${HavePulled} && ${Me.Equip[ranged].Durability}>0
		{
		do
					{
		        	
						;call ImpFacePrecision ${Target.X} ${Target.Y}
						;call CheckFacing
						move forward
						WaitFrame
					}
				while ${Target.Distance} >= ${PullingRange} && !${HavePulled}
		
		          call UpdateHudStatus "Supposed to be pulling but I'm a stupid piece of shit. Dist ${Target.Distance}"
			  move -stop
			  call CastSpell "RANGED_SPELL" ${AttackGUID}
			  wait 60 ${Target.Distance}<=${CombatMaxDist}
			  HavePulled:Set[TRUE]
		}
		else
		{
			if ${Unit[${AttackGUID}].Distance}<10
			{
			HavePulled:Set[TRUE]
			}
		}
		#endif
		
;		#ifdef CS_PULL
;		HavePulled:Set[TRUE]
;		#endif
		
		
		;if ${Me.InCombat}
;{
		
	/*
	if ${Target.Distance} >= ${CombatMaxDist}
		;		if ${Target.Distance} >= ${PullingRange}
				{
					call ImpFacePrecision ${Target.X} ${Target.Y}
					call CheckFacing
					move forward
					do
					{
		        	
						call ImpFacePrecision ${Target.X} ${Target.Y}
						call CheckFacing
						move forward
						WaitFrame
					}
					while ${Target.Distance}>= ${CombatMaxDist}
		
					move -stop forward
		
					;wait for half a second to give our pc a chance to move
					wait 5
		}
	*/
		if ${Unit[${AttackGUID}].Distance}<${CombatMinDist}
		{
			#ifdef DEBUG
			call Debug "Too close backing up"
			#endif
			;press and hold the backward button 
			wowpress -release moveforward
			wowpress -hold movebackward
			wait 3
		}


; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return
		}
		

		if ${Me.Buff[Stealth](exists)} && ${Unit[${AttackGUID}].Distance}<6 && ${Me.Action[Cheap Shot].Usable}
		{
			#ifdef PICK_POCKETS
			call CastSpell "Pick Pocket" ${Target.GUID}
			waitframe
			#endif
			
			if ${Target.CreatureType.Equal[Humanoid]} || ${Target.CreatureType.Equal[Demon]}
						{
										call CastSpell "Pick Pocket" ${Target.GUID}
										waitframe
			}
				
			Do
			{
			wowpress -hold moveforward
			call CastOnRun "Cheap Shot" ${Target.GUID}
			waitframe
			}
			while ${Me.Buff[Stealth](exists)} && ${Unit[${AttackGUID}].Distance}<5
			
			
			
			
			
			HavePulled:Set[TRUE]
			
		}
		
		;If we are close enough stop running
				if ${Unit[${AttackGUID}].Distance}>${CombatMinDist}&&${Unit[${AttackGUID}].Distance}<${CombatMaxDist}
				{
					waitframe
					wowpress -release moveforward
					wowpress -release movebackward
					StuckCheck:Set[FALSE]
				}
		
		#ifdef USE_GOUGE
		; Use Gouge and Backstab, if available
		if ${Me.Target(exists)}&&${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>45&&${Spell[Backstab](exists)}&&!${Spell[Backstab].Cooldown}&&${Target.PctHPs}>0
		{
			call GougeBackstab
		}
		#endif
		
		#ifdef BLIND_BAND
		Aggros:Search[-units,-nearest,-aggro,-alive,-range 0-30]
		if ${Aggros.Count}<=1 && ${Me.PctHPs}<BLIND_BAND_HP && ${Item[-inventory,BANDAGE_NAME](exists)} && ${Item[-inventory,Blinding Powder](exists)} && !${Me.Buff[Recently Bandaged](exists)} && ${Me.CurrentEnergy}>${Spell[Blind].Mana} && !${Spell[Blind].Cooldown}
		{
			call CastSpell "Blind" ${Target.GUID}
			wait 20 ${Target.Buff[Blind](exists)}
			if ${Target.Buff[Blind](exists)}
			{
				call BandageMe
			}
		
		}
		#endif
		
		if ${Me.Action[Riposte].Usable}&&${Unit[${AttackGUID}].Distance}<5 && ${Me.CurrentEnergy}>10 && ${Spell[Riposte](exists)} && !${Spell[Riposte].Cooldown}
		{ 
			call CastSpell "Riposte" ${Target.GUID}
		}


		#ifdef USE_KICK
		if ${Unit[${AttackGUID}].Distance}<5&&${Target.Casting.ID(exists)}&&${Me.CurrentEnergy}>25 & ${Spell[Kick](exists)}
		{					
			call CastSpell "Kick" ${Target.GUID}
		}
		#endif

		#ifdef USE_FLURRY
		Aggros:Search[-units,-nearest,-aggro,-alive,-range 0-5]
		if ${Aggros.Count}>1
		{
			if ${Target.PctHPs}>25&&!${Spell[Blade Flurry].Cooldown}&&${Me.CurrentEnergy}>25&&${Spell[Blade Flurry](exists)} && !${Me.Buff[Blade Flurry](exists)}
			{
			call CastSpell "Blade Flurry"
			}
		}
		Aggros:Clear
		#endif

; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return
		}
		
		
		if ${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>=25&&${Target.PctHPs}>48&&!${Spell[Kidney Shot].Cooldown}&&${WoWScript[GetComboPoints()]}>=4
   		{
   			call CastSpell "Kidney Shot" ${Unit[${AttackGUID}]}
   		}
   		
   		
   		if ${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>=35&&${Math.Calc[(${WoWScript[GetComboPoints()]}*${EvMult})]}>${Target.PctHPs}&& !${Spell[FINISHING_MOVE].Cooldown} || ${Unit[${AttackGUID}].Distance}<5 && ${Me.CurrentEnergy}>35 && (${WoWScript[GetComboPoints()]}>=FINISH_POINTS)
					        {
							ClosedToMelee:Set[TRUE]
							if !${Spell[Cold Blood].Cooldown} && ${Spell[Cold Blood](exists)}
							{
								call CastSpell "Cold Blood"
								wait 10
							}
							call UpdateHudStatus "FINISHING_MOVE because Multi value ${WoWScript[GetComboPoints()]}*${EvMult} > Mob Health ${Target.PctHPs}"
							call CastSpell "FINISHING_MOVE"  ${Target.GUID}
                				}

		
	
		#ifdef USE_SLICE
		Aggros:Search[-units,-nearest,-aggro,-alive,-range 0-20]
		if ${Unit[${AttackGUID}].Distance}<5&&(${Me.CurrentEnergy}>${Spell[Slice and Dice].Mana})&&!${Spell[Slice and Dice].Cooldown}&&${WoWScript[GetComboPoints()]}<=SLICE_POINTS && ${Target.PctHPs}>50 && !${Me.Buff[Slice and Dice](exists)} || (${Me.CurrentEnergy}>${Spell[Slice and Dice].Mana})&&!${Spell[Slice and Dice].Cooldown}&&${WoWScript[GetComboPoints()]}<=2 && ${Aggros.Count}>1 && !${Me.Buff[Slice and Dice](exists)}
		{
			ClosedToMelee:Set[TRUE]
			call CastSpell "Slice and Dice"  ${Me.GUID}
			waitframe
		}
		Aggros:Clear
		#endif
		
		;jump_value:Clear
				
		#ifdef USE_GHOSTLY_STRIKE
		if ${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>= 40 &&!${Spell[Ghostly Strike].Cooldown}&&${Spell[Ghostly Strike](exists)}
				{
				
					jump_value:Set[${Math.Rand[100]}]
					if (${jump_value}>JUMP_CHANCE)
						{
						wowpress jump
						}		
					call CastSpell "Ghostly Strike"  ${Target.GUID}
					waitframe
		}
		#endif
		
		if ${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>SINISTER_COST&&!${Spell[Sinister Strike].Cooldown}
		{
			jump_value:Set[${Math.Rand[100]}]
			if (${jump_value}>JUMP_CHANCE)
				{
				wowpress jump
				}		
			ClosedToMelee:Set[TRUE]
			call CastSpell "Sinister Strike"  ${Target.GUID}
			waitframe
		}

		if ${Unit[${AttackGUID}].Distance}<5&&${Me.CurrentEnergy}>35&&${Math.Calc[(${WoWScript[GetComboPoints()]}*${EvMult})]}>${Target.PctHPs} && !${Spell[FINISHING_MOVE].Cooldown} || ${Unit[${AttackGUID}].Distance}<5 && ${Me.CurrentEnergy}>35 && (${WoWScript[GetComboPoints()]}>=FINISH_POINTS)
					        {
							if !${Spell[Cold Blood].Cooldown} && ${Spell[Cold Blood](exists)}
							{
								call CastSpell "Cold Blood"
								wait 10
							}
							call UpdateHudStatus "Evisc because Multi value ${WoWScript[GetComboPoints()]}*EV_MULT > Mob Health ${Target.PctHPs}"
							jump_value:Set[${Math.Rand[100]}]
											if (${jump_value}>JUMP_CHANCE)
											{
											wowpress jump
											}	
		
							call CastSpell "FINISHING_MOVE"  ${Target.GUID}
                }

		
; Check if the target is engaged already
		if ${Unit[${AttackGUID}].Tapped}
		{
			call UpdateHudStatus "Target already engaged"
			TargetGUID:Set[NOTARGET]
			Return
		}		
		#ifdef USE_VANISH
		if ${Unit[${AttackGUID}].Distance}<5&&${Me.PctHPs}<=VANISH_HP_PCT&&${Target.PctHPs}>=35
		{
			RLG:Set[TRUE]
			call CastSpell "Vanish"  ${Target.GUID}
			return
		}
		#endif

		call snarfpotion
		
		if ${ObstacleCheckTimer}
		{
			; Check to make sure we have moved since the last check and if not then try and avoid the
			; obstacle thats in our path
			;if ${Math.Calc[${Me.X}-${SavX}]}<1&&${Math.Calc[${Me.Y}-${SavY}]}<1&&${Unit[${AttackGUID}].Distance}>${CombatMaxDist}
			if ${Math.Distance[${Me.X},${Me.Y},${SavX},${SavY}]}<1 && ${Unit[${AttackGUID}].Distance}>${CombatMaxDist}
			{
				; I think i might be stuck so jump then save off the current time
				;jump_value:Set[${Math.Rand[100]}]
				;		if jump_value<JUMP_CHANCE-1
				;				{
				;				wowpress Jump
				;				}
				;jump_value:Clear
				wowpress jump
				if !${StuckCheck}
				{
					#ifdef DEBUG
						call Debug "I might be stuck"
					#endif
					StuckCheck:Set[TRUE]
					StuckCheckTime:Set[${LavishScript.RunningTime}]
				} 
				else
				{
					; If I am still stuck after .4 seconds then try and avoid the obstacle.
					if ${Math.Calc[${LavishScript.RunningTime}-${StuckCheckTime}]}>400
					{
						#ifdef DEBUG
							call Debug "Yep I am stuck trying to free myself"
						#endif
						wowpress Jump
						;StuckCheck:Set[TRUE]
					}
				
					; If I am still stuck after 3 seconds then try and avoid the obstacle.
					if ${Math.Calc[${LavishScript.RunningTime}-${StuckCheckTime}]}>3000
					{
						#ifdef DEBUG
							call Debug "Yep I am stuck trying to free myself"
						#endif
						call Obstacle
						StuckCheck:Set[FALSE]
					}
				}
			}
			
			; If I have moved away from my saved spot reset my stuck toggle
			if ${StuckCheck}&&${Math.Calc[${Me.X}-${SavX}]}>3||${Math.Calc[${Me.Y}-${SavY}]}>3
			{
				#ifdef DEBUG
					call Debug "I am no longer stuck"
				#endif
				StuckCheck:Set[FALSE]
			}
		
			; Check if we have exceeded bail out timer
			if ${LavishScript.RunningTime}>${BailOut}
			{
				GUIDBlacklist:Set[${TargetGUID},AVOID]
				call UpdateHudStatus "Combat timeout reached"
				TargetGUID:Set[NOTARGET]
				return
			}
			
			; Store our current position.
			SavX:Set[${Me.X}]
			SavY:Set[${Me.Y}]
			
			; Set a timer to check our position again in a second or so.
			TimedCommand 5 ObstacleCheckTimer:Set[TRUE]
		}
		
				
	}
;}
	while !${Unit[${AttackGUID}].Dead}&&!${Me.Dead}
	{
		; Update stats
		if !${Me.Dead}
		{
			call UpdateStats
		}
	}

	
	

	wowpress -release movebackward
	wowpress -release moveforward

	call RogueDebug "Checking Aggro before Downtime"
	;Reset flags to do combat prep and downtime if we are not still aggroed
	Aggros:Search[-units,-nearest,-aggro,-alive,-range 0-50]
	call RogueDebug "Found ${Aggros.Count} aggros"
	if !${Aggros.Count}
	{
		call Debug "Resetting Downtime and CombatPrep Flags"
		DoDowntime:Set[TRUE]
		DoCombatPrep:Set[TRUE]
	}
	Aggros:Clear

}

function snarfpotion() 
{ 
;call UpdateHudStatus "Checking to see if I need to use a potion"
;this needs to be rewritten for mana potions. Priests can heal themselfs if they have mana

if ${Item[Greater Healing Potion](exists)} 
    { 
    if (${Me.PctHPs}<25)&&(${Target.PctHPs}>35) 
       { 
       call UpdateHudStatus "Snarfing Greater Healing Potion" 
       Item[Greater Healing Potion]:Use 
       return 
       } 
    } 
if ${Item[Healing Potion](exists)} 
    { 
    if (${Me.PctHPs}<25)&&(${Target.PctHPs}>35) 
       { 
       call UpdateHudStatus "Snarfing Healing Potion" 
       Item[Healing Potion]:Use 
       return 
       } 
    } 
if ${Item[Lesser Healing Potion](exists)} 
    { 
    if (${Me.PctHPs}<25)&&(${Target.PctHPs}>35) 
       { 
       call UpdateHudStatus "Snarfing Lesser Healing Potion" 
       Item[Lesser Healing Potion]:Use 
       return 
       } 
    } 
if ${Item[Minor Healing Potion](exists)} 
    { 
    if ${Me.PctHPs}<25 && ${Target.PctHPs}>35 
       { 
       call UpdateHudStatus "Snarfing Minor Healing Potion" 
       Item[Minor Healing Potion]:Use 
       return 
       } 
    } 
} 

function Downtime()
{
	call UpdateStats
	
	#ifdef USE_BAND
	{
		if ${Me.PctHPs}<BAND_HP
			{
			call BandageMe
			}
	}
	#endif
	
	wait 10
	call RogueDebug "I ENTERED DOWNTIME... ${Me.PctHPs}<${MinHealthPct}"

	if ${Me.PctHPs}<${MinHealthPct}
	{
		call RogueDebug "Check Durability"
		call CheckDurability
		wait 10
		call RogueDebug "Begin While... ${Me.PctHPs}<99&&!${Me.InCombat}&&!${Me.Dead}&&!${Me.Ghost}"
		while ${Me.PctHPs}<90&&!${Me.InCombat}&&!${Me.Dead}&&!${Me.Ghost}
		{
			call RogueDebug "Eating yadda"
			if ${SitWhenRest} && !${Me.Sitting}
			{
				wowpress SITORSTAND
			}

			if ${Me.PctHPs}<${MinHealthPct} && !${Me.Buff[Food](exists)}
			{
				call Eat
				cast "Stealth"
				wait 40 ${Me.Buff[Food](exists)}
			}

			waitframe 
  		 }
	}

	if ${Me.Sitting}
		{
		wowpress SITORSTAND
		}
	
	#ifdef POISON_MAIN
	if !${Me.InCombat} && !${Me.Equip[mainhand].Enchantment[MAINHAND_POISON](exists)} && ${Item[MAINHAND_POISON](exists)}
	{
		wait 10
		Item[MAINHAND_POISON]:Use
		wait 20 ${WoWScript[SpellIsTargeting()]}

		; Check if the spell is awaiting a target and supply one if it is
		if ${WoWScript[SpellIsTargeting()]}
		{
			Object[${Me.Equip[mainhand]}]:PickUp
			wait 20 ${Me.Casting}
		}
		wait 50 !${Me.Casting}
	}
	#endif 
	
	#ifdef POISON_OFFHAND
   	; Check for poison on our off hand, if duel wielding
	if !${Me.InCombat} && ${Me.Equip[offhand](exists)} && !${Me.Equip[offhand].Enchantment[OFFHAND_POISON](exists)} && ${Item[OFFHAND_POISON](exists)}
	{
		wait 10
		Item[OFFHAND_POISON]:Use
		wait 20 ${WoWScript[SpellIsTargeting()]}

		; Check if the spell is awaiting a target and supply one if it is
		if ${WoWScript[SpellIsTargeting()]}
		{
			Object[${Me.Equip[offhand]}]:PickUp
			;Object[OFFHAND]:Pickup
			;type /use 17
			;press enter
			wait 20 ${Me.Casting}
		}
		wait 50 !${Me.Casting}
	}	
	#endif
	
	call check_for_lootable_containers
	
	#ifdef PATROL_STEALTH
	if !${Me.Buff[Stealth](exists)} && !${Spell[Stealth].Cooldown}
	cast "Stealth"
	#endif
	; Reset downtime flag
	DoDowntime:Set[FALSE]
}

function BandageMe()
{
if !${Me.Buff[Recently Bandaged](exists)} && ${Item[-inventory,BANDAGE_NAME](exists)} && ${Item[-inventory,BANDAGE_NAME].Usable}
	{
	declare FormerTarget string ${Me.Target}
	target ${Me.GUID}
	{
	Item[BANDAGE_NAME]:Use
	wait 20 ${Me.Casting}
	}
	wait 100 !${Me.Casting}
	target ${FormerTarget}
	}
}

function GougeBackstab()
{
        MainHandWeaponSubType:Set[${Me.Equip[16].SubType}]

        call CastSpell "Gouge" ${Target.GUID}
        wait 10 ${Me.Target.Buff[Gouge](exists)}
        if ${Me.Target.Buff[Gouge](exists)}
        {
                if !${MainHandWeaponSubType:Equal[Dagger]}
                {
                        echo "Switching to Dagger"
                        Me.Bag[0].Item[1]:Use
                        waitframe
                        call MoveBehind 1
                        wait 40 ${Me.CurrentEnergy}>=60
                        if ${Me.CurrentEnergy}>=60
                        {
                                echo "Casting Backstab 03"
                                call CastSpell "Backstab" ${Target.GUID}
                                echo "Backstab 03 Complete"
                        }
                        echo "Switching to Normal"
                        Me.Bag[0].Item[1]:Use
                        wait 10
                }
                else
                {
                        call MoveBehind 1
                        wait 40 ${Me.CurrentEnergy}>=60
                        if ${Me.CurrentEnergy}>=60
                        {
                                echo "Casting Backstab 04"
                                call CastSpell "Backstab" ${Target.GUID}
                                echo "Backstab 04 Complete"
                                wait 10
                        }
                }
        }
}

function MoveBehind(float Precision)
{
   declare PointX float local
   declare PointY float local
   declare degrees float local
   declare SavX float local ${X}
   declare SavY float local ${Y}
   ;set BailOut timer (4 minutes)
   declare BailOut int local ${Math.Calc[${LavishScript.RunningTime}+(1000*240)]}
   
   call UpdateHudStatus "Attempting to move behind target."
   ;Check that we are not already there!
   if "${Math.Distance[${Me.X},${Me.Y},${PointX},${PointY}]}>${Precision}"
   {
      echo "Moving Behind Target"
      Do
      {   
         echo "Moving Behind Target 02"
         degrees:Set[${Target.Heading.DegreesCCW}+180]
         ;The number below, the Precision, and the movement of the mob will determine the distance
         PointX:Set[${Math.Calc[2*${Math.Cos[${degrees}].Milli}+${Target.X}]}]
         PointY:Set[${Math.Calc[2*${Math.Sin[${degrees}].Milli}+${Target.Y}]}]
         
         ;press and hold the forward button
         ;wowpress -hold moveforward
         move forward
         
         ;ensure we are still facing our target loc
         Face -fast  ${PointX} ${PointY}
         ;wait for half a second to give our pc a chance to move
         wait 5
         ;check to make sure we have moved if not then try and avoid the
         ;obstacle thats in our path
         if ${Me.X}==${SavX}&&${Me.Y}==${SavY}
         {
            call Obstacle
         }
         ;store our current location for future checking
         SavX:Set[${Me.X}]
         SavY:Set[${Me.Y}]
      }
      while "(${Math.Distance[${Me.X},${Me.Y},${PointX},${PointY}]}>${Precision})&&(!${Me.Dead})&&(!${Me.InCombat})&&(${LavishScript.RunningTime}<${BailOut})"

      ;Made it to our target loc
      move -stop
      waitframe
      face -fast ${Target.X} ${Target.Y}
      echo "Movement Completed"
   }
}

function Dismount()
{
if ${Me.Mount(exists)}
      {
         if ${MountSpell}
         {
            Me.Buff["${MyMount}"]:Remove
         }
         else
         {
            Item["${MyMount}"]:Use
         }
         wait 30 !${Me.Mount(exists)}
      }    
}

function lootContainer(string itemName) 
{ 
   if !${Me.Casting} 
   { 
      Item["${itemName}"]:Use 
      wait 10 ${LootWindow(exists)} 

      lootall 
      wait 15 !${LootWindow(exists)} 
   } 
   else 
   { 
      wait 10 
   } 
} 


function check_for_lootable_containers() 
{ 
   while ${Item["Big-mouth Clam"].Slot(exists)} && ${Item["Big-mouth Clam"].Bag.Number(exists)} 
   { 
      call lootContainer "Big-mouth Clam" 
   } 
   
      while ${Item["Scum Covered Bag"].Slot(exists)} && ${Item["Scum Covered Bag"].Bag.Number(exists)} 
      { 
         call lootContainer "Scum Covered Bag" 
      } 

   
   while ${Item["Thick-shelled Clam"].Slot(exists)} && ${Item["Thick-shelled Clam"].Bag.Number(exists)} 
      { 
         call lootContainer "Thick-shelled Clam" 
   } 
   while ${Item["Bloated Catfish"].Slot(exists)} && ${Item["Bloated Catfish"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Catfish" 
   } 
   while ${Item["Bloated Mud Snapper"].Slot(exists)} && ${Item["Bloated Mud Snapper"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Mud Snapper" 
   } 
   while ${Item["Bloated Redgill"].Slot(exists)} && ${Item["Bloated Redgill"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Redgill" 
   } 
   while ${Item["Bloated Salmon"].Slot(exists)} && ${Item["Bloated Salmon"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Salmon" 
   } 
   while ${Item["Bloated Smallfish"].Slot(exists)} && ${Item["Bloated Smallfish"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Smallfish" 
   } 
   while ${Item["Bloated Trout"].Slot(exists)} && ${Item["Bloated Trout"].Bag.Number(exists)} 
   { 
      call lootContainer "Bloated Trout" 
   } 
   while ${Item["Dented Crate"].Slot(exists)} && ${Item["Dented Crate"].Bag.Number(exists)} 
   { 
      call lootContainer "Dented Crate" 
   } 
   while ${Item["Heavy Crate"].Slot(exists)} && ${Item["Heavy Crate"].Bag.Number(exists)} 
   { 
      call lootContainer "Heavy Crate" 
   } 
   while ${Item["Message in a Bottle"].Slot(exists)} && ${Item["Message in a Bottle"].Bag.Number(exists)} 
   { 
      call lootContainer "Message in a Bottle" 
   } 
   while ${Item["Sealed Crate"].Slot(exists)} && ${Item["Sealed Crate"].Bag.Number(exists)} 
   { 
      call lootContainer "Sealed Crate" 
   } 
   while ${Item["Small Chest"].Slot(exists)} && ${Item["Small Chest"].Bag.Number(exists)} 
   { 
      call lootContainer "Heavy Crate" 
   } 
   while ${Item["Waterlogged Crate"].Slot(exists)} && ${Item["Waterlogged Crate"].Bag.Number(exists)} 
   { 
      call lootContainer "Waterlogged Crate" 
   } 
   while ${Item["Battered Chest"].Slot(exists)} && ${Item["Battered Chest"].Bag.Number(exists)} 
   { 
      call lootContainer "Battered Chest" 
   } 
   while ${Item["Large Battered Chest"].Slot(exists)} && ${Item["Large Battered Chest"].Bag.Number(exists)} 
   { 
      call lootContainer "Large Battered Chest" 
   } 
}