All pastes #633879 Raw Edit

Someone

public cpp v1 · immutable
#633879 ·published 2007-07-26 00:07 UTC
rendered paste body
/*+--+ +--+       +-----+|  | |  |       |  _  ||  |_|  |       | |_| |_|   _   |       |   _   ||  | |  |       |  |_|  ||  | |  |       |       |+--+ +--+arry   +-------+otter' Warrior's Vision !For OpenBot 1.07Credits and thanks to all the devs & supporters of Openbot.Code skeletton based on previous warrior routines, credits to c0ke & casper7526Enhancements by Kaganus and Overlook.This Warrior routines is released on the ** Harry Botter's Common Sense Open License **This means it's free for everyone, EXCEPT if you do share more than 50% of Bytelock's genes.In this case you have to pay a special license, starting price around 500$ ;)V 2.0 - 2007 06 11Now compatible with OpenBot 1.07.02*/objectdef oClass inherits oBase{	;----------------------	;--- Rest Variables ---	;----------------------		variable int RestHP = 50		;----------------------	;--- Range Settings ---	;----------------------	variable int PullRange = 25	variable int MaxRanged = 25	variable int MinRanged = 8	variable int MaxMelee = 5	variable int MinMelee = 2		variable string PrimStat = Stamina	variable string SecStat = Agility	variable string WeapType = Sword	variable int LastEquipAttempt	variable bool DualWield = FALSE		member CanShield()	{		if ${Me.Skill[433]} > 0		{			return TRUE		}	}		member ArmorType()	{		;Thanks to Complex for supplying me with the skill # info		;WoWSkill for Plate is 293		if ${Me.Skill[293]} > 0		{				return Plate		}		;wowSkill for Mail is 413		elseif ${Me.Skill[413]} > 0		{			return Mail		}		;WoWSkill for Leather is 414		elseif ${Me.Skill[414]} > 0		{			return Leather		}		;WoWSkill for cloth is 415		elseif ${Me.Skill[415]} > 0		{			return Cloth		}		echo "ArmorType returned nothing, something is wrong with the Skill values"	}	member ShouldEquip(string ItemGUID, string ItemType)	{		if ${ItemType.Equal[Armor]}		{			if ${This.ArmorWeight[${ItemGUID}]} > ${This.ArmorWeight[${Me.Equip[${Item[${ItemGUID}].EquipType}].GUID}]}			{				return TRUE			}			return FALSE		}		if ${ItemType.Equal[Weapon]}		{			if ${This.WeaponWeight[${ItemGUID}]} > ${This.WeaponWeight[${Me.Equip[${Item[${ItemGUID}].EquipType}].GUID}]}			{				return TRUE			}			return FALSE		}		if ${ItemType.Equal[Bag]}		{			if !${Object[${ItemGUID}](exists)}			{				return FALSE			}			if ${This.BagWeight[${ItemGUID}]} > 0			{				return TRUE			}			return FALSE		}	}	member ArmorWeight(string NewItemGUID)	{		return ${Math.Calc[${Item[${NewItemGUID}].${PrimStat}} + (${Item[${NewItemGUID}].${SecStat}}*.9) + (${Item[${NewItemGUID}].Armor}*${This.ClassArmorweight})]}	}	member WeaponWeight(string NewItemGUID)	{		return ${Math.Calc[${Item[${NewItemGUID}].${PrimStat}} + (${Item[${NewItemGUID}].${SecStat}}*.9) + (${Item[${NewItemGUID}].DPS}*${This.ClassDPSWeight})]}	}	member BagWeight(string NewItemGUID)	{		if !${Object[${NewItemGUID}](exists)}			return 0		if ${Object[${NewItemGUID}].Slots} > ${Me.Bag[1].Slots}			return 1		if ${Object[${NewItemGUID}].Slots} > ${Me.Bag[2].Slots}			return 2		if ${Object[${NewItemGUID}].Slots} > ${Me.Bag[3].Slots}			return 3		if ${Object[${NewItemGUID}].Slots} > ${Me.Bag[4].Slots}			return 4		if ${Object[${NewItemGUID}].Slots} <= ${Me.Bag[1].Slots}			return 0		if ${Object[${NewItemGUID}].Slots} <= ${Me.Bag[2].Slots}			return 0		if ${Object[${NewItemGUID}].Slots} <= ${Me.Bag[3].Slots}			return 0		if ${Object[${NewItemGUID}].Slots} <= ${Me.Bag[4].Slots}			return 0	}	member ClassArmorWeight()	{		if ${Me.Class.Equal[Warrior]} || ${Me.Class.Equal[Paladin]}		{			return .75		}		if ${Me.Class.Equal[Rogue]} || ${Me.Class.Equal[Shaman]} || ${Me.Class.Equal[Hunter]}		{			return .4		}		if ${Me.Class.Equal[Warlock]} || ${Me.Class.Equal[Priest]} || ${Me.Class.Equal[Mage]}		{			return .25		}	}	member ClassDPSWeight()	{		if ${Me.Class.Equal[Rogue]} || ${Me.Class.Equal[Warrior]}		{			return .9		}		if ${Me.Class.Equal[Shaman]} || ${Me.Class.Equal[Paladin]} || ${Me.Class.Equal[Hunter]}		{			return .75		}		if ${Me.Class.Equal[Warlock]} || ${Me.Class.Equal[Priest]} || ${Me.Class.Equal[Mage]}		{			return .25		}	}	method AutoEquip()	{		variable int counter = 1		variable int counterx = 1		variable guidlist ItemSearch		variable guidlist BaggieSearch		;For now, using PrimStat and SecStat as the stat vars		;Also using WeapType as the preferred weapon type		ItemSearch:Search[-items,-inventory]		BaggieSearch:Search[-containers,-inventory]		echo "AutoEquip: ItemSearch Count - ${ItemSearch.Count}, ItemSearch[${Math.Calc[${ItemSearch.Count}-1]}] - ${ItemSearch.GUID[${Math.Calc[${ItemSearch.Count}-1]}]}"		if ${ItemSearch.Count} > 0		{			do			{				if ${Item[${ItemSearch.GUID[${counter}]}].SubType.Equal[Shield]}				{					echo "Autoequip: Entered Shield if"					if ${This.CanShield} && ${This.ShouldEquip[${ItemSearch.GUID[${counter}]},Armor]}					{						echo "AutoEquip: Attempting to equip ${Item[${ItemSearch.GUID[${counter}]}].Name}"						Item[${ItemSearch.GUID[${counter}]}]:Use						WoWScript EquipPendingItem(0)					}				}				if ${Item[${ItemSearch.GUID[${counter}]}].SubType.Equal[${This.ArmorType}]}				{					echo "AutoEquip: Entered This.ArmorType if"					echo "${This.ArmorType} ${PrimStat} ${SecStat} ${WeapType}"					if ${This.ShouldEquip[${ItemSearch.GUID[${counter}]},Armor]}					{						echo "AutoEquip: Attempting to equip ${ItemSearch.GUID[${counter}].Name}"						Item[${ItemSearch.GUID[${counter}]}]:Use						WoWScript EquipPendingItem(0)					}				}				if ${Item[${ItemSearch.GUID[${counter}]}].SubType.Equal[${WeapType}]}				{					echo "AutoEquip: Entered WeapType if"					if ${This.ShouldEquip[${ItemSearch.GUID[${counter}]},Weapon]}					{						echo "AutoEquip: Attempting to equip ${ItemSearch.GUID[${counter}].Name}"						Item[${ItemSearch.GUID[${counter}]}]:Use						WoWScript EquipPendingItem(0)					}				}				counter:Inc			}			while ${ItemSearch.GUID[${counter}](exists)}		}		if ${BaggieSearch.Count} > 0		{			do			{				if ${Object[${BaggieSearch.GUID[${counterx}]}].SubType.Equal[Bag]} && ${This.CanAttemptEquip}				{					echo "AutoEquip: Entered Bag if"					if ${This.ShouldEquip[${BaggieSearch.GUID[${counterx}]},Bag]}					{						echo "AutoEquip: Attempting to equip ${BaggieSearch.GUID[${counterx}]} aka ${BaggieSearch.Name[${counterx}]}"						Object[${BaggieSearch.GUID[${counterx}]}]:PickUp						WoWScript PickupInventoryItem(ContainerIDToInventoryID(${This.BagWeight[${BaggieSearch.GUID[${counterx}]}]}))						WoWScript EquipPendingItem(0)						return					}					}				counterx:Inc			}			while ${counterx} <= ${BaggieSearch.Count}		}	}	member CanAttemptEquip()	{		if (${This.LastEquipAttempt} == 0) || (${LavishScript.RunningTime} > ${LastEquipAttempt})		{			return TRUE		}		return FALSE	}	method SetLastEquipAttempt()	{		LastEquipAttempt:Set[${Math.Calc[${LavishScript.RunningTime} + 10000]}]	}		method Initialize()	{	}	member NeedRest()	{		if (${Me.PctHPs} < ${RestHP}) || (${Me.Buff[Food](exists)} && ${Me.PctHPs} < 100)		{			return TRUE		}		return FALSE	}		method RestPulse()	{		This:Output["RestPulse Check"]		if ${Movement.Speed}		{			Move -stop		}							if !${Me.Buff[Food](exists)}		{			if ${Spell["Cannibalize"]{exists)} && !${Spell["Cannibalize"].Cooldown}  && (${Object[-dead,-humanoid,-range 0-5](exists)} || ${Object[-dead,-undead,-range 0-5](exists)})			{				Toon:CastSpell["Cannibalize"]				return				}			elseif ${Consumable.HasFood} && ${Me.PctHPs} < 100			{				Consumable:useFood				return			}		}		This:Output["Running AutoEquip Check"]		This:AutoEquip()	}	member NeedBuff()	{		return FALSE	}		method BuffPulse()	{	}		member NeedPullBuff()	{		return FALSE	}	method PullBuffPulse()	{	}		member NeedCombatBuff()	{		if !${Me.Buff["Battle Shout"](exists)} && ${Spell["Battle Shout"](exists)}		{			return TRUE		}		return FALSE	}	method CombatBuffPulse()	{		Toon:CastSpell["Battle Shout"]		return	}		method PullPulse()	{		if !${Me.Target(exists)}		{			return		}				if !${Me.Attacking}		{			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 			WoWScript AttackTarget()		}				if  ${Me.InCombat} || !${Spell["Charge"](exists)} || ${Spell["Charge"].Cooldown} || ${Target.Distance} > 25 || ${Target.Distance} < 8   		{			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}]    			Navigator:MoveToLoc[${Target.X},${Target.Y},${Target.Z}]   			This:Output["Can't use Charge, moving to target"]      		return   		}				if !${Me.InCombat} && ${Spell["Charge"](exists)} && !${Spell["Charge"].Cooldown} && ${Target.Distance} <= 25 && ${Target.Distance} >=8   		{   			if !${Me.Buff[Battle Stance](exists)}   			{   				Toon:CastSpell["Battle Stance"]   				This:Output["Battle stance switch to use Charge"]				return   			}			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 			Toon:CastSpell["Charge"]			return		}	}		method AttackPulse()	{		Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 		; If we dont have a target why are we doing anything?		if !${Target(exists)} || ${Target.Dead}		{			return		}				; Face the target		Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 				; Stop if we are at the right distance		if ${Movement.Speed} && ${Target.Distance} <= ${This.MaxMelee} && ${Target.Distance} >= ${This.MinMelee}		{			move -stop			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 			return		}				;If we are not close enough lets move closer		if ${Target.Distance}> ${This.MaxMelee}		{			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 			Move Forward			This:Output["Moving forward"]			return		}      		;If we are too close lets back up a bit		if ${Target.Distance} < ${This.MinMelee}		{			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}]			Move Backward			This:Output["Moving backward"]			return		}		if !${Me.Attacking}		{			Navigator:FaceXYZ[${Target.X},${Target.Y},${Target.Z}] 			WoWScript AttackTarget()		}		/*		+---------------------------------------------------------------------------------+		|Multi-mobs logic																  |		+---------------------------------------------------------------------------------+		*/				; *** GENERIC MULTI-MOBS ***		if  ${Toon.AggroWithin[10,TRUE]} > 1		{			; *** DEMO SHOUT ***			; to reduce inc damages			if ${Spell["Demoralizing Shout"](exists)} && !${Target.Buff["Demoralizing Shout"](exists)} && ${Me.CurrentRage} >= 10			{				Toon:CastSpell["Demoralizing Shout"]				return			}						; *** THUNDER CLAP ***			if !${Target.Buff[Thunder Clap](exists)} && ${Spell["Thunder Clap"](exists)} && ${Target.PctHPs} > 40 && ${Me.CurrentRage} >= 20			{				if ${Me.Buff["Berserker Stance"](exists)}				{					Toon:CastSpell["Battle Stance"]					This:Output["Battle stance switch to use Thunder Clap"]					return				}				Toon:CastSpell["Thunder Clap"]				return			}						; *** HEALTH POTION ***			if ${Consumable.HasHPot} && ${Me.PctHPs} < 40			{				Consumable:useHPot				return			}		}						; *** 3 OR MORE ***		; let's use our best AOE !		if  ${Toon.AggroWithin[10,TRUE]} >= 3		{			; *** RETALIATION ***			if ${Spell["Retaliation"](exists)} && !${Spell["Retaliation"].Cooldown} && ${Me.PctHPs} > 40			{				if !${Me.Buff[Battle Stance](exists)}				{					Toon:CastSpell["Battle Stance"]					This:Output["Battle stance switch to use Retaliation"]					return				}				Toon:CastSpell["Retaliation"]				return			}						; *** WHIRLWIND ***			elseif ${Spell["Whirlwind"](exists)} && !${Spell["Whirlwind"].Cooldown}	&& ${Me.CurrentRage} >= 25			{				if !${Me.Buff[Berserker Stance](exists)}				{					Toon:CastSpell["Berserker Stance"]					This:Output["Berserker stance switch to use Whirlwind"]					return				}				Toon:CastSpell["Whirlwind"]				return			}						; *** INTIMIDATING SHOUT ***			; comment out if you're afraid of pulling whole map of mobs :D			elseif ${Spell["Intimidating Shout"](exists)} && !${Spell["Intimidating Shout"].Cooldown} && ${Me.PctHPs} < 60 && ${Me.CurrentRage} >= 25			{				Toon:CastSpell["Intimidating Shout"]				return			}		}				; *** 2 MOBS ***		if  ${Toon.AggroWithin[10,TRUE]} == 2		{			; *** SWEEPING STRIKES ***			if ${Spell["Sweeping Strikes"](exists)} && !${Spell["Sweeping Strikes"].Cooldown} && ${Target.PctHPs} > 35 && ${Me.CurrentRage} >= 30			{				if !${Me.Buff["Battle Stance"](exists)}				{					Toon:CastSpell["Battle Stance"]					This:Output["Battle stance switch to use Sweeping Strikes"]					return				}				Toon:CastSpell["Sweeping Strikes"]				return			}			; *** CLEAVE ***			elseif ${Spell["Cleave"](exists)} && !${Me.Action[Cleave].Active} && !${Me.Buff["Sweeping Strikes"](exists)} && ${Me.CurrentRage} >= 20			{				Toon:CastSpell["Cleave"]				return			}		}				/*		+---------------------------------------------------------------------------------+		|Single Combat logic															  |		+---------------------------------------------------------------------------------+		*/						; --- VICTORY RUSH ---		if ${Spell["Victory Rush"](exists)} && !${Spell["Victory Rush"].Cooldown} && ${Me.Action["Victory Rush"].Usable}  		{			Toon:CastSpell["Victory Rush"]			return		}				; --- ME ALL GREEN ---		if ${Spell["Blood Fury"](exists)} && !${Spell["Blood Fury"].Cooldown} && ${Target.PctHPs} > 70 && ${Me.PctHPs} > 70		{			Toon:CastSpell["Blood Fury"]			return		}				; Battle shout should now be managed by CombatBuffPulse()		; I let this comment as a reminder in case things don't work as intended				; --- SPELLS INTERRUPT LOGIC ---		if ${Target.Casting.ID(exists)}		{			; --- WAR STOMP ---			if ${Spell["War Stomp"](exists)} && !${Spell["War Stomp"].Cooldown} 			{				Toon:CastSpell["War Stomp"]				return			}						; --- CONCUSSION BLOW ---			elseif ${Spell["Concussion Blow"](exists)} && !${Spell["Concussion Blow"].Cooldown} && ${Me.CurrentRage} >= 15			{				Toon:CastSpell["Concussion Blow"]				return				}						; --- SHIELD BASH ---			elseif ${Spell["Shield Bash"](exists)} && ${Me.Action["Shield Bash"].Usable} && ${Me.CurrentRage} >= 10			{				Toon:CastSpell["Shield Bash"]				return			}						; --- PUMMEL ---			elseif ${Spell["Pummel"](exists)} && !${Spell["Pummel"].Cooldown} && ${Me.CurrentRage} >= 10			{				if !${Me.Buff["Berserker Stance"](exists)}				{					Toon:CastSpell["Berserker Stance"]					This:Output[Berserker stance switch to use Pummel]					return				}				Toon:CastSpell["Pummel"]				return			}		}				; --- REND ---		if !${Target.Buff["Rend"](exists)} && ${Spell["Rend"](exists)} && ${Target.PctHPs} > 70 && ${Me.CurrentRage} >= 10 && !${Me.Action["Overpower"].Usable} && !${Me.Buff["Berserker Stance"](exists)} && !${Target.CreatureType.Equal[Demon]} && !${Target.CreatureType.Equal[Elemental]} && !${Target.CreatureType.Equal[Undead]} && !${Target.CreatureType.Equal[Mechanical]}		{			Toon:CastSpell["Rend"]			return		}						; --- OVERPOWER ---		if ${Spell["Overpower"](exists)} && !${Spell["Overpower"].Cooldown} && ${Me.Action["Overpower"].Usable} && ${Me.CurrentRage} >= 5		{			Toon:CastSpell["Overpower"]			return		}				; --- HAMSTRING & PIERCING HOWL ---		; only for humanoids		if ${Target.CreatureType.Equal[Humanoid]} && ${Spell["Hamstring"](exists)} && ${Me.CurrentRage} >= 10 && ${Target.PctHPs} < 25 && !${Target.Buff["Hamstring"](exists)} && !${Target.Buff["Piercing Howl"](exists)}		{			if ${Me.Buff["Defensive Stance"](exists)}			{				Toon:CastSpell["Battle Stance"]				This:Output[Battle stance switch to use Hamstring]				return			}			Toon:CastSpell["Hamstring"]			return						if ${Spell["Piercing Howl"](exists)}  && ${Target.Distance} > 5 && ${Target.Distance} <= 10 && !${Target.Buff["Hamstring"](exists)} && !${Target.Buff["Piercing Howl"](exists)}			{				Toon:CastSpell["Piercing Howl"]				return			}		}				; --- EXECUTE ---		if ${Spell["Execute"](exists)} && ${Target.PctHPs} < 20 && ${Me.CurrentRage} >= 15		{			if ${Me.Buff["Defensive Stance"](exists)}			{				Toon:CastSpell["Battle Stance"]				This:Output["Battle stance switch to use Execute"]				return			}			Toon:CastSpell["Execute"]			return		}				; --- RAMPAGE ---		if ${Spell["Rampage"](exists)} && ${Me.Action["Rampage"].Usable} && ${Target.PctHPs} > 60 && ${Me.CurrentRage} >= 20		{			Toon:CastSpell["Rampage"]			return		}		; --- MAIN STRIKE ---		; after lvl 40		if ${Me.Level} >= 40 && ${Target.PctHPs} > 15		{			; --- BLOODTHIRST ---			if ${Spell["Bloodthirst"](exists)} && !${Spell["Bloodthirst"].Cooldown} && ${Me.CurrentRage} >= 30			{				Toon:CastSpell["Bloodthirst"]				return			}						; --- MORTAL STRIKE ---			elseif ${Spell["Mortal Strike"](exists)} && !${Spell["Mortal Strike"].Cooldown} && ${Me.CurrentRage} >= 30			{				Toon:CastSpell["Mortal Strike"]				return			}						; --- SHIELD SLAM ---			elseif ${Spell["Shield Slam"](exists)} && !${Spell["Shield Slam"].Cooldown} && ${Me.CurrentRage} >= 20			{				Toon:CastSpell["Shield Slam"]				return			}						; --- DEVASTATE --- 			; only if shield slam is on cooldown.			elseif ${Spell["Devastate"](exists)} && !${Spell["Devastate"].Cooldown} && ${Spell["Shield Slam"].Cooldown} && ${Me.CurrentRage} >= 15 			{				Toon:CastSpell["Devastate"]				return			}						; --- SLAM or HEROIC STRIKE ---			elseif ${Me.CurrentRage} > 15 && !${Spell["Bloodthirst"](exists)} && !${Spell["Mortal Strike"](exists)} && !${Spell["Shield Slam"](exists)} && !${Spell["Devastate"](exists)}			{				ImpSlamPoints:Set[${TalentTree.PointsInTalent["Improved Slam"]}]				if ${ImpSlamPoints} >= 1 && !${Me.Action[Slam].Active}				{					Toon:CastSpell["Slam"]					This:Output[Improved Slam Detected, use it !]					return									}				elseif !${Me.Action[Heroic Strike].Active}				{					Toon:CastSpell["Heroic Strike"]					return				}			}		}				; --- HEROIC STRIKE & SLAM ---		; main dps spell before lvl 40 or if we have too much rage		if (${Me.Level} < 40 || ${Me.CurrentRage} > 55)  && !${Me.Action["Overpower"].Usable} && !${Me.Action["Execute"].Usable} && ${Me.CurrentRage} >= 15		{			ImpSlamPoints:Set[${TalentTree.PointsInTalent["Improved Slam"]}]			if ${ImpSlamPoints} >= 1 && !${Me.Action[Slam].Active}			{				Toon:CastSpell["Slam"]				This:Output[Improved Slam Detected, use it !]				return			}			elseif !${Me.Action[Heroic Strike].Active}			{				Toon:CastSpell["Heroic Strike"]				return			}		}				; --- BLOODRAGE ---		if ${Spell["Bloodrage"](exists)} && !${Spell["Bloodrage"].Cooldown} && ${Me.CurrentRage} < 10 && ${Me.PctHPs} > 70 && ${Target.PctHPs} > 70		{			Toon:CastSpell["Bloodrage"]			return		}				; --- BERSERKING ---		; Trolls racial		if ${Spell["Berserking"](exists)} && !${Spell["Berserking"].Cooldown} && ${Me.Action["Berserking"].Usable} && ${Me.PctHPs} < 60  && ${Target.PctHPs} > 45        {			Toon:CastSpell["Berserking"]			return		}				; --- LAST MAN STANDING ---		; Disarm, Last Stand, potions & trinkets		if ${Me.PctHPs} < 35		{			; --- DISARM ---			; only on humanoids that haven't mana			if ${Target.CreatureType.Equal[Humanoid]} && ${Spell["Disarm"](exists)} && !${Spell["Disarm"].Cooldown} && !${Target.CurrentMana} > 0 && ${Me.PctHPs} <= 35 && ${Target.PctHPs} > 20 && ${Me.CurrentRage} >= 20			{				if !${Me.Buff["Defensive Stance"](exists)}				{					Toon:CastSpell["Defensive Stance"]					This:Output[Defensive stance switch to use Disarm]					return				}				Toon:CastSpell["Disarm"]				return			}			; --- LAST STAND ---			elseif ${Spell["Last Stand"](exists)} && !${Spell["Last Stand"].Cooldown} && ${Me.PctHPs} < 10			{				Toon:CastSpell["Last Stand"]				return			}			; TODO HEAL / DODGE TRINKETS						; --- GIFT OF THE NAARU ---			; Draenaï Racial			elseif ${Spell["Gift of the Naaru"](exists)} && ${Spell["Gift of the Naaru"].Cooldown} && ${Me.PctHPs} < 35			{				Toon:CastSpell["Gift of the Naaru"]				return			} 						; --- HEALTH POTION ---			elseif ${Consumable.HasHPot} && ${Me.PctHPs} < 25 && ${Target.PctHPs} > 20			{				Consumable:useHPot				return			}		}	}}