All pastes #940813 Raw Edit

Stuff

public text v1 · immutable
·published 2008-03-13 09:12 UTC
rendered paste body
objectdef oClass inherits oBase
{
	;----------------------
	;--- Rest Variables ---
	;----------------------
	variable int RestHP = 80

	;----------------------
	;--- Range Settings ---
	;----------------------
	variable int PullRange = 25
	variable int MaxRanged = 30
	variable int MinRanged = 15
	variable int MaxMelee = 5
	variable int MinMelee = 2


	variable string RVersion = 1.0
	variable bool HaveEarthTotem = ${Item[-items,-inventory,"Earth Totem"](exists)}


	/* Don't touch these */
	variable guidlist myTotemList

	method Initialize()
	{
	}


	member NeedRest()
	{
		if ${Me.InCombat}
		{
			return FALSE
		}
		if ${Me.Buff[Food](exists)}
		{
			if ${Me.PctHPs} < 100
			{
				return TRUE
			}
		}
		if ${Me.Buff[Drink](exists)}
		{
			if ${Me.PctMana} < 100
			{
				return TRUE
			}
		}
		if ${Me.PctHPs} < ${RestHP}
		{
			return TRUE
		}
		return FALSE
	}

	method RestPulse()
	{
		if !${Me.InCombat}
		{
			; If I am sitting and full stand up
			if ${Me.Sitting} && ${Me.PctHPs}==100 && ${Me.PctMana}==100
			{
				wowpress jump
			}
			
			if ${Movement.Speed}
			{
				Move -stop
			}

			if ${Me.Target(exists)}
			{
				WoWScript ClearTarget()
			}

			if ${Me.PctHPs} < ${RestHP} && ${Consumable.HasFood} && !${Me.Buff[Food](exists)}
			{
				Consumable:useFood
			}
		}
	}

	;------------------
	;--- Buff SetUp ---
	;------------------

	member NeedBuff()
	{
		return FALSE
	}

	method BuffPulse()
	{
	}

	;------------------
	;--- Pull SetUp ---
	;------------------

	member NeedPullBuff()
	{
		return FALSE
	}

	method PullBuffPulse()
	{
	}

	;------------------------
	;--- CombatBuff SetUp ---
	;------------------------

	member NeedCombatBuff()
	{
		/* Check for global cooldown */
		if !${Me.GlobalCooldown}
		{
			/* Lightning Shield buff check */
			if ${Spell[Lightning Shield](exists)} && !${Me.Buff[Lightning Shield](exists)}
			{
				echo "Debug: NeedCombatBuff: Lightning Shield"
				return TRUE	
			}
			/* If we need a heal, heal */
			if ${This.NeedHeal}
			{
				echo "Debug: NeedCombatBuff: NeedHeal"
				return TRUE
			}
			/* Check totems */
			if ${This.GetTotem[0]}
			{
				echo "DEBUG: NeedCombatBuff: Totem"
				return TRUE
			}
		}
		return FALSE
	}
	
	/* Moved NeedTotem logic to a member */
	member GetTotem(int Which)
	{
		/* Handle all earth totems */
		if ${This.HaveEarthTotem}
		{
			if ${Spell[Stoneskin Totem](exists)} && !${This.FindTotem[Stoneskin Totem]} && \
				${This.GetCurrentTargets} == 1
			{
				echo "DEBUG: NeedTotem: Returning Stoneskin Totem"
				if ${Which} == 1
				{
					echo "DEBUG: GetTotem(${Which}): Returning Stoneskin Totem"
					return "Stoneskin Totem"
				}
				elseif ${Which} == 0
				{
					echo "DEBUG: GetTotem(${Which}): Returning TRUE"
					return TRUE
				}
			}
			if ${Spell[Stoneclaw Totem](exists)} && !${This.FindTotem[Stoneclaw Totem]} && \
				${This.GetCurrentTargets} > 1 && !${Spell[Stoneclaw Totem].Cooldown}
			{
				if ${Which} == 1
				{
					echo "DEBUG: GetTotem(${Which}): Returning Stoneclaw Totem"
					return "Stoneclaw Totem"
				}
				elseif ${Which} == 0
				{
					echo "DEBUG: GetTotem(${Which}): Returning TRUE"
					return TRUE
				}
			}
		}
		if ${Which} == 1
		{
			echo "DEBUG: GetTotem(${Which}): Returning FALSE"
			return FALSE
		}
		elseif ${Which} == 0
		{
			echo "DEBUG: GetTotem(${Which}): Returning NULL"
			return NULL
		}
	}

	method CombatBuffPulse()
	{
		/* Lightning Shield cast */
		if ${Spell[Lightning Shield](exists)} && !${Me.Buff[Lightning Shield](exists)}
		{
			echo "DEBUG: CombatBuffPulse: Casting Lightning Shield"
			Toon:CastSpell[Lightning Shield]
			return
		}

		/* do Healing */
		if ${This.NeedHeal}
		{
			echo "DEBUG: CombatBuffPulse: Casting Lightning Shield"
			This:DoBestHeal
			return
		}

		/* Cast best totem */
		if ${This.GetTotem[0]}
		{
			echo "DEBUG: CombatBuffPulse: Casting Best Totem"
			Toon:CastSpell[${This.GetTotem[1]}]
			return
		}
	}

	;------------------
	;--- Pull SetUp ---
	;------------------
	member InRange()
	{
		if ${Target.Distance} < 25
		{
			return TRUE
		}
		
		return FALSE
	}

	method PullPulse()
	{
		if !${Me.Target(exists)}
		{
			return
		}
		if ${Me.Target.Dead}
		{
			WoWScript ClearTarget()
			return
		}
		if !${Me.Target.Attackable}
		{
			WoWScript ClearTarget()
			return
		}

		if ${Me.Sitting}
		{
			WoWpress jump
		}

		if ${Target.Distance} == 0
		{
			return
		}
		
		;This:Output["Facing ${Target.GUID} ${Target.Location}"]
		Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}]

		; Make sure we are in distance for attacking
		
		; Make sure we are in distance for attacking
		/* Also make sure I'm not casting, so I don't interrupt */
		if ${Target.Distance} > ${This.MaxRanged} && !${Me.Casting}
		{
			wowpress -hold moveforward
			return
		}

		; Stop if we are
		if ${Target.Distance} > ${MinRanged} && ${Target.Distance} < (${This.PullRange} - 5) && ${Movement.Speed}
		{
			Move -stop
		}
		
		if ${Me.GlobalCooldown}
		{
			return
		}

		/* Pull with Lightning Bolt */
		if ${Target.Distance} <= ${This.PullRange} && !${Me.Casting}
		{
			echo "DEBUG: Pull: Casting Lightning Bolt"
			Toon:CastSpell[Lightning Bolt]
			return
		}

		/* Make sure we're not currently attacking before we toggle */
		if !${Me.Attacking}
		{
			WoWScript AttackTarget()
		}
	}

	;--------------------
	;--- Combat SetUp ---
	;--------------------

	method AttackPulse()
	{
		POI.IInteracting:Set[FALSE]

		if !${Target(exists)} || ${Target.GUID.Equal[${Me.GUID}]} || ${Target.Dead}
		{
			This:Output["I need a target"]
			Toon:NeedTarget[1]
		}

		if !${Me.Target(exists)}
		{
			move -stop
			return
		}
		if ${Me.Target.Dead}
		{
			WoWScript ClearTarget()
			move -stop
			return
		}
		if !${Me.Target.Attackable}
		{
			WoWScript ClearTarget()
			move -stop
			return
		}

		if ${Me.Sitting}
		{
			WoWpress jump
		}
		
		if ${Target.Distance} < 6 && ${Movement.Speed}
		{
			move -stop
		}
		if ${Me.Target(exists)} && !${Me.InCombat}
		{
			; Why do I have a target in attack pulse and am not in combat?
			WoWScript ClearTarget()
			return
		}
		;This:Output["Facing ${Target.GUID} ${Target.Location}"]
		/* Make sure we're not feared before trying to turn, so the camera doesn't go all fucky */
		/* In fact, if we're feared, just return 'til we're not. I'll add de-fear (trinket) use later */
		if ${Me.Buff[Fear](exists)} || ${Me.Buff[Death Coil](exists)} || ${Me.Buff[Psychic Scream](exists)} \
			|| ${Me.Buff[Intimidation](exists)} || ${Me.Buff[Charge Stun](exists)} || \
			${Me.Buff[Cyclone](exists)} || ${Me.Buff[Seduction](exists)}
		{
			return
		}
		Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}]

		; Make sure we are in distance for attacking
		if ${Target.Distance}>${MaxRanged}
		{
			wowpress -hold moveforward
			return
		}
		; Stop if we are
		if ${Target.Distance} > ${MinRanged} && ${Target.Distance}<${MaxRanged} && ${Movement.Speed}
		{
			Move -stop
		}

		/* Make sure we're attacking; shamans are nice and melee-ish */
		if ${Me.InCombat} && !${Me.Attacking}
		{
			WoWScript AttackTarget()
		}
		
		/* Check for that damn global cooldown */
		if ${Me.GlobalCooldown}
		{
			return
		}
		/* If there's no cooldown, we're good to continue on */
		/* Earth shock? */
		if ${Spell[Earth Shock](exists)} && ${Me.CurrentMana} >= ${Spell[Earth Shock].Mana} && ${Target.Distance} < 20
		{
			Toon:CastSpell[Earth Shock]
			return
		}

	}

	/* NeedHeal member - determine if I need a heal in combat */
	member NeedHeal()
	{
		/* If we've got Gift of the Naaru on us, we don't need a heal yet */
		if ${Me.Buff[Gift of the Naaru](exists)}
		{
			echo "DEBUG: NeedHeal: Returning FALSE (Gift of the Naaru)"
			return FALSE
		}

		/* Make sure we need a heal, have a heal spell, and have mana for a heal */
		/* Healing Wave */
		if ${Me.PctHPs} > 25 && ${Me.PctHPs} <= 75 && ${Spell[Healing Wave](exists)}
		{
			echo "DEBUG: NeedHeal: Returning TRUE (Healing Wave)"
			return TRUE
		}

		/* If I'm under 25% HP, use lesser healing wave if I have it - don't want to get critkilled or 
		   interrupted to death, now do we? Use normal healing wave if we don't have lesser.*/
		if ${Me.PctHPs} <= 25
		{
			/* Check for Lesser Healing Wave */
			if ${Spell[Lesser Healing Wave](exists)}
			{
				echo "DEBUG: NeedHeal: Returning TRUE (Lesser Healing Wave)"
				return TRUE
			}
			/* Check for Healing Wave */
			elseif ${Spell[Healing Wave](exists)}
			{
				echo "DEBUG: NeedHeal: Returning TRUE (Healing Wave 2)"
				return TRUE
			}
		}
		echo "DEBUG: NeedHeal: Returning FALSE (None needed)"
		return FALSE
	}

	/* DoBestHeal method - use the most appropriate heal */
	method DoBestHeal()
	{
		/* Use Gift of the Naaru if we have it, it's free */
		if ${Me.PctHPs} <= 75 && ${Spell[Gift of the Naaru](exists)} && !${Spell[Gift of the Naaru].Cooldown}
		{
			/* Cast Gift of the Naaru */
			echo "DEBUG: DoBestHeal: Casting Gift of the Naaru"
			Toon:CastSpell[Gift of the Naaru]
			return
		}

		/* If my HP is between 25% and 75%, use normal healing wave */
		if ${Me.PctHPs} > 25 && ${Me.PctHPs} <= 75 && ${Spell[Healing Wave](exists)}
		{
			/* Cast Healing Wave */
			echo "DEBUG: DoBestHeal: Casting Healing Wave"
			Toon:CastSpell[Healing Wave]
			return
		}

		/* If I'm under 25% HP, use lesser healing wave if I have it - don't want to get critkilled or 
		   interrupted to death, now do we? Use normal healing wave if we don't have lesser.*/
		if ${Me.PctHPs} <= 25
		{
			/* Check for Lesser Healing Wave */
			if ${Spell[Lesser Healing Wave](exists)}
			{
				/* Cast Lesser Healing Wave */
				echo "DEBUG: DoBestHeal: Casting Lesser Healing Wave"
				Toon:CastSpell[Lesser Healing Wave]
				return
			}
			/* Check for Healing Wave */
			elseif ${Spell[Healing Wave](exists)}
			{
				/* Cast Healing Wave */
				echo "DEBUG: DoBestHeal: Casting Healing Wave (2)"
				Toon:CastSpell[Healing Wave]
				return
			}
		}
	}

	/* Member to check for a totem in myTotemList */
	member FindTotem(string TotemName)
	{
		/* The range of effect varies from totem to totem, so set the search range before we search */
		variable int searchRange = 0
		if ${TotemName.Equal[Stoneskin Totem]}
			This.searchRange:Set[20]
		elseif ${TotemName.Equal[Earthbind Totem]}
			This.searchRange:Set[10]
		elseif ${TotemName.Equal[Stoneclaw Totem]}
			This.searchRange:Set[15]

		/* First off, populate the totem GUIDlist */
		myTotemList:Search[-units,-range 0-${This.searchRange},-friendly,-level ${Me.Level}]

		/* For every entry in our totem list... */
		do
		{
			/* Make sure the unit is of CreatureType Totem */
			if ${Unit[${This.myTotemList.GUID[${myIdx}]}].CreatureType.Equal[Totem]}
			{
				/* Now check the unit's name against passed name, and owner against Me */
				if ${Unit[${This.myTotemList.GUID[${myIdx}]}].Name.Equal[${TotemName}]} && \
					${Unit[${myTotemList.GUID[${myIdx}]}].Owner.Name.Equal[${Me}]}
				{
					This:Output[DEBUG: Returning true to totem check]
					return TRUE
				}
			}
			myIdx:Inc
		}
		while ${myIdx} <= ${myTotemList.Count}
		This:Output[Debug: Returning false to totem check]
		return FALSE
	}

	/* Member to check number of current targets, used in determining totems */
	member GetCurrentTargets()
	{
		variable guidlist myHostileList
		myHostileList:Search[-units,-range 0-15,-hostile,-targetingme]
		echo "DEBUG: GetCurrentTargets: ${myHostileList.Count}"
		return ${myHostileList.Count}
	}
}