コード例 #1
0
ファイル: ItemPackets.cs プロジェクト: Kaioru/Edelstein
        private static void WriteItemPetData(this IPacketWriter p, ItemSlotPet i)
        {
            p.WriteByte(3);

            p.WriteItemBase(i);

            p.WriteString(i.PetName, 13);
            p.WriteByte(i.Level);
            p.WriteShort(i.Tameness);
            p.WriteByte(i.Repleteness);

            if (i.DateDead == null)
            {
                p.WriteLong(0);
            }
            else
            {
                p.WriteDateTime(i.DateDead.Value);
            }

            p.WriteShort(i.PetAttribute);
            p.WriteShort(i.PetSkill);
            p.WriteInt(i.RemainLife);
            p.WriteShort(i.Attribute);
        }
コード例 #2
0
ファイル: CharacterPackets.cs プロジェクト: Kaioru/Edelstein
 public static void WriteCharacterExtendSP(this IPacketWriter p, Character c)
 {
     p.WriteByte((byte)c.ExtendSP.Count);
     c.ExtendSP.ForEach(kv =>
     {
         p.WriteByte(kv.Key);
         p.WriteByte(kv.Value);
     });
 }
コード例 #3
0
 public void Write(IPacketWriter writer)
 {
     writer.WriteInt32(ClassId);
     writer.WriteFloat(FamePoints);
     writer.WriteFloat(PepPoints);
     writer.WriteFloat(Health);
     writer.WriteInt32(SelectedSkilldeckID);
     writer.WriteByte(ExtraBodyPoints);
     writer.WriteByte(ExtraMindPoints);
     writer.WriteByte(ExtraFocusPoints);
     writer.WriteByte(0); //mAvailableAttributePoints
 }
コード例 #4
0
 public void WriteLoginStream(IPacketWriter writer)
 {
     writer.WriteVector(Velocity);
     writer.WriteVector3(transform.position);
     writer.WriteByte((byte)Physics);
     writer.WriteByte(mMoveFrameID);
     writer.WriteByte((byte)GetState());
     writer.WriteInt32(bInvulnerable ? 1 : 0);
     writer.WriteFloat(GroundSpeedModifier);
     writer.WriteInt32(mDebugFilters);
     writer.WriteInt32(Visibility);
 }
コード例 #5
0
 public override void WriteAddStream(IPacketWriter writer)
 {
     writer.WriteVector(Velocity);
     writer.WriteVector3(transform.position);
     writer.WriteByte((byte)Physics);
     writer.WriteByte(mMoveFrameID);
     writer.WriteFloat(mPvPTimer);
     writer.WriteByte((byte)GetState());
     writer.WriteInt32(bInvulnerable ? 1 : 0);
     writer.WriteFloat(GroundSpeedModifier);
     writer.WriteInt32(mDebugFilters);
     writer.WriteInt32(Visibility); //bitfield hasPet invisible jumpedfromladder?
 }
コード例 #6
0
ファイル: DB_Item.cs プロジェクト: Flavelius/SBServer
 public void Write(IPacketWriter writer)
 {
     writer.WriteInt32(Id);
     writer.WriteInt32(ItemTypeID);
     writer.WriteByte(LocationType);
     writer.WriteInt32(LocationID);
     writer.WriteInt32(LocationSlot);
     writer.WriteInt32(CharacterID);
     writer.WriteInt32(StackSize);
     writer.WriteByte(Attuned);
     writer.WriteByte(Color1);
     writer.WriteByte(Color2);
     writer.WriteInt32(Serial);
 }
コード例 #7
0
 public void WriteLoginStream(IPacketWriter writer)
 {
     writer.WriteFloat(mFamePoints);
     writer.WriteFloat(mPePPoints);
     writer.WriteInt32(0); //mMayChooseClass ? (bitfield):0
     writer.WriteByte(mAvailableAttributePoints);
     writer.WriteFloat(mHealth);
     writer.WriteByte(0); //Camera mode (?)
     writer.WriteInt32(mMovementSpeed);
     writer.Write(mRecord);
     writer.WriteInt32(mStateRankShift);
     writer.WriteInt32(mExtraBodyPoints);  //not sure
     writer.WriteInt32(mExtraMindPoints);  //not sure
     writer.WriteInt32(mExtraFocusPoints); //not sure
 }
