This commit is contained in:
Longfeng Qin 2024-09-21 15:40:13 +08:00
parent 666110163e
commit 5cfd65a481
12 changed files with 217 additions and 107 deletions

View File

@ -42,6 +42,7 @@ namespace PSO2SERVER
public SocketClient Socket { get; private set; }
// Game properties, TODO Consider moving these somewhere else
public Account _account { get; set; }
public Flags _flags { get; set; }
public Character Character { get; set; }
//public Zone.Zone CurrentZone { get; set; }
public Map CurrentZone;

View File

@ -4,6 +4,119 @@ using PSO2SERVER.Packets.PSOPackets;
namespace PSO2SERVER.Models
{
public enum QuestType : byte
{
Unk0 = 0,
Extreme = 1,
ARKS = 3,
LimitedTime = 4,
ExtremeDebug = 5,
Blank1 = 6,
NetCafe = 8,
WarmingDebug = 9,
Blank2 = 10,
Advance = 11,
Expedition = 12,
FreeDebug = 13,
ArksDebug = 14,
Challenge = 16,
Urgent = 17,
UrgentDebug = 18,
TimeAttack = 19,
TimeDebug = 20,
ArksDebug2 = 21,
ArksDebug3 = 22,
ArksDebug4 = 23,
ArksDebug5 = 24,
ArksDebug6 = 25,
ArksDebug7 = 26,
ArksDebug8 = 27,
ArksDebug9 = 28,
ArksDebug10 = 29,
Blank3 = 30,
Recommended = 32,
Ultimate = 33,
UltimateDebug = 34,
AGP = 35,
Bonus = 36,
StandardTraining = 37,
HunterTraining = 38,
RangerTraining = 39,
ForceTraining = 40,
FighterTraining = 41,
GunnerTraining = 42,
TechterTraining = 43,
BraverTraining = 44,
BouncerTraining = 45,
SummonerTraining = 46,
AutoAccept = 47,
Ridroid = 48,
CafeAGP = 49,
BattleBroken = 50,
BusterDebug = 51,
Poka12 = 52,
StoryEP1 = 55,
Buster = 56,
HeroTraining = 57,
Amplified = 58,
DarkBlastTraining = 61,
Endless = 62,
Blank4 = 64,
PhantomTraining = 65,
AISTraining = 66,
DamageCalculation = 68,
EtoileTraining = 69,
Divide = 70,
Stars1 = 71,
Stars2 = 72,
Stars3 = 73,
Stars4 = 74,
Stars5 = 75,
Stars6 = 76,
}
[Flags]
public enum QuestTypeAvailable : UInt64
{
None = 0x0000000000000000,
All = 0xFFFFFFFFFFFFFFFF,
Extreme = 0x0000000000000002,
StoryEP1 = 0x0000000000000004,
Arks = 0x0000000000000008,
Limited = 0x0000000000000010,
ExtremeDebug = 0x0000000000000020,
Blank1 = 0x0000000000000040,
StoryEP2 = 0x0000000000000080,
NetCafeLimited = 0x0000000000000100,
Debug = 0x0000000000000200,
Blank2 = 0x0000000000000400,
Advance = 0x0000000000000800,
FreeField = 0x0000000000001000,
FreeDebug = 0x0000000000002000,
ArksDebug1 = 0x0000000000004000,
StoryDebug = 0x0000000000008000,
Challange = 0x0000010000010000,
Emergency = 0x0000020000020000,
EmergencyDebug = 0x0000040000040000,
TimeAttack = 0x0000080000080000,
TimeDebug = 0x0000000000100000,
ArksDebug2 = 0x0000000000200000,
ArksDebug3 = 0x0000000000400000,
ArksDebug4 = 0x0000000000800000,
ArksDebug5 = 0x0000000001000000,
ArksDebug6 = 0x0000000002000000,
ArksDebug7 = 0x0000000004000000,
ArksDebug8 = 0x0000000008000000,
ArksDebug9 = 0x0000000010000000,
ArksDebug10 = 0x0000000020000000,
Blank3 = 0x0000000040000000,
StoryEP3 = 0x0000000080000000,
Featured = 0x0000000100000000,
Ultimate = 0x0000000200000000,
UltimateDebug = 0x0000000400000000,
NotSet = 0x0000000800000000,
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public unsafe struct QuestDefiniton
{

View File

@ -15,8 +15,8 @@ namespace PSO2SERVER.Packets.Handlers
{
if (context.Character == null)
return;
var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data);
//var info = string.Format("[<--] 接收到的数据 (hex): ");
//Logger.WriteHex(info, data);
var reader = new PacketReader(data, position, size);
var obj = reader.ReadStruct<ObjectHeader>();

View File

@ -0,0 +1,28 @@
using System;
using PSO2SERVER.Models;
using PSO2SERVER.Packets.PSOPackets;
using PSO2SERVER.Party;
namespace PSO2SERVER.Packets.Handlers
{
[PacketHandlerAttr(0x0B, 0xCD)]
class AcceptStoryQuestHandler : PacketHandler
{
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
//var info = string.Format("[<--] 接收到的数据 (hex): ");
//Logger.WriteHex(info, data);
var reader = new PacketReader(data);
var name_id = reader.ReadUInt32();
var unk = reader.ReadUInt32();
Logger.Write("任务编号: " + name_id + " unk: " + unk);
//PartyManager.instance.CreateNewParty(context);
// 告诉客户端切换到加载界面
context.SendPacket(new LoadingScreenTransitionPacket());
}
}
}

View File

@ -12,7 +12,7 @@ namespace PSO2SERVER.Packets.Handlers
{
QuestDefiniton def = new QuestDefiniton
{
dateOrSomething = "2012/01/05",
dateOrSomething = "2024/09/21",
needsToBeNonzero = 0x00000020,
getsSetToWord = 0x0000000B,
questNameString = 30010,
@ -27,7 +27,7 @@ namespace PSO2SERVER.Packets.Handlers
QuestDifficultyPacket.QuestDifficulty diff = new QuestDifficultyPacket.QuestDifficulty
{
dateOrSomething = "2012/01/05",
dateOrSomething = "2024/09/21",
something = 0x20,
something2 = 0x0B,
questNameString = 30010,
@ -41,7 +41,7 @@ namespace PSO2SERVER.Packets.Handlers
questDef = def
};
context.currentParty.currentQuest = quest;
context.SendPacket(new SetQuestInfoPacket(def, context._account));
context.SendPacket(new SetQuestInfoPacket(def, context._account.AccountId));
context.SendPacket(new QuestStartPacket(def, diff));
}

View File

@ -9,8 +9,8 @@ namespace PSO2SERVER.Packets.Handlers
{
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data);
//var info = string.Format("[<--] 接收到的数据 (hex): ");
//Logger.WriteHex(info, data);
var reader = new PacketReader(data);
var obj = reader.ReadStruct<ObjectHeader>();

View File

@ -23,11 +23,14 @@ namespace PSO2SERVER.Packets.Handlers
if (context._account == null || context.Character == null)
return;
var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data);
//var info = string.Format("[<--] 接收到的数据 (hex): ");
//Logger.WriteHex(info, data);
var reader = new PacketReader(data);
var flag = reader.ReadStruct<SetFlagPacket>();
if (flag.flag_type == FlagType.Account)
context._flags.Set((int)flag.id, (byte)flag.value);
}
}
}

View File

@ -9,87 +9,6 @@ namespace PSO2SERVER.Packets.PSOPackets
{
class QuestAvailablePacket : Packet
{
public enum QuestType
{
Extreme,
StoryEP1,
Arks,
Limited,
ExtremeDebug,
Blank1,
StoryEP2,
NetCafeLimited,
Debug,
Blank2,
Advance,
FreeField,
FreeDebug,
ArksDebug1,
StoryDebug,
Challenge,
Emergency,
EmergencyDebug,
TimeAttack,
TimeDebug,
ArksDebug2,
ArksDebug3,
ArksDebug4,
ArksDebug5,
ArksDebug6,
ArksDebug7,
ArksDebug8,
ArksDebug9,
ArksDebug10,
Blank3,
StoryEP3,
Featured,
Ultimate,
UltimateDebug,
NotSet
}
[Flags]
public enum QuestTypeAvailable : UInt64
{
None = 0x0000000000000000,
All = 0xFFFFFFFFFFFFFFFF,
Extreme = 0x0000000000000002,
StoryEP1 = 0x0000000000000004,
Arks = 0x0000000000000008,
Limited = 0x0000000000000010,
ExtremeDebug = 0x0000000000000020,
Blank1 = 0x0000000000000040,
StoryEP2 = 0x0000000000000080,
NetCafeLimited = 0x0000000000000100,
Debug = 0x0000000000000200,
Blank2 = 0x0000000000000400,
Advance = 0x0000000000000800,
FreeField = 0x0000000000001000,
FreeDebug = 0x0000000000002000,
ArksDebug1 = 0x0000000000004000,
StoryDebug = 0x0000000000008000,
Challange = 0x0000010000010000,
Emergency = 0x0000020000020000,
EmergencyDebug = 0x0000040000040000,
TimeAttack = 0x0000080000080000,
TimeDebug = 0x0000000000100000,
ArksDebug2 = 0x0000000000200000,
ArksDebug3 = 0x0000000000400000,
ArksDebug4 = 0x0000000000800000,
ArksDebug5 = 0x0000000001000000,
ArksDebug6 = 0x0000000002000000,
ArksDebug7 = 0x0000000004000000,
ArksDebug8 = 0x0000000008000000,
ArksDebug9 = 0x0000000010000000,
ArksDebug10 = 0x0000000020000000,
Blank3 = 0x0000000040000000,
StoryEP3 = 0x0000000080000000,
Featured = 0x0000000100000000,
Ultimate = 0x0000000200000000,
UltimateDebug = 0x0000000400000000,
NotSet = 0x0000000800000000,
}
public short[] amount = new short[Enum.GetValues(typeof(QuestType)).Length];
QuestTypeAvailable available = QuestTypeAvailable.Arks;

View File

@ -3,37 +3,69 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static PSO2SERVER.Packets.PSOPackets.QuestAvailablePacket;
namespace PSO2SERVER.Packets.PSOPackets
{
public class SetQuestInfoPacket : Packet
{
/// <summary>
/// Name ID of the quest.
/// </summary>
public uint Name { get; set; }
public uint Unk1 { get; set; }
public uint Unk2 { get; set; }
public ushort Unk3 { get; set; }
public ushort Unk4 { get; set; }
/// <summary>
/// Player who accepted the quest.
/// </summary>
public ObjectHeader Player { get; set; }
public uint[] Unk5 { get; set; } = new uint[5];
public byte Unk6 { get; set; }
public byte Unk7 { get; set; }
public byte Unk8 { get; set; }
/// <summary>
/// Quest difficulty.
/// </summary>
public byte Diff { get; set; }
/// <summary>
/// Quest type.
/// </summary>
public QuestType QuestType { get; set; }
QuestDefiniton questdef;
Database.Account p;
public SetQuestInfoPacket(QuestDefiniton questdef, Database.Account p)
public SetQuestInfoPacket(QuestDefiniton questdef, int accountid)
{
this.questdef = questdef;
this.p = p;
Player = new ObjectHeader((uint)accountid, ObjectType.Player);
}
public override byte[] Build()
{
PacketWriter writer = new PacketWriter();
writer.Write(questdef.questNameString);
writer.Write(0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)1);
writer.WriteStruct(new ObjectHeader((uint)p.AccountId, ObjectType.Player));
writer.Write(0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write((ushort)0);
writer.Write(Unk1);
writer.Write(Unk2);
writer.Write(Unk3);
writer.Write(Unk4);
//writer.Write((ushort)1);
writer.WriteStruct(Player);
writer.Write(0);
writer.Write(0);
writer.Write(0);
writer.Write(0);
writer.Write(0);
writer.Write(Unk6);
writer.Write(Unk7);
writer.Write(Unk8);
writer.Write(Diff);
writer.Write((byte)QuestType);
return writer.ToArray();
}
public override PacketHeader GetHeader()

View File

@ -18,11 +18,11 @@ namespace PSO2SERVER.Packets.PSOPackets
public uint _value { get; set; }
public uint _unk { get; set; }
public ServerSetFlagPacket(uint flag, bool value)
public ServerSetFlagPacket(uint flag, uint value)
{
_flag_type = FlagType.Account;
_id = flag;
_value = value ? 1u : 0u; // 将 bool 转换为 uint;
_value = value;
_unk = 0; // 设定未知字段的默认值
}

View File

@ -3,14 +3,24 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static PSO2SERVER.Models.Flags;
namespace PSO2SERVER.Packets.PSOPackets
{
public class ServerSetParamPacket : Packet
{
/// Flag type.
public FlagType _param_type { get; set; }
/// Flag ID.
public uint _id { get; set; }
/// Flag value.
public uint _value { get; set; }
public ServerSetParamPacket()
public ServerSetParamPacket(uint flag, uint value)
{
_param_type = FlagType.Account;
_id = flag;
_value = value;
}
#region implemented abstract members of Packet
@ -18,6 +28,9 @@ namespace PSO2SERVER.Packets.PSOPackets
public override byte[] Build()
{
var pkt = new PacketWriter();
pkt.Write((uint)_param_type);
pkt.Write((uint)_id);
pkt.Write((uint)_value);
return pkt.ToArray();
}

View File

@ -185,6 +185,7 @@
<Compile Include="Packets\Handlers\04-ObjectHandler\04-08-MovementActionHandler.cs" />
<Compile Include="Packets\Handlers\04-ObjectHandler\04-3C-ActionUpdateHandler.cs" />
<Compile Include="Packets\Handlers\04-ObjectHandler\04-71-MovementEndHandler.cs" />
<Compile Include="Packets\Handlers\0B-QuestHandler\0B-CD-AcceptStoryQuestHandler.cs" />
<Compile Include="Packets\Handlers\0B-QuestHandler\0B-09-UNK.cs" />
<Compile Include="Packets\Handlers\0B-QuestHandler\0B-15-QuestCounterAvailableHander.cs" />
<Compile Include="Packets\Handlers\0B-QuestHandler\0B-17-QuestListRequestHandler.cs" />