コード例 #1
0
        public void ParseItemPacket14()
        {
            var bytes  = new byte[] { 0x9C, 0x00, 0x1B, 0x10, 0x87, 0x00, 0x00, 0x00, 0x10, 0x20, 0x80, 0x00, 0x01, 0x6C, 0x94, 0xA8, 0xF0, 0xA3, 0xEC, 0x0D, 0x0D, 0x04, 0xCC, 0xE3, 0xFF, 0xFF, 0x03 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.EssenceOfHatred, packet.Item.Name);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(ClassificationType.Essence, packet.Item.Classification);
        }
コード例 #2
0
        public void ParseItemPacket11()
        {
            var bytes  = new byte[] { 0x9C, 0x04, 0x17, 0x10, 0x1B, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x00, 0x10, 0x22, 0xF6, 0x86, 0x07, 0x82, 0x86, 0xF0, 0x1F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.HoradricCube, packet.Item.Name);
            Assert.Equal(QualityType.Normal, packet.Item.Quality);
            Assert.Equal(ClassificationType.QuestItem, packet.Item.Classification);
            Assert.Empty(packet.Item.Properties);
        }
コード例 #3
0
        public void ParseItemPacket3()
        {
            var bytes  = new byte[] { 0x9D, 0x08, 0x30, 0x10, 0x12, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x50, 0x4A, 0x10, 0xD6, 0x56, 0x07, 0x02, 0xAD, 0x8D, 0x50, 0xC3, 0x32, 0x98, 0x80, 0x59, 0x48, 0x85, 0x48, 0xB0, 0xE2, 0x62, 0x44, 0x60, 0x45, 0x4A, 0xCA, 0x16, 0x23, 0xFF, 0x01 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.Amulet, packet.Item.Name);
            Assert.Equal(ClassificationType.Amulet, packet.Item.Classification);
            Assert.Equal(5, packet.Item.Properties.Count);
            Assert.Equal(23, packet.Item.Properties[StatType.ColdResistance].Value);
            Assert.Equal(35, packet.Item.Properties[StatType.PoisonResistance].Value);
            Assert.Equal(2, packet.Item.Properties[StatType.SorceressSkills].Value);
            Assert.Equal(7, packet.Item.Properties[StatType.ReplenishLife].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MagicalDamageReduction].Value);
        }
コード例 #4
0
        public void ParseItemPacket10()
        {
            var bytes  = new byte[] { 0x9D, 0x05, 0x2D, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x10, 0x46, 0x2A, 0x36, 0x47, 0x07, 0x02, 0x2E, 0xB1, 0x85, 0x29, 0x40, 0x41, 0x59, 0x91, 0x12, 0x71, 0x8D, 0x8E, 0xC1, 0xA6, 0x46, 0x68, 0xA3, 0x42, 0xFC, 0x07 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.BattleStaff, packet.Item.Name);
            Assert.Equal(QualityType.Magical, packet.Item.Quality);
            Assert.Equal(ClassificationType.Staff, packet.Item.Classification);
            Assert.Equal(5, packet.Item.Properties.Count);
            Assert.Equal(2, packet.Item.Properties[StatType.SorceressSkills].Value);
            Assert.Equal(4, packet.Item.Properties[StatType.ReplenishLife].Value);
            Assert.Equal(3, packet.Item.GetValueToSkill(Skill.EnergyShield));
            Assert.Equal(1, packet.Item.GetValueToSkill(Skill.ChainLightning));
            Assert.Equal(2, packet.Item.GetValueToSkill(Skill.StaticField));
        }
コード例 #5
0
        public void ParseItemPacket12()
        {
            var bytes  = new byte[] { 0x9D, 0x15, 0x39, 0x01, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x80, 0x00, 0x01, 0x00, 0x88, 0x28, 0xE7, 0x76, 0x06, 0x82, 0xDA, 0x31, 0x05, 0x3B, 0x68, 0x38, 0x4C, 0xA0, 0x00, 0x45, 0x51, 0x51, 0x58, 0x14, 0x17, 0x25, 0xCB, 0x85, 0x90, 0x39, 0xA1, 0x90, 0x42, 0x61, 0x85, 0x42, 0x0B, 0x05, 0x08, 0x5D, 0xFE, 0x03 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.RingMail, packet.Item.Name);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(ClassificationType.Armor, packet.Item.Classification);
            Assert.Equal(12, packet.Item.Properties.Count);
            Assert.Equal(50, packet.Item.Properties[StatType.DefenseVsMelee].Value);
            Assert.Equal(5, packet.Item.Properties[StatType.MaximumFireResistance].Value);
            Assert.Equal(5, packet.Item.Properties[StatType.MaximumColdResistance].Value);
            Assert.Equal(5, packet.Item.Properties[StatType.MaximumLightningResistance].Value);
            Assert.Equal(5, packet.Item.Properties[StatType.MaximumPoisonResistance].Value);
        }
