Example #1
0
        public static unsafe byte[] TeamMember(Character Player)
        {
            ushort PacketType = 0x402;
            uint Model = (uint)Player.Model;
            string tqs = "TQServer";
            byte[] Packet = new byte[36 + tqs.Length];

            fixed (byte* p = Packet)
            {
                *((ushort*)p) = (ushort)(Packet.Length - tqs.Length);
                *((ushort*)(p + 2)) = (ushort)PacketType;
                *(p + 5) = 1;

                for (int i = 0; i < Player.Name.Length; i++)
                {
                    *(p + 8 + i) = Convert.ToByte(Player.Name[i]);
                }
                *((uint*)(p + 24)) = (uint)Player.ID;
                *((uint*)(p + 28)) = (uint)Model;
                *((ushort*)(p + 32)) = (ushort)Player.MaxHP;
                *((ushort*)(p + 34)) = (ushort)Player.CurrentHP;
                for (int i = 0; i < tqs.Length; i++)
                {
                    *(p + 36 + i) = Convert.ToByte(tqs[i]);
                }
            }
            return Packet;
        }
Example #2
0
            public static uint MeleePlayerVsMonster(Entities.Character Attacker, Entities.Monster Attacked)
            {
                uint Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);

                Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                if (Attacked.Info.Defense >= Damage)
                {
                    Damage = 1;
                }
                else
                {
                    Damage -= Attacked.Info.Defense;
                }
                if (Attacker.Level > Attacked.Info.Level)
                {
                    int dLvl = Attacker.Level - Attacked.Info.Level;
                    if (dLvl >= 3 && dLvl <= 5)
                    {
                        Damage = (uint)(Damage * 1.5);
                    }
                    else if (dLvl > 5 && dLvl <= 10)
                    {
                        Damage *= 2;
                    }
                    else if (dLvl > 10 && dLvl <= 20)
                    {
                        Damage *= 3;
                    }
                    else if (dLvl > 20)
                    {
                        Damage = (uint)(Damage * (1 + (.3 * dLvl / 5)));
                    }
                }
                return(Math.Max(1, Damage));
            }
Example #3
0
        public static void CalculateMaxHP(Entities.Character Character)
        {
            double HP = (Character.Vitality * 24) + ((Character.Strength + Character.Agility + Character.Spirit) * 3) + 1;

            switch (Character.Class)
            {
            case 11:
                HP *= 1.05;
                break;

            case 12:
                HP *= 1.08;
                break;

            case 13:
                HP *= 1.10;
                break;

            case 14:
                HP *= 1.12;
                break;

            case 15:
                HP *= 1.15;
                break;

            default: break;
            }
            HP += Character.BonusHPByItems;
            Character.MaxHitPoints = (ushort)HP;
        }
Example #4
0
            public static uint RangedPlayerVsPlayer(Entities.Character Attacker, Entities.Character Attacked)
            {
                uint Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);

                Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                int _dodge = Attacked.Dodge;

                Damage = (uint)((double)Damage * (1 - ((double)_dodge * .01)));
                Damage = (uint)((double)Damage * .15);
                return(Math.Max(1, Damage));
            }
Example #5
0
        public static void CalculateMaxMana(Entities.Character Character)
        {
            byte  manaBoost = 5;
            sbyte JobID     = (sbyte)(Character.Class / 10);

            if (JobID == 13 || JobID == 14)
            {
                manaBoost += (byte)(5 * (Character.Class - (JobID * 10)));
            }

            Character.MaxMana = (ushort)(Character.Spirit * manaBoost);
        }
