Core/Creatures: Implemented UNIT_NPC_FLAG_GOSSIP as viewer dependent and update npcflags on quest changes
Port From (https://github.com/TrinityCore/TrinityCore/commit/dd15d763cc0529afc9b7f077817645d875608626)
This commit is contained in:
@@ -112,6 +112,8 @@ namespace Game.Chat
|
|||||||
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);
|
||||||
|
|
||||||
|
player.UpdateNearbyCreatureNpcFlags();
|
||||||
|
|
||||||
handler.SendSysMessage(CypherStrings.CommandQuestRemoved);
|
handler.SendSysMessage(CypherStrings.CommandQuestRemoved);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2332,8 +2332,18 @@ namespace Game.Entities
|
|||||||
uint GetViewerDependentNpcFlags(UnitData unitData, int i, Unit unit, Player receiver)
|
uint GetViewerDependentNpcFlags(UnitData unitData, int i, Unit unit, Player receiver)
|
||||||
{
|
{
|
||||||
uint npcFlag = unitData.NpcFlags[i];
|
uint npcFlag = unitData.NpcFlags[i];
|
||||||
if (i == 0 && unit.IsCreature() && !receiver.CanSeeSpellClickOn(unit.ToCreature()))
|
if (i == 0)
|
||||||
npcFlag &= ~(uint)NPCFlags.SpellClick;
|
{
|
||||||
|
Creature creature = unit.ToCreature();
|
||||||
|
if (creature != null)
|
||||||
|
{
|
||||||
|
if (!receiver.CanSeeGossipOn(creature))
|
||||||
|
npcFlag &= ~(uint)(NPCFlags.Gossip | NPCFlags.QuestGiver);
|
||||||
|
|
||||||
|
if (!receiver.CanSeeSpellClickOn(creature))
|
||||||
|
npcFlag &= ~(uint)NPCFlags.SpellClick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return npcFlag;
|
return npcFlag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -841,6 +841,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
Global.ScriptMgr.OnQuestStatusChange(this, questId);
|
Global.ScriptMgr.OnQuestStatusChange(this, questId);
|
||||||
Global.ScriptMgr.OnQuestStatusChange(this, quest, oldStatus, questStatusData.Status);
|
Global.ScriptMgr.OnQuestStatusChange(this, quest, oldStatus, questStatusData.Status);
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CompleteQuest(uint quest_id)
|
public void CompleteQuest(uint quest_id)
|
||||||
@@ -1228,6 +1230,8 @@ namespace Game.Entities
|
|||||||
if (quest.HasFlag(QuestFlags.UpdatePhaseshift))
|
if (quest.HasFlag(QuestFlags.UpdatePhaseshift))
|
||||||
updateVisibility = PhasingHandler.OnConditionChange(this, false);
|
updateVisibility = PhasingHandler.OnConditionChange(this, false);
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
|
|
||||||
//lets remove flag for delayed teleports
|
//lets remove flag for delayed teleports
|
||||||
SetCanDelayTeleport(false);
|
SetCanDelayTeleport(false);
|
||||||
|
|
||||||
@@ -1258,6 +1262,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (updateVisibility)
|
if (updateVisibility)
|
||||||
UpdateObjectVisibility();
|
UpdateObjectVisibility();
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRewardedQuest(uint questId)
|
public void SetRewardedQuest(uint questId)
|
||||||
@@ -1910,6 +1916,8 @@ namespace Game.Entities
|
|||||||
Global.ScriptMgr.OnQuestStatusChange(this, quest, oldStatus, status);
|
Global.ScriptMgr.OnQuestStatusChange(this, quest, oldStatus, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
SendQuestUpdate(questId);
|
SendQuestUpdate(questId);
|
||||||
}
|
}
|
||||||
@@ -2184,6 +2192,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
if (updateVisibility)
|
if (updateVisibility)
|
||||||
UpdateObjectVisibility();
|
UpdateObjectVisibility();
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DespawnPersonalSummonsForQuest(uint questId)
|
public void DespawnPersonalSummonsForQuest(uint questId)
|
||||||
@@ -2705,6 +2715,8 @@ namespace Game.Entities
|
|||||||
if (updatePhaseShift)
|
if (updatePhaseShift)
|
||||||
PhasingHandler.OnConditionChange(this);
|
PhasingHandler.OnConditionChange(this);
|
||||||
|
|
||||||
|
UpdateNearbyCreatureNpcFlags();
|
||||||
|
|
||||||
if (updateZoneAuras)
|
if (updateZoneAuras)
|
||||||
{
|
{
|
||||||
UpdateZoneDependentAuras(GetZoneId());
|
UpdateZoneDependentAuras(GetZoneId());
|
||||||
@@ -2753,6 +2765,39 @@ namespace Game.Entities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanSeeGossipOn(Creature creature)
|
||||||
|
{
|
||||||
|
if (creature.HasNpcFlag(NPCFlags.Gossip))
|
||||||
|
{
|
||||||
|
if (GetGossipMenuForSource(creature) != 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for cases with questgiver/ender without gossip menus
|
||||||
|
if (creature.HasNpcFlag(NPCFlags.QuestGiver))
|
||||||
|
{
|
||||||
|
QuestRelationResult objectQIR = Global.ObjectMgr.GetCreatureQuestInvolvedRelations(creature.GetEntry());
|
||||||
|
foreach (uint quest_id in objectQIR)
|
||||||
|
{
|
||||||
|
QuestStatus status = GetQuestStatus(quest_id);
|
||||||
|
if (status == QuestStatus.Complete || status == QuestStatus.Incomplete)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestRelationResult objectQR = Global.ObjectMgr.GetCreatureQuestRelations(creature.GetEntry());
|
||||||
|
foreach (uint quest_id in objectQR)
|
||||||
|
{
|
||||||
|
Quest quest = Global.ObjectMgr.GetQuestTemplate(quest_id);
|
||||||
|
if (quest == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CanTakeQuest(quest, false))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QuestObjective GetQuestObjectiveForItem(uint itemId, bool onlyIncomplete)
|
QuestObjective GetQuestObjectiveForItem(uint itemId, bool onlyIncomplete)
|
||||||
{
|
{
|
||||||
QuestObjective findObjectiveForItem(int tempItemId)
|
QuestObjective findObjectiveForItem(int tempItemId)
|
||||||
|
|||||||
@@ -5490,6 +5490,35 @@ namespace Game.Entities
|
|||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateNearbyCreatureNpcFlags()
|
||||||
|
{
|
||||||
|
List<Creature> creatures = GetCreatureListWithOptionsInGrid(GetVisibilityRange(), new() { IgnorePhases = false });
|
||||||
|
|
||||||
|
UpdateData udata = new(GetMapId());
|
||||||
|
ObjectFieldData objMask = new();
|
||||||
|
UnitData unitMask = new();
|
||||||
|
for (int i = 0; i < m_unitData.NpcFlags.GetSize(); ++i)
|
||||||
|
unitMask.MarkChanged(m_unitData.NpcFlags, i);
|
||||||
|
|
||||||
|
foreach (Creature creature in creatures)
|
||||||
|
{
|
||||||
|
if (!HaveAtClient(creature))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// skip creatures which dont have any npcflags set
|
||||||
|
if (creature.GetNpcFlags() == 0 && creature.GetNpcFlags2() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
creature.BuildValuesUpdateForPlayerWithMask(udata, objMask.GetUpdateMask(), unitMask.GetUpdateMask(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!udata.HasData())
|
||||||
|
return;
|
||||||
|
|
||||||
|
udata.BuildPacket(out UpdateObject packet);
|
||||||
|
SendPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
public void SendInitialPacketsBeforeAddToMap()
|
public void SendInitialPacketsBeforeAddToMap()
|
||||||
{
|
{
|
||||||
if (!m_teleport_options.HasAnyFlag(TeleportToOptions.Seamless))
|
if (!m_teleport_options.HasAnyFlag(TeleportToOptions.Seamless))
|
||||||
|
|||||||
@@ -445,6 +445,8 @@ namespace Game
|
|||||||
|
|
||||||
if (quest != null)
|
if (quest != null)
|
||||||
Global.ScriptMgr.OnQuestStatusChange(_player, quest, oldStatus, QuestStatus.None);
|
Global.ScriptMgr.OnQuestStatusChange(_player, quest, oldStatus, QuestStatus.None);
|
||||||
|
|
||||||
|
_player.UpdateNearbyCreatureNpcFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
GetPlayer().UpdateCriteria(CriteriaType.AbandonAnyQuest, 1);
|
GetPlayer().UpdateCriteria(CriteriaType.AbandonAnyQuest, 1);
|
||||||
|
|||||||
@@ -3752,6 +3752,8 @@ namespace Game.Spells
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
player.UpdateNearbyCreatureNpcFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.SendTaxi)]
|
[SpellEffectHandler(SpellEffectName.SendTaxi)]
|
||||||
|
|||||||
Reference in New Issue
Block a user