private List <BTNode> ConfessorPaletressBehaviour() { var nodes = new List <BTNode>(); GameObject memoryMonster = null; var shaman = mbox.clients.FirstOrDefault(client => client.Player.UnitClass == UnitClass.Shaman); var pala = mbox.clients.FirstOrDefault(client => client.Player.UnitClass == UnitClass.Paladin); var priest = mbox.clients.FirstOrDefault(client => client.Player.UnitClass == UnitClass.Priest); var common = new LeafAction((() => { if (paletress == null) { paletress = mbox.me.ObjectManager.FirstOrDefault(obj => obj.Type == GameObjectType.Unit && totch.GetName(mbox.me.ControlInterface, obj) == PaletressName); if (paletress != null) { paletressGUID = paletress.GUID; } } // ensure tremor totem if (!mbox.me.ObjectManager.Any(obj => obj.EntryID == TremorTotem)) { if (shaman != null && shaman.Player.HealthPct > 0) { shaman.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Tremor Totem", TargetGUID = 0 } ); Thread.Sleep(1000); } } // cleanse Paletress's debuffs int lowPlayerCount = 0; foreach (var player in mbox.clients.Select(cli => cli.Player).Where(pla => pla.HealthPct > 0)) { if (player.HealthPct < 50) { lowPlayerCount++; } foreach (var aura in player.Auras) { if (PaletressDebuffIds.Contains(aura.auraID)) { if (pala != null && pala.Player.HealthPct > 0) { pala.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Cleanse", TargetGUID = player.GUID } ); break; } } } } if (lowPlayerCount >= 2) { if (pala != null && pala.Player.HealthPct > 0) { if (!pala.IsOnCooldown("Divine Sacrifice")) { pala.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Divine Sacrifice", TargetGUID = 0 } ); } } } return(BTStatus.Success); })); // Paletress disappeared - end condition var paletressGone = new Decorator( (() => { return(!mbox.me.ObjectManager.Any(obj => obj.GUID == paletressGUID)); }), new LeafAction((() => { return(BTStatus.Success); }))); var argentAdds = new Decorator( (() => { return(!totch.IsAttackableByTank(paletress)); }), new LeafAction((() => { foreach (var argentAdd in ArgentAdds) { foreach (var unit in mbox.me.ObjectManager.Where(obj => obj.Type == GameObjectType.Unit && obj.IsInCombat())) { if (argentAdd == unit.EntryID) { mbox.GroupTargetGuids[0] = unit.GUID; goto end; } } } end: return(BTStatus.Failed); }))); var memoryAsTarget = new Decorator((() => { return(paletress.Auras.Select(aura => aura.auraID).Contains(PaletressReflectiveShield)); }), new LeafAction((() => { if (memoryMonster != null) { mbox.GroupTargetGuids[0] = memoryMonster.GUID; mbox.me.ControlInterface.remoteControl.SelectUnit(memoryMonster.GUID); mbox.me.CastSpellOnGuid(GenericGroupManager.GetTauntAbilityForTankClass(mbox.me.Player.UnitClass), memoryMonster.GUID); foreach (var aura in memoryMonster.Auras) { if (PaletressRenewIds.Contains(aura.auraID)) { if (priest != null && priest.Player.HealthPct > 0) { priest.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Dispel Magic", TargetGUID = memoryMonster.GUID } ); break; } } } if (priest != null && priest.Player.HealthPct > 0) { if (!priest.IsOnCooldown("Power Infusion")) { priest.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Power Infusion", TargetGUID = priest.Player.GUID } ); } } if (shaman != null && shaman.Player.HealthPct > 0) { if (!shaman.IsOnCooldown("Bloodlust")) { shaman.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Bloodlust", TargetGUID = 0 } ); } } } else { mbox.GroupTargetGuids[0] = 0; memoryMonster = mbox.me.ObjectManager.FirstOrDefault(obj => obj.Type == GameObjectType.Unit && totch.GetName(mbox.me.ControlInterface, obj).Contains("Memory")); } return(BTStatus.Failed); }))); var paletressAsTarget = new Decorator((() => { return(totch.IsAttackableByTank(paletress) && !paletress.Auras.Select(aura => aura.auraID).Contains(PaletressReflectiveShield)); }), new LeafAction((() => { mbox.GroupTargetGuids[0] = paletress.GUID; mbox.me.ControlInterface.remoteControl.SelectUnit(paletress.GUID); mbox.me.CastSpellOnGuid(GenericGroupManager.GetTauntAbilityForTankClass(mbox.me.Player.UnitClass), paletress.GUID); foreach (var aura in paletress.Auras) { if (PaletressRenewIds.Contains(aura.auraID)) { var priest = mbox.clients.FirstOrDefault(client => client.Player.UnitClass == UnitClass.Priest); if (priest != null && priest.Player.HealthPct > 0) { priest.EnqueuePrioritySpellCast( new SpellCast { Coordinates = null, SpellName = "Dispel Magic", TargetGUID = paletress.GUID } ); break; } } } return(BTStatus.Failed); }))); var select = new Selector(paletressGone, argentAdds, memoryAsTarget, paletressAsTarget); nodes.Add(common); nodes.Add(select); return(nodes); }
private BTNode NormalCombatBehaviour() { var nodes = new List <BTNode>(); var getTargets = new LeafAction((() => { mbox.me.ExecLua("print('Running normal combat now')"); var units = mbox.me.ObjectManager.Where(obj => obj.Type == GameObjectType.Unit) .Select(unit => new Tuple <string, GameObject>(totch.GetName(mbox.me.ControlInterface, unit), unit)); foreach (var championName in GrandChampionsNames) { foreach (var unit in units) { if (unit.Item1 == championName) { GrandChampionsUnits.Add(unit.Item2); } } } return(GrandChampionsUnits.Count == 3 ? BTStatus.Success : BTStatus.Running); })); nodes.Add(getTargets); var prepare = new LeafAction((() => { var needsRegen = false; foreach (var client in mbox.clients) { // if have mana, drink until regenerated if (client.Player.MaxMana != 0) { if (client.Player.ManaPct < 70) { needsRegen = true; if (!mbox.me.HasAura(client.Player, "Drink")) { client.ExecLua(mbox.UtilScript); client.ExecLua( $"filter = function(itemName) return itemName == \"{drink}\" end;" + $"sfUseInventoryItem(filter)"); } } } } if (needsRegen) { return(BTStatus.Running); } return(BTStatus.Success); })); nodes.Add(prepare); long _guidForCtm = 0; var combat = new LeafAction((() => { // target champion GameObject currentlyTargetedChampion = null; foreach (var champion in GrandChampionsUnits) { if (champion.HealthPct > 0) { currentlyTargetedChampion = champion; mbox.me.ControlInterface.remoteControl.SelectUnit(champion.GUID); mbox.GroupTargetGuids[0] = champion.GUID; break; } } if (currentlyTargetedChampion == null) { return(BTStatus.Success); } var targetCoords = currentlyTargetedChampion.Coordinates; // check for Bladestorm GameObject bladestormingChampion = null; var bladestormCoords = Vector3.Zero; foreach (var champion in GrandChampionsUnits) { if (champion.HealthPct > 0) { foreach (var aura in champion.Auras) { if (aura.auraID == BladestormId) { bladestormingChampion = champion; bladestormCoords = bladestormingChampion.Coordinates; break; } } } } // aggregate threateners _ = totch.grpMgr.Execute(); float getCloseDist = 30; float runAwayFromBsDist = 14; foreach (var client in mbox.clients) { var playerCoords = client.Player.Coordinates; var diff = (targetCoords - playerCoords); var distance = diff.Length(); // if not tank if (client != totch.tank) { // run away from Bladestorm if (bladestormingChampion != null) { diff = (bladestormCoords - playerCoords); distance = diff.Length(); if (distance <= 6) { var adjusted = ((diff * runAwayFromBsDist) / distance); var finalTargetCoords = targetCoords - adjusted; client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); break; } } // step out of Poison if (client.Player.Auras.Select(aura => aura.auraID).Any(auraId => PoisonBottleIds.Contains(auraId))) { var finalTargetCoords = playerCoords + new Vector3(5f, 0f, 0f); client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); continue; } // get close, if far if (distance > getCloseDist) { var adjusted = ((diff * getCloseDist) / distance); var finalTargetCoords = targetCoords - adjusted; client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); } } else { var tankDist = 4; // as tank, always sit on target var adjusted = ((diff * tankDist) / distance); var finalTargetCoords = targetCoords - adjusted; client .ControlInterface .remoteControl .CGPlayer_C__ClickToMove( client.Player.GetAddress(), ClickToMoveType.Move, ref _guidForCtm, ref finalTargetCoords, 1f); } } return(BTStatus.Running); })); nodes.Add(combat); return(new Sequence(false, nodes.ToArray())); }