-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Review comments; use a Task.Delay to properly space out the training …
…reset.
- Loading branch information
1 parent
a337f60
commit 1644f59
Showing
2 changed files
with
109 additions
and
105 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
202 changes: 107 additions & 95 deletions
202
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 |
---|---|---|
@@ -1,126 +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 : GameRequestPacketHandler<C2SInstanceTraningRoomSetEnemyReq, S2CInstanceTraningRoomSetEnemyRes> | ||
public class InstanceTraningRoomSetEnemyHandler : GameStructurePacketHandler<C2SInstanceTraningRoomSetEnemyReq> | ||
{ | ||
public InstanceTraningRoomSetEnemyHandler(DdonGameServer server) : base(server) | ||
{ | ||
} | ||
|
||
public override S2CInstanceTraningRoomSetEnemyRes Handle(GameClient client, C2SInstanceTraningRoomSetEnemyReq request) | ||
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. | ||
|
||
var layoutId = InstanceTraningRoomGetEnemyListHandler.TrainingRoomLayout; | ||
client.Send(new S2CInstanceTraningRoomSetEnemyRes()); | ||
|
||
switch (request.OptionId) | ||
client.Party.SendToAll(new S2CInstanceEnemyGroupResetNtc() | ||
{ | ||
case 1: // Two orc soldiers | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = layoutId, | ||
EnemyData = new CDataLayoutEnemyData() | ||
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() | ||
{ | ||
PositionIndex = 0, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
EnemyId = 0x15800, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = (ushort)request.Lv, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 1, | ||
}); | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = layoutId, | ||
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() | ||
{ | ||
PositionIndex = 1, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
EnemyId = 0x15800, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = (ushort)request.Lv, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 1, | ||
}); | ||
break; | ||
case 2: // Cyclops | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = layoutId, | ||
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() | ||
{ | ||
PositionIndex = 2, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
EnemyId = 0x15000, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = (ushort)request.Lv, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 1, | ||
}); | ||
break; | ||
case 3: //Ogre | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = layoutId, | ||
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() | ||
{ | ||
PositionIndex = 3, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
EnemyId = 0x15500, | ||
NamedEnemyParamsId = 47, // Training <name> | ||
Lv = (ushort)request.Lv, | ||
RepopCount = 10, | ||
Scale = 100, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 1, | ||
}); | ||
break; | ||
case 4: //Passive Zuhl | ||
client.Party.SendToAll(new S2CInstanceEnemyRepopNtc() | ||
{ | ||
LayoutId = layoutId, | ||
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() | ||
{ | ||
PositionIndex = 4, | ||
EnemyInfo = new CDataStageLayoutEnemyPresetEnemyInfoClient() | ||
LayoutId = TrainingRoomLayout, | ||
EnemyData = new CDataLayoutEnemyData() | ||
{ | ||
EnemyId = 0x100101, | ||
NamedEnemyParamsId = 722, // Practice <name>, has extra HP. | ||
Lv = (ushort)request.Lv, | ||
RepopCount = 10, | ||
Scale = 75, | ||
IsBossGauge = true, | ||
} | ||
}, | ||
WaitSecond = 1, | ||
}); | ||
break; | ||
} | ||
|
||
return new S2CInstanceTraningRoomSetEnemyRes(); | ||
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; | ||
} | ||
}); | ||
} | ||
} | ||
} |