All pastes #390825 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-03-11 18:21 UTC
rendered paste body
;Stealthy's Mage Routine
;Debugging/Testing Stages 0.24
;Current status: Stable, 90% bug free (the way to be!)
;Designed for use with WoWBot 15b.
;Conjuring/eating/drinking borrowed from EQJoe, can't get much better than how he has it.

;notes: work on hilly targeting
;notes: Totem code, add code to deal with pets (NPC warlocks, hunters)
;notes: finish combat (currently works, just not all there), finish HP test, finish a lot of things
;Working on now: AoEing/Polymorphing/add handling, fixing getsafespot (search). Up next: 0 xp/hr bug,
; looting bugs (if still exist), add manastone function
;History: 0.24, Fixxed run to bum fuck egypt bug, fixed a minor pull issue and a few bracket errors
;History: 0.23, Pull bug fixed. Will no longer try to spam pull until too close.
;History: 0.22, Many bugs ironed out, quite stable although incomplete. Safe to use when not around water.
;History: 0.21, somewhat works, quite buggy. Too long a list.



#define ROUTINES
#define DEBUG
function Attack(string AttackGUID)
{
	;These need to be set.
	;frostspec - if you're frostspec or not, pyropull - pull with pyro if true, arcmissiletalent - if
	;you have 5/5 imp arc missiles make it true, useflamestrike - allow use of flamestrike in AoE situations,
	;useblizzard - allow use of blizzard in AoE situations
	declare frostspec bool local FALSE
	declare Pyropull bool global TRUE
	declare arcmissiletalent bool global TRUE
	declare UseFlamestrike bool global TRUE
	declare UseBlizzard bool global FALSE
	;don't touch these, they're autoset
	;
	;seriously ,don't touch 'em
	declare HavePulled bool global
	declare UseFrostWard bool global
	declare UseFireWard bool global
	declare Immune-Frost bool global
	declare Immune-Fire bool global
	declare Dampen bool global
	declare RangedMode bool local
	declare hastarget bool global 
	declare testx float global
	declare testy float global
	declare safex1 float global
	declare safey1 float global
	declare angle float global
	declare NoSafeSpot bool global
	declare testfail int global
	declare Adds1 guidlist global
	declare Aggros1 guidlist global
	declare Aggros2 guidlist global
	declare Mobs guidlist global

	SavedWaypointX:Set[${Me.X}]
	SavedWaypointY:Set[${Me.Y}]

	echo "${AttackGUID}"
	if ${AttackGUID[NULL]}||${AttackGUID.Equal[NOTARGET]}
	{
		call UpdateHudStatus "No Target."
		Return
	}
	;elites code borrowed from eqjoe, not much improvement to make. RLG is getting improved, however.
	if ${Unit[${AttackGUID}].Classification.Equal[Elite]} 
	{ 
		if !${Me.InCombat} 
		{ 
			call UpdateHudStatus "Target is an elite, don't bother attacking them" 
			GUIDBlacklist:Set[${AttackGUID},AVOID] 
			TargetGUID:Set[NOTARGET] 
			Return 
		} 
		else 
		{ 
			call UpdateHudStatus "Aggrod an elite RUN after we sheep!!" 
			if !${Spell[Polymorph].Cooldown}&&${Spell[Polymorph](exists)} 
			{ 
				call CastSpell Polymorph ${AttackGUID} 
			}    
;			RLG:Set[TRUE] 
			GUIDBlacklist:Set[${AttackGUID},AVOID] 
			TargetGUID:Set[NOTARGET] 
			Return 
		} 
	} 
	call UpdateHudStatus "Attacking ${Object[${AttackGUID}].Name}" 
	if ${Unit[${AttackGUID}].Distance}<${PullingRange}&&!${HavePulled} 
	{
		move -stop
		
		Target ${AttackGUID}
	}
	Do
	{
		if ${Me.Sitting}
		{
			wowpress SITORSTAND
		}
		;If already pulled, just nuke. Nothing more.
		echo "${HavePulled} PULLED STATUS"
		if ${HavePulled}
		{
			echo "ALREADY FUCKING PULLED"
			echo "${AttackGUID}"
			call Nukes ${AttackGUID}
		}	
		else
		{
			;save XYZ for stuck dist checking later, that's getting improved as well
			DistX:Set[${Me.X}]
			DistY:Set[${Me.Y}]
			DistZ:Set[${Me.Z}]
			;Do we still have a target?
			if !${Unit[${AttackGUID}](exists)}
			{
				echo "Target disappeared :("
				call UpdateHudStatus "Target is gone."
				TargetGUID:Set[NOTARGET]
				Return
			}	
			;Check to see if it's been tapped
			if ${Unit[${AttackGUID}].Tapped}
			{
				echo "Target stolen, stopping casting if I was casting."
				call UpdateHudStatus "Target stolen; tapped."
				if ${Me.Casting}
				wowpress JUMP
				TargetGUID:Set[NOTARGET]
				Return
			}		
			;Check to see if it's not tapped yet, but has a target
			if ${Unit[${AttackGUID}](exists)}
			{
				Target ${AttackGUID}
				call checkassist
				wowpress ASSIST
				call removecheckassist
				if ${hastarget}
				{
					echo "Ignoring target from assistcheck"
					call UpdateHudStatus "It's got a target; ignore."
					TargetGUID:Set[NOTARGET]
					Return
				}			
			}
			if ${Unit[${AttackGUID}].PctHPs}==0
			{
				;Target's dead, move on.
				TargetGUID:Set[NOTARGET]
				Return
			}
				
			;If our target's in range and not targetted, target him.
			if !${Target.GUID.Equal[${AttackGUID}]} && ${Unit[${AttackGUID}].Distance}<${TargetingRange}
			{
				echo ${Unit[${AttackGUID}].Distance}
				echo "Targeting our target"
				call UpdateHudStatus "Targeting ${AttackGUID}"
				Target ${AttackGUID}
				wait 10
				face -fast ${Target.X} ${Target.Y}
				wait 3
			}			
			;Do the combat prep
			if (${Target.GUID.Equal[${AttackGUID}]}) && (${Unit[${AttackGUID}].Distance}<${TargetingRange}) && !${Me.InCombat} && !${HavePulled} && ${DoCombatPrep}
			{
				echo "doing combatprep"
				call UpdateHudStatus "Doing CombatPrep for fight with ${AttackGUID}"
				DoCombatPrep:Set[TRUE]
				call CombatPrep
			}		
			;If we're not in targeting range, get in range.
			if (${Unit[${AttackGUID}].Distance}>${PullingRange})
			{
				face ${Target.X} ${Target.Y}
				move forward
				wait 3
				Return
			}
			if !${RangedMode} && ${Unit[${AttackGUID}].Distance} > ${RangedMinDist} 
			{ 
				RangedMode:Set[TRUE] 
				call UpdateHudStatus "Entered Ranged Mode" 
			}          
			;Check if we need to switch out of Ranged Mode 
			if ${RangedMode} && ${Unit[${AttackGUID}].Distance} < ${RangedMinDist} 
			{ 
				RangedMode:Set[FALSE] 
				call UpdateHudStatus "Left Ranged Mode" 
			} 
			if !${Me.Attacking}&&${Unit[${AttackGUID}](exists)}&&!${RangedMode} 
			{ 
				echo "Not in ranged mode, staffsmacking and nuking"
				WoWScript AttackTarget() 
				call Nukes ${AttackGUID}
			} 
			;All should be well, start the pull.	
			echo "${Unit[${AttackGUID}].Distance} distance"
			echo "${PullingRange} pulling range"
			echo "${TargetingRange} target range"
			if (${Unit[${AttackGUID}].Distance}<${PullingRange}) && ${Unit[${AttackGUID}].Distance}>20 && (${Unit[${AttackGUID}].Distance}<${TargetingRange}) && ${RangedMode} && !${HavePulled}
			{
				echo "x ${Unit[${AttackGUID}].X} y ${Unit[${AttackGUID}].Y}"
				Face ${Target.X} ${Target.Y} 
				call CheckFacing
				move -stop 
				wait 5 
				echo "Pulling"
				;Attach atom for pullcheck
				Event[UNIT_SPELLCAST_SUCCEEDED]:AttachAtom[pullcheck]
				;Check for what spell would be best to pull with and use it.
				;If you're fire and got pyro, use it.
				if !${frostspec} && ${Pyropull} && ${Spell["Pyroblast"](exists)} && !${Immune-Fire} && !${HavePulled}
				{
					echo "pyroblast pulling"
					call UpdateHudStatus "Pulling with Pyroblast"
					call CastSpell "Pyroblast" ${AttackGUID}
					HavePulled:Set[TRUE]
					echo "${HavePulled} pulled"
;					Return
				}		
				;Pull with a fireball if pyro doesn't exist
				if !${frostspec} && (!${Spell["Pyroblast"](exists)}||!${Pyropull}) && !${Immune-Fire} && !${HavePulled}
				{
					echo "fireball pulling"
					call UpdateHudStatus "Pulling with Fireball"
					call CastSpell "Fireball" ${AttackGUID}
					HavePulled:Set[TRUE]
					echo "${HavePulled} pulled"
;					Return
				}		
				;Frost spec? Frostbolt!
				if ${frostspec} && !${Immune-Frost} && !${HavePulled}
				{
					echo "Frostbolt pulling"
					call UpdateHudStatus "Pulling with Frostbolt"
					call CastSpell "Frostbolt" ${AttackGUID}
					HavePulled:Set[TRUE]
					Return
				}		
				;If you're a frosty and it's frost immune, you can't exactly frostbolt it...
				if ${frostspec} && ${Immune-Frost} && !${HavePulled}
				{
					echo "firebolt pulling - frost immune"
					call UpdateHudStatus "Pulling with Fireball"
					call CastSpell "Fireball" ${AttackGUID}
					HavePulled:Set[TRUE]
					Return
				}		
				;Likewise, if you're fire and it's fire immune, can't use fire.
				if !${frostspec} && ${Immune-Fire} && !${HavePulled}
				{
					echo "Frostbolt pulling - fire immune"
					call UpdateHudStatus "Pulling with Frostbolt"
					call CastSpell "Frostbolt" ${AttackGUID}
					HavePulled:Set[TRUE]
					Return
				}		
			}
			elseif (${Unit[${AttackGUID}].Distance}<${PullingRange}) && ${Unit[${AttackGUID}].Distance}<20 && (${Unit[${AttackGUID}].Distance}<${TargetingRange}) && ${RangedMode}
			{
				echo "Too close to pull, nuking"
				call UpdateHudStatus "Nuking"
				call Nukes ${AttackGUID}
				HavePulled:Set[TRUE]
				Return
			}
		}
	;Just in case it's an add we're starting to fight, add a 'pulled' check for it. 5 yard pyroblasts annoy me.
	if (${Unit[${AttackGUID}].Distance}<5)
	{
		HavePulled:Set[TRUE]
	}
	;If the target's dead, go ahead and reset pulled flag
	if (${Unit[${AttackGUID}].PctHPs}==0)
	{
		echo "Setting pulled FALSE"
		HavePulled:Set[FALSE]
	}
	;If we're good on pull, start the nukes!
	if ${HavePulled}
	{
		echo "Pulled good, starting nukes"
		call UpdateHudStatus "Starting Nukes"
		call Nukes ${AttackGUID}
	}
	}
	While !${Unit[${AttackGUID}].Dead}&&!${Me.Dead}

	; Update Status
	if ${Me.Dead}
	{
		#ifdef DEBUG
		call Debug "Updating Status"
		#endif
		call UpdateStats
	}
}
function Nukes(string AttackGUID)
{
	;Check for any adds. This works because Nukes loops.
	Adds1:Search[-units,-alive,-aggro,-range 0-10]
	;MAKE SURE WE'RE FACING THE GODDAMN TARGET
	face ${Target.X} ${Target.Y}
	wait 2
	;Make sure it's in casting range... this should fit any spec with at least rank 3 fireball/frostbolt
	if (${Unit[${AttackGUID}].Distance}>36)
	{
		move forward
		wait 3
		move -stop
		return
	}
	;What better way to start than with clearcast?
	if ${Me.Buff["Clearcasting"](exists)}
	{
		if ${arcmissletalent}
		{
			echo "Clearcast one rack 'o Missiles"
			call UpdateHudStatus "Casting Arcane Missiles"
			call CastSpell "Arcane Missiles" ${AttackGUID}
		}	
		if ${frostspec} && !${Immune-Frost}
		{
			echo "Clearcasting me a frostbolt"
			call UpdateHudStatus "Casting Frostbolt"
			call CastSpell "Frostbolt" ${AttackGUID}
		}
		;Aww crap... clearcast and it's frost immune. No free lolcrit for you.
		if ${frostspec} && ${Immune-Frost}
		{
			echo "Poor frostmage clearcasting a fireball"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
		}
		;Firespec? Good man (or woman)!
		if !${frostspec} && !${Immune-Fire}
		{
			echo "Clearcast cooking: One fireball"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
		}
		;Fire mage fighting lava elementals? Shame on you.
		if !${frostspec} && ${Immune-Fire}
		{
			echo "Clearcasting a frostbolt because I'm a bad fire mage"
			call UpdateHudStatus "Casting Frostbolt"
			call CastSpell "Frostbolt" ${AttackGUID}
		}
	}
	;Well, that's great. What about arc power?
	if ${Spell["Arcane Power"](exists)} && !${Spell["Arcane Power"].Cooldown}
	{
		echo "I have the power!"
		call UpdateHudStatus "Casting Arcane Power"
		call CastSpell "Arcane Power" ${Me.GUID}
	}
	;Ain't that nifty? You know, I'm pretty sure that if we have arc power, we have something else...
	if ${Spell["Presence of Mind"](exists)} && !${Spell["Presence of Mind"].Cooldown}
	{
		echo "One cruise missile coming up"
		call UpdateHudStatus "Casting Presence of Mind"
		call CastSpell "Presence of Mind" ${Me.GUID}
	}
	;Now then, what are we going to do with this newfound power? You know what.
	if ${Me.Buff["Presence of Mind"](exists)}
	{
		;We gotta pick our poison.
		if !${frostspec} && ${Spell["Pyroblast"](exists)} && !${Immune-Fire}
		{
			echo "FIRIN MAH LAZAR CANNON!"
			call UpdateHudStatus "Casting Pyroblast"
			call CastSpell "Pyroblast" ${AttackGUID}
		}
		if !${frostspec} && !${Spell["Pyroblast"](exists)} && !${Immune-Fire}
		{
			echo "Firin mah...mini... lazar cannon!"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
		}
		;Unfortunately, there's -always- a frosty.
		if ${frostspec} && !${Immune-Frost}
		{
			echo "Pew pew frostbolt"
			call UpdateHudStatus "Casting Frostbolt"
			call CastSpell "Frostbolt" ${AttackGUID}
		}
		;That's fine and dandy, but what if we're a naughty mage fighting something immune to our spec?
		if ${Immune-Frost}
		{
			echo ":'( It's immune, fireBALLIN'"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
		}
		if ${Immune-Fire}
		{
			echo ":'( It's immune, frostLAMIN'"
			call UpdateHudStatus "Casting Frostbolt"
			call CastSpell "Frostbolt" ${AttackGUID}
		}
	}
	;Ok, ok, I know what you're saying. What if we're too new for this nice stuff?	
	;Well... you get the basic nukes + the rest of the routine.
	if !${Immune-Fire} && !${frostspec}
	{
		if ${Math.Rand[2]}==1
		{
			echo "Nuking Fireball"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
		}
		elseif ${Spell["Fireblast"](exists)}
		{
			echo "Nuking Fireblast"
			call UpdateHudStatus "Casting Fire Blast"
			call CastSpell "Fire Blast" ${AttackGUID}
		}
	}
	if !${Immune-Frost} && ${frostspec}
	{
		echo "Nuking Frostbolt"
		call UpdateHudStatus "Casting Frostbolt"
		call CastSpell "Frostbolt" ${AttackGUID}
	}
	if ${Immune-Fire} && !${frostspec}
	{
		echo "Seminuking Frostbolt"
		call UpdateHudStatus "Casting Frostbolt"
		call CastSpell "Frostbolt" ${AttackGUID}
	}
	if ${Immune-Frost} && ${frostspec}
	{
		echo "Seminuking Fire"
		call UpdateHudStatus "Casting Fireball"
		call CastSpell "Fireball" ${AttackGUID}
	}
	if ${Unit[${AttackGUID}].Distance}<20 && !${Spell["Fire Blast"].Cooldown} && ${Spell["Fire Blast"](exists)}
	{
		echo "Fireblasting"
		call UpdateHudStatus "Casting Fireball"
		call CastSpell "Fire Blast" ${AttackGUID}
	}
	if ${Unit[${AttackGUID}].Casting(exists)} && ${Spell["Counterspell"](exists)} && !${Spell["Counterspell"].Cooldown}
	{
		echo "Counterspelling"
		call UpdateHudStatus "Casting Counterspell"
		call CastSpell "Counterspell" ${AttackGUID}
	}
	;By now, mob should be on you. So, we're going to want to get away from it.
	if ${Unit[${AttackGUID}].Distance}<5 && !${Unit[${AttackGUID}].PctHPs}==0
	{
		call FrostNovaAttackSet
	}
	;And there's your nukes. But wait! Ice lance, anyone?
	if ${Unit[${AttackGUID}].Buff["Frostbite"](exists)}||${Unit[${AttackGUID}].Buff["Frozen"](exists)}||${Unit[${AttackGUID}].Buff["Frost Nova"](exists)} && !${Immune-Frost} && ${Spell["Ice Lance"](exists)} && !${Spell["Ice Lance"].Cooldown}
	{
		echo "Icelance!"
		call UpdateHudStatus "Casting Ice Lance"
		call CastSpell "Ice Lance" ${AttackGUID}
	}
	;Right about now would be a good time to check HP/MP and pot/bandage/evocate if needed.
	if ${Me.PctHPs}<50
	{
		echo "Low HP, seeing what I can do"
		if !${Me.Buff["Recently Bandaged"](exists)} && ${Item.[${bandages}](exists)} && ${Unit[${AttackGUID}].Distance}>9
		{
			echo "I got bandaids!"
			call UpdateHudStatus "Bandaging"
			call UseBestBandage(${Me.GUID})
		}
	}
	if ${Me.PctMana}<50 && !${Spell["Evocation"].Cooldown} && ${Spell["Evocation"](exists)}
	{
		echo "Time for that evocate."
		echo "Bubbling before evocate just in case"
		call UpdateHudStatus "Casting Mana Shield"
		call CastSpell "Mana Shield" ${Me.GUID}
		call UpdateHudStatus "Evocating."
		call CastSpell "Evocation" ${Me.GUID}
	}
	if ${Me.PctMana}<30 || ${Me.PctHPs}<30
	{
		echo "Checkin for pots"
		call UpdateHudStatus "Checking for potions"
		call pots
	}
	;While we're at it, let's see if any combat buffs need fixed. If we have the mana.
	if ${Me.PctMana}>50
	{
		if !${Me.Buff["Dampen Magic"](exists)} && ${DampenMagic}
		{
			echo "Dampening that damn Magic"
			call UpdateHudStatus "Casting Dampen Magic"
			call CastSpell "Dampen Magic" ${Me.GUID}
		}
		if ${frostspec} && !${Me.Buff["Ice Barrier"](exists)} && ${Spell["Ice Barrier"](exists)} && !${Spell["Ice Barrier"].Cooldown}
		{
			echo "Getting me an Ice Barrier"
			call UpdateHudStatus "Casting Ice Barrier"
			call CastSpell "Ice Barrier" ${Me.GUID}
		}
		if ${frostspec} && !${Me.Buff["Ice Barrier"](exists)} && ${Spell["Ice Barrier"](exists)} && ${Spell["Ice Barrier"].Cooldown} && ${Spell["Cold Snap"](exists)} && !${Spell["Cold Snap"].Cooldown}
		{
			echo "brr, getting cold. Damn cold snap."
			call UpdateHudStatus "Casting Cold Snap"
			call CastSpell "Cold Snap" ${Me.GUID}
			echo "At least that cold snap brought me some armor!"
			call UpdateHudStatus "Casting Ice Barrier"
			call CastSpell "Ice Barrier" ${Me.GUID}
		}
		;Do we need frost/fire ward?
		if ${UseFrostWard} && !${Spell["Frost Ward"].Cooldown}
		{
			echo "canttouchthis - frost"
			call UpdateHudStatus "Casting Frost Ward"
			call CastSpell "Frost Ward" ${Me.GUID}
		}
		if ${UseFireWard} && !${Spell["Fire Ward"].Cooldown}
		{
			echo "canttouchthis - fire"
			call UpdateHudStatus "Casting Fire Ward"
			call CastSpell "Fire Ward" ${Me.GUID}
		}
	}
	;I'm relatively sure that most of us have fireblast. But wait! Let's mix it up a little.
	if (${Unit[${AttackGUID}].Distance}<20) && !${Immune-Fire} && ${Spell["Fire Blast"](exists)} && !${Spell["Fire Blast"].Cooldown}
	{
		if ${Math.Rand[2]}==0
		{
			echo "Fireball!"
			call UpdateHudStatus "Casting Fireball"
			call CastSpell "Fireball" ${AttackGUID}
			wait 30
		}
		if ${Math.Rand[2]}==1
		{
			echo "Fireblast!"
			call UpdateHudStatus "Casting Fireblast"
			call CastSpell "Fireblast" ${AttackGUID}
			wait 1
		}
	}
	;Let's see. What else is there in the bag 'o tricks?	
	;ah yes, scorching and wanding.
	if (${Unit[${AttackGUID}].PctHPs}<12.5&&${Unit[${AttackGUID}].PctHPs}>10) && !${Immune-Fire} && ${Spell["Scorch"](exists)}
	{
		echo "${Unit[${AttackGUID}].PctHPs} hp"
		echo "Scorching their ass 'til dead."
		call UpdateHudStatus "Casting Scorch"
		call CastSpell "Scorch" ${AttackGUID}
	}
	if (${Unit[${AttackGUID}].PctHPs}<10) && ${Me.PctHPs}>40
	{
		echo "${Unit[${AttackGUID}].PctHPs} hp"
		echo "Wanding"
		call UpdateHudStatus "Wanding"
		call CastSpell "Shoot" ${AttackGUID}
	}
	;Modify this a little for ignite
	if (${Unit[${AttackGUID}].PctHPs}<12.5) && (${Me.PctHPs}>25) && ${Unit[${AttackGUID}].Buff["Ignite"](exists)}
	{
		echo "${Unit[${AttackGUID}].PctHPs} hp"
		echo "Ignited; wanding"
		call UpdateHudStatus "Wanding"
		call CastSpell "Shoot" ${AttackGUID}
	}
	;Let's try some intelligent use of AoEs.
	Aggros1:Search[-units,-aggro,-alive,-range 0-10,-levels ${Math.Calc[${Me.Level}-1]}-${Math.Calc[${Me.Level}+1]}]
	Aggros2:Search[-units,-aggro,-alive,-range 0-10,-levels ${Math.Calc[${Me.Level}-4]}-${Math.Calc[${Me.Level}-2]}]
	if (${Aggros1.Count}>1) || (${Aggros2.Count}>2)
	{
		;Need a way to target add and polymorph it. Until then...
		;Blast Wave.
		if ${Spell["Blast Wave"](exists)} && !${Spell["Blast Wave"].Cooldown} && !${Immune-Fire}
		{
			echo "Multiple mobs, AoEing fire style"
			call UpdateHudStatus "Casting Blast Wave"
			call CastSpell "Blast Wave" ${AttackGUID}
		}
		;With any luck, this ignited them, so they'll be stuck where they are for now. So use our other fire AoE.
		if !${Immune-Fire} && !${Spell["Flamestrike"].Cooldown} && !${frostspec} && ${UseFlamestrike} && ${Spell["Flamestrike"](exists)}
		{
			echo "Multiple mobs, using other fire AoE"
			call UpdateHudStatus "Casting Flamestrike"
			call CastSpell "Flamestrike" ${AttackGUID}
			ClickTerrain(${Target.X}, ${Target.Y}, ${Target.Z}
		}
		;Ok, and now then, there's a good chance they're either immune to Fire or you're frost
		if (${Immune-Fire}||${frostspec})&&!${Spell["Cone of Cold"].Cooldown}&&!${Immune-Frost} && ${Spell["Cone of Cold"](exists)}
		{
			echo "Multiple mobs, using Cone of Cold"
			call UpdateHudStatus "Casting Cone of Cold"
			call CastSpell "Cone of Cold" ${AttackGUID}
		}
		;Use blizzard if we have enough mana and you've set it to be used... only do it if frost spec.
		if ${UseBlizzard} && ${frostspec} && ${Me.PctMana}>50 && !${Immune-Frost} && ${Spell["Blizzard"](exists)}
		{
			echo "Going to try a manashield/blizzard, hope for freezes"
			call UpdateHudStatus "Casting Blizzard"
			call CastSpell "Blizzard" ${AttackGUID}
			ClickTerrain(${Target.X}, ${Target.Y}, ${Target.Z})
		}
		;And, of course.. arcane explosion.
		if ${Me.PctMana}>15 && ${Unit[${AttackGUID}].PctHPs}<4
		{
			echo "AE'ing this bitch to death."
			call UpdateHudStatus "Casting Arcane Explosion"
			call CastSpell "Arcane Explosion" ${AttackGUID}
		}
	}
	if ${Unit[${AttackGUID}].PctHPs}>0 && !${Me.Dead}
	{
		echo "restarting nuke loop"
		call Nukes ${AttackGUID}
	}
	if ${Unit[${AttackGUID}].PctHPs}==0 && !${Me.InCombat}
	{
		echo "Doing after-combat downtime"
;		waitframe
		call Downtime
		Aggros1:Clear
		Aggros2:Clear
		Adds1:Clear
	}
	if (${Unit[${AttackGUID}].PctHPs}==0 && ${Me.InCombat})
	{
		echo "I'm in combat though attackguid is dead. No downtime yet.."
		wait 10
		if ${Me.InCombat}
		{
			if ${Adds1.Count}>2
			{
				call FrostNovaAttackSet
				Target ${Adds1[2]}
				if ${Spell["Polymorph"](exists)} && !${Target.Buff["Polymorph"](exists)}
				{
					call CastSpell "Polymorph" ${Target.GUID}
				}
				do
				{
					AttackGUID:Set[${Adds1[1]}]
					TargetGUID:Set[${Adds1[1]}]
					call Attack ${AttackGUID}
				}
				while !${Unit[${Adds1[1]}].PctHPs}==0 && ${Target(exists)}
				do
				{
					AttackGUID:Set[${Adds1[2]}]
					TargetGUID:Set[${Adds1[2]}]
					call Attack ${AttackGUID}
				}
				while ${Unit[${Adds1[1]}].PctHPs}==0 && !${Unit[${Adds1[2]}].PctHPs}==0 && ${Target(exists)}
			}
		}
	}
;	Return
}
function Downtime()
{
	if !${Variable[MAGICWATER_NAME](exists)}&&${Spell[Conjure Water](exists)} 
	{ 
		call SetMageSummons 
		DoDowntime:Set[TRUE]
		Return
	} 
	if (${Me.PctHPs}<${MinHealthPct}||${Me.PctMana}<${MinManaPct})
	{
		do
		{
			call MakeDrink
			call MakeFood
			call MageDrink
			call MageEat
			DoDowntime:Set[TRUE]
		}
		while (${Me.PctHPs} < 100 || ${Me.PctMana} < 100) && !${Me.InCombat} && !${Me.Dead} && !${Me.Ghost}
;		DoDowntime:Set[FALSE]
		Return		
	}
	waitframe
	if !${Me.Buff["Arcane Intellect"](exists)} && !${Me.PctMana}==100
	{
		call buffs
	}
	DoDowntime:Set[FALSE]
}
;EQJoe's MakeFood section.
function MakeFood()
{
	if !${Item[${MAGICFOOD_NAME}](exists)}&&${Spell[Conjure Food](exists)}&&!${Me.Buff[Food](exists)}&&!${Me.Buff[Drink](exists)}
	{
		if ${Me.CurrentMana}>${Spell[Conjure Food].Mana} 
		{ 
			if ${Me.Sitting} 
			{ 
				wowpress SITORSTAND 
			}          
			call UpdateHudStatus "Making ${MAGICFOOD_NAME}" 
			call CastSpell "Conjure Food" ${Me.GUID} 
			wait 5 
		}  
		if (${Item[${MAGICFOOD_NAME}].StackCount}<3)
		{
			call UpdateHudStatus "Making More ${MAGICFOOD_NAME}" 
			call CastSpell "Conjure Food" ${Me.GUID} 
			if !${Me.InCombat}
			{
				wait 5 
			}
			else 
			{
				return
			}
		} 
		return
	}
}
;EQJoe's MageEat section.
function MageEat() 
{ 
	if ${Me.CurrentHPs}<${Me.MaxHPs}&&${Item[${MAGICFOOD_NAME}](exists)}&&!${Me.Buff[Food](exists)}
	{ 
		call UpdateHudStatus "Eating Food Now" 
		Item[${MAGICFOOD_NAME}]:Use 
		wait 15 
	}         
}
;EQJoe's MakeDrink section.
function MakeDrink()
{
	if !${Item[${MAGICWATER_NAME}](exists)}&&${Spell[Conjure Water](exists)}&&!${Me.Buff[Drink](exists)}  
	{ 
		if ${Me.CurrentMana}>${Spell[Conjure Water].Mana} 
		{ 
			if ${Me.Sitting} 
			{ 
				wowpress SITORSTAND 
			} 
			call UpdateHudStatus "Making ${MAGICWATER_NAME}" 
			call CastSpell "Conjure Water" ${Me.GUID} 
			if !${Me.InCombat}
			{
				wait 5
			} 	
			if (${Item[${MAGICWATER_NAME}].StackCount}<3)
			{
				call UpdateHudStatus "Making More ${MAGICWATER_NAME}" 
				call CastSpell "Conjure Water" ${Me.GUID} 
				if !${Me.InCombat}
				{
					wait 5 
				}
				else
				{
        				return
        			}
			}
		} 
	}
	return
}
;EQJoe's MageDrink section.
function MageDrink() 
{ 
	if ${Me.CurrentMana}<${Me.MaxMana}&&${Item[${MAGICWATER_NAME}](exists)}&&!${Me.Buff[Drink](exists)} 
	{ 
		call UpdateHudStatus "Drinking water now " 
		Item[${MAGICWATER_NAME}]:Use 
		wait 25 
	} 
} 
function pots()
{
	if ${Me.PctHPs}<15 && ${Unit[${AttackGUID}].PctHPs}>25
	{
		echo "Drinking best healing potion"
		call DrinkBestHealingPotion
	}
	if ${Me.PctMana}<15 && ${Unit[${AttackGUID}].PctMana}>25
	{
		echo "Drinking best mana potion"
		call DrinkBestManaPotion
	}
}
function CombatPrep()
{
	if !${Me.InCombat}&&!${HavePulled}
	{
		if ${UseFrostWard} && !${Spell["Frost Ward"].Cooldown} && ${Spell["Frost Ward"](exists)}
		{
			echo "Combatprep: Frost Ward"
			call UpdateHudStatus "Casting Frost Ward"
			call CastSpell "Frost Ward" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if ${UseFireWard} && !${Spell["Fire Ward"].Cooldown} && ${Spell["Fire Ward"](exists)}
		{
			echo "Combatprep: Fire Ward"
			call UpdateHudStatus "Casting Fire Ward"
			call CastSpell "Fire Ward" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return	
		}
		if ${DampenMagic} && !${Me.Buff["Dampen Magic"](exists)} && ${Spell["Dampen Magic"](exists)}
		{
			echo "Combatprep: Dampen Magic"
			call UpdateHudStatus "Casting Dampen Magic"
			call CastSpell "Dampen Magic" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if ${Spell["Combustion"](exists)} && !${Spell["Combustion"].Cooldown} && !${Me.Buff["Combustion"](exists)}
		{
			echo "Combatprep: Combustion"
			call UpdateHudStatus "Casting Combustion"
			call CastSpell "Combustion" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if ${Spell["Cold Snap"](exists)} && ${Spell["Ice Barrier"].Cooldown} && !${Spell["Cold Snap"].Cooldown} && !${Me.Buff["Ice Barrier"](exists)}
		{
			echo "Combatprep: cold Snap"
			call UpdateHudStatus "Casting Cold Snap"
			call CastSpell "Cold Snap" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if ${Spell["Ice Barrier"](exists)} && !${Spell["Ice Barrier"]Cooldown} && !${Me.Buff["Ice Barrier"](exists)}
		{
			echo "Combatprep: Ice Barrier"
			call UpdateHudStatus "Casting Ice Barrier"
			call CastSpell "Ice Barrier" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if !${Spell["Ice Armor"](exists)} && !${Me.Buff["Frost Armor"](exists)}
		{
			echo "Combatprep: Frost Armor"
			call UpdateHudStatus "Casting Frost Armor"
			call CastSpell "Frost Armor" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if ${Spell["Ice Armor"](exists)} && !${Me.Buff["Ice Armor"](exists)}
		{
			echo "Combatprep: Ice Armor"
			call UpdateHudStatus "Casting Ice Armor"
			call CastSpell "Ice Armor" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			Return
		}
		if !${Item[${MANASTONE}](exists)} && ${Spell[${MANASTONE_SPELLNAME}](exists)}
		{
			echo "Conjuring me a Mana Gem"
			call UpdateHudStatus "Conjuring ${MANASTONE}"
			call CastSpell "${MANASTONE_SPELLNAME}" ${Me.GUID}
			DoCombatPrep:Set[TRUE]
			wait 2
			Return
		}	
		if ${Me.PctMana}<${MinManaPct}&&
		{
			echo "Combatprep: Need Mana"
			if ${Spell["Evocation"](exists)} && !${Spell["Evocation"].Cooldown}
			{
				echo "Combatprep: Evocation"
				call UpdateHudStatus "Casting Evocation"
				call CastSpell "Evocation" ${Me.GUID}
				wait 80
			}
			call pots
			call Downtime
		}
		DoCombatPrep:Set[FALSE]
		call Downtime
	}
}
function buffs()
{
	if ${Me.PctMana}<${MinManaPct}
	{
		call Downtime
		return
	}
	if ${Me.PctMana}>${MinManaPct}
	{
		if ${Spell["Arcane Intellect"](exists)} && !${Me.Buff["Arcane Intellect"](exists)}
		{
			echo "Buffs: Arcane Int"
			call UpdateHudStatus "Casting Arcane Intellect"
			call CastSpell "Arcane Intellect" ${Me.GUID}
		}
		if !${Spell["Ice Armor"](exists)} && !${Me.Buff["Frost Armor"](exists)}
		{
			echo "Buffs: Frost Armor"
			call UpdateHudStatus "Casting Frost Armor"
			call CastSpell "Frost Armor" ${Me.GUID}
		}
		if ${Spell["Ice Armor"](exists)} && !${Me.Buff["Ice Armor"](exists)}
		{
			echo "Buffs: Ice Armor"
			call UpdateHudStatus "Casting Ice Armor"
			call CastSpell "Ice Armor" ${Me.GUID}
		}
		if ${DampenMagic} && !${Me.Buff["Dampen Magic"](exists)} && ${Spell["Dampen Magic"](exists)}
		{
			echo "Buffs: Dampen Magic"
			call UpdateHudStatus "Casting Dampen Magic"
			call CastSpell "Dampen Magic" ${Me.GUID}
		}
		if ${Spell["Cold Snap"](exists)} && ${Spell["Ice Barrier"].Cooldown} && !${Spell["Cold Snap"].Cooldown} && !${Me.Buff["Ice Barrier"](exists)}
		{
			echo "Buffs: cold Snap"
			call UpdateHudStatus "Casting Cold Snap"
			call CastSpell "Cold Snap" ${Me.GUID}
		}
		if ${Spell["Ice Barrier"](exists)} && !${Spell["Ice Barrier"]Cooldown} && !${Me.Buff["Ice Barrier"](exists)}
		{
			echo "Buffs: Ice Barrier"
			call UpdateHudStatus "Casting Ice Barrier"
			call CastSpell "Ice Barrier" ${Me.GUID}
		}
		Return
	}
}
;EQJoe's SetMageSummons section.
function SetMageSummons() 
{ 
declare MageFoodSummon int 
declare MageDrinkSummon int 
declare MAGICFOOD_NAME string script 
declare MAGICWATER_NAME string script 
declare MANASTONE string script 
declare MANASTONE_SPELLNAME string script 

	MageFoodSummon:Set[${Spell[Conjure Food].Level}] 
        ;echo ${Spell[Conjure Food].Level} 
        ;echo ${MageFoodSummon} 
	Switch ${MageFoodSummon} 
	{ 
		case 6 
		MAGICFOOD_NAME:Set[Conjured Muffin] 
		break 
		case 12 
		MAGICFOOD_NAME:Set[Conjured Bread] 
		break 
		case 22 
		MAGICFOOD_NAME:Set[Conjured Rye] 
		break 
		case 32 
		MAGICFOOD_NAME:Set[Conjured Pumpernickel] 
		break 
		case 42 
		MAGICFOOD_NAME:Set[Conjured Sourdough] 
		break 
		case 52    
		MAGICFOOD_NAME:Set[Conjured Sweet Roll] 
		break 
		case 60    
		MAGICFOOD_NAME:Set[Conjured Cinnamon Roll] 
		break     
;		case 70
;		MAGICFOOD_NAME:Set[Conjured Croissants]
;		break
	}    
   	MageDrinkSummon:Set[${Spell[Conjure Water].Level}] 
	Switch ${MageDrinkSummon} 
	{ 
		case 4 
		MAGICWATER_NAME:Set[Conjured Water] 
		break 
		case 10 
		MAGICWATER_NAME:Set[Conjured Fresh Water] 
		break 
		case 20 
		MAGICWATER_NAME:Set[Conjured Purified Water] 
		break 
		case 30    
		MAGICWATER_NAME:Set[Conjured Spring Water] 
		break 
		case 40    
		MAGICWATER_NAME:Set[Conjured Mineral Water] 
		break 
		case 50 
		MAGICWATER_NAME:Set[Conjured Sparkling Water] 
		break 
		case 60 
		MAGICWATER_NAME:Set[Conjured Crystal Water] 
		break 
		case 65
		MAGICWATER_NAME:Set[Conjured Mountain Spring Water]
		break
		case 70
		MAGICWATER_NAME:Set[Conjured Glacier Water]
		break
	}
	if ${Spell[Conjure Mana Agate](exists)}&&!${Spell[Conjure Mana Jade](exists)} 
	{    
		MANASTONE:Set[Mana Agate] 
		MANASTONE_SPELLNAME:Set[Conjure Mana Agate] 
        } 
        if ${Spell[Conjure Mana Jade](exists)}&&!${Spell[Conjure Mana Citrine](exists)} 
	{ 
		MANASTONE:Set[Mana Jade] 
		MANASTONE_SPELLNAME:Set[Conjure Mana Jade] 
        } 
        if ${Spell[Conjure Mana Citrine](exists)}&&!${Spell[Conjure Mana Ruby](exists)} 
	{ 
		MANASTONE:Set[Mana Citrine] 
		MANASTONE_SPELLNAME:Set[Conjure Mana Citrine] 
        } 
        if ${Spell[Conjure Mana Ruby](exists)}
	{ 
		MANASTONE:Set[Mana Ruby] 
		MANASTONE_SPELLNAME:Set[Conjure Mana Ruby] 
        } 
        
        call UpdateHudStatus "Setting Drink to ${MAGICWATER_NAME}" 
        call UpdateHudStatus "Setting Food to ${MAGICFOOD_NAME}" 
	call UpdateHudStatus "Setting Mana Stone to ${MANASTONE}" 
}    
function GetSafeSpot(angle)
{
	if ${testfail}==8
	{
		NoSafeSpot:set TRUE
	}
	if ${testfail}<8
	{
		safex1:Set[0]
		safey1:Set[0]
		testx:Set[${Math.Calc[12*${Math.Cos[${angle}]}+${Me.X}]}]
		testy:Set[${Math.Calc[12*${Math.Sin[${angle}]}+${Me.Y}]}]
		echo "${testx} test x"
		echo "${testy} test y"
		echo "${Me.X} my X"
		echo "${Me.Y} my Y"
		echo "${Me.Heading} my angle"
		echo "${angle} angle being used"
		echo "${Math.Calc[${Math.Cos[${angle}]}]} cos angle"
		echo "${Math.Calc[12*${Math.Cos[${angle}]}]} 12 * cos angle"
		echo "${Math.Calc[12*${Math.Cos[${angle}]}+${Me.X}]} whole thing"
		Mobs:Search[-units,-origin ${textx},${testy},${Me.Z},-alive,-hostile,-range 0-25]
		echo "${Mobs.Count} mobs count"
		if ${Mobs.Count}==0
		{
			echo "Safe spot good."
			safex1:Set[${testx}]
			safey1:Set[${testy}]
			echo "${safex1} safe X, ${testx} test X"
			echo "${safey1} safe y, ${testy} test Y"
			testfail:Set[0]
		}
		if ${Mobs.Count}>0
		{
			echo "Our spot sucks, trying to get another..."
			testfail:Set[${Math.Calc[${testfail}+1]}]
			angle:Set[${Math.Calc[${Me.heading}+45]}]
			call GetSafeSpot(${Math.Calc[${angle}+45]})
		}
	}	
}
function inittriggers()
{
	Event[PLAYER_TARGET_CHANGED]:AttachAtom[assistcheck]
	Event[CHAT_MSG_COMBAT_XP_GAIN]:AttachAtom[resetbugcheck]
}
function checkassist()
{
	Event[PLAYER_TARGET_CHANGED]:AttachAtom[assistcheck]
}
function removecheckassist()
{
	Event[PLAYER_TARGET_CHANGED]:DetachAtom[assistcheck]
}
function assistcheck()
{
	if !${Target.GUID.Equal[${Me.GUID}]}
	{
		hastarget:Set[TRUE]
	}
	else
	{
		hastarget:Set[FALSE]
	}
}
atom(script) immunechecks(string eventid , text, Message)
{
	if ${Message.Find["Chilled"]}||${Message.Find["Frostbolt"]}||${Message.Find["Cone of Cold"]}||${Message.Find["Frost Nova"]}&&${Message.Find["failed"]}&&${Message.Find["immune"]}
	{
		Immune-Frost:Set[TRUE]
	}
	if ${Message.Find["afflicted by Chilled"]}||${Message.Find["Frostbolt hits"]}||${Message.Find["Cone of Cold hits"]}||${Message.Find["Frost Nova hits"]}
	{
		Immune-Frost:Set[FALSE]
	}
	if ${Message.Find["Pyroblast"]}||${Message.Find["Fireball"]}||${Message.Find["Fireblast"]}||${Message.Find["Scorch"]}&&${Message.Find["failed"]}&&${Message.Find["immune"]}
	{
		Immune-Fire:Set[TRUE]
	}
	if ${Message.Find["Pyroblast"]}||${Message.Find["Fireball"]}||${Message.Find["Fireblast"]}||${Message.Find["Scorch"]}&&!${Message.Find["immune"]}
	{
		Immune-Fire:Set[FALSE]
	}
	if ${Message.Find["hits you for"]}&&${Message.Find["Nature damage"]}||${Message.Find["Shadow damage"]}||${Message.Find["Holy damage"]}||${Message.Find["Fire damage"]}||${Message.Find["Frost damage"]}
	{
		DampenMagic:Set[TRUE]
	}
}
atom(script) damagecheck(string eventid , text, Message)
{
	if ${Message.Find["hits you"]}&&${Message.Find["Frost damage"]}
	{
		UseFrostWard:Set[TRUE]
	}
	if ${Message.Find["hits you"]}&&${Message.Find["Fire damage"]}
	{
		UseFireWard:Set[TRUE]
	}
}
atom(script) pullcheck(string EventName, uint EventID, string playerid, string spellcast)
{
	if ${playerid.Find["player"]} && (${spellcast.Find["Fireball"]}||${spellcast.Find["Frostbolt"]}||${spellcast.Find["Pyroblast"]})
	{
		echo "Pullcheck passed"
		HavePulled:Set[TRUE]
	}
}
function hpsample()
{
	if !${pullsample1}
	{
		echo "Taking HP sample 1"
		hpsample1:Set[${Unit[${AttackGUID}].PctHPs}]
		pullsample1:Set[TRUE]
	}
	if ${pullsample1}
	{
		echo "Taking HP sample 2"
		hpsample2:Set[${Unit[${AttackGUID}].PctHPs}]
		pullsample2:Set[TRUE]
	}
	if ${pullsample2}
	{
		echo "Taking HP sample 3"
		hpsample3:Set[${Unit[${AttackGUID}].PctHPs}]
		pullsample3:Set[TRUE]
	}
	if ${pullsample3}
	{
		echo "Taking HP sample 4"
		hpsample4:Set[${Unit[${AttackGUID}].PctHPs}]
		pullsample4:Set[TRUE]
	}
	if ${hpsample1}==${hpsample2}==${hpsample3}==${hpsample4}
	{
		echo "Hp has stayed the same, bugged mob"
		GUIDBlacklist:Set[${AttackGUID},AVOID]
		TargetGUID:Set[NOTARGET]
	}		
	else
	{
		echo "Mob not bugged"
		BuggedCheck:Set[TRUE]
	}
}
function resetbugcheck(string eventid , text, Message)
{
	if ${Message.Find["dies, you gain"]} && ${Message.Find["experience"]}
	{
		BuggedCheck:Set[FALSE]
	}
}		
function FrostNovaAttackSet()
{
	if !${Immune-Frost} && ${Spell["Frost Nova"](exists)}
	{
		echo "${Target.Distance} distance3"
		if ${Unit[${AttackGUID}].Distance}<5
		{
			if !${Spell["Frost Nova"].Cooldown} && !${Immune-Frost} && ${Spell["Frost Nova"](exists)}
			{
				call GetSafeSpot ${Me.Heading}
				if !${NoSafeSpot} && !${Target.Dead}
				{
					echo "Entrapping and getting away"
					call CastSpell "Frost Nova" ${AttackGUID}
					wait 2
					face ${safex1} ${safey1}
					wait 2
					if ${Spell["Blink"](exists)} && !${Spell["Blink"].Cooldown}
					{
						echo "Blinking"
						call CastSpell "Blink" ${Me.GUID}
					}
					face ${safex1} ${safey1}
					call moveto ${safex1} ${safey1} 2
					face ${Target.X} ${Target.Y}
				}
			}
			;Sometimes trap and get away won't work... so just get away.
			if !${Spell["Blink"].Cooldown} && ${Spell["Blink"](exists)} && (${Spell["Frost Nova"].Cooldown} || ${Immune-Frost})
			{
				call GetSafeSpot ${Me.Heading}
				if !${NoSafeSpot} && !${Target.Dead}
				{
					echo "Can't entrap, just getting away"
					face ${safex1} ${safey1}
					echo "Blinking"
					call CastSpell "Blink" ${Me.GUID}
					face ${safex1} ${safey1}
					call moveto ${safex1} ${safey1} 2
					face ${Target.X} ${Target.Y}
				}
			}
			;And sometimes, you just can't get away.
			if ${Spell["Blink"].Cooldown} || ${NoSafeSpot}
			{
				if !${Spell["Frost Nova"].Cooldown} && ${Spell["Frost Nova"](exists)} && !${Immune-Frost}
				{
					echo "Can't get away, FN'ing for the hell of it"
					call UpdateHudStatus "Casting Frost Nova"
					call CastSpell "Frost Nova" ${AttackGUID}
				}
			}
		}
	}
}