-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #510 from RyanYappert/feat/training-room
Feature: Implement traning (sic) room.
- Loading branch information
Showing
15 changed files
with
289 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Arrowgene.Ddon.GameServer/Handler/InstanceTraningRoomGetEnemyListHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Arrowgene.Ddon.Server; | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Logging; | ||
using System.Collections.Generic; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class InstanceTraningRoomGetEnemyListHandler : GameRequestPacketHandler<C2SInstanceTraningRoomGetEnemyListReq, S2CInstanceTraningRoomGetEnemyListRes> | ||
{ | ||
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(QuestGetQuestCompletedListHandler)); | ||
|
||
|
||
public InstanceTraningRoomGetEnemyListHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CInstanceTraningRoomGetEnemyListRes Handle(GameClient client, C2SInstanceTraningRoomGetEnemyListReq request) | ||
{ | ||
// These OptionIds are intepreted in InstanceTraningRoomSetEnemyHandler. | ||
return new S2CInstanceTraningRoomGetEnemyListRes() | ||
{ | ||
MaxLv = 100, | ||
InfoList = new List<CDataTraningRoomEnemyHeader>() | ||
{ | ||
new CDataTraningRoomEnemyHeader() | ||
{ | ||
OptionId = 1, | ||
Name = "Orc Soldiers" | ||
}, | ||
new CDataTraningRoomEnemyHeader() | ||
{ | ||
OptionId = 2, | ||
Name = "Cyclops" | ||
}, | ||
new CDataTraningRoomEnemyHeader() | ||
{ | ||
OptionId = 3, | ||
Name = "Ogre" | ||
}, | ||
new CDataTraningRoomEnemyHeader() | ||
{ | ||
OptionId = 4, | ||
Name = "Training Dummy Zuhl" | ||
}, | ||
} | ||
}; | ||
} | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
Arrowgene.Ddon.GameServer/Handler/InstanceTraningRoomSetEnemyHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using Arrowgene.Ddon.Shared.Entity.PacketStructure; | ||
using Arrowgene.Ddon.Shared.Entity.Structure; | ||
using Arrowgene.Ddon.Shared.Network; | ||
using System.Threading.Tasks; | ||
|
||
namespace Arrowgene.Ddon.GameServer.Handler | ||
{ | ||
public class InstanceTraningRoomSetEnemyHandler : GameStructurePacketHandler<C2SInstanceTraningRoomSetEnemyReq> | ||
{ | ||
public InstanceTraningRoomSetEnemyHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
private static readonly CDataStageLayoutId TrainingRoomLayout = new CDataStageLayoutId(349, 0, 1); | ||
private static readonly int RepopDelay = 2000; // ms | ||
|
||
public override void Handle(GameClient client, StructurePacket<C2SInstanceTraningRoomSetEnemyReq> packet) | ||
{ | ||
|
||
// TODO: Enemies that share the same positionIndex sometimes spawn with the wrong HP. | ||
// To avoid this in the meantime, each enemy must have its own unique positionIndex. | ||
// But the training room layout only has 6 (0-5) indices, so you can only have six different spawns. | ||
|
||
client.Send(new S2CInstanceTraningRoomSetEnemyRes()); | ||
|
||
client.Party.SendToAll(new S2CInstanceEnemyGroupResetNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout | ||
}); | ||
|
||
ushort level = (ushort)packet.Structure.Lv; | ||
|
||
Task.Delay(RepopDelay).ContinueWith(_ => { | ||
switch (packet.Structure.OptionId) | ||
{ | ||
case 1: // Two orc soldiers | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
PositionIndex = 0, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
{ | ||
EnemyId = 0x15800, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = level, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 0, | ||
}); | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
PositionIndex = 1, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
{ | ||
EnemyId = 0x15800, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = level, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 0, | ||
}); | ||
break; | ||
case 2: // Cyclops | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
PositionIndex = 2, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
{ | ||
EnemyId = 0x15000, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = level, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 0, | ||
}); | ||
break; | ||
case 3: //Ogre | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
PositionIndex = 3, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
{ | ||
EnemyId = 0x15500, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = level, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 0, | ||
}); | ||
break; | ||
case 4: //Passive Zuhl | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
PositionIndex = 4, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
{ | ||
EnemyId = 0x100101, | ||
NamedEnemyParamsId = 722, // Practice <name>, has extra HP. | ||
Lv = level, | ||
RepopCount = 10, | ||
Scale = 75, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 0, | ||
}); | ||
break; | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SInstanceTraningRoomGetEnemyListReq.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Network; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure | ||
{ | ||
public class C2SInstanceTraningRoomGetEnemyListReq : IPacketStructure | ||
{ | ||
public PacketId Id => PacketId.C2S_INSTANCE_TRANING_ROOM_GET_ENEMY_LIST_REQ; | ||
public class Serializer : PacketEntitySerializer<C2SInstanceTraningRoomGetEnemyListReq> | ||
{ | ||
|
||
public override void Write(IBuffer buffer, C2SInstanceTraningRoomGetEnemyListReq obj) | ||
{ | ||
} | ||
|
||
public override C2SInstanceTraningRoomGetEnemyListReq Read(IBuffer buffer) | ||
{ | ||
return new C2SInstanceTraningRoomGetEnemyListReq(); | ||
} | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SInstanceTraningRoomSetEnemyReq.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Arrowgene.Buffers; | ||
using Arrowgene.Ddon.Shared.Network; | ||
|
||
namespace Arrowgene.Ddon.Shared.Entity.PacketStructure | ||
{ | ||
public class C2SInstanceTraningRoomSetEnemyReq : IPacketStructure | ||
{ | ||
public PacketId Id => PacketId.C2S_INSTANCE_TRANING_ROOM_SET_ENEMY_REQ; | ||
|
||
/// <summary> | ||
/// Value returned from the TraningRoomGetEnemyList dialog. | ||
/// </summary> | ||
public uint OptionId { get; set; } | ||
public uint Lv { get; set; } | ||
|
||
public C2SInstanceTraningRoomSetEnemyReq() | ||
{ | ||
OptionId = 0; | ||
Lv = 0; | ||
} | ||
|
||
public class Serializer : PacketEntitySerializer<C2SInstanceTraningRoomSetEnemyReq> | ||
{ | ||
|
||
public override void Write(IBuffer buffer, C2SInstanceTraningRoomSetEnemyReq obj) | ||
{ | ||
WriteUInt32(buffer, obj.OptionId); | ||
WriteUInt32(buffer, obj.Lv); | ||
} | ||
|
||
public override C2SInstanceTraningRoomSetEnemyReq Read(IBuffer buffer) | ||
{ | ||
C2SInstanceTraningRoomSetEnemyReq obj = new C2SInstanceTraningRoomSetEnemyReq(); | ||
obj.OptionId = ReadUInt32(buffer); | ||
obj.Lv = ReadUInt32(buffer); | ||
return obj; | ||
} | ||
} | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
Arrowgene.Ddon.Shared/Entity/PacketStructure/C2STrainingRoomSetEnemyReq.cs
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
Arrowgene.Ddon.Shared/Entity/PacketStructure/C2STraningRoomGetEnemyListReq.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.