예제 #1
0
        public static Int32 GetDamageMonster2Player(Monster Attacker, Player Target)
        {
            Double Damage = 0;

            Double Reborn = 1.00;

            if (Target.Metempsychosis == 1)
            {
                Reborn -= 0.30; //30%
            }
            else if (Target.Metempsychosis >= 2)
            {
                Reborn -= 0.50; //50%
            }
            switch (Attacker.AtkType)
            {
            case 2:
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                Damage = AdjustDamageMonster2Player(Damage, Attacker, Target);

                Damage -= Target.Defence;
                break;
            }

            case 21:
            {
                Damage = Attacker.MagicAtk;
                Damage = AdjustDamageMonster2Player(Damage, Attacker, Target);

                Damage *= ((Double)(100 - Target.MagicDef) / 100);
                Damage -= Target.MagicBlock;
                Damage *= 0.75;
                break;
            }
            }

            Damage *= Reborn;
            Damage *= Target.Bless;
            Damage *= Target.GemBonus;

            if (Damage < 1)
            {
                Damage = 1;
            }

            Damage = AdjustMinDamageMonster2Player(Damage, Attacker, Target);

            if (Target.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage = 1;
                World.BroadcastRoomMsg(Target, new MsgName(Target.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            return((Int32)Math.Round(Damage, 0));
        }
예제 #2
0
        public static Int32 GetDamagePlayer2Monster(Player Attacker, Monster Target)
        {
            Double Damage = 0;

            switch (Attacker.AtkType)
            {
            case 2:
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                Damage = AdjustDamagePlayer2Monster(Damage, Attacker, Target);

                Damage -= Target.Defence;
                break;
            }

            case 21:
            {
                Damage = Attacker.MagicAtk;
                Damage = AdjustDamagePlayer2Monster(Damage, Attacker, Target);

                Damage *= ((Double)(100 - Target.MagicDef) / 100);
                Damage -= Target.MagicBlock;
                Damage *= 0.75;
                break;
            }

            case 25:
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                Damage = AdjustDamagePlayer2Monster(Damage, Attacker, Target);
                break;
            }
            }

            if (Damage < 1)
            {
                Damage = 1;
            }

            Damage = AdjustMinDamagePlayer2Monster(Damage, Attacker, Target);

            if (Attacker.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage *= 2;
                World.BroadcastRoomMsg(Attacker, new MsgName(Attacker.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            return((Int32)Math.Round(Damage, 0));
        }
예제 #3
0
        public bool FindFloorItemCell(ref UInt16 aPosX, ref UInt16 aPosY, int aRange)
        {
            UInt16 posX = aPosX, posY = aPosY;
            var    items = (from item in FloorItems.Values
                            where MyMath.CanSee(item.X, item.Y, posX, posY, aRange)
                            select item);

            posX = (UInt16)(posX + MyMath.Generate(-aRange, aRange));
            posY = (UInt16)(posY + MyMath.Generate(-aRange, aRange));

            if ((from item in items where item.X == posX && item.Y == posY select item).Count() == 0)
            {
                if (GetFloorAccess(posX, posY)) // IsLayItemEnable => FloorMask && IsMoveEnable
                {
                    aPosX = posX;
                    aPosY = posY;
                    return(true);
                }
            }

            for (int i = Math.Max(aPosX - aRange, 0); i <= aPosX + aRange && i < Width; ++i)
            {
                for (int j = Math.Max(aPosY - aRange, 0); j <= aPosY + aRange && j < Height; ++j)
                {
                    if ((from item in items where item.X == posX && item.Y == posY select item).Count() > 0)
                    {
                        continue;
                    }

                    if (GetFloorAccess(posX, posY)) // IsLayItemEnable => FloorMask && IsMoveEnable
                    {
                        aPosX = posX;
                        aPosY = posY;
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #4
0
        public static Boolean WeaponSkill(Player Attacker, AdvancedEntity Target)
        {
            try
            {
                if (Attacker.TransformEndTime != 0)
                {
                    return(false);
                }

                Item RWeapon = Attacker.GetItemByPos(4);
                Item LWeapon = Attacker.GetItemByPos(5);

                Int16 RType = 0;
                if (RWeapon != null)
                {
                    RType = (Int16)(RWeapon.Type / 1000);
                }

                Int16 LType = 0;
                if (LWeapon != null)
                {
                    LType = (Int16)(LWeapon.Type / 1000);
                }

                if (RType == 421)
                {
                    RType = 420;
                }

                if (LType == 421)
                {
                    LType = 421;
                }

                List <UInt16> Magics = new List <UInt16>();
                foreach (var magic in Attacker.Magics)
                {
                    if (!magic.TargetType.HasFlag(MagicTarget.Passive))
                    {
                        continue;
                    }

                    if (magic.WeaponSubtype != 0 && magic.WeaponSubtype != RType && magic.WeaponSubtype != LType)
                    {
                        continue;
                    }

                    Magics.Add(magic.Type);
                }

                if (Magics.Count <= 0)
                {
                    return(false);
                }

                Byte           RandNumber = (Byte)MyMath.Generate(0, (Magics.Count - 1));
                COServer.Magic WMagic     = Attacker.GetMagicByType(Magics.ToArray()[RandNumber]);
                if (WMagic != null)
                {
                    Magic.Info Info = new Magic.Info();
                    if (Database.AllMagics.TryGetValue((WMagic.Type * 10) + WMagic.Level, out Info))
                    {
                        if (MyMath.Success(Info.Success))
                        {
                            Attacker.MagicType  = WMagic.Type;
                            Attacker.MagicLevel = WMagic.Level;
                            if (Info.Sort == MagicSort.AtkStatus || Info.Sort == MagicSort.Line)
                            {
                                Battle.UseMagic(Attacker, Target, Attacker.X, Attacker.Y);
                                Attacker.MagicType  = 0;
                                Attacker.MagicLevel = 0;
                                return(true);
                            }
                            else
                            {
                                Battle.UseMagic(Attacker, null, Attacker.X, Attacker.Y);
                                Attacker.MagicType  = 0;
                                Attacker.MagicLevel = 0;
                                return(true);
                            }
                        }
                    }
                }
                return(false);
            }
            catch (Exception exc) { sLogger.Error(exc); return(false); }
        }
예제 #5
0
        public static Int32 GetDamagePlayer2Environment(Player Attacker, TerrainNPC Target, UInt16 MagicType, Byte MagicLevel)
        {
            Magic.Info Info = new Magic.Info();
            Database.AllMagics.TryGetValue((MagicType * 10) + MagicLevel, out Info);

            Double Damage = 0;

            if (Info.Type == 1115 || (Info.WeaponSubtype != 0 && Info.WeaponSubtype != 500))
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }

                Damage -= Target.Defence;
            }
            else if (Info.WeaponSubtype == 500)
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }
            }
            else
            {
                Damage = Attacker.MagicAtk;
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }

                Damage *= ((Double)(100 - Target.MagicDef) / 100);
                Damage -= Target.MagicBlock;
            }

            if (Damage < 1)
            {
                Damage = 1;
            }

            if (Attacker.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage *= 2;
                World.BroadcastRoomMsg(Attacker, new MsgName(Attacker.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }

            return((Int32)Math.Round(Damage, 0));
        }
예제 #6
0
        public static Boolean WeaponAttribute(Player Attacker, AdvancedEntity Target)
        {
            try
            {
                if (Attacker.TransformEndTime != 0)
                {
                    return(false);
                }

                Item RWeapon = Attacker.GetItemByPos(4);
                Item LWeapon = Attacker.GetItemByPos(5);

                List <UInt16> Magics = new List <UInt16>();

                if (RWeapon != null && RWeapon.Attribute >= 200)
                {
                    if (Database.AllMagics.ContainsKey(((RWeapon.Attribute + 10000) * 10)))
                    {
                        Magics.Add((UInt16)(RWeapon.Attribute + 10000));
                    }
                }

                if (LWeapon != null && LWeapon.Attribute >= 200)
                {
                    if (Database.AllMagics.ContainsKey(((LWeapon.Attribute + 10000) * 10)))
                    {
                        Magics.Add((UInt16)(LWeapon.Attribute + 10000));
                    }
                }

                if (Magics.Count <= 0)
                {
                    return(false);
                }

                Byte   RandNumber = (Byte)MyMath.Generate(0, (Magics.Count - 1));
                UInt16 Magic      = Magics.ToArray()[RandNumber];

                Magic.Info Info = new Magic.Info();
                if (Database.AllMagics.TryGetValue((Magic * 10), out Info))
                {
                    if (MyMath.Success(Info.Success))
                    {
                        Attacker.MagicType  = Magic;
                        Attacker.MagicLevel = 0;
                        if (Info.Sort == MagicSort.AtkStatus && Target != null)
                        {
                            Battle.UseMagic(Attacker, Target, Attacker.X, Attacker.Y);
                            return(true);
                        }
                        else
                        {
                            Battle.UseMagic(Attacker, Attacker, Attacker.X, Attacker.Y);
                            return(true);
                        }
                    }
                }
                return(false);
            }
            catch (Exception exc) { sLogger.Error(exc); return(false); }
        }
예제 #7
0
        public static Int32 GetDamagePlayer2Player(Player Attacker, Player Target, UInt16 MagicType, Byte MagicLevel)
        {
            Magic.Info Info = new Magic.Info();
            Database.AllMagics.TryGetValue((MagicType * 10) + MagicLevel, out Info);

            Double Damage = 0;

            Double Reborn = 1.00;

            if (Target.Metempsychosis == 1)
            {
                Reborn -= 0.30; //30%
            }
            else if (Target.Metempsychosis >= 2)
            {
                Reborn -= 0.50; //50%
            }
            Double Dodge = 1.00 - (Math.Min(Target.Dodge, 100.00) / 100.00);

            if (Info.Type == 1115 || (Info.WeaponSubtype != 0 && Info.WeaponSubtype != 500))
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                if (Attacker.HasStatus(Status.SuperAtk))
                {
                    Damage *= 0.2; //PvP Reduction!
                }
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }

                Damage -= Target.Defence;
            }
            else if (Info.WeaponSubtype == 500)
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);
                if (Attacker.HasStatus(Status.SuperAtk))
                {
                    Damage *= 0.2; //PvP Reduction!
                }
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }

                Damage *= Dodge;
                Damage *= 0.12;
            }
            else
            {
                Damage = Attacker.MagicAtk;
                if (Info.Power > 30000)
                {
                    Damage *= (Double)(Info.Power - 30000) / 100;
                }
                else
                {
                    Damage += Info.Power;
                }

                Damage *= ((Double)(100 - Target.MagicDef) / 100);
                Damage -= Target.MagicBlock;
                Damage *= 0.75;
            }

            Damage *= Reborn;
            Damage *= Target.Bless;
            Damage *= Target.GemBonus;

            if (Damage < 1)
            {
                Damage = 1;
            }

            if (Attacker.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage *= 2;
                World.BroadcastRoomMsg(Attacker, new MsgName(Attacker.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            if (Target.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage = 1;
                World.BroadcastRoomMsg(Target, new MsgName(Target.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            return((Int32)Math.Round(Damage, 0));
        }
예제 #8
0
        public static Int32 GetDamagePlayer2Player(Player Attacker, Player Target)
        {
            Double Damage = 0;

            Double Reborn = 1.00;

            if (Target.Metempsychosis == 1)
            {
                Reborn -= 0.30; //30%
            }
            else if (Target.Metempsychosis >= 2)
            {
                Reborn -= 0.50; //50%
            }
            Double Dodge = 1.00 - (Math.Min(Target.Dodge, 100.00) / 100.00);

            switch (Attacker.AtkType)
            {
            case 2:
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);

                if (Attacker.HasStatus(Status.SuperAtk))
                {
                    Damage *= 0.2;         //PvP Reduction!
                }
                Damage -= Target.Defence;
                break;
            }

            case 21:
            {
                Damage = Attacker.MagicAtk;

                Damage *= ((Double)(100 - Target.MagicDef) / 100);
                Damage -= Target.MagicBlock;
                Damage *= 0.75;

                break;
            }

            case 25:
            {
                Damage = MyMath.Generate(Attacker.MinAtk, Attacker.MaxAtk);

                if (Attacker.HasStatus(Status.SuperAtk))
                {
                    Damage *= 0.2;         //PvP Reduction!
                }
                Damage *= Dodge;
                Damage *= 0.12;
                break;
            }
            }

            Damage *= Reborn;
            Damage *= Target.Bless;
            Damage *= Target.GemBonus;

            if (Damage < 1)
            {
                Damage = 1;
            }

            if (Attacker.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage *= 2;
                World.BroadcastRoomMsg(Attacker, new MsgName(Attacker.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            if (Target.LuckyTime > 0 && MyMath.Success(10))
            {
                Damage = 1;
                World.BroadcastRoomMsg(Target, new MsgName(Target.UniqId, "LuckyGuy", Network.MsgName.NameAct.RoleEffect), true);
            }
            return((Int32)Math.Round(Damage, 0));
        }