private void checkAndUse(MItem item, String buff = "", double incDamage = 0, bool ignoreHP = false) { try { if (Config.Item(item.menuVariable) != null) { // check if is configured to use if (Config.Item(item.menuVariable).GetValue<bool>()) { int actualHeroHpPercent = (int)(((_player.Health - incDamage) / _player.MaxHealth) * 100); //after dmg not Actual ^^ int actualHeroManaPercent = (int)(_player.MaxMana > 0 ? ((_player.Mana / _player.MaxMana) * 100) : 0); #region DeffensiveSpell ManaRegeneratorSpell PurifierSpell OffensiveSpell KSAbility if (item.type == ItemTypeId.DeffensiveSpell || item.type == ItemTypeId.ManaRegeneratorSpell || item.type == ItemTypeId.PurifierSpell || item.type == ItemTypeId.OffensiveSpell || item.type == ItemTypeId.KSAbility) { var spellSlot = Utility.GetSpellSlot(_player, item.menuVariable); if (spellSlot != SpellSlot.Unknown) { if (_player.Spellbook.CanUseSpell(spellSlot) == SpellState.Ready) { if (item.type == ItemTypeId.DeffensiveSpell) { int usePercent = Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value; if (actualHeroHpPercent <= usePercent) { _player.Spellbook.CastSpell(spellSlot); } } else if (item.type == ItemTypeId.ManaRegeneratorSpell) { int usePercent = Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value; if (actualHeroManaPercent <= usePercent && !_player.InFountain()) { _player.Spellbook.CastSpell(spellSlot); } } else if (item.type == ItemTypeId.PurifierSpell) { if ((Config.Item("defJustOnCombo").GetValue<bool>() && Config.Item("comboModeActive").GetValue<KeyBind>().Active) || (!Config.Item("defJustOnCombo").GetValue<bool>())) { if (checkCC(_player)) { _player.Spellbook.CastSpell(spellSlot); checkCCTick = Utils.TickCount + 2500; } } } else if (item.type == ItemTypeId.OffensiveSpell || item.type == ItemTypeId.KSAbility) { #region Ignite if (item == ignite) { // TargetSelector.TargetingMode.LowHP FIX/Check Obj_AI_Hero target = TargetSelector.GetTarget(item.range, TargetSelector.DamageType.Physical); // Check about DamageType if (target != null) { var aaspeed = _player.AttackSpeedMod; float aadmg = 0; // attack speed checks if (aaspeed < 0.8f) aadmg = _player.FlatPhysicalDamageMod * 3; else if (aaspeed > 1f && aaspeed < 1.3f) aadmg = _player.FlatPhysicalDamageMod * 5; else if (aaspeed > 1.3f && aaspeed < 1.5f) aadmg = _player.FlatPhysicalDamageMod * 7; else if (aaspeed > 1.5f && aaspeed < 1.7f) aadmg = _player.FlatPhysicalDamageMod * 9; else if (aaspeed > 2.0f) aadmg = _player.FlatPhysicalDamageMod * 11; // Will calculate for base hp regen, currenthp, etc float dmg = (_player.Level * 20) + 50; float regenpersec = (target.FlatHPRegenMod + (target.HPRegenRate * target.Level)); float dmgafter = (dmg - ((regenpersec * 5) / 2)); float aaleft = (dmgafter + target.Health / _player.FlatPhysicalDamageMod); //var pScreen = Drawing.WorldToScreen(target.Position); if (target.Health < (dmgafter + aadmg) && _player.Distance(target, false) <= item.range) { bool overIgnite = Config.Item("overIgnite").GetValue<bool>(); if ((!overIgnite && !target.HasBuff("summonerdot")) || overIgnite) { _player.Spellbook.CastSpell(spellSlot, target); //Drawing.DrawText(pScreen[0], pScreen[1], System.Drawing.Color.Crimson, "Kill in " + aaleft); } } } } #endregion else { try { string[] jungleMinions; if (Utility.Map.GetMap().Type.Equals(Utility.Map.MapType.TwistedTreeline)) { jungleMinions = new string[] { tVilemaw.name, tWraith.name, tGolem.name, tWolf.name }; } else { jungleMinions = new string[] { blue.name, red.name, razor.name, baron.name, krug.name, wolf.name, dragon.name, gromp.name, crab.name }; } float searchRange = item == choR ? getChoUltRange() : (item.range + 300); // Get minions in 800 range var minions = MinionManager.GetMinions(_player.Position, searchRange, MinionTypes.All, MinionTeam.Neutral); if (minions.Count() > 0) { int smiteDmg = getSmiteDmg(); foreach (Obj_AI_Base minion in minions) { float range = item == choR ? getChoUltRange() : item.range + minion.BoundingRadius + _player.BoundingRadius; if (_player.Distance(minion, false) <= range) { int dmg = item.type == ItemTypeId.OffensiveSpell ? smiteDmg : (int)Damage.GetSpellDamage(_player, minion, spellSlot); if (minion.Health <= dmg && jungleMinions.Any(name => minion.Name.StartsWith(name) && ((minion.Name.Length - name.Length) <= 6) && Config.Item(name).GetValue<bool>())) { if (item.spellType == SpellType.SkillShotLine || item.spellType == SpellType.SkillShotCone || item.spellType == SpellType.SkillShotCircle) { _player.Spellbook.CastSpell(spellSlot, minion.Position); } else { _player.Spellbook.CastSpell(spellSlot, item.spellType == SpellType.Self ? null : minion); } } } } } } catch { Game.PrintChat("Problem with MasterActivator(Smite)."); } } } } } } #endregion else if (item.type == ItemTypeId.Ability || item.type == ItemTypeId.TeamAbility) { try { var spellSlot = Utility.GetSpellSlot(_player, item.name); if (spellSlot != SpellSlot.Unknown) { if (_player.Spellbook.CanUseSpell(spellSlot) == SpellState.Ready) { int usePercent = !ignoreHP ? Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value : 100; int manaPercent = Config.Item(item.menuVariable + "UseManaPct") != null ? Config.Item(item.menuVariable + "UseManaPct").GetValue<Slider>().Value : 0; //Console.WriteLine("ActualMana%-> " + actualHeroManaPercent + " Mana%->" + manaPercent + " Acthp%->" + actualHeroHpPercent + " Use%->" + usePercent); if (actualHeroManaPercent >= manaPercent && actualHeroHpPercent <= usePercent) { if (item.spellType == SpellType.TargetEnemy) { if (checkTarget(item.range)) { _player.Spellbook.CastSpell(item.abilitySlot, target); } } else { _player.Spellbook.CastSpell(item.abilitySlot, _player); } } } } } catch (Exception e) { Console.WriteLine("Problem with MasterActivator(AutoShield)."); Console.WriteLine(e); } } else { if (Items.HasItem(item.id)) { //Console.WriteLine("Tem item->" + item.id + item.name); if (Items.CanUseItem(item.id)) { if (item.type == ItemTypeId.Offensive) { if (checkTarget(item.range)) { int actualTargetHpPercent = (int)((target.Health / target.MaxHealth) * 100); if (checkUsePercent(item, actualTargetHpPercent)) { useItem(item.id, (item.range == 0 || item.spellType == SpellType.Self) ? null : target); } } } else if (item.type == ItemTypeId.OffensiveAOE) { if (checkTarget(item.range)) { // FIX-ME: In frost case, we must check the affected area, not just ppl in range(item). if (Utility.CountEnemiesInRange(_player, (int)item.range) >= Config.Item(item.menuVariable + "UseXUnits").GetValue<Slider>().Value) { useItem(item.id, (item.range == 0 || item.spellType == SpellType.Self) ? null : target); } } } else if (item.type == ItemTypeId.HPRegenerator) { if (checkUsePercent(item, actualHeroHpPercent) && !_player.InFountain() && !Utility.IsRecalling(_player)) { if ((buff != "" && !checkBuff(buff)) || buff == "") { useItem(item.id); } } } else if (item.type == ItemTypeId.Deffensive) { if (checkUsePercent(item, actualHeroHpPercent) && !_player.InFountain() && (Config.Item("useRecalling").GetValue<bool>() || !Utility.IsRecalling(_player))) { if ((buff != "" && !checkBuff(buff)) || buff == "") { useItem(item.id); } } } else if (item.type == ItemTypeId.ManaRegenerator) { if (checkUsePercent(item, actualHeroManaPercent) && !_player.InFountain() && !Utility.IsRecalling(_player)) { if ((buff != "" && !checkBuff(buff)) || buff == "") { useItem(item.id); } } } else if (item.type == ItemTypeId.Buff) { if (checkTarget(item.range)) { if (!checkBuff(item.name)) { useItem(item.id); } } else { if (checkBuff(item.name)) { useItem(item.id); } } } else if (item.type == ItemTypeId.Purifier) { if ((Config.Item("defJustOnCombo").GetValue<bool>() && Config.Item("comboModeActive").GetValue<KeyBind>().Active) || (!Config.Item("defJustOnCombo").GetValue<bool>())) { if (checkCC(_player)) { useItem(item.id); checkCCTick = Utils.TickCount + 2500; } } } } } } } } } catch (Exception e) { Console.WriteLine(e); } }
private void teamCheckAndUse(MItem item, String buff = "", double incDmg = 0, Obj_AI_Base attacked = null, Obj_AI_Base attacker = null, bool ignoreHP = false) { if (Config.Item(item.menuVariable) != null) { // check if is configured to use if (Config.Item(item.menuVariable).GetValue<bool>()) { #region DeffensiveSpell ManaRegeneratorSpell PurifierSpell if (item.type == ItemTypeId.DeffensiveSpell || item.type == ItemTypeId.ManaRegeneratorSpell || item.type == ItemTypeId.PurifierSpell) { //Console.WriteLine("TCandU-> " + item.name); var spellSlot = Utility.GetSpellSlot(_player, item.menuVariable); if (spellSlot != SpellSlot.Unknown) { var activeAllyHeros = getActiveAllyHeros(item); if (activeAllyHeros.Count() > 0) { int usePercent = Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value; foreach (Obj_AI_Hero hero in activeAllyHeros) { //Console.WriteLine("Hero-> " + hero.SkinName); int enemyInRange = Utility.CountEnemiesInRange(hero, 700); if (enemyInRange >= 1) { int actualHeroHpPercent = (int)(((_player.Health - incDmg) / _player.MaxHealth) * 100); //after dmg not Actual ^^ int actualHeroManaPercent = (int)((_player.Mana / _player.MaxMana) * 100); //Console.WriteLine("actHp% -> " + actualHeroHpPercent + " useOn%-> " + usePercent + " IncDMG-> " + incDmg); if ((item.type == ItemTypeId.DeffensiveSpell && actualHeroHpPercent <= usePercent) || (item.type == ItemTypeId.ManaRegeneratorSpell && actualHeroManaPercent <= usePercent)) { _player.Spellbook.CastSpell(spellSlot); } } } } } } #endregion #region TeamAbility TeamAbilityAOE else if (item.type == ItemTypeId.TeamAbility) { try { if (!Config.Item(attacked.SkinName).GetValue<bool>()) { return; } if (_player.Distance(attacked, false) <= item.range) { var spellSlot = Utility.GetSpellSlot(_player, item.name); if (spellSlot != SpellSlot.Unknown) { if (_player.Spellbook.CanUseSpell(spellSlot) == SpellState.Ready) { int usePercent = !ignoreHP ? Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value : 100; int manaPercent = Config.Item(item.menuVariable + "UseManaPct") != null ? Config.Item(item.menuVariable + "UseManaPct").GetValue<Slider>().Value : 0; int actualHeroHpPercent = (int)(((attacked.Health - incDmg) / attacked.MaxHealth) * 100); //after dmg not Actual ^^ int playerManaPercent = (int)((_player.Mana / _player.MaxMana) * 100); if (playerManaPercent >= manaPercent && actualHeroHpPercent <= usePercent) { if (item.type == ItemTypeId.TeamAbility && item.spellType != SpellType.SkillShotCircle && item.spellType != SpellType.SkillShotCone && item.spellType != SpellType.SkillShotLine) { _player.Spellbook.CastSpell(item.abilitySlot, attacked); } else { Vector3 pos = attacked.Position; // extend 20 to attacker direction THIS 20 COST RANGE if (attacker != null) { if (_player.Distance(attacked.Position.Extend(attacker.Position, 20), false) <= item.range) { pos = attacked.Position.Extend(attacker.Position, 20); } } _player.Spellbook.CastSpell(item.abilitySlot, pos); } } } } } } catch (Exception e) { Console.WriteLine("Problem with MasterActivator(AutoShieldTeam)."); Console.WriteLine(e); } } #endregion #region Others else { if (Items.HasItem(item.id)) { if (Items.CanUseItem(item.id)) { var activeAllyHeros = getActiveAllyHeros(item); if (activeAllyHeros.Count() > 0) { foreach (Obj_AI_Hero hero in activeAllyHeros) { #region Purifier if (item.type == ItemTypeId.Purifier) { if ((Config.Item("defJustOnCombo").GetValue<bool>() && Config.Item("comboModeActive").GetValue<KeyBind>().Active) || (!Config.Item("defJustOnCombo").GetValue<bool>())) { if (checkCC(hero)) { useItem(item.id, hero); } } } #endregion #region Deffensive else if (item.type == ItemTypeId.Deffensive) { int enemyInRange = Utility.CountEnemiesInRange(hero, 700); if (enemyInRange >= 1) { int usePercent = Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value; int actualHeroHpPercent = (int)((hero.Health / hero.MaxHealth) * 100); if (actualHeroHpPercent <= usePercent) { if (item.spellType == SpellType.Self) { useItem(item.id); } else { useItem(item.id, hero); } } } } #endregion } } } } } #endregion } } }
private IEnumerable<Obj_AI_Hero> getActiveAllyHeros(MItem item) { var activeAllyHeros = from hero in ObjectManager.Get<Obj_AI_Hero>() where hero.Team == _player.Team && Config.Item(hero.SkinName).GetValue<bool>() && hero.Distance(_player, false) <= item.range && !hero.IsDead select hero; return activeAllyHeros; }
private void createMenuItem(MItem item, String parent, int defaultValue = 0, bool mana = false, int minManaPct = 0) { if (item.type == ItemTypeId.Ability || item.type == ItemTypeId.TeamAbility) { var abilitySlot = Utility.GetSpellSlot(_player, item.name); if (abilitySlot != SpellSlot.Unknown && abilitySlot == item.abilitySlot) { var menu = new Menu(item.menuName, "menu" + item.menuVariable); menu.AddItem(new MenuItem(item.menuVariable, "Enable").SetValue(true)); menu.AddItem(new MenuItem(item.menuVariable + "UseOnPercent", "Use on HP%")).SetValue(new Slider(defaultValue, 0, 100)); if (minManaPct > 0) { menu.AddItem(new MenuItem(item.menuVariable + "UseManaPct", "Min Mana%")).SetValue(new Slider(minManaPct, 0, 100)); } var menuUseAgainst = new Menu("Filter", "UseAgainst"); menuUseAgainst.AddItem(new MenuItem("tower" + item.menuVariable, "Tower").SetValue(true)); menuUseAgainst.AddItem(new MenuItem("ignite" + item.menuVariable, "Ignite").SetValue(true)); menuUseAgainst.AddItem(new MenuItem("king" + item.menuVariable, "BoRKing").SetValue(false)); menuUseAgainst.AddItem(new MenuItem("basic" + item.menuVariable, "Basic ATK").SetValue(false)); var enemyHero = from hero in ObjectManager.Get<Obj_AI_Hero>() where hero.Team != _player.Team select hero; if (enemyHero.Count() > 0) { foreach (Obj_AI_Hero hero in enemyHero) { var menuUseAgainstHero = new Menu(hero.BaseSkinName, "useAgainst" + hero.BaseSkinName); menuUseAgainstHero.AddItem(new MenuItem(item.menuVariable + hero.BaseSkinName, "Enabled").SetValue(true)); menuUseAgainstHero.AddItem(new MenuItem(SpellSlot.Q + item.menuVariable + hero.BaseSkinName, "Q").SetValue(false)); menuUseAgainstHero.AddItem(new MenuItem(SpellSlot.W + item.menuVariable + hero.BaseSkinName, "W").SetValue(false)); menuUseAgainstHero.AddItem(new MenuItem(SpellSlot.E + item.menuVariable + hero.BaseSkinName, "E").SetValue(false)); menuUseAgainstHero.AddItem(new MenuItem(SpellSlot.R + item.menuVariable + hero.BaseSkinName, "R").SetValue(false)); menuUseAgainstHero.AddItem(new MenuItem("ignore" + item.menuVariable + hero.BaseSkinName, "Ignore %HP").SetValue(true)); menuUseAgainst.AddSubMenu(menuUseAgainstHero); // Bring all, passives, summoners spells, etc; /*if (hero.Spellbook.Spells.Count() > 0) { var menuUseAgainstHero = new Menu(hero.BaseSkinName, "useAgainst" + hero.BaseSkinName); menuUseAgainstHero.AddItem(new MenuItem(item.menuVariable, "Enable").SetValue(true)); foreach(SpellDataInst spell in hero.Spellbook.Spells) { menuUseAgainstHero.AddItem(new MenuItem("useAgainstSpell" + spell.Name, spell.Name).SetValue(true)); } menuUseAgainst.AddSubMenu(menuUseAgainstHero); } else { Game.PrintChat("MasterActivator cant get " + hero.BaseSkinName + " spells!"); }*/ } } menu.AddSubMenu(menuUseAgainst); Config.SubMenu(parent).AddSubMenu(menu); } } else if (item.type == ItemTypeId.KSAbility) { var abilitySlot = Utility.GetSpellSlot(_player, item.name); if (abilitySlot != SpellSlot.Unknown && abilitySlot == item.abilitySlot) { var ksAbMenu = new Menu(item.menuName, "menu" + item.menuVariable); ksAbMenu.AddItem(new MenuItem(item.menuVariable, "Enable").SetValue(true)); //choRMenu.AddItem(new MenuItem(choR.menuVariable + "plus", "Plus").SetValue(false)); ksAbMenu.AddItem(new MenuItem(item.menuVariable + "drawRange", "Draw Range").SetValue(true)); ksAbMenu.AddItem(new MenuItem(item.menuVariable + "drawBar", "Draw Bar").SetValue(true)); Config.SubMenu(parent).AddSubMenu(ksAbMenu); } } else { var menu = new Menu(item.menuName, "menu" + item.menuVariable); menu.AddItem(new MenuItem(item.menuVariable, "Enable").SetValue(true)); if (defaultValue != 0) { if (item.type == ItemTypeId.OffensiveAOE) { menu.AddItem(new MenuItem(item.menuVariable + "UseXUnits", "On X Units")).SetValue(new Slider(defaultValue, 1, 5)); } else { menu.AddItem(new MenuItem(item.menuVariable + "UseOnPercent", "Use on " + (mana == false ? "%HP" : "%Mana"))).SetValue(new Slider(defaultValue, 0, 100)); } } Config.SubMenu(parent).AddSubMenu(menu); } }
// And about ignore HP% check? private void justUseAgainstCheck(MItem item, double incDmg, Obj_AI_Base attacker = null, Obj_AI_Base attacked = null, SpellSlot attackerSpellSlot = SpellSlot.Unknown, AttackId attackId = AttackId.Unknown) { // Se tem o spell if (Utility.GetSpellSlot(_player, item.name) != SpellSlot.Unknown) { if (attacker != null && attacked != null) { bool use = false; if (attackId != AttackId.Unknown) { switch (attackId) { case AttackId.Basic: use = Config.Item("basic" + item.menuVariable).GetValue<bool>(); break; case AttackId.Ignite: use = Config.Item("king" + item.menuVariable).GetValue<bool>(); break; case AttackId.King: use = Config.Item("ignite" + item.menuVariable).GetValue<bool>(); break; case AttackId.Tower: use = Config.Item("tower" + item.menuVariable).GetValue<bool>(); break; case AttackId.Spell: use = Config.Item(item.menuVariable + attacker.BaseSkinName).GetValue<bool>() && Config.Item(attackerSpellSlot + item.menuVariable + attacker.BaseSkinName).GetValue<bool>(); break; } } if (use) { bool ignoreHP = false; if (attackId == AttackId.Spell) { ignoreHP = Config.Item("ignore" + item.menuVariable + attacker.BaseSkinName).GetValue<bool>(); } if (item.type == ItemTypeId.Ability && attacked.IsMe) { checkAndUse(item, "", incDmg, ignoreHP); } else if (item.type == ItemTypeId.TeamAbility) { teamCheckAndUse(item, "", incDmg, attacked, attacker, ignoreHP); } } } // OFF JustPred else { checkAndUse(item, "", incDmg); teamCheckAndUse(item, "", incDmg, attacked); } } }
private void ksDrawDmg(MItem item, Obj_AI_Base minion, MMinion jMinion, Vector2 hpBarPos, float hpXPos) { if (Config.Item(item.menuVariable) != null) { if (Config.Item(item.menuVariable).GetValue<bool>() && Config.Item(item.menuVariable + "drawBar").GetValue<bool>()) { float spellDmg = (float)Damage.GetSpellDamage(_player, minion, item.abilitySlot); var spellDmgPercent = spellDmg / minion.MaxHealth; hpXPos = hpBarPos.X + (jMinion.width * spellDmgPercent); Drawing.DrawLine(hpXPos, hpBarPos.Y, hpXPos, hpBarPos.Y + 5, 2, spellDmg >= minion.Health ? System.Drawing.Color.BlueViolet : System.Drawing.Color.Black); } } }
private void ksDrawRange(MItem item) { if (Config.Item(item.menuVariable) != null) { if (Config.Item(item.menuVariable).GetValue<bool>() && Config.Item(item.menuVariable + "drawRange").GetValue<bool>()) { float range = item == choR ? getChoUltRange() : item.range; Drawing.DrawCircle(_player.Position, range, System.Drawing.Color.Brown); } } }
private bool checkUsePercent(MItem item, int actualPercent) { int usePercent = Config.Item(item.menuVariable + "UseOnPercent").GetValue<Slider>().Value; return actualPercent <= usePercent ? true : false; }