Skip to content

Commit 07fa7c3

Browse files
committed
fix: Add support for raw command replay
Quest flags were only able to be replayed via the JSON Quest Flag implementation. If a quest uses raw commands to set on/off flags they were not handled. This change adds support to handle the on/off behavior of flag commands set directly using the quest commands. Co-authored-by: @hankhotspur
1 parent 77dec43 commit 07fa7c3

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

Arrowgene.Ddon.GameServer/Quests/Quest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,21 @@ private List<CDataQuestProcessState> GetProcessState(uint step, out uint announc
284284
}
285285
}
286286

287+
foreach (var resultCommand in block.ResultCommands)
288+
{
289+
var questFlag = QuestResultCommandExtension.ToQuestFlag(resultCommand);
290+
if (questFlag == null)
291+
{
292+
continue;
293+
}
294+
if (!questFlags.ContainsKey(questFlag.Type))
295+
{
296+
questFlags[questFlag.Type] = new Dictionary<int, QuestFlag>();
297+
}
298+
questFlags[questFlag.Type][questFlag.Value] = questFlag;
299+
}
300+
301+
287302
if (step == stepsFound)
288303
{
289304
break;

Arrowgene.Ddon.Shared/Model/Quest/QuestCheckCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;

Arrowgene.Ddon.Shared/Model/Quest/QuestResultCommand.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Arrowgene.Ddon.Shared.Entity.Structure;
12
using System;
23
using System.Collections.Generic;
34
using System.Linq;
@@ -281,4 +282,67 @@ public enum QuestResultCommand : ushort
281282
/// </summary>
282283
SetQuestLayoutEnemyBodyPose = 134, // 0x00634820 (cQuestProcess* this, s32 stageNo, s32 groupNo, s32 setNo, s32 poseId)
283284
}
285+
286+
public static class QuestResultCommandExtension
287+
{
288+
public static readonly Dictionary<QuestResultCommand, (QuestFlagType Type, QuestFlagAction Action)> gFlagStateChangeCommands = new()
289+
{
290+
[QuestResultCommand.QstLayoutFlagOn] = (QuestFlagType.QstLayout, QuestFlagAction.Set),
291+
[QuestResultCommand.QstLayoutFlagOff] = (QuestFlagType.QstLayout, QuestFlagAction.Clear),
292+
[QuestResultCommand.WorldManageLayoutFlagOn] = (QuestFlagType.WorldManageLayout, QuestFlagAction.Set),
293+
[QuestResultCommand.WorldManageLayoutFlagOff] = (QuestFlagType.WorldManageLayout, QuestFlagAction.Clear),
294+
[QuestResultCommand.WorldManageQuestFlagOn] = (QuestFlagType.WorldManageQuest, QuestFlagAction.Set),
295+
[QuestResultCommand.WorldManageQuestFlagOff] = (QuestFlagType.WorldManageQuest, QuestFlagAction.Clear),
296+
[QuestResultCommand.MyQstFlagOn] = (QuestFlagType.MyQst, QuestFlagAction.Set),
297+
[QuestResultCommand.MyQstFlagOff] = (QuestFlagType.MyQst, QuestFlagAction.Clear),
298+
[QuestResultCommand.LotOn] = (QuestFlagType.Lot, QuestFlagAction.Set),
299+
[QuestResultCommand.LotOff] = (QuestFlagType.Lot, QuestFlagAction.Clear),
300+
};
301+
302+
public static bool IsFlagStateChangeCommand(this QuestResultCommand commandId)
303+
{
304+
return gFlagStateChangeCommands.ContainsKey(commandId);
305+
}
306+
307+
public static (QuestFlagType Type, QuestFlagAction Action) GetFlagStateChangeProperties(this QuestResultCommand commandId)
308+
{
309+
if (!gFlagStateChangeCommands.ContainsKey(commandId))
310+
{
311+
return (QuestFlagType.None, QuestFlagAction.None);
312+
}
313+
return gFlagStateChangeCommands[commandId];
314+
}
315+
316+
public static QuestFlag ToQuestFlag(CDataQuestCommand questCommand)
317+
{
318+
QuestResultCommand cmd = (QuestResultCommand) questCommand.Command;
319+
if (!cmd.IsFlagStateChangeCommand())
320+
{
321+
return null;
322+
}
323+
324+
var props = cmd.GetFlagStateChangeProperties();
325+
var questFlag = new QuestFlag()
326+
{
327+
Type = props.Type,
328+
Action = props.Action,
329+
Value = questCommand.Param01,
330+
PreventReplay = false,
331+
};
332+
333+
switch (props.Type)
334+
{
335+
case QuestFlagType.WorldManageLayout:
336+
case QuestFlagType.WorldManageQuest:
337+
questFlag.QuestId = questCommand.Param02;
338+
break;
339+
case QuestFlagType.Lot:
340+
questFlag.stageInfo = Stage.StageInfoFromStageNo((uint)questCommand.Param01);
341+
questFlag.Value = questCommand.Param02;
342+
break;
343+
}
344+
345+
return questFlag;
346+
}
347+
}
284348
}

0 commit comments

Comments
 (0)