Example #6
0
File: BP.cs Project: halo779/EoEmu
        public static void BP(Character CSocket)
        {
            int BP = CSocket.Level;

            foreach (KeyValuePair<int, Struct.ItemInfo> Item in CSocket.Equipment)
            {
                byte ItemQuality = (byte)(Item.Value.ItemID % 10);
                switch (ItemQuality)
                {
                    case 0:
                        {
                            BP += 1;
                            break;
                        }
                    case 1:
                        {
                            BP += 2;
                            break;
                        }
                    case 2:
                        {
                            BP += 3;
                            break;
                        }
                    case 3:
                        {
                            BP += 4;
                            break;
                        }
                    case 4:
                        {
                            BP += 5;
                            break;
                        }
                }
                if (Item.Value.Soc1 != 0)
                {
                    BP += 1;
                }
                if (Item.Value.Soc2 != 0)
                {
                    BP += 1;
                }
            }
            BP += (CSocket.NAM * 0);
            BP += (CSocket.RAM * 2);
            BP += (CSocket.SAM * 4);

            CSocket.BP = BP;
        }
Example #7
0
            public static uint MeleePlayerVsPlayer(Entities.Character Attacker, Entities.Character Attacked)
            {
                uint Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);

                Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                if (Attacked.PDefense >= Damage)
                {
                    Damage = 1;
                }
                else
                {
                    Damage -= Attacked.PDefense;
                }
                return(Math.Max(1, Damage));
            }
Example #8
0
 public static int Damage(Character Attacker, Character Attacked, int AType, int SkillID, int SkillLevel)
 {
     if (Attacker.MinAttack > Attacker.MaxAttack)
     {
         return 0;
     }
     if (AType == 2)
     {
         int Damage = MainGS.Rand.Next(Attacker.MinAttack, Attacker.MaxAttack);
         Damage -= Attacked.Defense;
         double Tort = 0;
         Tort += Attacked.NBG * 0.05;
         Tort += Attacked.RBG * 0.10;
         Tort += Attacked.SBG * 0.15;
         Damage = (int)Math.Floor(Damage * (1 - Tort));
         if (Attacked.Bless > 0)
         {
             Damage = (int)Math.Floor(Damage * (1 - (Attacked.Bless * 0.01)));
         }
         //TODO: Superman
         if (Damage < 0)
             Damage = 1;
         if ((Attacked.isGM || Attacked.isPM) && Attacked.Invincible)
             Damage = 0;
         return Damage;
     }
     else if (AType == 21)
     {
         int Damage = AddedMagicDamage(SkillID, SkillLevel);
         Damage += Attacker.MagicAttack;
         if (Attacked.MagicDefense > 0)
         {
             double MDef = 1;
             if (Attacked.MagicDefense < 90)
             {
                 MDef = (Attacked.MagicDefense * 0.01);
             }
             else
             {
                 MDef = (90 * 0.01);
             }
             Damage = (int)Math.Floor(Damage - (Damage * MDef));
         }
         Damage = Convert.ToInt32(Damage * 0.75);
         Damage += Attacker.BonusMagicAttack;
         Damage -= Attacked.BonusMagicDefense;
         double Tort = 0;
         Tort += Attacked.NBG * 0.05;
         Tort += Attacked.RBG * 0.10;
         Tort += Attacked.SBG * 0.15;
         Damage = (int)Math.Floor(Damage * (1 - Tort));
         if (Attacked.Bless > 0)
         {
             Damage = (int)Math.Floor(Damage * (1 - (Attacked.Bless * 0.01)));
         }
         if (Damage < 0)
             Damage = 1;
         if ((Attacked.isGM || Attacked.isPM) && Attacked.Invincible)
             Damage = 0;
         return Damage;
     }
     else if (AType == 25)
     {
         int Damage = MainGS.Rand.Next(Attacker.MinAttack, Attacker.MaxAttack);
         if (Attacked.Dodge > 0)
         {
             double Dodge = 0;
             if (Attacked.Dodge <= 94)
                 Dodge = Attacked.Dodge * 0.01;
             else
                 Dodge = 94 * 0.01;
             Damage = (int)Math.Floor(Damage - (Damage * Dodge));
         }
         Damage += Attacker.BonusMagicAttack;
         Damage -= Attacked.BonusMagicDefense;
         double Tort = 0;
         Tort += Attacked.NBG * 0.05;
         Tort += Attacked.RBG * 0.10;
         Tort += Attacked.SBG * 0.15;
         Damage = (int)Math.Floor(Damage * (1 - Tort));
         if (Attacked.Bless > 0)
         {
             Damage = (int)Math.Floor(Damage * (1 - (Attacked.Bless * 0.01)));
         }
         if (Damage < 0)
             Damage = 1;
         if ((Attacked.isGM || Attacked.isPM) && Attacked.Invincible)
             Damage = 0;
         return Damage;
     }
     return 0;
 }