コード例 #6
0
        public void ParseItemPacket7()
        {
            var bytes  = new byte[] { 0x9D, 0x08, 0x38, 0x05, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x08, 0x80, 0x00, 0x01, 0x90, 0x04, 0x90, 0x73, 0xD6, 0x06, 0x12, 0xAD, 0xE1, 0xBB, 0xF0, 0x03, 0x4B, 0xB0, 0x07, 0xF3, 0x30, 0x02, 0x65, 0x80, 0x57, 0x17, 0x13, 0xDC, 0x88, 0xB0, 0x6A, 0x95, 0x8C, 0x00, 0x41, 0x8A, 0x03, 0x1E, 0x85, 0x0B, 0xC2, 0x7F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.MarteldeFer, packet.Item.Name);
            Assert.Equal(ClassificationType.Hammer, packet.Item.Classification);
            Assert.Equal(6, packet.Item.Properties.Count);
            Assert.Equal(110, packet.Item.Properties[StatType.AttackRating].Value);
            Assert.Equal(171, packet.Item.Properties[StatType.EnhancedMaximumDamage].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumLightningDamage].Value);
            Assert.Equal(8, packet.Item.Properties[StatType.MinimumLightningDamage].MaximumValue);
            Assert.Equal(7, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(5, packet.Item.Properties[StatType.MinimumLifeStolenPerHit].Value);
            Assert.Equal(2, packet.Item.Properties[StatType.SecondaryMinimumDamage].Value);
        }
コード例 #7
0
        public void ParseItemPacket13()
        {
            var bytes  = new byte[] { 0x9D, 0x15, 0x34, 0x05, 0x44, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x80, 0x00, 0x01, 0x00, 0x08, 0x98, 0x77, 0xE7, 0x06, 0x82, 0xE5, 0xB1, 0x00, 0x1E, 0x17, 0x32, 0x82, 0x04, 0x29, 0x50, 0x12, 0xB4, 0xA4, 0x91, 0xAD, 0x51, 0x22, 0xD8, 0x34, 0x09, 0x6D, 0x84, 0x8C, 0x5A, 0x4C, 0xC6, 0x7F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.YewWand, packet.Item.Name);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(ClassificationType.Wand, packet.Item.Classification);
            Assert.Equal(8, packet.Item.Properties.Count);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumLightningDamage].Value);
            Assert.Equal(40, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(3, packet.Item.GetValueToSkill(Skill.AmplifyDamage));
            Assert.Equal(1, packet.Item.GetValueToSkill(Skill.Terror));
            Assert.Equal(2, packet.Item.GetValueToSkill(Skill.CorpseExplosion));
            Assert.Equal(3, packet.Item.GetValueToSkill(Skill.IronMaiden));
        }
コード例 #8
0
        public void ParseItemPacket1()
        {
            var bytes  = new byte[] { 0x9D, 0x05, 0x35, 0x10, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x10, 0x4A, 0x12, 0xD6, 0x56, 0x07, 0x02, 0xAE, 0x0D, 0xD2, 0xC4, 0x5C, 0xB8, 0x88, 0x2F, 0xE8, 0x81, 0x40, 0x48, 0x80, 0x2B, 0x01, 0x60, 0x5A, 0xA1, 0x60, 0x23, 0x20, 0x90, 0x49, 0xD1, 0x21, 0x62, 0xF8, 0x0F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.Amulet, packet.Item.Name);
            Assert.Equal(ClassificationType.Amulet, packet.Item.Classification);
            Assert.Equal(6, packet.Item.Properties.Count);
            Assert.Equal(10, packet.Item.Properties[StatType.ColdResistance].Value);
            Assert.Equal(29, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.BarbarianSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumColdDamage].MinimumValue);
            Assert.Equal(4, packet.Item.Properties[StatType.MinimumColdDamage].MaximumValue);
            Assert.Equal(3, packet.Item.Properties[StatType.DamageReduction].Value);
            Assert.Equal(6, packet.Item.Properties[StatType.Strength].Value);
        }
コード例 #9
0
        public void ParseItemPacket6()
        {
            var bytes  = new byte[] { 0x9D, 0x05, 0x36, 0x05, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x10, 0x04, 0x22, 0x13, 0x86, 0x07, 0x82, 0xA5, 0xE1, 0x3B, 0xF1, 0x07, 0x4B, 0xF0, 0x0B, 0x2B, 0x10, 0x07, 0x53, 0x00, 0xF3, 0x91, 0xE2, 0x41, 0x46, 0x70, 0xE0, 0x8A, 0xBA, 0xC8, 0x4E, 0x3C, 0x58, 0x10, 0xFC, 0x07 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.DoubleAxe, packet.Item.Name);
            Assert.Equal(ClassificationType.Axe, packet.Item.Classification);
            Assert.Equal(31U, packet.Item.Durability);
            Assert.Equal(48U, packet.Item.MaximumDurability);
            Assert.Equal(6, packet.Item.Properties.Count);
            Assert.Equal(15, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumLightningDamage].MinimumValue);
            Assert.Equal(7, packet.Item.Properties[StatType.MinimumLightningDamage].MaximumValue);
            Assert.Equal(2, packet.Item.Properties[StatType.BarbarianSkills].Value);
            Assert.Equal(30, packet.Item.Properties[StatType.IncreasedAttackSpeed].Value);
            Assert.Equal(15, packet.Item.Properties[StatType.FireResistance].Value);
            Assert.Equal(2, packet.Item.Properties[StatType.MaximumDamage].Value);
        }
