Core/Quests: Implemented new db table quest_objectives_completion_effect
* Turn off automatic phase updates on quest objective completion * Allow more convenient conversation and spell casts on quest objective completion Port From (https://github.com/TrinityCore/TrinityCore/commit/a2be8d202823706ad4b29c2dc988c0fe978ae652)
This commit is contained in:
@@ -2432,6 +2432,8 @@ namespace Game.Entities
|
||||
public void UpdateQuestObjectiveProgress(QuestObjectiveType objectiveType, int objectId, long addCount, ObjectGuid victimGuid = default)
|
||||
{
|
||||
bool anyObjectiveChangedCompletionState = false;
|
||||
bool updatePhaseShift = false;
|
||||
bool updateZoneAuras = false;
|
||||
|
||||
foreach (var objectiveStatusData in m_questObjectiveStatus.LookupByKey((objectiveType, objectId)))
|
||||
{
|
||||
@@ -2535,6 +2537,20 @@ namespace Game.Entities
|
||||
if (objectiveWasComplete != objectiveIsNowComplete)
|
||||
anyObjectiveChangedCompletionState = true;
|
||||
|
||||
if (objectiveIsNowComplete && objective.CompletionEffect != null)
|
||||
{
|
||||
if (objective.CompletionEffect.GameEventId.HasValue)
|
||||
GameEvents.Trigger(objective.CompletionEffect.GameEventId.Value, this, null);
|
||||
if (objective.CompletionEffect.SpellId.HasValue)
|
||||
CastSpell(this, objective.CompletionEffect.SpellId.Value, true);
|
||||
if (objective.CompletionEffect.ConversationId.HasValue)
|
||||
Conversation.CreateConversation(objective.CompletionEffect.ConversationId.Value, this, GetPosition(), GetGUID());
|
||||
if (objective.CompletionEffect.UpdatePhaseShift)
|
||||
updatePhaseShift = true;
|
||||
if (objective.CompletionEffect.UpdateZoneAuras)
|
||||
updateZoneAuras = true;
|
||||
}
|
||||
|
||||
if (objectiveIsNowComplete && CanCompleteQuest(questId, objective.Id))
|
||||
CompleteQuest(questId);
|
||||
else if (objectiveStatusData.QuestStatusPair.Status.Status == QuestStatus.Complete)
|
||||
@@ -2545,7 +2561,14 @@ namespace Game.Entities
|
||||
if (anyObjectiveChangedCompletionState)
|
||||
UpdateVisibleGameobjectsOrSpellClicks();
|
||||
|
||||
PhasingHandler.OnConditionChange(this);
|
||||
if (updatePhaseShift)
|
||||
PhasingHandler.OnConditionChange(this);
|
||||
|
||||
if (updateZoneAuras)
|
||||
{
|
||||
UpdateZoneDependentAuras(GetZoneId());
|
||||
UpdateAreaDependentAuras(GetAreaId());
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasQuestForItem(uint itemid)
|
||||
|
||||
@@ -7181,8 +7181,10 @@ namespace Game
|
||||
}
|
||||
|
||||
// Load `quest_objectives`
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
result = DB.World.Query("SELECT QuestID, ID, Type, StorageIndex, ObjectID, Amount, Flags, Flags2, ProgressBarWeight, Description FROM quest_objectives ORDER BY `Order` ASC, StorageIndex ASC");
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
result = DB.World.Query("SELECT qo.QuestID, qo.ID, qo.Type, qo.StorageIndex, qo.ObjectID, qo.Amount, qo.Flags, qo.Flags2, qo.ProgressBarWeight, qo.Description, " +
|
||||
// 10 11 12 13 14
|
||||
"qoce.GameEventID, qoce.SpellID, qoce.ConversationID, qoce.UpdatePhaseShift, qoce.UpdateZoneAuras FROM quest_objectives qo LEFT JOIN quest_objectives_completion_effect qoce ON qo.ID = qoce.ObjectiveID ORDER BY `Order` ASC, StorageIndex ASC");
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 quest objectives. DB table `quest_objectives` is empty.");
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace Game
|
||||
|
||||
public void LoadQuestObjective(SQLFields fields)
|
||||
{
|
||||
QuestObjective obj = new();
|
||||
QuestObjective obj = new();
|
||||
obj.QuestID = fields.Read<uint>(0);
|
||||
obj.Id = fields.Read<uint>(1);
|
||||
obj.Type = (QuestObjectiveType)fields.Read<byte>(2);
|
||||
@@ -247,6 +247,31 @@ namespace Game
|
||||
obj.ProgressBarWeight = fields.Read<float>(8);
|
||||
obj.Description = fields.Read<string>(9);
|
||||
|
||||
bool hasCompletionEffect = false;
|
||||
for (var i = 10; i < 15; ++i)
|
||||
{
|
||||
if (!fields.IsNull(i))
|
||||
{
|
||||
hasCompletionEffect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasCompletionEffect)
|
||||
{
|
||||
obj.CompletionEffect = new QuestObjectiveAction();
|
||||
if (!fields.IsNull(10))
|
||||
obj.CompletionEffect.GameEventId = fields.Read<uint>(10);
|
||||
if (!fields.IsNull(11))
|
||||
obj.CompletionEffect.SpellId = fields.Read<uint>(11);
|
||||
if (!fields.IsNull(12))
|
||||
obj.CompletionEffect.ConversationId = fields.Read<uint>(12);
|
||||
if (!fields.IsNull(13))
|
||||
obj.CompletionEffect.UpdatePhaseShift = fields.Read<bool>(13);
|
||||
if (!fields.IsNull(14))
|
||||
obj.CompletionEffect.UpdateZoneAuras = fields.Read<bool>(14);
|
||||
}
|
||||
|
||||
Objectives.Add(obj);
|
||||
_usedQuestObjectiveTypes[(int)obj.Type] = true;
|
||||
}
|
||||
@@ -996,6 +1021,15 @@ namespace Game
|
||||
public StringArray Text = new((int)Locale.Total);
|
||||
}
|
||||
|
||||
public class QuestObjectiveAction
|
||||
{
|
||||
public uint? GameEventId;
|
||||
public uint? SpellId;
|
||||
public uint? ConversationId;
|
||||
public bool UpdatePhaseShift;
|
||||
public bool UpdateZoneAuras;
|
||||
}
|
||||
|
||||
public class QuestObjective
|
||||
{
|
||||
public uint Id;
|
||||
@@ -1009,6 +1043,7 @@ namespace Game
|
||||
public float ProgressBarWeight;
|
||||
public string Description;
|
||||
public int[] VisualEffects = Array.Empty<int>();
|
||||
public QuestObjectiveAction CompletionEffect;
|
||||
|
||||
public bool IsStoringValue()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user