Example #1
0
        public static void UpdateCharacterInventoryStatus(Client gc, Item Source, bool Equiped)
        {
            ItemData  idata = ItemFactory.GetItemData(Source.ItemID);
            Character chr   = gc.Character;

            int MaxAttack = 5;
            int Attack    = 3;
            int MaxMagic  = 4;
            int Magic     = 4;

            MaxAttack += ((chr.Str - 3) * 2 + chr.Str / 5);
            MaxAttack += ((chr.Dex - 3) * 2 + chr.Dex / 5);
            Attack    += ((chr.Dex - 3) * 1 + chr.Dex / 5);
            MaxMagic  += ((chr.Int - 3) * 2 + chr.Int / 5);
            Magic     += ((chr.Int - 3) * 2 + chr.Int / 5);

            // 技能攻擊力+、魔攻力+
            Dictionary <int, byte> Skill = new Dictionary <int, byte>();

            foreach (Skill sl in chr.Skills.getSkills())
            {
                Skill.Add(sl.SkillID, sl.SkillLevel);
            }
            if (InventoryType.Is劍(Source.ItemID) && Skill.ContainsKey(10101))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10101]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10101]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10101]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10101]);
                }
            }
            if (InventoryType.Is刀(Source.ItemID) && Skill.ContainsKey(10102))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10102]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10102]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10102]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10102]);
                }
            }
            if (InventoryType.Is手套(Source.ItemID) && Skill.ContainsKey(10201))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10201]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10201]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10201]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10201]);
                }
            }
            if (InventoryType.Is爪(Source.ItemID) && Skill.ContainsKey(10202))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10202]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10202]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10202]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10202]);
                }
            }
            if (InventoryType.Is扇(Source.ItemID) && Skill.ContainsKey(10301))
            {
                if (Equiped)
                {
                    chr.MaxMagic += (short)(MaxMagic * 0.02 * Skill[10301]);
                    chr.Magic    += (short)(Magic * 0.02 * Skill[10301]);
                }
                else
                {
                    chr.MaxMagic -= (short)(MaxMagic * 0.02 * Skill[10301]);
                    chr.Magic    -= (short)(Magic * 0.02 * Skill[10301]);
                }
            }
            if (InventoryType.Is杖(Source.ItemID) && Skill.ContainsKey(10302))
            {
                if (Equiped)
                {
                    chr.MaxMagic += (short)(MaxMagic * 0.03 * Skill[10302]);
                    chr.Magic    += (short)(Magic * 0.03 * Skill[10302]);
                }
                else
                {
                    chr.MaxMagic -= (short)(MaxMagic * 0.03 * Skill[10302]);
                    chr.Magic    -= (short)(Magic * 0.03 * Skill[10302]);
                }
            }
            if (InventoryType.Is斧(Source.ItemID) && Skill.ContainsKey(10401))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.02 * Skill[10401]);
                    chr.Attack    += (short)(Attack * 0.02 * Skill[10401]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.02 * Skill[10401]);
                    chr.Attack    -= (short)(Attack * 0.02 * Skill[10401]);
                }
            }
            if (InventoryType.Is輪(Source.ItemID) && Skill.ContainsKey(10402))
            {
                if (Equiped)
                {
                    chr.MaxAttack += (short)(MaxAttack * 0.03 * Skill[10402]);
                    chr.Attack    += (short)(Attack * 0.03 * Skill[10402]);
                }
                else
                {
                    chr.MaxAttack -= (short)(MaxAttack * 0.03 * Skill[10402]);
                    chr.Attack    -= (short)(Attack * 0.03 * Skill[10402]);
                }
            }
            //if (Skill.ContainsKey(10501) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
            //{

            //}
            //if (Skill.ContainsKey(10502) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
            //{

            //}

            // Hp
            if (idata.Hp != -1)
            {
                if (Equiped)
                {
                    chr.MaxHp += idata.Hp;
                }
                else
                {
                    chr.MaxHp -= idata.Hp;
                }
            }
            // Mp
            if (idata.Mp != -1)
            {
                if (Equiped)
                {
                    chr.MaxMp += idata.Mp;
                }
                else
                {
                    chr.MaxMp -= idata.Mp;
                }
            }
            // 物理攻擊力
            if (idata.Attack != -1)
            {
                if (Equiped)
                {
                    chr.Attack    += idata.Attack;
                    chr.MaxAttack += idata.Attack;
                }
                else
                {
                    chr.Attack    -= idata.Attack;
                    chr.MaxAttack -= idata.Attack;
                }
            }
            // 魔法攻擊力
            if (idata.Magic != -1)
            {
                if (Equiped)
                {
                    chr.Magic    += idata.Magic;
                    chr.MaxMagic += idata.Magic;
                }
                else
                {
                    chr.Magic    -= idata.Magic;
                    chr.MaxMagic -= idata.Magic;
                }
            }

            // 力量
            if (idata.Str != -1)
            {
                if (Equiped)
                {
                    chr.Str        += idata.Str;
                    chr.UpgradeStr += idata.Str;
                    chr.MaxHp      += (short)(3 * idata.Str);
                    chr.MaxAttack  += (short)(2 * idata.Str);
                }
                else
                {
                    chr.Str        -= idata.Str;
                    chr.UpgradeStr -= idata.Str;
                    chr.MaxHp      -= (short)(3 * idata.Str);
                    chr.MaxAttack  -= (short)(2 * idata.Str);
                }
            }
            // 精力
            if (idata.Dex != -1)
            {
                if (Equiped)
                {
                    chr.Dex        += idata.Dex;
                    chr.UpgradeDex += idata.Dex;
                    chr.Attack     += (short)(1 * idata.Dex);
                    chr.MaxAttack  += (short)(2 * idata.Dex);
                }
                else
                {
                    chr.Dex        -= idata.Dex;
                    chr.UpgradeDex -= idata.Dex;
                    chr.Attack     -= (short)(1 * idata.Dex);
                    chr.MaxAttack  -= (short)(2 * idata.Dex);
                }
            }
            // 氣力
            if (idata.Vit != -1)
            {
                if (Equiped)
                {
                    chr.Vit        += idata.Vit;
                    chr.UpgradeVit += idata.Vit;
                    chr.Defense    += (short)(5 * idata.Vit);
                    chr.MaxHp      += (short)(20 * idata.Vit);
                }
                else
                {
                    chr.Vit        -= idata.Vit;
                    chr.UpgradeVit -= idata.Vit;
                    chr.Defense    -= (short)(5 * idata.Vit);
                    chr.MaxHp      -= (short)(20 * idata.Vit);
                }
            }
            // 智力
            if (idata.Int != -1)
            {
                if (Equiped)
                {
                    chr.Int        += idata.Int;
                    chr.UpgradeInt += idata.Int;
                    chr.MaxMp      += (short)(3 * idata.Int);
                    chr.Magic      += (short)(2 * idata.Int);
                    chr.MaxMagic   += (short)(2 * idata.Int);
                }
                else
                {
                    chr.Int        -= idata.Int;
                    chr.UpgradeInt -= idata.Int;
                    chr.MaxMp      -= (short)(3 * idata.Int);
                    chr.Magic      -= (short)(2 * idata.Int);
                    chr.MaxMagic   -= (short)(2 * idata.Int);
                }
            }
            // 迴避率
            if (idata.Avoid != -1)
            {
                if (Equiped)
                {
                    chr.Avoid += idata.Avoid;
                }
                else
                {
                    chr.Avoid -= idata.Avoid;
                }
            }
            // 防禦力
            if (idata.Defense != -1)
            {
                if (Equiped)
                {
                    chr.Defense += idata.Defense;
                }
                else
                {
                    chr.Defense -= idata.Defense;
                }
            }

            // 武器
            if (Source.ItemID / 100000 == 79 || Source.ItemID / 100000 == 80)
            {
                Attack  = 0;
                Attack += Source.Level1 * 10;
                Attack += Source.Level2 * 9;
                Attack += Source.Level3 * 8;
                Attack += Source.Level4 * 7;
                Attack += Source.Level5 * 6;
                Attack += Source.Level6 * 5;
                Attack += Source.Level7 * 4;
                Attack += Source.Level8 * 3;
                Attack += Source.Level9 * 2;
                Attack += Source.Level10 * 1;
                if (Equiped)
                {
                    chr.Attack        += (short)Attack;
                    chr.MaxAttack     += (short)Attack;
                    chr.UpgradeAttack += (short)Attack;
                }
                else
                {
                    chr.Attack        -= (short)Attack;
                    chr.MaxAttack     -= (short)Attack;
                    chr.UpgradeAttack -= (short)Attack;
                }
            }

            // 衣服
            if (Source.ItemID / 100000 == 81 || Source.ItemID / 100000 == 95)
            {
                int Defense = 0;
                Defense += Source.Level1 * 20;
                Defense += Source.Level2 * 18;
                Defense += Source.Level3 * 16;
                Defense += Source.Level4 * 14;
                Defense += Source.Level5 * 12;
                Defense += Source.Level6 * 10;
                Defense += Source.Level7 * 8;
                Defense += Source.Level8 * 6;
                Defense += Source.Level9 * 4;
                Defense += Source.Level10 * 2;
                if (Equiped)
                {
                    chr.Defense        += (short)Defense;
                    chr.UpgradeDefense += (short)Defense;
                }
                else
                {
                    chr.Defense        -= (short)Defense;
                    chr.UpgradeDefense -= (short)Defense;
                }
            }

            if (chr.Hp > chr.MaxHp)
            {
                chr.Hp = chr.MaxHp;
            }
            if (chr.Mp > chr.MaxMp)
            {
                chr.Mp = chr.MaxMp;
            }

            StatusPacket.UpdateStat(gc);
        }
