PSO2SERVER/Server/Protocol/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs

84 lines
3.4 KiB
C#
Raw Normal View History

2024-09-16 02:56:02 +08:00
using System;
using PSO2SERVER.Models;
using PSO2SERVER.Protocol.Packets;
2024-12-06 03:42:25 +08:00
using PSO2SERVER.Party;
2024-09-16 02:56:02 +08:00
namespace PSO2SERVER.Protocol.Handlers
2024-09-16 02:56:02 +08:00
{
2024-09-20 11:48:27 +08:00
[PacketHandlerAttr(0x0E, 0x0C)]
2024-12-03 13:18:58 +08:00
public class QuestDifficultyStartHandler : PacketHandler
2024-09-16 02:56:02 +08:00
{
2024-12-06 03:42:25 +08:00
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; }
2024-09-16 02:56:02 +08:00
// Go go maximum code duplication (for now)
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
2024-10-26 11:44:15 +08:00
var info = string.Format("[<--] 接收到的数据 (hex): {0}字节", data.Length);
Logger.WriteHex(info, data);
2024-09-16 02:56:02 +08:00
2024-12-06 03:42:25 +08:00
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
};
2024-09-16 02:56:02 +08:00
2024-12-06 03:42:25 +08:00
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
};
2024-10-26 11:44:15 +08:00
2024-12-06 03:42:25 +08:00
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)));
2024-10-26 11:44:15 +08:00
2024-09-16 02:56:02 +08:00
}
}
}