Example #9
0
 public static int Damage(Character Attacker, Monster Attacked, int AType, int MagicID, int MagicLevel)
 {
     if (Attacker.MinAttack > Attacker.MaxAttack)
     {
         return 0;
     }
     //TODO: Magic, Archer
     if (AType == 2)
     {
         int Damage = MainGS.Rand.Next(Attacker.MinAttack, Attacker.MaxAttack);
         if (Attacked.Info.Name != "CoEmuGuard" && Attacked.Info.Name != "CoEmuPatrol" && Attacked.Info.Name != "GuildPatrol" && Attacked.Info.Name != "GuardReviver")
         {
             int Leveldiff = (Attacker.Level + 2) - Attacked.Level;
             int Damageadd = (int)Math.Floor(1 + (Leveldiff / 5) * 0.8);
             if (Damageadd > 1)
                 Damage = Damageadd * Damage;
         }
         Damage -= Attacked.Info.Defense;
         if (Damage < 0)
             Damage = 1;
         //TODO: Superman
         return Damage;
     }
     else if (AType == 21)
     {
         int Damage = AddedMagicDamage(MagicID, MagicLevel);
         Damage += Attacker.MagicAttack;
         if (Attacked.Info.MDefense > 0)
         {
             double MDef = (Attacked.Info.MDefense * 0.01);
             Damage = (int)Math.Floor(Damage - (Damage * MDef));
         }
         if (Attacked.Info.Name != "CoEmuGuard" && Attacked.Info.Name != "CoEmuPatrol" && Attacked.Info.Name != "GuildPatrol" && Attacked.Info.Name != "GuardReviver")
         {
             int Leveldiff = (Attacker.Level + 2) - Attacked.Level;
             int Damageadd = (int)Math.Floor(1 + (Leveldiff / 5) * 0.8);
             if (Damageadd > 1)
                 Damage = Damageadd * Damage;
         }
         if (Damage < 0)
             Damage = 1;
         return Damage;
     }
     else if (AType == 25)
     {
         int Damage = MainGS.Rand.Next(Attacker.MinAttack, Attacker.MaxAttack);
         if (Attacked.Info.Dodge > 0)
         {
             double Dodge = Attacked.Info.Dodge * 0.01;
             Damage = (int)Math.Floor(Damage - (Damage * Dodge));
         }
         if (Attacked.Info.Name != "CoEmuGuard" && Attacked.Info.Name != "CoEmuPatrol" && Attacked.Info.Name != "GuildPatrol" && Attacked.Info.Name != "GuardReviver")
         {
             int Leveldiff = (Attacker.Level + 2) - Attacked.Level;
             int Damageadd = (int)Math.Floor(1 + (Leveldiff / 5) * 0.8);
             if (Damageadd > 1)
                 Damage = Damageadd * Damage;
         }
         if (Damage < 0)
             Damage = 1;
         return Damage;
     }
     return 0;
 }
Example #10
0
            public static uint MagicPlayerVsPlayer(Entities.Character Attacker, Entities.Character Attacked, Skills.Skill Skill)
            {
                uint Damage = 0;

                switch (Skill.SkillInfo.DamageType)
                {
                    #region Magic
                case Enums.DamageType.Magic:
                {
                    Damage = Skill.SkillInfo.Damage;
                    Damage = (uint)((double)(Damage + Attacker.MagicAttack) * (1 + ((double)Attacker.PhoenixGemBonus / 100)));
                    Damage = (uint)((double)Damage * (1 - ((double)Attacked.MDefenseByPct / 100)));
                    if (Attacked.MDefenseByVal >= Damage)
                    {
                        Damage = 1;
                    }
                    else
                    {
                        Damage -= Attacked.MDefenseByVal;
                    }
                    Damage = (uint)((double)(Damage * Skill.SkillInfo.EffectValue));
                    break;
                }

                    #endregion
                    #region Ranged
                case Enums.DamageType.Ranged:
                {
                    Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);
                    Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                    Damage = (uint)((double)Damage * Skill.SkillInfo.EffectValue);
                    Damage = (uint)((double)Damage * ((double)(210 - Attacked.Dodge) / 100));
                    Damage = (uint)(Math.Min(1, Damage * (Attacked.Dodge * .01)));
                    Damage = (uint)((double)Damage * .15);
                    break;
                }

                    #endregion
                    #region Melee
                case Enums.DamageType.Melee:
                {
                    Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);
                    Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                    Damage = (uint)((double)Damage * Skill.SkillInfo.EffectValue);
                    if (Attacked.PDefense >= Damage)
                    {
                        Damage = 1;
                    }
                    else
                    {
                        Damage -= Attacked.PDefense;
                    }
                    break;
                }

                    #endregion
                    #region HealHP
                case Enums.DamageType.HealHP: return(Skill.SkillInfo.Damage);

                    #endregion
                    #region HealMP
                case Enums.DamageType.HealMP: return(Skill.SkillInfo.Damage);

                    #endregion
                default: break;
                }
                return(Math.Max(1, Damage));
            }
Example #11
0
            public static uint MagicPlayerVsMonster(Entities.Character Attacker, Entities.Monster Attacked, Skills.Skill Skill)
            {
                uint Damage = 0;

                switch (Skill.SkillInfo.DamageType)
                {
                    #region Magic
                case Enums.DamageType.Magic:
                {
                    Damage = Skill.SkillInfo.Damage;
                    Damage = (uint)((double)(Damage + Attacker.MagicAttack) * (1 + ((double)Attacker.PhoenixGemBonus / 100)));
                    if (Attacked.Info.MagicDefense >= Damage)
                    {
                        Damage = 1;
                    }
                    else
                    {
                        Damage -= Attacked.Info.MagicDefense;
                    }
                    Damage = (uint)((double)(Damage * Skill.SkillInfo.EffectValue));
                    break;
                }

                    #endregion
                    #region Ranged
                case Enums.DamageType.Ranged:
                {
                    Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);
                    Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                    Damage = (uint)((double)Damage * ((double)(210 - Attacked.Info.Dodge) / 100));
                    Damage = (uint)((double)Damage * Skill.SkillInfo.EffectValue);
                    Damage = (uint)(Math.Min(1, Damage * (Attacked.Info.Dodge * .01)));
                    break;
                }

                    #endregion
                    #region Melee
                case Enums.DamageType.Melee:
                {
                    Damage = (uint)Program.Random.Next(Attacker.MinAttack, Attacker.MaxAttack);
                    Damage = (uint)((double)Damage * (1 + (Attacker.DragonGemBonus / 100)));
                    if (Attacked.Info.Defense >= Damage)
                    {
                        Damage = 1;
                    }
                    else
                    {
                        Damage -= Attacked.Info.Defense;
                    }
                    Damage = (uint)((double)Damage * Skill.SkillInfo.EffectValue);
                    break;
                }

                    #endregion
                    #region HealHP
                case Enums.DamageType.HealHP: return(Skill.SkillInfo.Damage);

                    #endregion
                    #region HealMP
                case Enums.DamageType.HealMP: return(Skill.SkillInfo.Damage);

                    #endregion
                default: break;
                }
                if (Attacker.Level > Attacked.Info.Level)
                {
                    int dLvl = Attacker.Level - Attacked.Info.Level;
                    if (dLvl >= 3 && dLvl <= 5)
                    {
                        Damage = (uint)(Damage * 1.5);
                    }
                    else if (dLvl > 5 && dLvl <= 10)
                    {
                        Damage *= 2;
                    }
                    else if (dLvl > 10 && dLvl <= 20)
                    {
                        Damage *= 3;
                    }
                    else if (dLvl > 20)
                    {
                        Damage = (uint)(Damage * (1 + (.3 * dLvl / 5)));
                    }
                }
                return(Math.Max(1, Damage));
            }