Example #2
0
        public static void SkillLevelUp_Req(InPacket lea, Client gc)
        {
            byte Type = lea.ReadByte();
            byte Slot = lea.ReadByte();

            var chr = gc.Character;

            if (chr.SkillBonus < 1)
            {
                return;
            }

            List <Skill> s  = chr.Skills.getSkills();
            Skill        sl = null;

            foreach (Skill skill in s)
            {
                if (skill.Type == Type && skill.Slot == Slot)
                {
                    sl = skill;
                    break;
                }
            }

            if (sl == null || (sl.SkillID == 1 && sl.SkillLevel + 1 > 5) || (sl.SkillID == 2 && sl.SkillLevel + 1 > 10) || (sl.SkillID == 3 && sl.SkillLevel + 1 > 20) || (sl.SkillID == 4 && sl.SkillLevel + 1 > 20) || sl.SkillLevel + 1 > 20)
            {
                return;
            }

            chr.SkillBonus--;
            sl.SkillLevel++;

            if (sl.SkillID == 10101 || sl.SkillID == 10201 || sl.SkillID == 10301 || sl.SkillID == 10401 || sl.SkillID == 10501 || sl.SkillID == 10102 || sl.SkillID == 10202 || sl.SkillID == 10302 || sl.SkillID == 10402 || sl.SkillID == 10502)
            {
                if (chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon] != null)
                {
                    int ItemID    = chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID;
                    int MaxAttack = 5;
                    int Attack    = 3;
                    int MaxMagic  = 4;
                    int Magic     = 4;
                    MaxAttack += ((chr.Str - 3) * 2 + chr.Str / 5);
                    MaxAttack += ((chr.Dex - 3) * 2 + chr.Dex / 5);
                    Attack    += ((chr.Dex - 3) * 1 + chr.Dex / 5);
                    MaxMagic  += ((chr.Int - 3) * 2 + chr.Int / 5);
                    Magic     += ((chr.Int - 3) * 2 + chr.Int / 5);

                    // 技能攻擊力+、魔攻力+
                    if (InventoryType.Is劍(ItemID) && sl.SkillID == 10101)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is刀(ItemID) && sl.SkillID == 10102)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is手套(ItemID) && sl.SkillID == 10201)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is爪(ItemID) && sl.SkillID == 10202)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is扇(ItemID) && sl.SkillID == 10301)
                    {
                        chr.MaxMagic -= (short)(MaxMagic * 0.02 * (sl.SkillLevel - 1));
                        chr.Magic    -= (short)(Magic * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxMagic += (short)(MaxMagic * 0.02 * sl.SkillLevel);
                        chr.Magic    += (short)(Magic * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is杖(ItemID) && sl.SkillID == 10302)
                    {
                        chr.MaxMagic -= (short)(MaxMagic * 0.03 * (sl.SkillLevel - 1));
                        chr.Magic    -= (short)(Magic * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxMagic += (short)(MaxMagic * 0.03 * sl.SkillLevel);
                        chr.Magic    += (short)(Magic * 0.03 * sl.SkillLevel);
                    }
                    if (InventoryType.Is斧(ItemID) && sl.SkillID == 10401)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.02 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.02 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.02 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.02 * sl.SkillLevel);
                    }
                    if (InventoryType.Is輪(ItemID) && sl.SkillID == 10402)
                    {
                        chr.MaxAttack -= (short)(MaxAttack * 0.03 * (sl.SkillLevel - 1));
                        chr.Attack    -= (short)(Attack * 0.03 * (sl.SkillLevel - 1));
                        chr.MaxAttack += (short)(MaxAttack * 0.03 * sl.SkillLevel);
                        chr.Attack    += (short)(Attack * 0.03 * sl.SkillLevel);
                    }
                    //if (Skill.ContainsKey(10501) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
                    //{

                    //}
                    //if (Skill.ContainsKey(10502) && InventoryType.Is(chr.Items[InventoryType.ItemType.Equip, (byte)InventoryType.EquipType.Weapon].ItemID))
                    //{

                    //}
                    StatusPacket.UpdateStat(gc);
                }
            }

            SkillPacket.updateSkillLevel(gc, chr.SkillBonus, Type, Slot, sl.SkillLevel);
        }