Exemplo n.º 1
0
        public static float CalculateMyDamage(Hero globalTarget)
        {
            var mana      = Members.MyHero.MaximumMana;
            var rearm     = Abilities.FindAbility("tinker_rearm");
            var laser     = Abilities.FindAbility("tinker_laser");
            var rocked    = Abilities.FindAbility("tinker_heat_seeking_missile");
            var allItems  = new List <Ability>();
            var allItems2 = new List <Ability>(Members.MyHero.Inventory.Items.Where(x =>
                                                                                    IsItemEnableNew(x.StoredName()) && (x.ManaCost > 0 || x.StoredName() == "item_soul_ring"))
                                               .OrderBy(PriorityHelper)
                                               .ToList());

            allItems.AddRange(allItems2);

            if (rocked.Level > 0 && IsItemEnableNew(rocked.StoredName()))
            {
                allItems.Add(rocked);
            }
            if (laser.Level > 0 && IsItemEnableNew(laser.StoredName()))
            {
                allItems.Add(laser);
            }
            if (rearm.Level > 0)
            {
                allItems.Add(rearm);
            }
            var haveEb      = allItems.Any(x => x.StoredName() == "item_ethereal_blade" && x.CanBeCasted());
            var haveVeil    = allItems.Any(x => x.StoredName() == "item_veil_of_discord" && x.CanBeCasted());
            var myDmg       = 0f;
            var extraDamage = haveEb && !globalTarget.HasModifier("modifier_item_ethereal_blade_ethereal") ? 40 : 0;

            extraDamage += haveVeil && !globalTarget.HasModifier("modifier_item_veil_of_discord_debuff") ? 25 : 0;
            if (allItems.Count == 0 || (rearm.Level == 0))
            {
                myDmg = allItems.Sum(
                    x =>
                    AbilityDamage.CalculateDamage(x, Members.MyHero, globalTarget,
                                                  minusMagicResistancePerc: extraDamage));
                return((int)(globalTarget.Health - myDmg));
            }

            //Printer.Print($"[mana]: init");
            Printer.ConsolePrint($"[mana]: Init. [count]: {allItems.Count}. [possible]: {allItems.Count(x => mana > x.ManaCost)}");
            var wasRearmed    = true;
            var templarStacks = globalTarget.FindModifier("modifier_templar_assassin_refraction_absorb_stacks");
            var stacks        = templarStacks?.StackCount ?? 0;
            var hasRainDrop   = globalTarget.FindItem("item_infused_raindrop", true)?.Cooldown <= 0;
            var wasNama       = mana;
            var linkDef       = globalTarget.IsLinkensProtected();

            while (mana > 5 && allItems.Count(x => mana > x.ManaCost) > 0 && wasRearmed && wasNama >= mana)
            {
                wasRearmed = false;
                foreach (var x in allItems)
                {
                    if (mana > x.ManaCost)
                    {
                        //Printer.ConsolePrint($"[mana]: {x.StoredName()} -> {x.ManaCost}/{mana}");
                        if (x.StoredName() == "item_soul_ring")
                        {
                            mana += 150;
                            Printer.ConsolePrint($"[mana]: {mana} (+150) soul ring");
                            continue;
                        }

                        var mCost = x.ManaCost;
                        if (!(mana - mCost > 0))
                        {
                            break;
                        }
                        mana -= mCost;

                        var dmgFromSpell = AbilityDamage.CalculateDamage(x, Members.MyHero, globalTarget,
                                                                         minusMagicResistancePerc: extraDamage);
                        if (x.GetAbilityId() == AbilityId.tinker_laser)
                        {
                            if (Members.LaserBuff)
                            {
                                dmgFromSpell += 100;
                            }
                        }
                        if (x.IsAbilityBehavior(AbilityBehavior.UnitTarget) && linkDef && !x.IsDisable())
                        {
                            dmgFromSpell = 0;
                            linkDef      = false;
                        }
                        if (stacks > 0)
                        {
                            stacks--;
                            myDmg += 0;
                        }
                        else
                        {
                            if (AbilityDamage.GetDamageType(x) == DamageType.Magical && hasRainDrop && dmgFromSpell > 50)
                            {
                                hasRainDrop   = false;
                                dmgFromSpell -= Math.Min(120, dmgFromSpell);
                                dmgFromSpell  = Math.Max(dmgFromSpell, 0);
                            }
                            myDmg += dmgFromSpell;
                        }
                        //Printer.Print($"[mana]: {mana} (-{mCost}) {x.StoredName()} -> damage: {myDmg}");

                        if (x.StoredName() == rearm.StoredName())
                        {
                            Printer.ConsolePrint($"[mana]: {mana} (-{mCost}) {x.StoredName()}");
                            wasRearmed = true;
                            continue;
                        }
                        Printer.ConsolePrint($"[mana]: {mana} (-{mCost}) {x.StoredName()} -> damage: {dmgFromSpell} || total:{myDmg}");
                    }
                    else
                    {
                        Printer.ConsolePrint($"[mana]: {x.StoredName()} -> {x.ManaCost}/{mana} cant cast this!");
                    }
                }

                /*Printer.ConsolePrint($"[mana]: {rearm.StoredName()} -> {rearm.ManaCost}/{mana}");
                 * mana -= rearm.ManaCost;*/
            }
            var healthAfterShit = (int)(globalTarget.Health - myDmg);

            return(healthAfterShit);
        }