コード例 #10
0
        public void ParseItemPacket9()
        {
            var bytes  = new byte[] { 0x9D, 0x05, 0x2E, 0x10, 0x13, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x10, 0x0C, 0x4A, 0x77, 0xC6, 0x06, 0x82, 0xE5, 0x91, 0x06, 0x16, 0x48, 0x28, 0xA4, 0x41, 0x6D, 0xC8, 0xF0, 0x13, 0x30, 0x02, 0x0C, 0x3E, 0x50, 0x00, 0xA1, 0xC3, 0x7F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.LightGauntlets, packet.Item.Name);
            Assert.Equal(ClassificationType.Gloves, packet.Item.Classification);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(12U, packet.Item.Defense);
            Assert.Equal(10U, packet.Item.Durability);
            Assert.Equal(18U, packet.Item.MaximumDurability);
            Assert.Equal(6, packet.Item.Properties.Count);
            Assert.Equal(20, packet.Item.Properties[StatType.FasterCastRate].Value);
            Assert.Equal(25, packet.Item.Properties[StatType.ManaRecoveryBonus].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.FireSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumFireDamage].MinimumValue);
            Assert.Equal(6, packet.Item.Properties[StatType.MinimumFireDamage].MaximumValue);
            Assert.Equal(10, packet.Item.Properties[StatType.Defense].Value);
            Assert.Equal(29, packet.Item.Properties[StatType.EnhancedDefense].Value);
        }
コード例 #11
0
        public void ParseItemPacket8()
        {
            var bytes  = new byte[] { 0x9D, 0x08, 0x31, 0x01, 0x29, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x70, 0x70, 0x60, 0x56, 0xC7, 0x06, 0x02, 0xE7, 0xB1, 0x05, 0xAC, 0x18, 0x19, 0x41, 0x30, 0x74, 0x62, 0x24, 0xC5, 0xC8, 0x8A, 0x91, 0x16, 0x23, 0x4E, 0x14, 0x59, 0xEC, 0x09, 0xB2, 0xFF };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.FullPlateMail, packet.Item.Name);
            Assert.Equal(ClassificationType.Armor, packet.Item.Classification);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(162U, packet.Item.Defense);
            Assert.Equal(70U, packet.Item.Durability);
            Assert.Equal(70U, packet.Item.MaximumDurability);
            Assert.Equal(8, packet.Item.Properties.Count);
            Assert.Equal(134, packet.Item.Properties[StatType.EnhancedDefense].Value);
            Assert.Equal(35, packet.Item.Properties[StatType.FireResistance].Value);
            Assert.Equal(35, packet.Item.Properties[StatType.ColdResistance].Value);
            Assert.Equal(35, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(35, packet.Item.Properties[StatType.PoisonResistance].Value);
            Assert.Equal(10, packet.Item.Properties[StatType.AttackerTakesDamage].Value);
            Assert.Equal(2, packet.Item.Properties[StatType.LightRadius].Value);
            Assert.Equal(100, packet.Item.Properties[StatType.ExtraGold].Value);
        }
コード例 #12
0
        public void ParseItemPacket2()
        {
            var bytes  = new byte[] { 0x9C, 0x04, 0x38, 0x07, 0x37, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0x00, 0x04, 0x22, 0x36, 0x87, 0x06, 0x82, 0xAF, 0x21, 0x6C, 0x75, 0x00, 0x31, 0x90, 0x05, 0x29, 0xF1, 0x06, 0x23, 0x90, 0x02, 0x0A, 0x0A, 0x04, 0x0C, 0x14, 0x28, 0x33, 0xB2, 0x13, 0x22, 0x29, 0x26, 0x56, 0x4C, 0xB4, 0x98, 0x00, 0x80, 0x72, 0x62, 0xF8, 0x0F };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.BoneShield, packet.Item.Name);
            Assert.Equal(ClassificationType.Shield, packet.Item.Classification);
            Assert.Equal(31U, packet.Item.Defense);
            Assert.Equal(40U, packet.Item.Durability);
            Assert.Equal(40U, packet.Item.MaximumDurability);
            Assert.Equal(9, packet.Item.Properties.Count);
            Assert.Equal(30, packet.Item.Properties[StatType.FasterBlockRate].Value);
            Assert.Equal(20, packet.Item.Properties[StatType.IncreasedBlocking].Value);
            Assert.Equal(24, packet.Item.Properties[StatType.EnhancedDefense].Value);
            Assert.Equal(34, packet.Item.Properties[StatType.FireResistance].Value);
            Assert.Equal(19, packet.Item.Properties[StatType.ColdResistance].Value);
            Assert.Equal(19, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(19, packet.Item.Properties[StatType.PoisonResistance].Value);
            Assert.Equal(6, packet.Item.Properties[StatType.AttackerTakesDamage].Value);
            Assert.Equal(8, packet.Item.Properties[StatType.Strength].Value);
        }
