Core/AI: Kick Gossip functions upstairs, from UnitAI to CreatureAI - they only make sense for Creatures anyway.

Port From (https://github.com/TrinityCore/TrinityCore/commit/0aed5a35efd0305c1c3046430a1b348f2049a1c5)
This commit is contained in:
hondacrx
2021-04-28 10:53:26 -04:00
parent 4f650d6e90
commit cb471274e8
6 changed files with 48 additions and 51 deletions
-2
View File
@@ -387,8 +387,6 @@ namespace Framework.Constants
CovenantCallingQuest = 0x80000,
CovenantCallingRewardCompleteNoPOI = 0x100000,
CovenantCallingRewardCompletePOI = 0x200000,
ScriptedDefault = 0x80000000
}
[Flags]
+32 -2
View File
@@ -29,8 +29,8 @@ namespace Game.AI
{
bool _moveInLineOfSightLocked;
List<AreaBoundary> _boundary = new();
bool _negateBoundary;
bool _negateBoundary;
protected new Creature me;
protected EventMap _events = new();
@@ -470,6 +470,36 @@ namespace Game.AI
// called when the corpse of this creature gets removed
public virtual void CorpseRemoved(long respawnDelay) { }
/// == Gossip system ================================
// Called when the dialog status between a player and the creature is requested.
public virtual QuestGiverStatus? GetDialogStatus(Player player)
{
return null;
}
// Called when a player opens a gossip dialog with the creature.
public virtual bool GossipHello(Player player) { return false; }
// Called when a player selects a gossip item in the creature's gossip menu.
public virtual bool GossipSelect(Player player, uint menuId, uint gossipListId) { return false; }
// Called when a player selects a gossip with a code in the creature's gossip menu.
public virtual bool GossipSelectCode(Player player, uint menuId, uint gossipListId, string code)
{
return false;
}
// Called when a player accepts a quest from the creature.
public virtual void QuestAccept(Player player, Quest quest) { }
// Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
public virtual void QuestReward(Player player, Quest quest, uint opt)
{
QuestReward(player, quest, LootItemType.Item, opt);
}
public virtual void QuestReward(Player player, Quest quest, LootItemType type, uint opt) { }
public virtual void PassengerBoarded(Unit passenger, sbyte seatId, bool apply) { }
public virtual void OnSpellClick(Unit clicker, ref bool result) { }
+5 -5
View File
@@ -47,6 +47,11 @@ namespace Game.AI
public virtual void SetGUID(ObjectGuid guid, int id = 0) { }
public virtual ObjectGuid GetGUID(int id = 0) { return ObjectGuid.Empty; }
/// <summary>
/// Called when the dialog status between a player and the gameobject is requested.
/// </summary>
public virtual QuestGiverStatus? GetDialogStatus(Player player) { return null; }
/// <summary>
/// Called when a player opens a gossip dialog with the gameobject.
/// </summary>
@@ -76,11 +81,6 @@ namespace Game.AI
}
public virtual void QuestReward(Player player, Quest quest, LootItemType type, uint opt) { }
/// <summary>
/// Called when the dialog status between a player and the gameobject is requested.
/// </summary>
public virtual QuestGiverStatus GetDialogStatus(Player player) { return QuestGiverStatus.ScriptedDefault; }
// Called when a Player clicks a GameObject, before GossipHello
// prevents achievement tracking if returning true
public virtual bool OnReportUse(Player player) { return false; }
-32
View File
@@ -491,43 +491,11 @@ namespace Game.AI
public virtual void HealDone(Unit to, uint addhealth) { }
public virtual void SpellInterrupted(uint spellId, uint unTimeMs) { }
/// <summary>
/// Called when a player opens a gossip dialog with the creature.
/// </summary>
public virtual bool GossipHello(Player player) { return false; }
/// <summary>
/// Called when a player selects a gossip item in the creature's gossip menu.
/// </summary>
public virtual bool GossipSelect(Player player, uint menuId, uint gossipListId) { return false; }
/// <summary>
/// Called when a player selects a gossip with a code in the creature's gossip menu.
/// </summary>
public virtual bool GossipSelectCode(Player player, uint menuId, uint gossipListId, string code) { return false; }
/// <summary>
/// Called when a player accepts a quest from the creature.
/// </summary>
public virtual void QuestAccept(Player player, Quest quest) { }
/// <summary>
/// Called when a player completes a quest and is rewarded, opt is the selected item's index or 0
/// </summary>
public virtual void QuestReward(Player player, Quest quest, uint opt)
{
QuestReward(player, quest, LootItemType.Item, opt);
}
public virtual void QuestReward(Player player, Quest quest, LootItemType type, uint opt) { }
/// <summary>
/// Called when a game event starts or ends
/// </summary>
public virtual void OnGameEvent(bool start, ushort eventId) { }
// Called when the dialog status between a player and the creature is requested.
public virtual QuestGiverStatus GetDialogStatus(Player player) { return QuestGiverStatus.ScriptedDefault; }
public virtual void WaypointPathStarted(uint nodeId, uint pathId) { }
public virtual void WaypointStarted(uint nodeId, uint pathId) { }
+8 -6
View File
@@ -1854,18 +1854,20 @@ namespace Game.Entities
{
case TypeId.GameObject:
{
QuestGiverStatus questStatus = questgiver.ToGameObject().GetAI().GetDialogStatus(this);
if (questStatus != QuestGiverStatus.ScriptedDefault)
return questStatus;
QuestGiverStatus? questStatus = questgiver.ToGameObject().GetAI().GetDialogStatus(this);
if (questStatus.HasValue)
return questStatus.Value;
qr = Global.ObjectMgr.GetGOQuestRelationBounds(questgiver.GetEntry());
qir = Global.ObjectMgr.GetGOQuestInvolvedRelationBounds(questgiver.GetEntry());
break;
}
case TypeId.Unit:
{
QuestGiverStatus questStatus = questgiver.ToCreature().GetAI().GetDialogStatus(this);
if (questStatus != QuestGiverStatus.ScriptedDefault)
return questStatus;
QuestGiverStatus? questStatus = questgiver.ToCreature().GetAI().GetDialogStatus(this);
if (questStatus.HasValue)
return questStatus.Value;
qr = Global.ObjectMgr.GetCreatureQuestRelationBounds(questgiver.GetEntry());
qir = Global.ObjectMgr.GetCreatureQuestInvolvedRelationBounds(questgiver.GetEntry());
break;
+3 -4
View File
@@ -360,7 +360,6 @@ namespace Game
case TypeId.Player:
{
//For AutoSubmition was added plr case there as it almost same exclute AI script cases.
Unit unitQGiver = obj.ToUnit();
// Send next quest
Quest nextQuest = _player.GetNextQuest(packet.QuestGiverGUID, quest);
if (nextQuest != null)
@@ -376,9 +375,9 @@ namespace Game
}
_player.PlayerTalkClass.ClearMenus();
var qGiverAI = unitQGiver.GetAI();
if (qGiverAI != null)
qGiverAI.QuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID);
Creature creatureQGiver = obj.ToCreature();
if (creatureQGiver != null)
creatureQGiver.GetAI().QuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID);
break;
}
case TypeId.GameObject: