Skip to content

Commit 42e4504

Browse files
committed
fix: Fix quest enemy spawn when loading into area
Fixed an issue when the player teleports to a location right next to a set of enemies which is also used for a quest. Since the client can query the default enemy list before the active quest list for the area, it is possible that the quest enemies will not spawn. This change issues a reset packet to the groups which are required for the quest if they were requested before the area quest list was sent to the player.
1 parent 89df71c commit 42e4504

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

Arrowgene.Ddon.GameServer/Enemies/InstanceEnemyManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ public bool HasInstanceEnemy(StageLayoutId stageId, byte index)
145145
}
146146
}
147147

148+
public bool HasEnemyGroup(StageLayoutId stageId)
149+
{
150+
lock (_EnemyData)
151+
{
152+
return _EnemyData.ContainsKey(stageId);
153+
}
154+
}
155+
148156
public void ResetEnemyNode(StageLayoutId stageId)
149157
{
150158
lock (_EnemyData)

Arrowgene.Ddon.GameServer/Handler/QuestGetSetQuestListHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public override S2CQuestGetSetQuestListRes Handle(GameClient client, C2SQuestGet
6969
CompletedQuest questStats = client.Party.Leader?.Client.Character.CompletedQuests.GetValueOrDefault(quest.QuestId);
7070
res.SetQuestList.Add(quest.ToCDataSetQuestList(0, questStats?.ClearCount ?? 0));
7171
client.Party.QuestState.AddNewQuest(quest, 0);
72+
// Enemy requests arrive before the quest list, so loaded groups may have generic enemies. Reset them.
73+
quest.ResetEnemiesForStage(client, client.Character.Stage, onlyLoaded: true);
7274
}
7375
}
7476

Arrowgene.Ddon.GameServer/Quests/Quest.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -916,11 +916,12 @@ public virtual void ResetEnemiesForBlock(GameClient client, QuestBlock questBloc
916916
}
917917
}
918918

919-
public virtual void ResetEnemiesForStage(GameClient client, StageLayoutId stageId)
919+
public virtual void ResetEnemiesForStage(GameClient client, StageLayoutId stageId, bool onlyLoaded = false)
920920
{
921921
foreach (var (groupId, group) in EnemyGroups)
922922
{
923-
if (group.StageLayoutId.Id == stageId.Id)
923+
if (group.StageLayoutId.Id == stageId.Id
924+
&& (!onlyLoaded || client.Party.InstanceEnemyManager.HasEnemyGroup(group.StageLayoutId)))
924925
{
925926
// Cleanup old contexts if we are replacing monsters with new ones
926927
foreach (var enemy in group.Enemies)
@@ -929,13 +930,11 @@ public virtual void ResetEnemiesForStage(GameClient client, StageLayoutId stageI
929930
ContextManager.RemoveContext(client.Party, uid);
930931
}
931932

932-
S2CInstanceEnemyGroupResetNtc resetNtc = new S2CInstanceEnemyGroupResetNtc()
933+
client.Party.InstanceEnemyManager.ResetEnemyNode(group.StageLayoutId);
934+
client.Party.SendToAll(new S2CInstanceEnemyGroupResetNtc()
933935
{
934936
LayoutId = group.StageLayoutId.ToCDataStageLayoutId()
935-
};
936-
937-
client.Party.InstanceEnemyManager.ResetEnemyNode(group.StageLayoutId);
938-
client.Party.SendToAll(resetNtc);
937+
});
939938
}
940939
}
941940
}

0 commit comments

Comments
 (0)