using System; using PSO2SERVER.Models; using PSO2SERVER.Protocol.Packets; using PSO2SERVER.Party; namespace PSO2SERVER.Protocol.Handlers { [PacketHandlerAttr(0x0E, 0x0C)] public class QuestDifficultyStartHandler : PacketHandler { public string name { get; set; } public string password { get; set; } public string comments { get; set; } public string questname { get; set; } public byte min_level { get; set; } public byte max_level { get; set; } public byte playstyle { get; set; } public PartyFlags partyFlags { get; set; } public ulong unk { get; set; } // Go go maximum code duplication (for now) public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { var info = string.Format("[<--] 接收到的数据 (hex): {0}字节", data.Length); Logger.WriteHex(info, data); var reader = new PacketReader(data, position, size); name = reader.ReadUtf16(0x11CB, 0x98); password = reader.ReadUtf16(0x11CB, 0x98); comments = reader.ReadUtf16(0x11CB, 0x98); questname = reader.ReadUtf16(0x11CB, 0x98); min_level = reader.ReadByte(); max_level = reader.ReadByte(); playstyle = reader.ReadByte(); partyFlags = (PartyFlags)reader.ReadByte(); unk = reader.ReadUInt64(); // 打印输出 Logger.Write($"name: {name}"); Logger.Write($"Password: {password}"); Logger.Write($"Comments: {comments}"); Logger.Write($"Quest name: {questname}"); Logger.Write($"Min Level: {min_level}"); Logger.Write($"Max Level: {max_level}"); Logger.Write($"Playstyle: {playstyle}"); Logger.Write($"Party Flags: {partyFlags}"); // 如果 PartyFlags 是枚举类型 Logger.Write($"Unknown Value: {unk}"); QuestDefiniton def = new QuestDefiniton { dateOrSomething = "2012/01/05", quest_obj = new ObjectHeader(0x20, ObjectType.Quest), questNameid = 30010, playTime = QuestEstimatedTime.Short, partyType = QuestPartyType.SinglePartyQuest, difficulties = QuestDifficultyType.NORMAL | QuestDifficultyType.HARD | QuestDifficultyType.VERY_HARD | QuestDifficultyType.SUPER_HARD, sub_class_req_level = 1, // Not sure why but these need to be set for the quest to be enabled quest_type = (QuestType)0xF1, field_101 = 1 }; QuestDifficulty diff = new QuestDifficulty { dateOrSomething = "2012/01/05", quest_obj = new ObjectHeader(0x20, ObjectType.Quest), name_id = 30010, // These are likely bitfields area = 0x01, planet = 0x03, unk1 = 0x03, unk2 = 0x00 }; var quest = new Quest("arks_010120") { questDef = def }; context.currentParty.currentQuest = quest; context.SendPacket(new SetQuestInfoPacket(def, context._account.AccountId)); context.SendPacket(new PartySetQuestPacket(0x753A, 0, def, diff, new ObjectHeader((uint)context._account.AccountId, ObjectType.Player))); } } }