예제 #1
0
        protected override List <string> InternalUse(ColossoFighter User)
        {
            //Psynergy Handling
            List <string> log = new List <string>();

            //Get enemies and targeted enemies
            double[] actualSpread           = new double[2 * Range - 1];
            List <ColossoFighter> enemyTeam = User.battle.GetTeam(User.enemies);
            List <ColossoFighter> targets   = GetTarget(User);

            int ii = 0;

            foreach (var t in targets)
            {
                if (!t.IsAlive)
                {
                    continue;
                }

                if (PPCost > 1 && t.IsImmuneToPsynergy || t.HasCondition(Condition.Key) || t.HasCondition(Condition.Trap) || t.HasCondition(Condition.Decoy))
                {
                    log.Add($"A magical barrier is protecting {t.Name}.");
                    continue;
                }

                //Effects that trigger before damage
                log.AddRange(Effects.Where(e => e.ActivationTime == TimeToActivate.beforeDamge).ApplyAll(User, t));

                if (!t.IsAlive)
                {
                    continue;
                }

                var baseDmg = Global.RandomNumber(0, 4);
                var dmg     = AttackBased ?
                              Math.Max(0,
                                       (User.Stats.Atk * User.MultiplyBuffs("Attack") - t.Stats.Def * t.ignoreDefense * t.MultiplyBuffs("Defense")) / 2)
                    : (int)Power;

                //                var elMult = 1 + Math.Max(0.0, (int)User.elstats.GetPower(element) * User.MultiplyBuffs("Power") - (int)t.elstats.GetRes(element) * t.MultiplyBuffs("Resistance")) / (attackBased ? 400 : 200);
                var elMult = 1 + (User.ElStats.GetPower(Element) * User.MultiplyBuffs("Power") - t.ElStats.GetRes(Element) * t.MultiplyBuffs("Resistance")) / (AttackBased ? 400 : 200);
                elMult = Math.Max(0.5, elMult);
                elMult = Math.Max(0, elMult);
                var distFromCenter = Math.Abs(enemyTeam.IndexOf(t) - TargetNr);
                var spreadMult     = IgnoreSpread ? 1 : spread[distFromCenter];
                var prctdmg        = (uint)(t.Stats.MaxHP * PercentageDamage / 100);
                var realDmg        = (uint)((baseDmg + dmg + AddDamage) * DmgMult * elMult * spreadMult * t.defensiveMult * User.offensiveMult + prctdmg);
                var punctuation    = "!";

                if (User.offensiveMult > 1)
                {
                    Console.WriteLine($"{User.Name} uses {Name} with multiplier {User.offensiveMult}");
                }

                if (t.ElStats.GetRes(Element) == t.ElStats.HighestRes())
                {
                    punctuation = ".";
                }

                if (t.ElStats.GetRes(Element) == t.ElStats.LeastRes())
                {
                    punctuation = "!!!";
                    if (User is PlayerFighter k)
                    {
                        k.battleStats.AttackedWeakness++;
                    }
                }

                realDmg = Math.Max(1, realDmg);

                log.AddRange(t.DealDamage(realDmg, punctuation));
                User.damageDoneThisTurn += realDmg;

                log.AddRange(Effects.Where(e => e.ActivationTime == TimeToActivate.afterDamage).ApplyAll(User, t));

                if (User is PlayerFighter p)
                {
                    p.battleStats.DamageDealt += realDmg;
                    if (!t.IsAlive)
                    {
                        if (AttackBased && Range == 1)
                        {
                            p.battleStats.KillsByHand++;
                        }
                        p.battleStats.Kills++;
                    }
                }

                if (t.IsAlive && t.HasCondition(Condition.Counter))
                {
                    var  counterAtk    = t.Stats.Atk * t.MultiplyBuffs("Attack");
                    var  counterDef    = User.Stats.Def * User.MultiplyBuffs("Defense") * User.ignoreDefense;
                    uint CounterDamage = (uint)Global.RandomNumber(0, 4);
                    if (counterDef < counterAtk)
                    {
                        CounterDamage += (uint)((counterAtk - counterDef) * User.defensiveMult / 2);
                    }
                    log.Add($"{t.Name} strikes back!");
                    log.AddRange(User.DealDamage(CounterDamage));
                }
                ii++;
            }

            return(log);
        }