コード例 #8
0
        public static void WriteSecondaryStatsToLocal(this IPacketWriter writer, ISecondaryStats secondary)
        {
            var stats = secondary.ToDictionary();
            var now   = DateTime.UtcNow;

            writer.WriteSecondaryStatsFlag(stats);

            SecondaryStatsOrder.WriteOrderLocal.ForEach(t =>
            {
                if (!secondary.HasStat(t))
                {
                    return;
                }

                var stat      = stats[t];
                var remaining = stat.DateExpire.HasValue ? (stat.DateExpire.Value - now).TotalMilliseconds : int.MaxValue;

                writer.WriteShort((short)stat.Value);
                writer.WriteInt(stat.Reason);
                writer.WriteInt((int)remaining);
            });

            writer.WriteByte(0); // nDefenseAtt
            writer.WriteByte(0); // nDefenseState

            if (
                secondary.HasStat(SecondaryStatType.SwallowAttackDamage) &&
                secondary.HasStat(SecondaryStatType.SwallowDefence) &&
                secondary.HasStat(SecondaryStatType.SwallowCritical) &&
                secondary.HasStat(SecondaryStatType.SwallowMaxMP) &&
                secondary.HasStat(SecondaryStatType.SwallowEvasion)
                )
            {
                writer.WriteByte(0);
            }

            if (secondary.HasStat(SecondaryStatType.Dice))
            {
                writer.WriteBytes(new byte[22]);
            }

            if (secondary.HasStat(SecondaryStatType.BlessingArmor))
            {
                writer.WriteInt(0);
            }

            // TODO: TWOSTATE
        }
コード例 #9
0
 private byte[] ConvertRequestToByteArray(RegisterResultRequest request)
 {
     _packetWriter.WriteByte(request.PacketId);
     _packetWriter.WriteString(request.Nickname);
     _packetWriter.WriteBool(request.Registered);
     return(_packetWriter.GetBytes());
 }
コード例 #10
0
 public void WriteAddStream(IPacketWriter writer)
 {
     writer.WriteFloat(mHealth);
     writer.WriteByte(mFrozenFlags);
     writer.WriteInt32(mMovementSpeed);
     writer.WriteInt32(mStateRankShift);
 }
コード例 #11
0
        private byte[] ConvertRequestToByteArray(RegisterRequest request, string nickname)
        {
            _packetWriter.WriteByte(request.PacketId);
            _packetWriter.WriteGuid(request.UniqueId);
            _packetWriter.WriteString(nickname);

            return(_packetWriter.GetBytes());
        }
コード例 #12
0
        public void WriteToPacket(IPacketWriter writer)
        {
            writer.WritePoint2D(_position);
            writer.WritePoint2D(_vPosition);

            writer.WriteByte((byte)_fragments.Count);
            _fragments.ForEach(f => writer.Write(f));
        }
コード例 #13
0
        public void WriteToPacket(IPacketWriter writer)
        {
            var history = History
                          .OfType <AbstractModifyInventoryOperation>()
                          .OrderBy(o => o.Timestamp)
                          .ToList();

            writer.WriteByte((byte)history.Count);
            history.ForEach(o => writer.Write(o));
        }
コード例 #14
0
 public void WriteLoginStream(IPacketWriter writer) //TODO unpack db data and use that
 {
     Debug.LogWarning("TODO unpack db data and use that");
     writer.Write(SkilldeckSkills, (index, skill) =>
     {
         writer.WriteInt32(0);          //skilldeck id?
         writer.WriteInt32(skill != null ? skill.GetResourceId() : 0);
         writer.WriteByte((byte)index); //deckslot
     });
 }
コード例 #15
0
        public static void WriteSecondaryStatsToRemote(this IPacketWriter writer, ISecondaryStats secondary)
        {
            var stats = secondary.ToDictionary();

            writer.WriteSecondaryStatsFlag(stats);

            SecondaryStatsOrder.WriteOrderRemote.ForEach(kv =>
            {
                if (!secondary.HasStat(kv.Key))
                {
                    return;
                }
                kv.Value.Invoke(stats[kv.Key], writer);
            });

            writer.WriteByte(0); // nDefenseAtt
            writer.WriteByte(0); // nDefenseState

            // TODO: TWOSTATE
        }
