Ejemplo n.º 1
0
        internal static int AddDamage(HPInstance hpi, Unit hero, string notes)
        {
            Id++;
            var id = Id;

            var aiHero = ZLib.GetUnits().FirstOrDefault(x => x.Instance.NetworkId == hero.Instance.NetworkId);

            if (aiHero != null && !ZLib.DamageCollection.ContainsKey(id))
            {
                aiHero.Attacker = hpi.Attacker;

                if (aiHero.Instance.IsValid)
                {
                    switch (hpi.EventType)
                    {
                    case EventType.Spell:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Spell);
                        break;

                    case EventType.Buff:
                        aiHero.BuffDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Buff);

                        if (notes == "aura.Evade")
                        {
                            aiHero.Events.Add(EventType.Ultimate);
                        }

                        break;

                    case EventType.Troy:
                        aiHero.TroyDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Troy);

                        if (notes != "debug.Test")
                        {
                            aiHero.Events.AddRange(hpi.GameData.EventTypes);
                        }

                        break;

                    case EventType.Item:
                        aiHero.ItemDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Spell);
                        break;

                    case EventType.TurretAttack:
                        aiHero.TowerDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.TurretAttack);
                        break;

                    case EventType.MinionAttack:
                        aiHero.MinionDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.MinionAttack);
                        break;

                    case EventType.AutoAttack:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.AutoAttack);
                        break;

                    case EventType.Stealth:
                        aiHero.Events.Add(EventType.Stealth);
                        break;

                    case EventType.Initiator:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Initiator);
                        break;

                    case EventType.Danger:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Danger);
                        break;

                    case EventType.CrowdControl:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.CrowdControl);
                        break;

                    case EventType.Ultimate:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.Ultimate);
                        break;

                    case EventType.ForceExhaust:
                        aiHero.AbilityDamage += hpi.PredictedDmg;
                        aiHero.Events.Add(EventType.ForceExhaust);
                        break;
                    }

                    if (hpi.EventType == EventType.Stealth)
                    {
                        hpi.PredictedDmg = 0;
                    }

                    var damageEventArgs = new PredictDamageEventArgs {
                        HpInstance = hpi
                    };
                    ZLib.TriggerOnPredictDamage(hero, damageEventArgs);

                    if (damageEventArgs.NoProcess)
                    {
                        Helpers.ResetIncomeDamage(aiHero);
                        ZLib.DamageCollection.Add(id, null);
                        return(id);
                    }

                    hpi.Id = id;
                    ZLib.DamageCollection.Add(id, hpi);
                }
            }

            return(id);
        }