コード例 #13
0
        public void ParseItemPacket5()
        {
            var bytes  = new byte[] { 0x9D, 0x08, 0x2F, 0x10, 0x12, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x01, 0xF0, 0x30, 0x21, 0x97, 0xE6, 0x06, 0x02, 0xED, 0x95, 0xCE, 0x48, 0x40, 0xD3, 0x64, 0x94, 0x11, 0x30, 0x98, 0x12, 0x2A, 0xA9, 0x12, 0x2B, 0xB9, 0x92, 0x59, 0xA1, 0x95, 0xFF };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.Ring, packet.Item.Name);
            Assert.Equal(ClassificationType.Ring, packet.Item.Classification);
            Assert.Equal(QualityType.Unique, packet.Item.Quality);
            Assert.Equal(11, packet.Item.Properties.Count);
            Assert.Equal(20, packet.Item.Properties[StatType.Mana].Value);
            Assert.Equal(25, packet.Item.Properties[StatType.EnhancedMana].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.MinimumLightningDamage].MinimumValue);
            Assert.Equal(12, packet.Item.Properties[StatType.MinimumLightningDamage].MaximumValue);
            Assert.Equal(1, packet.Item.Properties[StatType.AmazonSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.PaladinSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.NecromancerSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.SorceressSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.BarbarianSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.DruidSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.AssassinSkills].Value);
            Assert.Equal(1, packet.Item.Properties[StatType.AllSkills].Value);
        }
コード例 #14
0
ファイル: GameData.cs プロジェクト: dkuwahara/D2NG
        internal void ItemUpdate(ParseItemPacket packet)
        {
            var item = packet.Item;

            Items[item.Id] = packet.Item;
            switch (item.Action)
            {
            case Action.put_in_container:
                PutInContainer(item);
                break;

            case Action.remove_from_container:
                RemoveFromContainer(item);
                break;

            case Action.add_quantity:
                break;

            default:
                // Do nothing because we don't know
                break;
            }
        }
コード例 #15
0
        public void ParseItemPacket4()
        {
            var bytes  = new byte[] { 0x9D, 0x08, 0x3A, 0x07, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x08, 0x80, 0x00, 0x01, 0xB0, 0x00, 0x80, 0x07, 0xB7, 0x06, 0x12, 0xA7, 0x31, 0x0B, 0x95, 0x08, 0x9D, 0x90, 0x05, 0x0D, 0x20, 0x06, 0x8C, 0xB8, 0xA9, 0x89, 0x16, 0x27, 0x63, 0x4A, 0x27, 0x28, 0x52, 0x50, 0xAC, 0xA0, 0x10, 0x21, 0x50, 0xA0, 0xCC, 0xC8, 0xFE, 0x03 };
            var packet = new ParseItemPacket(new D2gsPacket(bytes));

            Assert.Equal(ItemName.BarbedShield, packet.Item.Name);
            Assert.Equal(ClassificationType.Shield, packet.Item.Classification);
            Assert.Equal(60U, packet.Item.Defense);
            Assert.True(packet.Item.HasSockets);
            Assert.Equal(1U, packet.Item.Sockets);
            Assert.Equal(1U, packet.Item.UsedSockets);
            Assert.Equal(53U, packet.Item.Durability);
            Assert.Equal(55U, packet.Item.MaximumDurability);
            Assert.Equal(8, packet.Item.Properties.Count);
            Assert.Equal(17, packet.Item.Properties[StatType.FasterHitRecovery].Value);
            Assert.Equal(30, packet.Item.Properties[StatType.FasterBlockRate].Value);
            Assert.Equal(20, packet.Item.Properties[StatType.IncreasedBlocking].Value);
            Assert.Equal(20, packet.Item.Properties[StatType.FireResistance].Value);
            Assert.Equal(20, packet.Item.Properties[StatType.ColdResistance].Value);
            Assert.Equal(20, packet.Item.Properties[StatType.LightningResistance].Value);
            Assert.Equal(39, packet.Item.Properties[StatType.PoisonResistance].Value);
            Assert.Equal(2, packet.Item.Properties[StatType.DamageReduction].Value);
        }