コード例 #16
0
ファイル: Game_NPCPawn.cs プロジェクト: Flavelius/SBServer
 public override void WriteAddStream(IPacketWriter writer)
 {
     writer.WriteInt32(CharacterStats.mRecord.MaxHealth);
     writer.WriteFloat(CharacterStats.mRecord.Physique);
     writer.WriteFloat(CharacterStats.mRecord.Morale);
     writer.WriteFloat(CharacterStats.mRecord.Concentration);
     writer.WriteInt32(NPCFameLevel);
     writer.WriteInt32(NPCPePRank);
     writer.WriteInt32(NPCType.GetResourceId());
     writer.Write(RelatedQuestsIds, writer.WriteInt32);
     writer.WriteVector3(transform.position);
     writer.WriteByte((byte)mMovementFlags);
     writer.WriteInt32(mNetFocus != null ? mNetFocus.GetRelevanceID() : -1);
     writer.WriteVector(mNetFocusLocation);
     writer.WriteRotator(mDefaultRotation);
     writer.WriteByte((byte)mCurrentState); //probably mNetState
     writer.WriteInt32(bInvulnerable ? 0 : 1);
     writer.WriteFloat(GroundSpeedModifier);
     writer.WriteInt32(mDebugFilters);
     writer.WriteInt32(Visibility);
 }
コード例 #17
0
        public void WriteData(IPacketWriter writer)
        {
            writer.WriteInt(Info.ID);

            writer.WritePoint2D(Position);
            writer.WriteByte((byte)Action);
            writer.WriteShort((short)(Foothold?.ID ?? 0));

            writer.WriteShort((short)RX0);
            writer.WriteShort((short)RX1);

            writer.WriteBool(true); // enabled
        }
コード例 #18
0
        public static void WriteGuildData(this IPacketWriter writer, IGuild g)
        {
            writer.WriteInt(g.ID);
            writer.WriteString(g.Name);

            for (var i = 0; i < 6; i++)
            {
                if (i < g.Grade.Length)
                {
                    writer.WriteString(g.Grade[i]);
                }
                else
                {
                    writer.WriteString(string.Empty);
                }
            }

            writer.WriteByte((byte)g.Members.Count);

            g.Members.ForEach(m => writer.WriteInt(m.ID));
            g.Members.ForEach(m => writer.WriteGuildMemberData(m));

            writer.WriteInt(g.MaxMemberNum);

            writer.WriteShort(g.MarkBg);
            writer.WriteByte(g.MarkBgColor);
            writer.WriteShort(g.Mark);
            writer.WriteByte(g.MarkColor);

            writer.WriteString(g.Notice);
            writer.WriteInt(g.Point);

            writer.WriteInt(0); // Alliance

            writer.WriteByte(g.Level);

            writer.WriteShort(0); // GuildSkills
        }
コード例 #19
0
ファイル: ItemPackets.cs プロジェクト: Kaioru/Edelstein
        private static void WriteItemBundleData(this IPacketWriter p, ItemSlotBundle i)
        {
            p.WriteByte(2);

            p.WriteItemBase(i);

            p.WriteShort(i.Number);
            p.WriteString(i.Title);
            p.WriteShort(i.Attribute);

            if ((i.TemplateID / 10000) == 207 || (i.TemplateID / 10000) == 233) // TODO: constants, recharge items
            {
                p.WriteLong(0);
            }
        }
コード例 #20
0
ファイル: DB_Character.cs プロジェクト: Flavelius/SBServer
 public void Write(IPacketWriter writer)
 {
     writer.WriteInt32(Id);
     writer.WriteByte(Dead);
     writer.WriteInt32(AccountID);
     writer.WriteString(Name);
     writer.WriteVector(Location);
     writer.WriteInt32(worldID);
     writer.WriteInt32(Money);
     writer.WriteInt32(AppearancePart1);
     writer.WriteInt32(AppearancePart2);
     writer.WriteRotator(Rotation);
     writer.WriteInt32(FactionId);
     writer.WriteInt32(LastUsedTimestamp);
 }
コード例 #21
0
        private byte[] ConvertRequestToByteArray(OutgoingMessageRequest request)
        {
            var reponseRequest = new IncomingMessageRequest(request.Nickname, request.Message, request.Destination, request.PrivateMessage);

            _packetWriter.WriteByte(reponseRequest.PacketId);
            _packetWriter.WriteString(reponseRequest.Nickname);
            _packetWriter.WriteString(reponseRequest.Message);
            _packetWriter.WriteBool(reponseRequest.Destination != null);
            if (reponseRequest.Destination != null)
            {
                _packetWriter.WriteString(reponseRequest.Destination);
                _packetWriter.WriteBool(reponseRequest.PrivateMessage);
            }
            return(_packetWriter.GetBytes());
        }
コード例 #22
0
ファイル: ItemPackets.cs プロジェクト: Kaioru/Edelstein
        private static void WriteItemEquipData(this IPacketWriter p, ItemSlotEquip i)
        {
            p.WriteByte(1);

            p.WriteItemBase(i);

            p.WriteByte(i.RUC);
            p.WriteByte(i.CUC);

            p.WriteShort(i.STR);
            p.WriteShort(i.DEX);
            p.WriteShort(i.INT);
            p.WriteShort(i.LUK);
            p.WriteShort(i.MaxHP);
            p.WriteShort(i.MaxMP);
            p.WriteShort(i.PAD);
            p.WriteShort(i.MAD);
            p.WriteShort(i.PDD);
            p.WriteShort(i.MDD);
            p.WriteShort(i.ACC);
            p.WriteShort(i.EVA);

            p.WriteShort(i.Craft);
            p.WriteShort(i.Speed);
            p.WriteShort(i.Jump);
            p.WriteString(i.Title);
            p.WriteShort(i.Attribute);

            p.WriteByte(i.LevelUpType);
            p.WriteByte(i.Level);
            p.WriteInt(i.EXP);
            p.WriteInt(i.Durability);

            p.WriteInt(i.IUC);

            p.WriteByte(i.Grade);
            p.WriteByte(i.CHUC);

            p.WriteShort(i.Option1);
            p.WriteShort(i.Option2);
            p.WriteShort(i.Option3);
            p.WriteShort(i.Socket1);
            p.WriteShort(i.Socket2);

            if (!i.CashItemSN.HasValue)
            {
                p.WriteLong(0);
            }
            p.WriteLong(0);
            p.WriteInt(0);
        }
コード例 #23
0
ファイル: CharacterPackets.cs プロジェクト: Kaioru/Edelstein
        public static void WriteCharacterStats(this IPacketWriter p, Character c)
        {
            p.WriteInt(c.ID);
            p.WriteString(c.Name, 13);

            p.WriteByte(c.Gender);
            p.WriteByte(c.Skin);
            p.WriteInt(c.Face);
            p.WriteInt(c.Hair);

            c.Pets.ForEach(sn => p.WriteLong(sn));

            p.WriteByte(c.Level);
            p.WriteShort(c.Job);
            p.WriteShort(c.STR);
            p.WriteShort(c.DEX);
            p.WriteShort(c.INT);
            p.WriteShort(c.LUK);
            p.WriteInt(c.HP);
            p.WriteInt(c.MaxHP);
            p.WriteInt(c.MP);
            p.WriteInt(c.MaxMP);

            p.WriteShort(c.AP);
            if (GameConstants.IsExtendSPJob(c.Job)) p.WriteCharacterExtendSP(c);
            else p.WriteShort(c.SP);

            p.WriteInt(c.EXP);
            p.WriteShort(c.POP);

            p.WriteInt(c.TempEXP);
            p.WriteInt(c.FieldID);
            p.WriteByte(c.FieldPortal);
            p.WriteInt(c.PlayTime);
            p.WriteShort(c.SubJob);
        }
コード例 #24
0
        private byte[] ConvertRequestToByteArray(OutgoingMessageRequest request)
        {
            _packetWriter.WriteByte(request.PacketId);
            _packetWriter.WriteString(request.Nickname);

            if (request.Message.StartsWith("/p") || request.Message.StartsWith("/m"))
            {
                WriteTargetedMessages(request);
            }
            else
            {
                WriteGlobalMessage(request);
            }

            return(_packetWriter.GetBytes());
        }
コード例 #25
0
ファイル: CharacterPackets.cs プロジェクト: Kaioru/Edelstein
        public static void WriteCharacterLook(this IPacketWriter p, Character c)
        {
            p.WriteByte(c.Gender);
            p.WriteByte(c.Skin);
            p.WriteInt(c.Face);

            p.WriteBool(false);
            p.WriteInt(c.Hair);

            var inventory = c.Inventories[ItemInventoryType.Equip];
            var equipped = inventory.Items
                .Where(kv => kv.Key < 0)
                .ToDictionary();
            var stickers = equipped
                .Select(kv => equipped.ContainsKey((short)(kv.Key - 100))
                    ? new KeyValuePair<short, AbstractItemSlot>(kv.Key, equipped[(short)(kv.Key - 100)])
                    : kv)
                .ToDictionary();
            var unseen = equipped
                .Except(stickers)
                .ToDictionary(
                    kv => kv.Key <= -100 ? kv.Key - 100 : kv.Key,
                    kv => kv.Value
                );

            stickers.ForEach(kv =>
            {
                p.WriteByte((byte)Math.Abs(kv.Key));
                p.WriteInt(kv.Value.TemplateID);
            });
            p.WriteByte(0xFF);

            unseen.ForEach(kv =>
            {
                p.WriteByte((byte)Math.Abs(kv.Key));
                p.WriteInt(kv.Value.TemplateID);
            });
            p.WriteByte(0xFF);

            p.WriteInt(inventory.Items.ContainsKey(-111)
                ? inventory.Items[-111].TemplateID
                : 0);

            for (var i = 0; i < 3; i++)
                p.WriteInt(0);
        }
コード例 #26
0
ファイル: Game_NPCPawn.cs プロジェクト: Flavelius/SBServer
 public void Write(IPacketWriter writer)
 {
     writer.WriteVector(Destination);
     writer.WriteByte((byte)flags);
 }
コード例 #27
0
ファイル: CharacterPackets.cs プロジェクト: Kaioru/Edelstein
        public static void WriteCharacterData(this IPacketWriter p, Character c, CharacterDataFlags flags = CharacterDataFlags.All)
        {
            p.WriteLong((long)flags);
            p.WriteByte(0);
            p.WriteByte(0);

            if (flags.HasFlag(CharacterDataFlags.Character))
            {
                p.WriteCharacterStats(c);

                p.WriteByte(250); // nFriendMax
                p.WriteBool(false);
            }

            if (flags.HasFlag(CharacterDataFlags.Money)) p.WriteInt(c.Money);

            if (flags.HasFlag(CharacterDataFlags.InventorySize))
            {
                if (flags.HasFlag(CharacterDataFlags.ItemSlotEquip))
                    p.WriteByte((byte)c.Inventories[ItemInventoryType.Equip].SlotMax);
                if (flags.HasFlag(CharacterDataFlags.ItemSlotConsume))
                    p.WriteByte((byte)c.Inventories[ItemInventoryType.Consume].SlotMax);
                if (flags.HasFlag(CharacterDataFlags.ItemSlotInstall))
                    p.WriteByte((byte)c.Inventories[ItemInventoryType.Install].SlotMax);
                if (flags.HasFlag(CharacterDataFlags.ItemSlotEtc))
                    p.WriteByte((byte)c.Inventories[ItemInventoryType.Etc].SlotMax);
                if (flags.HasFlag(CharacterDataFlags.ItemSlotCash))
                    p.WriteByte((byte)c.Inventories[ItemInventoryType.Cash].SlotMax);
            }

            if (flags.HasFlag(CharacterDataFlags.AdminShopCount))
            {
                p.WriteInt(0);
                p.WriteInt(0);
            }

            if (flags.HasFlag(CharacterDataFlags.ItemSlotEquip))
            {
                var inventory = c.Inventories[ItemInventoryType.Equip].Items;
                var equip = inventory.Where(kv => kv.Key >= 0);
                var equipped = inventory.Where(kv => kv.Key >= -100 && kv.Key < 0);
                var equipped2 = inventory.Where(kv => kv.Key >= -1000 && kv.Key < -100);
                var dragonEquipped = inventory.Where(kv => kv.Key >= -1100 && kv.Key < -1000);
                var mechanicEquipped = inventory.Where(kv => kv.Key >= -1200 && kv.Key < -1100);

                new List<IEnumerable<KeyValuePair<short, AbstractItemSlot>>>
                    {
                        equipped, equipped2, equip, dragonEquipped, mechanicEquipped
                    }
                    .ForEach(e =>
                    {
                        e.ForEach(kv =>
                        {
                            p.WriteShort((short)(Math.Abs(kv.Key) % 100));
                            p.WriteItemData(kv.Value);
                        });
                        p.WriteShort(0);
                    });
            }

            new List<(CharacterDataFlags, ItemInventoryType)>
                {
                    (CharacterDataFlags.ItemSlotConsume, ItemInventoryType.Consume),
                    (CharacterDataFlags.ItemSlotInstall, ItemInventoryType.Install),
                    (CharacterDataFlags.ItemSlotEtc, ItemInventoryType.Etc),
                    (CharacterDataFlags.ItemSlotCash, ItemInventoryType.Cash)
                }
                .Where(t => flags.HasFlag(t.Item1))
                .ForEach(t =>
                {
                    var inventory = c.Inventories[t.Item2].Items;

                    inventory.ForEach(kv =>
                    {
                        p.WriteByte((byte)kv.Key);
                        p.WriteItemData(kv.Value);
                    });
                    p.WriteByte(0);
                });

            if (flags.HasFlag(CharacterDataFlags.SkillRecord))
            {
                p.WriteShort((short)c.SkillRecord.Count);

                c.SkillRecord.ForEach(kv =>
                {
                    p.WriteInt(kv.Key);
                    p.WriteInt(kv.Value.Level);
                    p.WriteDateTime(kv.Value.DateExpire ?? GameConstants.Permanent);

                    if (GameConstants.IsSkillNeedMasterLevel(kv.Key))
                        p.WriteInt(kv.Value.MasterLevel ?? 0);
                });
            }

            if (flags.HasFlag(CharacterDataFlags.SkillCooltime))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.QuestRecord))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.QuestComplete))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.MinigameRecord))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.CoupleRecord))
            {
                p.WriteShort(0); // Couple
                p.WriteShort(0); // Friend
                p.WriteShort(0); // Marriage
            }

            if (flags.HasFlag(CharacterDataFlags.MapTransfer))
            {
                for (var i = 0; i < 5; i++) p.WriteInt(0);
                for (var i = 0; i < 10; i++) p.WriteInt(0);
            }

            if (flags.HasFlag(CharacterDataFlags.NewYearCard))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.QuestRecordEx))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.WildHunterInfo))
            {
                if (c.Job / 100 == 33)
                {
                    p.WriteByte(0);
                    for (var i = 0; i < 5; i++) p.WriteInt(0);
                }
            }

            if (flags.HasFlag(CharacterDataFlags.QuestCompleteOld))
            {
                p.WriteShort(0);
            }

            if (flags.HasFlag(CharacterDataFlags.VisitorLog))
            {
                p.WriteShort(0);
            }
        }
コード例 #28
0
 public void WriteLoginStream(IPacketWriter writer)
 {
     writer.WriteInt32(GetRelevanceID());
     writer.WriteFloat(Time.realtimeSinceStartup);
     writer.WriteByte((byte)mNetState);
 }
コード例 #29
0
 public void WriteToPacket(IPacketWriter writer)
 {
     writer.WriteByte((byte)_history.Count);
     _history.ForEach(o => writer.Write(o));
 }
コード例 #30
0
 public void Write(IPacketWriter writer)
 {
     writer.WriteInt32(SkillID);
     writer.WriteByte((byte)TokenSlots);
 }