Beispiel #1
0
        public bool MagicHit(Combatant source, Combatant target, AbilityModifiers modifiers)
        {
            if (Hitp == 255 ||
                target.Absorbs(Elements) ||
                target.Voids(Elements))
            {
                return(true);
            }
            if (target.Death ||
                target.Sleep ||
                target.Confusion ||
                target.Stop ||
                target.Petrify ||
                target.Paralysed ||
                target.Peerless ||
                target.Reflect)
            {
                return(true);
            }

            if (source.Fury)
            {
                Hitp = Hitp - Hitp * 3 / 10;
            }

            // Magic Defense Percent
            if (source.CurrentBattle.Random.Next(1, 101) < target.MDefp)
            {
                return(false);
            }

            int hitp = Hitp + source.Level - target.Level / 2 - 1;

            return(source.CurrentBattle.Random.Next(100) < hitp);
        }
Beispiel #2
0
        protected static int RunElementalChecks(int dam, Combatant target, IEnumerable <Element> attackElements)
        {
            bool checksDone = false;

            if (attackElements.Contains(Element.Restorative))
            {
                dam = -dam;
            }

            foreach (Element e in attackElements)
            {
                if (target.Voids(e))
                {
                    dam        = 0;
                    checksDone = true;
                    break;
                }
            }

            if (!checksDone)
            {
                foreach (Element e in attackElements)
                {
                    if (target.Absorbs(e))
                    {
                        dam        = -dam;
                        checksDone = true;
                        break;
                    }
                }
            }

            if (!checksDone)
            {
                foreach (Element e in attackElements)
                {
                    if (target.Halves(e) && target.Weak(e))
                    {
                        continue;
                    }
                    else if (target.Halves(e))
                    {
                        dam = dam / 2;
                        break;
                    }
                    else if (target.Weak(e))
                    {
                        dam = dam * 2;
                        break;
                    }
                }
            }

            return(dam);
        }
Beispiel #3
0
        public bool PhysicalHit(Combatant source, Combatant target, AbilityModifiers modifiers)
        {
            int hitp;

            if (target.Absorbs(Elements) ||
                target.Voids(Elements) ||
                target.Death ||
                target.Sleep ||
                target.Confusion ||
                target.Stop ||
                target.Petrify ||
                target.Manipulate ||
                target.Paralysed ||
                target.Peerless)
            {
                hitp = 255;
            }
            else
            {
                hitp = (source.Dexterity / 4) + Hitp + source.Defp - target.Defp;

                if (source.Fury)
                {
                    hitp = hitp - hitp * 3 / 10;
                }
            }

            // Sanity
            if (hitp < 1)
            {
                hitp = 1;
            }

            int lucky = source.CurrentBattle.Random.Next(0, 100);

            // Lucky Hit
            if (lucky < Math.Floor(source.Luck / 4.0d))
            {
                hitp = 255;
            }
            // Lucky Evade
            else if (lucky < Math.Floor(target.Luck / 4.0d))
            {
                if (source is Ally && target is Enemy)
                {
                    hitp = 0;
                }
            }

            int r = source.CurrentBattle.Random.Next(65536) * 99 / 65536 + 1;

            return(r < hitp);
        }