Core/Scripts: unified scripted gossip/quest api

Port From (https://github.com/TrinityCore/TrinityCore/commit/6604849716bc73d82a4cdbf8c66bb188086ceae4)
This commit is contained in:
hondacrx
2020-05-22 13:28:20 -04:00
parent 87b63b0975
commit c2aee387a8
30 changed files with 1642 additions and 1367 deletions
+8 -11
View File
@@ -159,12 +159,12 @@ namespace Game
}
}
if (!Global.ScriptMgr.OnGossipHello(GetPlayer(), unit))
_player.PlayerTalkClass.ClearMenus();
if (!unit.GetAI().GossipHello(_player))
{
GetPlayer().PrepareGossipMenu(unit, unit.GetCreatureTemplate().GossipMenuId, true);
GetPlayer().SendPreparedGossip(unit);
}
unit.GetAI().GossipHello(GetPlayer());
}
[WorldPacketHandler(ClientOpcodes.GossipSelectOption)]
@@ -220,30 +220,27 @@ namespace Game
}
if (!string.IsNullOrEmpty(packet.PromotionCode))
{
if (unit)
if (unit != null)
{
unit.GetAI().GossipSelectCode(GetPlayer(), packet.GossipID, packet.GossipIndex, packet.PromotionCode);
if (!Global.ScriptMgr.OnGossipSelectCode(GetPlayer(), unit, GetPlayer().PlayerTalkClass.GetGossipOptionSender(packet.GossipIndex), GetPlayer().PlayerTalkClass.GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode))
if (!unit.GetAI().GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode))
GetPlayer().OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
}
else
{
go.GetAI().GossipSelectCode(GetPlayer(), packet.GossipID, packet.GossipIndex, packet.PromotionCode);
Global.ScriptMgr.OnGossipSelectCode(GetPlayer(), go, GetPlayer().PlayerTalkClass.GetGossipOptionSender(packet.GossipIndex), GetPlayer().PlayerTalkClass.GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode);
if (!go.GetAI().GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode))
_player.OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
}
}
else
{
if (unit != null)
{
unit.GetAI().GossipSelect(GetPlayer(), packet.GossipID, packet.GossipIndex);
if (!Global.ScriptMgr.OnGossipSelect(GetPlayer(), unit, GetPlayer().PlayerTalkClass.GetGossipOptionSender(packet.GossipIndex), GetPlayer().PlayerTalkClass.GetGossipOptionAction(packet.GossipIndex)))
if (!unit.GetAI().GossipSelect(_player, packet.GossipID, packet.GossipIndex))
GetPlayer().OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
}
else
{
go.GetAI().GossipSelect(GetPlayer(), packet.GossipID, packet.GossipIndex);
if (!Global.ScriptMgr.OnGossipSelect(GetPlayer(), go, GetPlayer().PlayerTalkClass.GetGossipOptionSender(packet.GossipIndex), GetPlayer().PlayerTalkClass.GetGossipOptionAction(packet.GossipIndex)))
if (!go.GetAI().GossipSelect(_player, packet.GossipID, packet.GossipIndex))
GetPlayer().OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
}
}
+6 -8
View File
@@ -74,13 +74,12 @@ namespace Game
// Stop the npc if moving
creature.StopMoving();
if (Global.ScriptMgr.OnGossipHello(GetPlayer(), creature))
_player.PlayerTalkClass.ClearMenus();
if (creature.GetAI().GossipHello(_player))
return;
GetPlayer().PrepareGossipMenu(creature, creature.GetCreatureTemplate().GossipMenuId, true);
GetPlayer().SendPreparedGossip(creature);
creature.GetAI().GossipHello(GetPlayer());
}
[WorldPacketHandler(ClientOpcodes.QuestGiverAcceptQuest)]
@@ -348,8 +347,8 @@ namespace Game
}
}
if (creatureQGiver && !Global.ScriptMgr.OnQuestReward(_player, creatureQGiver, quest, packet.ItemChoiceID))
creatureQGiver.GetAI().QuestReward(_player, quest, packet.ItemChoiceID);
_player.PlayerTalkClass.ClearMenus();
creatureQGiver.GetAI().QuestReward(_player, quest, packet.ItemChoiceID);
break;
}
case TypeId.GameObject:
@@ -369,9 +368,8 @@ namespace Game
}
}
if (!Global.ScriptMgr.OnQuestReward(_player, questGiver, quest, packet.ItemChoiceID))
questGiver.GetAI().QuestReward(_player, quest, packet.ItemChoiceID);
_player.PlayerTalkClass.ClearMenus();
questGiver.GetAI().QuestReward(_player, quest, packet.ItemChoiceID);
break;
}
default: