Core/Creatures: Added possibility to automatically despawn personal summons on quest remove
Port From (https://github.com/TrinityCore/TrinityCore/commit/b3dce0ac08d4f740505037aff2cad7685444db15)
This commit is contained in:
@@ -107,6 +107,7 @@ namespace Game.Chat
|
|||||||
|
|
||||||
player.RemoveActiveQuest(quest.Id, false);
|
player.RemoveActiveQuest(quest.Id, false);
|
||||||
player.RemoveRewardedQuest(quest.Id);
|
player.RemoveRewardedQuest(quest.Id);
|
||||||
|
player.DespawnPersonalSummonsForQuest(quest.Id);
|
||||||
|
|
||||||
Global.ScriptMgr.OnQuestStatusChange(player, quest.Id);
|
Global.ScriptMgr.OnQuestStatusChange(player, quest.Id);
|
||||||
Global.ScriptMgr.OnQuestStatusChange(player, quest, oldStatus, QuestStatus.None);
|
Global.ScriptMgr.OnQuestStatusChange(player, quest, oldStatus, QuestStatus.None);
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ namespace Game.Entities
|
|||||||
public uint? CreatureIDVisibleToSummoner;
|
public uint? CreatureIDVisibleToSummoner;
|
||||||
public uint? GroundMountDisplayID;
|
public uint? GroundMountDisplayID;
|
||||||
public uint? FlyingMountDisplayID;
|
public uint? FlyingMountDisplayID;
|
||||||
|
public List<uint> DespawnOnQuestsRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreatureAddon
|
public class CreatureAddon
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ namespace Game.Entities
|
|||||||
SetQuestSlot(slot, 0);
|
SetQuestSlot(slot, 0);
|
||||||
AbandonQuest(questId);
|
AbandonQuest(questId);
|
||||||
RemoveActiveQuest(questId);
|
RemoveActiveQuest(questId);
|
||||||
|
DespawnPersonalSummonsForQuest(questId);
|
||||||
|
|
||||||
if (quest.LimitTime != 0)
|
if (quest.LimitTime != 0)
|
||||||
RemoveTimedQuest(questId);
|
RemoveTimedQuest(questId);
|
||||||
@@ -226,6 +227,7 @@ namespace Game.Entities
|
|||||||
SetQuestSlot(slot, 0);
|
SetQuestSlot(slot, 0);
|
||||||
AbandonQuest(questId);
|
AbandonQuest(questId);
|
||||||
RemoveActiveQuest(questId);
|
RemoveActiveQuest(questId);
|
||||||
|
DespawnPersonalSummonsForQuest(questId);
|
||||||
|
|
||||||
if (quest.LimitTime != 0)
|
if (quest.LimitTime != 0)
|
||||||
RemoveTimedQuest(questId);
|
RemoveTimedQuest(questId);
|
||||||
@@ -2190,6 +2192,23 @@ namespace Game.Entities
|
|||||||
UpdateObjectVisibility();
|
UpdateObjectVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DespawnPersonalSummonsForQuest(uint questId)
|
||||||
|
{
|
||||||
|
List<Creature> creatureList = GetCreatureListWithOptionsInGrid(100.0f, new FindCreatureOptions() { IgnorePhases = true, PrivateObjectOwnerGuid = GetGUID() }); // we might want to replace this with SummonList in Player at some point
|
||||||
|
|
||||||
|
foreach (Creature creature in creatureList)
|
||||||
|
{
|
||||||
|
CreatureSummonedData summonedData = Global.ObjectMgr.GetCreatureSummonedData(creature.GetEntry());
|
||||||
|
if (summonedData == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (summonedData.DespawnOnQuestsRemoved != null)
|
||||||
|
{
|
||||||
|
if (summonedData.DespawnOnQuestsRemoved.Contains(questId))
|
||||||
|
creature.DespawnOrUnsummon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ushort GetReqKillOrCastCurrentCount(uint quest_id, int entry)
|
public ushort GetReqKillOrCastCurrentCount(uint quest_id, int entry)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1761,8 +1761,6 @@ namespace Game
|
|||||||
// We load the creature models after loading but before checking
|
// We load the creature models after loading but before checking
|
||||||
LoadCreatureTemplateModels();
|
LoadCreatureTemplateModels();
|
||||||
|
|
||||||
LoadCreatureSummonedData();
|
|
||||||
|
|
||||||
// Checking needs to be done after loading because of the difficulty self referencing
|
// Checking needs to be done after loading because of the difficulty self referencing
|
||||||
foreach (var template in creatureTemplateStorage.Values)
|
foreach (var template in creatureTemplateStorage.Values)
|
||||||
CheckCreatureTemplate(template);
|
CheckCreatureTemplate(template);
|
||||||
@@ -2018,12 +2016,13 @@ namespace Game
|
|||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} creature template models in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} creature template models in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||||
}
|
}
|
||||||
void LoadCreatureSummonedData()
|
|
||||||
|
public void LoadCreatureSummonedData()
|
||||||
{
|
{
|
||||||
uint oldMSTime = Time.GetMSTime();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
|
|
||||||
// 0 1 2 3
|
// 0 1 2 3 4
|
||||||
SQLResult result = DB.World.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID FROM creature_summoned_data");
|
SQLResult result = DB.World.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID, DespawnOnQuestsRemoved FROM creature_summoned_data");
|
||||||
if (result.IsEmpty())
|
if (result.IsEmpty())
|
||||||
{
|
{
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 creature summoned data definitions. DB table `creature_summoned_data` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 creature summoned data definitions. DB table `creature_summoned_data` is empty.");
|
||||||
@@ -2074,6 +2073,28 @@ namespace Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!result.IsNull(4))
|
||||||
|
{
|
||||||
|
List<uint> questList = new();
|
||||||
|
foreach (string questStr in result.Read<string>(4).Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (!uint.TryParse(questStr, out uint questId))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Quest quest = GetQuestTemplate(questId);
|
||||||
|
if (quest == null)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Sql, $"Table `creature_summoned_data` references non-existing quest {questId} in DespawnOnQuestsRemoved for creature {creatureId}, skipping");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
questList.Add(questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!questList.Empty())
|
||||||
|
summonedData.DespawnOnQuestsRemoved = questList;
|
||||||
|
}
|
||||||
|
|
||||||
} while (result.NextRow());
|
} while (result.NextRow());
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {creatureSummonedDataStorage.Count} creature summoned data definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
Log.outInfo(LogFilter.ServerLoading, $"Loaded {creatureSummonedDataStorage.Count} creature summoned data definitions in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||||
|
|||||||
@@ -437,6 +437,7 @@ namespace Game
|
|||||||
GetPlayer().TakeQuestSourceItem(questId, true); // remove quest src item from player
|
GetPlayer().TakeQuestSourceItem(questId, true); // remove quest src item from player
|
||||||
GetPlayer().AbandonQuest(questId); // remove all quest items player received before abandoning quest. Note, this does not remove normal drop items that happen to be quest requirements.
|
GetPlayer().AbandonQuest(questId); // remove all quest items player received before abandoning quest. Note, this does not remove normal drop items that happen to be quest requirements.
|
||||||
GetPlayer().RemoveActiveQuest(questId);
|
GetPlayer().RemoveActiveQuest(questId);
|
||||||
|
GetPlayer().DespawnPersonalSummonsForQuest(questId);
|
||||||
|
|
||||||
Log.outInfo(LogFilter.Network, "Player {0} abandoned quest {1}", GetPlayer().GetGUID().ToString(), questId);
|
Log.outInfo(LogFilter.Network, "Player {0} abandoned quest {1}", GetPlayer().GetGUID().ToString(), questId);
|
||||||
|
|
||||||
|
|||||||
@@ -3746,6 +3746,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
player.RemoveActiveQuest(quest_id, false);
|
player.RemoveActiveQuest(quest_id, false);
|
||||||
player.RemoveRewardedQuest(quest_id);
|
player.RemoveRewardedQuest(quest_id);
|
||||||
|
player.DespawnPersonalSummonsForQuest(quest_id);
|
||||||
|
|
||||||
Global.ScriptMgr.OnQuestStatusChange(player, quest_id);
|
Global.ScriptMgr.OnQuestStatusChange(player, quest_id);
|
||||||
Global.ScriptMgr.OnQuestStatusChange(player, quest, oldStatus, QuestStatus.None);
|
Global.ScriptMgr.OnQuestStatusChange(player, quest, oldStatus, QuestStatus.None);
|
||||||
|
|||||||
@@ -704,6 +704,9 @@ namespace Game
|
|||||||
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Data..."); // must be after loading pools fully
|
Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Data..."); // must be after loading pools fully
|
||||||
Global.GameEventMgr.LoadFromDB();
|
Global.GameEventMgr.LoadFromDB();
|
||||||
|
|
||||||
|
Log.outInfo(LogFilter.ServerLoading, "Loading creature summoned data...");
|
||||||
|
Global.ObjectMgr.LoadCreatureSummonedData(); // must be after LoadCreatureTemplates() and LoadQuests()
|
||||||
|
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loading NPCSpellClick Data..."); // must be after LoadQuests
|
Log.outInfo(LogFilter.ServerLoading, "Loading NPCSpellClick Data..."); // must be after LoadQuests
|
||||||
Global.ObjectMgr.LoadNPCSpellClickSpells();
|
Global.ObjectMgr.LoadNPCSpellClickSpells();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user