コード例 #16
0
        public static void HandleIncomingPacket(D2gsPacket eventArgs)
        {
            if (!Enum.IsDefined(typeof(InComingPacket), eventArgs.Type))
            {
                Log.Information($"Received unknown D2GS packet of type: 0x{(byte)eventArgs.Type,2:X2} with data {eventArgs.Raw.ToPrintString()}");
                return;
            }

            var incomingPacketType = (InComingPacket)eventArgs.Type;

            switch (incomingPacketType)
            {
            case InComingPacket.GameLoading:
            case InComingPacket.GameFlags:
            case InComingPacket.LoadSuccessful:
            case InComingPacket.LoadActComplete:
            case InComingPacket.UnloadActComplete:
            case InComingPacket.GameExitSuccess:
            case InComingPacket.MapHide:
            case InComingPacket.GameHandshake:
            case InComingPacket.PlayerStop:
            case InComingPacket.PlayerToTarget:
            case InComingPacket.ReportKill:
            case InComingPacket.GoldToInventory:
            case InComingPacket.AddExperienceByte:
            case InComingPacket.AddExperienceWord:
            case InComingPacket.AddExperienceDword:
            case InComingPacket.UpdateItemOSkill:
            case InComingPacket.UpdateItemSkill:
            case InComingPacket.SetSkill:
            case InComingPacket.Recv24:
            case InComingPacket.Recv25:
            case InComingPacket.NPCInfo:
            case InComingPacket.NPCTransaction:
            case InComingPacket.PlaySound:
            case InComingPacket.UpdateItemStats:
            case InComingPacket.UseStackableItem:
            case InComingPacket.Recv40:
            case InComingPacket.ClearCursor:
            case InComingPacket.Recv45:
            case InComingPacket.Relator1:
            case InComingPacket.Relator2:
            case InComingPacket.UseSkillOnTarget:
            case InComingPacket.UseSkillOnPoint:
            case InComingPacket.MercForHire:
            case InComingPacket.StartMercList:
            case InComingPacket.Recv50:
            case InComingPacket.QuestLogInfo:
            case InComingPacket.PlayerSlotRefresh:
            case InComingPacket.Recv54:
            case InComingPacket.Recv58:
            case InComingPacket.Recv5E:
            case InComingPacket.Recv5F:
            case InComingPacket.Recv61:
            case InComingPacket.Recv62:
            case InComingPacket.WaypointMenu:
            case InComingPacket.PlayerKillCount:
            case InComingPacket.Recv66:
            case InComingPacket.NPCMove:
            case InComingPacket.NPCMoveToTarget:
            case InComingPacket.Recv6A:
            case InComingPacket.NPCAction:
            case InComingPacket.NPCAttack:
            case InComingPacket.NPCStop:
            case InComingPacket.Recv6E:
            case InComingPacket.Recv6F:
            case InComingPacket.Recv70:
            case InComingPacket.Recv71:
            case InComingPacket.Recv72:
            case InComingPacket.Recv73:
            case InComingPacket.PlayerCorpseAssign:
            case InComingPacket.PlayerInProximity:
            case InComingPacket.ButtonAction:
            case InComingPacket.TradeAccepted:
            case InComingPacket.GoldInTrade:
            case InComingPacket.PetAction:
            case InComingPacket.AssignHotkey:
            case InComingPacket.UseScroll:
            case InComingPacket.SetItemState:
            case InComingPacket.Recv7E:
            case InComingPacket.AllyPartyInfo:
            case InComingPacket.AssignMerc:
            case InComingPacket.Recv86:
            case InComingPacket.SpecialQuestEvent:
            case InComingPacket.NPCWantInteract:
            case InComingPacket.PlayerRelationship:
            case InComingPacket.RelationshipUpdate:
            case InComingPacket.AssignPlayerToParty:
            case InComingPacket.CorpseAssign:
            case InComingPacket.Pong:
            case InComingPacket.PlayerPartyInfo:
            case InComingPacket.Recv91:
            case InComingPacket.Recv92:
            case InComingPacket.Recv93:
            case InComingPacket.Recvad:
            case InComingPacket.Recvb1:
            case InComingPacket.BaseSkillLevels:
            case InComingPacket.WeaponSwitch:
            case InComingPacket.Recv98:
            case InComingPacket.SkillTriggered:
            case InComingPacket.Recv9A:
            case InComingPacket.Recv9B:
            case InComingPacket.MercAttributeByte:
            case InComingPacket.MercAttributeWord:
            case InComingPacket.MercAttributeDword:
            case InComingPacket.AddMercExperienceByte:
            case InComingPacket.AddMercExperienceWord:
            case InComingPacket.Recva3:
            case InComingPacket.Recva4:
            case InComingPacket.ChargeupActive:
            case InComingPacket.DelayedState:
            case InComingPacket.LeaveGameConfirmed:
            case InComingPacket.EndState:
            case InComingPacket.AddUnit:
            case InComingPacket.NPCHeal:
            case InComingPacket.QuestInfo:
            case InComingPacket.GameQuestInfo:
                Log.Debug($"Received D2GS packet of type: {incomingPacketType} with data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.PartyAutomapInfo:
                var playerPartyInfoPacket = new PartyAutomapInfoPacket(eventArgs);
                Log.Information($"PartyAutomapInfo -> ID: {playerPartyInfoPacket.Id} Location: {playerPartyInfoPacket.Location}");
                break;

            case InComingPacket.PortalOwner:
                var portalOwnerPacket = new PortalOwnerPacket(eventArgs);
                Log.Information($"PortalOwner -> ID: {portalOwnerPacket.OwnerId} Name: {portalOwnerPacket.Name} TeleportOurSideId: {portalOwnerPacket.TeleportOurSideId} TeleportOtherSideId: {portalOwnerPacket.TeleportOtherSideId} with data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.AddEntityEffect:
                var addEntityEffectPacket = new AddEntityEffectPacket(eventArgs);
                Log.Information($"AddEntityEffect -> Type: {addEntityEffectPacket.EntityType} with id  {addEntityEffectPacket.EntityId} effect {addEntityEffectPacket.Effect} unknown {addEntityEffectPacket.Unknown1}  with data: {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.AddEntityEffect2:
                var addEntityEffectPacket2 = new AddEntityEffectPacket2(eventArgs);
                Log.Information($"AddEntityEffect2 -> Type: {addEntityEffectPacket2.EntityType} with id  {addEntityEffectPacket2.EntityId} effect {addEntityEffectPacket2.Effect} unknown {addEntityEffectPacket2.Unknown1}  with data: {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.UpdateEntityEffects:
                var removeEntityEffectPacket = new UpdateEntityEffectsPacket(eventArgs);
                Log.Information($"UpdateEntityEffectsPacket -> Type: {removeEntityEffectPacket.EntityType} with id  {removeEntityEffectPacket.EntityId} with effects: {string.Join(",",removeEntityEffectPacket.EntityEffects)} with data: {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.MapReveal:
                var mapRevealPacket = new MapRevealPacket(eventArgs);
                Log.Information($"MapReveal -> At {mapRevealPacket.Area} Loc: {mapRevealPacket.X}, {mapRevealPacket.Y}");
                break;

            case InComingPacket.NPCHit:
                var npcHitPacket = new NpcHitPacket(eventArgs);
                Log.Information($"NPC Hit -> EntityId: {npcHitPacket.EntityId} Type: {npcHitPacket.EntityType} LifePercentage: {npcHitPacket.LifePercentage} data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.AssignLevelWarp:
                var assignLevelWarpPacket = new AssignLevelWarpPacket(eventArgs);
                Log.Information($"AssignLevelWarp -> EntityId: {assignLevelWarpPacket.EntityId} Loc: {assignLevelWarpPacket.Location} WarpId: {assignLevelWarpPacket.WarpId} data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.LoadAct:
                var loadActPacket = new ActDataPacket(eventArgs);
                Log.Information($"LoadAct -> Act: {loadActPacket.Act} Area: {loadActPacket.Area} MapId: {loadActPacket.MapId}");
                break;

            case InComingPacket.AddAttributeByte:
            case InComingPacket.AddAttributeWord:
            case InComingPacket.AddAttributeDword:
                var addAttributePacket = new BaseAttributePacket(eventArgs);
                Log.Information($"AddAttribute -> {addAttributePacket.Attribute} {addAttributePacket.Value}");
                break;

            case InComingPacket.AssignNPC2:
                var assignNpcPacket = new AssignNpcPacket(eventArgs);
                Log.Information($"AssignNPC2 -> ID: {assignNpcPacket.EntityId} Unique Code: {assignNpcPacket.UniqueCode} Boss: {assignNpcPacket.IsBoss} BossMinion: {assignNpcPacket.IsBossMinion} Champ: {assignNpcPacket.IsChampion} Location: {assignNpcPacket.Location} Enchantments: {string.Join(",", assignNpcPacket.MonsterEnchantments)} data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.AssignNPC1:
                var assignTownNpcPacket = new AssignNpcPacket(eventArgs);
                Log.Information($"AssignNPC1 -> ID: {assignTownNpcPacket.EntityId} Unique Code: {assignTownNpcPacket.UniqueCode} Location: {assignTownNpcPacket.Location} data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.NPCState:
                var npcStatePacket = new NpcStatePacket(eventArgs);
                Log.Information($"NPCState -> ID: {npcStatePacket.EntityId} State: {npcStatePacket.EntityState} Location: {npcStatePacket.Location}");
                break;

            case InComingPacket.ObjectState:
                var objectStatePacket = new ObjectStatePacket(eventArgs);
                Log.Debug($"ObjectState -> ID: {objectStatePacket.ObjectId} Type: {objectStatePacket.ObjectType} State: {objectStatePacket.State}");
                break;

            case InComingPacket.RemoveObject:
                var removeObjectPacket = new RemoveObjectPacket(eventArgs);
                Log.Debug($"RemoveObject -> ID: {removeObjectPacket.EntityId} Type: {removeObjectPacket.EntityType}");
                break;

            case InComingPacket.AssignObject:
                var assignObjectPacket = new AssignObjectPacket(eventArgs);
                Log.Debug($"AssignObject -> ID: {assignObjectPacket.EntityId} Code: {assignObjectPacket.ObjectCode} Type: {assignObjectPacket.EntityType} Location: {assignObjectPacket.Location} with data {eventArgs.Raw.ToPrintString()}");
                break;

            case InComingPacket.ReassignPlayer:
                var reassignPlayerPacket = new ReassignPlayerPacket(eventArgs);
                Log.Information($"ReassignPlayer -> UnitType: {reassignPlayerPacket.UnitType} UnitId: {reassignPlayerPacket.UnitId} Location: {reassignPlayerPacket.Location}");
                break;

            case InComingPacket.AssignPlayer:
                var assignPlayerPacket = new AssignPlayerPacket(eventArgs);
                Log.Information($"AssignPlayer -> Id: {assignPlayerPacket.Id} Name: {assignPlayerPacket.Name} Location: {assignPlayerPacket.Location}");
                break;

            case InComingPacket.LifeManaUpdatePot:
                var LifeManaUpdatePotPacket = new LifeManaPotUpdatePacket(eventArgs);
                Log.Information($"LifeManaUpdatePot -> Life: {LifeManaUpdatePotPacket.Life} Mana: {LifeManaUpdatePotPacket.Mana} Location: {LifeManaUpdatePotPacket.Location}");
                break;

            case InComingPacket.LifeManaUpdate:
                var lifeManaUpdatePacket = new LifeManaUpdatePacket(eventArgs);
                Log.Information($"LifeManaUpdate -> Life: {lifeManaUpdatePacket.Life} Mana: {lifeManaUpdatePacket.Mana} Location: {lifeManaUpdatePacket.Location}");
                break;

            case InComingPacket.WorldItemAction:
            case InComingPacket.OwnedItemAction:
                var parseItemPacket = new ParseItemPacket(eventArgs);
                Log.Information($"{incomingPacketType} -> Id: {parseItemPacket.Item.Id} ({parseItemPacket.Item.Level}) Action: {parseItemPacket.Item.Action} Container: {parseItemPacket.Item.Container} Quality: {parseItemPacket.Item.Quality} Name: {parseItemPacket.Item.Name} Type: {parseItemPacket.Item.Type} Location: {parseItemPacket.Item.Location} u1 {parseItemPacket.Item.PlayerId} print: {parseItemPacket.Raw.ToPrintString()} with description {parseItemPacket.Item.GetFullDescription()}");
                break;

            case InComingPacket.ReceiveChat:
                var chatPacket = new ChatPacket(eventArgs);
                Log.Information($"ChatPacket -> Character: {chatPacket.CharacterName} Message: {chatPacket.Message}");
                break;

            case InComingPacket.WalkVerify:
                var walkVerifyPacket = new WalkVerifyPacket(eventArgs);
                Log.Information($"WalkVerify -> Location: {walkVerifyPacket.Location}");
                break;

            case InComingPacket.PlayerInGame:
                var playerInGamePacket = new PlayerInGamePacket(eventArgs);
                Log.Information($"PlayerInGame -> Id: {playerInGamePacket.Id} Name: {playerInGamePacket.Name} Class: {playerInGamePacket.Class}");
                break;

            case InComingPacket.PlayerLeftGame:
                var playerLeftGamePacket = new PlayerLeftGamePacket(eventArgs);
                Log.Information($"PlayerLeftGame -> Id: {playerLeftGamePacket.Id}");
                break;

            case InComingPacket.TownPortalState:
            case InComingPacket.EntityMove:
            case InComingPacket.EventMessage:
            case InComingPacket.QuestItemState:
            case InComingPacket.WardenRequest:
            case InComingPacket.GameDropped:
            case InComingPacket.IPBan:
            case InComingPacket.AttributeUpdate:
                Log.Information($"Received D2GS packet of type: {incomingPacketType} with data {eventArgs.Raw.ToPrintString()}");
                break;

            default:
                Log.Information($"Received Unknown D2GS packet of type: {incomingPacketType} with data {eventArgs.Raw.ToPrintString()}");
                break;
            }
        }
コード例 #17
0
ファイル: Game.cs プロジェクト: perryh/Diablo2Clientless1.09
        internal Game(GameServer gameServer)
        {
            _gameServer = gameServer;

            _gameServer.OnReceivedPacketEvent(InComingPacket.GameLoading, _ =>
            {
                if (IsInGame())
                {
                    Log.Information($"{Data?.Me?.Name}: Game loading..., About to drop, leaving game");
                    LeaveGame();
                }
            }
                                              );
            _gameServer.OnReceivedPacketEvent(InComingPacket.GameFlags, p => Initialize(new GameFlags(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.LoadAct, p => Data.Act.LoadActData(new ActDataPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.MapReveal, p => Data.Act.HandleMapRevealPacket(new MapRevealPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AssignLevelWarp, p => Data.Act.AddWarp(new AssignLevelWarpPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.GameHandshake, p => new GameHandshakePacket(p));
            _gameServer.OnReceivedPacketEvent(InComingPacket.NPCHit, p => Data.Act.UpdateNPCOnHit(new NpcHitPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.EntityMove, p => Data.EntityMove(new EntityMovePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AssignPlayer, p => Data.PlayerAssign(new AssignPlayerPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.ReassignPlayer, p => { var packet = new ReassignPlayerPacket(p);  Data.ReassignPlayer(packet.UnitId, packet.Location); });
            _gameServer.OnReceivedPacketEvent(InComingPacket.PartyAutomapInfo, p => { var packet = new PartyAutomapInfoPacket(p); Data.ReassignPlayer(packet.Id, packet.Location); });
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddExperienceByte, p => Data.AddExperience(new AddExpPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddExperienceWord, p => Data.AddExperience(new AddExpPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddExperienceDword, p => Data.AddExperience(new AddExpPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddAttributeByte, p => Data.SetAttribute(new BaseAttributePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddAttributeWord, p => Data.SetAttribute(new BaseAttributePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddAttributeDword, p => Data.SetAttribute(new BaseAttributePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.UpdateItemOSkill, p => Data.SetItemSkill(new SetItemSkillPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.UpdateItemSkill, p => Data.SetItemSkill(new SetItemSkillPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.SetSkill, p => Data.SetActiveSkill(new SetActiveSkillPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.QuestInfo, p => new QuestInfoPacket(p));
            _gameServer.OnReceivedPacketEvent(InComingPacket.GameQuestInfo, p => new GameQuestInfoPacket(p));
            _gameServer.OnReceivedPacketEvent(InComingPacket.ObjectState, p => Data.Act.UpdateObjectState(new ObjectStatePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.NPCState, p => Data.Act.UpdateNPCState(new NpcStatePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.NPCMove, p => { var packet = new NPCMovePacket(p); Data.Act.UpdateNPCLocation(packet.EntityId, packet.Location); });
            _gameServer.OnReceivedPacketEvent(InComingPacket.NPCStop, p => { var packet = new NPCStopPacket(p); Data.Act.UpdateNPCLocation(packet.EntityId, packet.Location); });
            _gameServer.OnReceivedPacketEvent(InComingPacket.AssignNPC2, p => Data.Act.AddNPC(new AssignNpcPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AssignNPC1, p => Data.Act.AddNPC(new AssignNpcPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.TownPortalState, p => Data.Act.UpdateTownPortal(new TownPortalStatePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.PortalOwner, p => Data.Act.UpdateTownPortalOwner(new PortalOwnerPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AssignObject, p => Data.Act.AddWorldObject(new AssignObjectPacket(p).AsWorldObject()));
            _gameServer.OnReceivedPacketEvent(InComingPacket.RemoveObject, p => Data.RemoveObject(new RemoveObjectPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.PlayerInGame, p => Data.PlayerJoin(new PlayerInGamePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.PlayerLeftGame, p => Data.PlayerLeave(new PlayerLeftGamePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.BaseSkillLevels, p => Data.SetSkills(new BaseSkillLevelsPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.LifeManaUpdatePot, p => Data.UpdateSelf(new LifeManaPotUpdatePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.Pong, _ => { lastPong = DateTime.Now; });
            _gameServer.OnReceivedPacketEvent(InComingPacket.LifeManaUpdate, p => Data.UpdateSelf(new LifeManaUpdatePacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.WorldItemAction, p =>
            {
                var itemPacket = new ParseItemPacket(p);
                Data.ItemUpdate(itemPacket);
                ItemDroppedHandler?.Invoke(itemPacket.Item);
            });
            _gameServer.OnReceivedPacketEvent(InComingPacket.OwnedItemAction, p =>
            {
                var itemPacket = new ParseItemPacket(p);
                Data.ItemUpdate(itemPacket);
                ItemOwnedHandler?.Invoke(itemPacket.Item);
            });
            _gameServer.OnReceivedPacketEvent(InComingPacket.WaypointMenu, p => Data.UpdateWaypointInfo(new WaypointMenuPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.WalkVerify, p => CheckAndPreventDesync(new WalkVerifyPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddEntityEffect, p => Data.AddEntityEffect(new AddEntityEffectPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.AddEntityEffect2, p => Data.AddEntityEffect2(new AddEntityEffectPacket2(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.UpdateEntityEffects, p => Data.UpdateEntityEffects(new UpdateEntityEffectsPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.CorpseAssign, p => Data.PlayerCorpseAssign(new CorpseAssignPacket(p)));
            _gameServer.OnReceivedPacketEvent(InComingPacket.PlayerStop, p => Data.PlayerStop(new PlayerStopPacket(p)));
        }