예제 #2
0
파일: Attack.cs 프로젝트: dom426/IodemBot
        protected override List <string> InternalUse(ColossoFighter User)
        {
            if (User.Weapon != null)
            {
                emote = User.Weapon.Icon;
            }

            var enemy = GetTarget(User).First();

            var log = new List <string>
            {
                $"{emote} {User.Name} attacks!"
            };

            if (!enemy.IsAlive)
            {
                log.Add($"{enemy.Name} is down already!");
                return(log);
            }

            int chanceToMiss = 16;

            if (User.HasCondition(Condition.Delusion))
            {
                chanceToMiss = 2;
            }

            if (Global.Random.Next(0, chanceToMiss) == 0)
            {
                log.Add($"{enemy.Name} dodges the blow!");
                return(log);
            }

            bool weaponUnleashed = User.Weapon != null && User.Weapon.IsUnleashable && Global.Random.Next(0, 100) <= User.unleashRate;

            if (weaponUnleashed)
            {
                log.Add($"{User.Weapon.IconDisplay} {User.Name}'s {User.Weapon.Name} lets out a howl! {User.Weapon.Unleash.UnleashName}!");
                User.Weapon.Unleash.Effects
                .Where(e => e.timeToActivate == IEffect.TimeToActivate.beforeDamge)
                .ToList()
                .ForEach(e => log.AddRange(e.Apply(User, enemy)));
            }

            if (!enemy.IsAlive)
            {
                return(log);
            }

            var  atk    = User.Stats.Atk * User.MultiplyBuffs("Attack");
            var  def    = enemy.Stats.Def * enemy.MultiplyBuffs("Defense") * enemy.ignoreDefense;
            uint damage = (uint)Global.Random.Next(0, 4);

            if (def < atk)
            {
                damage = (uint)((atk - def) / 2);
            }
            damage += User.addDamage;
            damage  = (uint)(damage * User.offensiveMult);

            var element = Element.none;

            if (User.Weapon != null)
            {
                element = User.Weapon.DamageAlignment;
            }

            if (weaponUnleashed)
            {
                element = User.Weapon.Unleash.UnleashAlignment;
            }

            //var elMult = 1 + Math.Max(0.0, (int)User.elstats.GetPower(element) * User.MultiplyBuffs("Power") - (int)enemy.elstats.GetRes(element) * enemy.MultiplyBuffs("Resistance")) / 400;
            var elMult = 1 + (User.ElStats.GetPower(element) * User.MultiplyBuffs("Power") - enemy.ElStats.GetRes(element) * enemy.MultiplyBuffs("Resistance")) / 400;

            var punctuation = "!";

            if (enemy.ElStats.GetRes(element) == enemy.ElStats.HighestRes())
            {
                punctuation = ".";
            }

            damage = (uint)(damage * elMult);
            damage = (uint)(damage * enemy.defensiveMult);

            if (enemy.ElStats.GetRes(element) == enemy.ElStats.LeastRes())
            {
                punctuation = "!!!";
                if (User is PlayerFighter p)
                {
                    p.battleStats.AttackedWeakness++;
                }
            }
            if (element == Psynergy.Element.none)
            {
                punctuation = "!";
            }

            User.addDamage = 0;
            if (!weaponUnleashed && Global.Random.Next(0, 8) == 0)
            {
                log.Add("Critical!!");
                damage = (uint)(damage * 1.25 + Global.Random.Next(5, 15));
            }
            damage = Math.Max(1, damage);

            log.AddRange(enemy.DealDamage(damage, punctuation));
            User.damageDoneThisTurn += damage;
            if (weaponUnleashed)
            {
                User.Weapon.Unleash.Effects
                .Where(e => e.timeToActivate == IEffect.TimeToActivate.afterDamage)
                .ToList()
                .ForEach(e => log.AddRange(e.Apply(User, enemy)));
            }

            if (enemy.IsAlive && enemy.HasCondition(Condition.Counter))
            {
                var  counterAtk    = enemy.Stats.Atk * enemy.MultiplyBuffs("Attack");
                var  counterDef    = User.Stats.Def * User.MultiplyBuffs("Defense") * User.ignoreDefense;
                uint CounterDamage = (uint)Global.Random.Next(0, 4);
                if (def < atk)
                {
                    CounterDamage = (uint)((counterAtk - counterDef) * User.defensiveMult / 2);
                }
                log.Add($"{enemy.Name} strikes back!");
                log.AddRange(User.DealDamage(CounterDamage));
            }

            if (User is PlayerFighter player)
            {
                player.battleStats.DamageDealt += damage;
                if (!enemy.IsAlive)
                {
                    player.battleStats.KillsByHand++;
                    player.battleStats.Kills++;
                    player.battleStats.HighestDamage = Math.Max(player.battleStats.HighestDamage, damage);
                }
            }
            return(log);
        }
예제 #3
0
        public override List <string> Apply(ColossoFighter user, ColossoFighter target)
        {
            var log = new List <string>();

            if (!target.IsAlive)
            {
                return(log);
            }

            if (target.HasCondition(Condition.Key) || target.HasCondition(Condition.Trap) || target.HasCondition(Condition.Decoy))
            {
                log.Add($"A magical barrier is protecting {target.Name}.");
                return(log);
            }

            if (!target.IsAlive)
            {
                return(log);
            }

            var baseDmg = Global.RandomNumber(0, 4);
            var dmg     = AttackBased ?
                          Math.Max(0,
                                   (user.Stats.Atk * user.MultiplyBuffs("Attack") - target.Stats.Def * target.IgnoreDefense * target.MultiplyBuffs("Defense")) / 2)
                : (int)Power;

            var elMult = 1 + (user.ElStats.GetPower(Element) * user.MultiplyBuffs("Power") - target.ElStats.GetRes(Element) * target.MultiplyBuffs("Resistance")) / (AttackBased ? 400 : 200);

            elMult = Math.Max(0.5, elMult);
            elMult = Math.Max(0, elMult);
            var prctdmg     = (uint)(target.Stats.MaxHP * PercentageDamage / 100);
            var realDmg     = (uint)((baseDmg + dmg + AddDamage) * DmgMult * elMult * target.DefensiveMult * user.OffensiveMult + prctdmg);
            var punctuation = "!";

            if (target.ElStats.GetRes(Element) == target.ElStats.HighestRes())
            {
                punctuation = ".";
            }

            if (target.ElStats.GetRes(Element) == target.ElStats.LowestRes())
            {
                punctuation = "!!!";
                if (user is PlayerFighter k)
                {
                    k.BattleStats.AttackedWeakness++;
                }
            }

            realDmg = Math.Max(1, realDmg);

            log.AddRange(target.DealDamage(realDmg, punctuation));
            user.DamageDoneThisTurn += realDmg;

            if (user is PlayerFighter p)
            {
                p.BattleStats.DamageDealt += realDmg;
                if (!target.IsAlive)
                {
                    p.BattleStats.Kills++;
                }
            }

            if (target.IsAlive && target.HasCondition(Condition.Counter))
            {
                var  counterAtk    = target.Stats.Atk * target.MultiplyBuffs("Attack");
                var  counterDef    = user.Stats.Def * user.MultiplyBuffs("Defense") * user.IgnoreDefense;
                uint counterDamage = (uint)Global.RandomNumber(0, 4);
                if (counterDef < counterAtk)
                {
                    counterDamage += (uint)((counterAtk - counterDef) * user.DefensiveMult / 2);
                }
                log.Add($"{target.Name} strikes back!");
                log.AddRange(user.DealDamage(counterDamage));
            }

            return(log);
        }
예제 #4
0
        protected override List <string> InternalUse(ColossoFighter User)
        {
            //Psynergy Handling
            List <string> log = new List <string>();

            //Get enemies and targeted enemies
            double[] actualSpread           = new double[2 * range - 1];
            List <ColossoFighter> enemyTeam = User.battle.GetTeam(User.enemies);
            List <ColossoFighter> targets   = GetTarget(User);

            int ii = 0;

            foreach (var t in targets)
            {
                if (!t.IsAlive)
                {
                    continue;
                }

                //Effects that trigger before damage
                effects
                .Where(e => e.timeToActivate == IEffect.TimeToActivate.beforeDamge)
                .ToList()
                .ForEach(e => log.AddRange(e.Apply(User, t)));

                if (!t.IsAlive)
                {
                    continue;
                }

                if (PPCost > 1 && t.IsImmuneToPsynergy)
                {
                    log.Add($"{t.Name} protects themselves with a magical barrier.");
                    return(log);
                }

                var baseDmg = Global.Random.Next(0, 4);
                var dmg     = attackBased ?
                              Math.Max(0,
                                       ((int)User.Stats.Atk * User.MultiplyBuffs("Attack") - (int)t.Stats.Def * t.ignoreDefense * t.MultiplyBuffs("Defense")) / 2)
                    : (int)power;

                //                var elMult = 1 + Math.Max(0.0, (int)User.elstats.GetPower(element) * User.MultiplyBuffs("Power") - (int)t.elstats.GetRes(element) * t.MultiplyBuffs("Resistance")) / (attackBased ? 400 : 200);
                var elMult = 1 + (User.ElStats.GetPower(element) * User.MultiplyBuffs("Power") - t.ElStats.GetRes(element) * t.MultiplyBuffs("Resistance")) / (attackBased ? 400 : 200);
                elMult = Math.Max(0, elMult);
                var distFromCenter = Math.Abs(enemyTeam.IndexOf(t) - targetNr);
                var spreadMult     = IgnoreSpread ? 1 : spread[distFromCenter];
                var prctdmg        = (uint)(t.Stats.MaxHP * percentageDamage / 100);
                var realDmg        = (uint)((baseDmg + dmg + addDamage) * dmgMult * elMult * spreadMult * t.defensiveMult * User.offensiveMult + prctdmg);
                var punctuation    = "!";

                if (t.ElStats.GetRes(element) == t.ElStats.HighestRes())
                {
                    punctuation = ".";
                }

                if (t.ElStats.GetRes(element) == t.ElStats.LeastRes())
                {
                    punctuation = "!!!";
                    if (User is PlayerFighter)
                    {
                        ((PlayerFighter)User).battleStats.AttackedWeakness++;
                    }
                }

                realDmg = Math.Max(0, realDmg);

                log.AddRange(t.DealDamage(realDmg, punctuation));
                effects
                .Where(e => e.timeToActivate == IEffect.TimeToActivate.afterDamage)
                .ToList()
                .ForEach(e => log.AddRange(e.Apply(User, t)));

                if (User is PlayerFighter)
                {
                    ((PlayerFighter)User).avatar.DealtDmg(realDmg);
                    if (!t.IsAlive)
                    {
                        if (attackBased && range == 1)
                        {
                            ((PlayerFighter)User).battleStats.KillsByHand++;
                        }
                        ((PlayerFighter)User).battleStats.Kills++;
                    }
                }

                if (t.IsAlive && t.HasCondition(Condition.Counter))
                {
                    var  counterAtk    = t.Stats.Atk * t.MultiplyBuffs("Attack");
                    var  counterDef    = User.Stats.Def * User.MultiplyBuffs("Defense") * User.ignoreDefense;
                    uint CounterDamage = (uint)Global.Random.Next(0, 4);
                    if (counterDef < counterAtk)
                    {
                        CounterDamage += (uint)((counterAtk - counterDef) * User.defensiveMult / 2);
                    }
                    log.Add($"{t.Name} strikes back!");
                    log.AddRange(User.DealDamage(CounterDamage));
                }

                ii++;
            }

            return(log);
        }