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
+34 -7
View File
@@ -18,14 +18,15 @@
using Framework.Dynamic;
using Game.Entities;
using Game.Spells;
using Framework.Constants;
namespace Game.AI
{
public class GameObjectAI
{
public GameObjectAI(GameObject g)
public GameObjectAI(GameObject gameObject)
{
go = g;
me = gameObject;
_scheduler = new TaskScheduler();
_events = new EventMap();
}
@@ -41,27 +42,53 @@ namespace Game.AI
public virtual void SetGUID(ulong guid, int id = 0) { }
public virtual ulong GetGUID(int id = 0) { return 0; }
/// <summary>
/// Called when a player opens a gossip dialog with the gameobject.
/// </summary>
public virtual bool GossipHello(Player player, bool reportUse) { return false; }
public virtual bool GossipSelect(Player player, uint sender, uint action) { return false; }
/// <summary>
/// Called when a player selects a gossip item in the gameobject'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 gameobject's gossip menu.
/// </summary>
public virtual bool GossipSelectCode(Player player, uint sender, uint action, string code) { return false; }
public virtual bool QuestAccept(Player player, Quest quest) { return false; }
public virtual bool QuestReward(Player player, Quest quest, uint opt) { return false; }
/// <summary>
/// Called when a player accepts a quest from the gameobject.
/// </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) { }
/// <summary>
/// Called when the dialog status between a player and the gameobject is requested.
/// </summary>
public virtual uint GetDialogStatus(Player player) { return 100; }
public virtual void Destroyed(Player player, uint eventId) { }
public virtual void Damaged(Player player, uint eventId) { }
public virtual void SetData64(uint id, ulong value) { }
public virtual ulong GetData64(uint id) { return 0; }
public virtual uint GetData(uint id) { return 0; }
public virtual void SetData(uint id, uint value) { }
public virtual void OnGameEvent(bool start, ushort eventId) { }
public virtual void OnStateChanged(uint state, Unit unit) { }
public virtual void OnLootStateChanged(uint state, Unit unit) { }
public virtual void OnStateChanged(GameObjectState state) { }
public virtual void EventInform(uint eventId) { }
public virtual void SpellHit(Unit unit, SpellInfo spellInfo) { }
protected TaskScheduler _scheduler;
protected EventMap _events;
public GameObject go;
public GameObject me;
}
public class NullGameObjectAI : GameObjectAI
+29 -5
View File
@@ -378,15 +378,39 @@ namespace Game.AI
public virtual void HealDone(Unit to, uint addhealth) { }
public virtual void SpellInterrupted(uint spellId, uint unTimeMs) {}
public virtual void GossipHello(Player player) { }
public virtual void GossipSelect(Player player, uint menuId, uint gossipListId) { }
public virtual void GossipSelectCode(Player player, uint menuId, uint gossipListId, string code) { }
/// <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) { }
public virtual void QuestSelect(Player player, Quest quest) { }
public virtual void QuestComplete(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) { }
/// <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.ScriptedNoStatus; }
public static AISpellInfoType[] AISpellInfo;
protected Unit me { get; private set; }
+26 -23
View File
@@ -789,17 +789,22 @@ namespace Game.AI
mEvadeDisabled = disable;
}
public override void GossipHello(Player player)
public override bool GossipHello(Player player)
{
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player);
return false;
}
public override void GossipSelect(Player player, uint menuId, uint gossipListId)
public override bool GossipSelect(Player player, uint menuId, uint gossipListId)
{
GetScript().ProcessEventsFor(SmartEvents.GossipSelect, player, menuId, gossipListId);
return false;
}
public override void GossipSelectCode(Player player, uint menuId, uint gossipListId, string code) { }
public override bool GossipSelectCode(Player player, uint menuId, uint gossipListId, string code)
{
return false;
}
public override void QuestAccept(Player player, Quest quest)
{
@@ -811,6 +816,11 @@ namespace Game.AI
GetScript().ProcessEventsFor(SmartEvents.RewardQuest, player, quest.Id, opt);
}
public override void OnGameEvent(bool start, ushort eventId)
{
GetScript().ProcessEventsFor(start ? SmartEvents.GameEventStart : SmartEvents.GameEventEnd, null, eventId);
}
public void SetCombatMove(bool on)
{
if (mCanCombatMove == on)
@@ -899,11 +909,6 @@ namespace Game.AI
GetScript().SetScript9(e, entry);
}
public override void OnGameEvent(bool start, ushort eventId)
{
GetScript().ProcessEventsFor(start ? SmartEvents.GameEventStart : SmartEvents.GameEventEnd, null, eventId);
}
public override void OnSpellClick(Unit clicker, ref bool result)
{
if (!result)
@@ -1043,9 +1048,9 @@ namespace Game.AI
public override void InitializeAI()
{
GetScript().OnInitialize(go);
GetScript().OnInitialize(me);
// do not call respawn event if go is not spawned
if (go.IsSpawned())
if (me.IsSpawned())
GetScript().ProcessEventsFor(SmartEvents.Respawn);
}
@@ -1060,31 +1065,29 @@ namespace Game.AI
public override bool GossipHello(Player player, bool reportUse)
{
Log.outDebug(LogFilter.ScriptsAi, "SmartGameObjectAI.GossipHello");
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player, reportUse ? 1 : 0u, 0, false, null, go);
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player, reportUse ? 1 : 0u, 0, false, null, me);
return false;
}
public override bool GossipSelect(Player player, uint sender, uint action)
public override bool GossipSelect(Player player, uint menuId, uint gossipListId)
{
GetScript().ProcessEventsFor(SmartEvents.GossipSelect, player, sender, action, false, null, go);
GetScript().ProcessEventsFor(SmartEvents.GossipSelect, player, menuId, gossipListId, false, null, me);
return false;
}
public override bool GossipSelectCode(Player player, uint sender, uint action, string code)
public override bool GossipSelectCode(Player player, uint menuId, uint gossipListId, string code)
{
return false;
}
public override bool QuestAccept(Player player, Quest quest)
public override void QuestAccept(Player player, Quest quest)
{
GetScript().ProcessEventsFor(SmartEvents.AcceptedQuest, player, quest.Id, 0, false, null, go);
return false;
GetScript().ProcessEventsFor(SmartEvents.AcceptedQuest, player, quest.Id, 0, false, null, me);
}
public override bool QuestReward(Player player, Quest quest, uint opt)
public override void QuestReward(Player player, Quest quest, uint opt)
{
GetScript().ProcessEventsFor(SmartEvents.RewardQuest, player, quest.Id, opt, false, null, go);
return false;
GetScript().ProcessEventsFor(SmartEvents.RewardQuest, player, quest.Id, opt, false, null, me);
}
public override uint GetDialogStatus(Player player)
@@ -1094,7 +1097,7 @@ namespace Game.AI
public override void Destroyed(Player player, uint eventId)
{
GetScript().ProcessEventsFor(SmartEvents.Death, player, eventId, 0, false, null, go);
GetScript().ProcessEventsFor(SmartEvents.Death, player, eventId, 0, false, null, me);
}
public override void SetData(uint id, uint value)
@@ -1114,9 +1117,9 @@ namespace Game.AI
GetScript().ProcessEventsFor(start ? SmartEvents.GameEventStart : SmartEvents.GameEventEnd, null, eventId);
}
public override void OnStateChanged(uint state, Unit unit)
public override void OnLootStateChanged(uint state, Unit unit)
{
GetScript().ProcessEventsFor(SmartEvents.GoStateChanged, unit, state);
GetScript().ProcessEventsFor(SmartEvents.GoLootStateChanged, unit, state);
}
public override void EventInform(uint eventId)
@@ -757,7 +757,7 @@ namespace Game.AI
}
break;
case SmartEvents.Link:
case SmartEvents.GoStateChanged:
case SmartEvents.GoLootStateChanged:
case SmartEvents.GoEventInform:
case SmartEvents.TimedEventTriggered:
case SmartEvents.InstancePlayerEnter:
@@ -1638,7 +1638,7 @@ namespace Game.AI
{ SmartEvents.IsBehindTarget, SmartScriptTypeMaskId.Creature },
{ SmartEvents.GameEventStart, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject },
{ SmartEvents.GameEventEnd, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject },
{ SmartEvents.GoStateChanged, SmartScriptTypeMaskId.Gameobject },
{ SmartEvents.GoLootStateChanged, SmartScriptTypeMaskId.Gameobject },
{ SmartEvents.GoEventInform, SmartScriptTypeMaskId.Gameobject },
{ SmartEvents.ActionDone, SmartScriptTypeMaskId.Creature },
{ SmartEvents.OnSpellclick, SmartScriptTypeMaskId.Creature },
@@ -1813,7 +1813,7 @@ namespace Game.AI
public GameEvent gameEvent;
[FieldOffset(16)]
public GoStateChanged goStateChanged;
public GoLootStateChanged goLootStateChanged;
[FieldOffset(16)]
public EventInform eventInform;
@@ -2009,9 +2009,9 @@ namespace Game.AI
{
public uint gameEventId;
}
public struct GoStateChanged
public struct GoLootStateChanged
{
public uint state;
public uint lootState;
}
public struct EventInform
{
+6 -6
View File
@@ -2736,16 +2736,16 @@ namespace Game.AI
if (go == null)
return;
//store hostage as id1
AddEvent(SmartEvents.GoStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 1, 0, 0, 0, 0, 0, SmartTargets.ClosestCreature, e.Action.installTtemplate.param1, 10, 0, 0);
AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 1, 0, 0, 0, 0, 0, SmartTargets.ClosestCreature, e.Action.installTtemplate.param1, 10, 0, 0);
//store invoker as id2
AddEvent(SmartEvents.GoStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 2, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0);
AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.StoreTargetList, 2, 0, 0, 0, 0, 0, SmartTargets.None, 0, 0, 0, 0);
//signal hostage
AddEvent(SmartEvents.GoStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.SetData, 0, 0, 0, 0, 0, 0, SmartTargets.Stored, 1, 0, 0, 0);
AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.SetData, 0, 0, 0, 0, 0, 0, SmartTargets.Stored, 1, 0, 0, 0);
//when hostage raeched end point, give credit to invoker
if (e.Action.installTtemplate.param2 != 0)
AddEvent(SmartEvents.DataSet, 0, 0, 0, 0, 0, 0, SmartActions.CallKilledmonster, e.Action.installTtemplate.param1, 0, 0, 0, 0, 0, SmartTargets.Stored, 2, 0, 0, 0);
else
AddEvent(SmartEvents.GoStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.CallKilledmonster, e.Action.installTtemplate.param1, 0, 0, 0, 0, 0, SmartTargets.Stored, 2, 0, 0, 0);
AddEvent(SmartEvents.GoLootStateChanged, 0, 2, 0, 0, 0, 0, SmartActions.CallKilledmonster, e.Action.installTtemplate.param1, 0, 0, 0, 0, 0, SmartTargets.Stored, 2, 0, 0, 0);
break;
}
default:
@@ -3632,9 +3632,9 @@ namespace Game.AI
ProcessAction(e, null, var0);
break;
}
case SmartEvents.GoStateChanged:
case SmartEvents.GoLootStateChanged:
{
if (e.Event.goStateChanged.state != var0)
if (e.Event.goLootStateChanged.lootState != var0)
return;
ProcessAction(e, unit, var0, var1);
break;
@@ -559,8 +559,6 @@ namespace Game.Entities
}
break;
}
Global.ScriptMgr.OnCreatureUpdate(this, diff);
}
public void Regenerate(PowerType power)
@@ -802,7 +802,6 @@ namespace Game.Entities
break;
}
}
Global.ScriptMgr.OnGameObjectUpdate(this, diff);
}
public void Refresh()
@@ -1306,9 +1305,7 @@ namespace Game.Entities
Player playerUser = user.ToPlayer();
if (playerUser != null)
{
if (Global.ScriptMgr.OnGossipHello(playerUser, this))
return;
playerUser.PlayerTalkClass.ClearMenus();
if (GetAI().GossipHello(playerUser, false))
return;
}
@@ -2207,7 +2204,7 @@ namespace Game.Entities
case GameObjectDestructibleState.Damaged:
{
EventInform(m_goInfo.DestructibleBuilding.DamagedEvent, eventInvoker);
Global.ScriptMgr.OnGameObjectDamaged(this, eventInvoker);
GetAI().Damaged(eventInvoker, m_goInfo.DestructibleBuilding.DamagedEvent);
RemoveFlag(GameObjectFlags.Destroyed);
AddFlag(GameObjectFlags.Damaged);
@@ -2232,8 +2229,8 @@ namespace Game.Entities
}
case GameObjectDestructibleState.Destroyed:
{
Global.ScriptMgr.OnGameObjectDestroyed(this, eventInvoker);
EventInform(m_goInfo.DestructibleBuilding.DestroyedEvent, eventInvoker);
GetAI().Destroyed(eventInvoker, m_goInfo.DestructibleBuilding.DestroyedEvent);
if (eventInvoker != null)
{
Battleground bg = eventInvoker.GetBattleground();
@@ -2287,8 +2284,7 @@ namespace Game.Entities
{
m_lootState = state;
m_lootStateUnitGUID = unit ? unit.GetGUID() : ObjectGuid.Empty;
GetAI().OnStateChanged((uint)state, unit);
Global.ScriptMgr.OnGameObjectLootStateChanged(this, (uint)state, unit);
GetAI().OnLootStateChanged((uint)state, unit);
// only set collision for doors on SetGoState
if (GetGoType() == GameObjectTypes.Door)
@@ -2308,7 +2304,8 @@ namespace Game.Entities
public void SetGoState(GameObjectState state)
{
SetUpdateFieldValue(m_values.ModifyValue(m_gameObjectData).ModifyValue(m_gameObjectData.State), (sbyte)state);
Global.ScriptMgr.OnGameObjectStateChanged(this, state);
if (GetAI() != null)
GetAI().OnStateChanged(state);
if (m_model != null && !IsTransport())
{
if (!IsInWorld)
+5 -4
View File
@@ -578,7 +578,7 @@ namespace Game.Entities
switch (questGiver.GetTypeId())
{
case TypeId.Unit:
Global.ScriptMgr.OnQuestAccept(this, (questGiver.ToCreature()), quest);
PlayerTalkClass.ClearMenus();
questGiver.ToCreature().GetAI().QuestAccept(this, quest);
break;
case TypeId.Item:
@@ -606,7 +606,7 @@ namespace Game.Entities
break;
}
case TypeId.GameObject:
Global.ScriptMgr.OnQuestAccept(this, questGiver.ToGameObject(), quest);
PlayerTalkClass.ClearMenus();
questGiver.ToGameObject().GetAI().QuestAccept(this, quest);
break;
default:
@@ -1817,11 +1817,12 @@ namespace Game.Entities
List<uint> qr;
List<uint> qir;
PlayerTalkClass.ClearMenus();
switch (questgiver.GetTypeId())
{
case TypeId.GameObject:
{
QuestGiverStatus questStatus = (QuestGiverStatus)Global.ScriptMgr.GetDialogStatus(this, questgiver.ToGameObject());
QuestGiverStatus questStatus = (QuestGiverStatus)questgiver.ToGameObject().GetAI().GetDialogStatus(this);
if (questStatus != QuestGiverStatus.ScriptedNoStatus)
return questStatus;
qr = Global.ObjectMgr.GetGOQuestRelationBounds(questgiver.GetEntry());
@@ -1830,7 +1831,7 @@ namespace Game.Entities
}
case TypeId.Unit:
{
QuestGiverStatus questStatus = (QuestGiverStatus)Global.ScriptMgr.GetDialogStatus(this, questgiver.ToCreature());
QuestGiverStatus questStatus = (QuestGiverStatus)questgiver.ToCreature().GetAI().GetDialogStatus(this);
if (questStatus != QuestGiverStatus.ScriptedNoStatus)
return questStatus;
qr = Global.ObjectMgr.GetCreatureQuestRelationBounds(questgiver.GetEntry());
+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:
+7 -65
View File
@@ -54,25 +54,25 @@ namespace Game.Scripting
return null;
}
public void ClearGossipMenuFor(Player player) { player.PlayerTalkClass.ClearMenus(); }
public static void ClearGossipMenuFor(Player player) { player.PlayerTalkClass.ClearMenus(); }
// Using provided text, not from DB
public void AddGossipItemFor(Player player, GossipOptionIcon icon, string text, uint sender, uint action)
public static void AddGossipItemFor(Player player, GossipOptionIcon icon, string text, uint sender, uint action)
{
player.PlayerTalkClass.GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0);
}
// Using provided texts, not from DB
public void AddGossipItemFor(Player player, GossipOptionIcon icon, string text, uint sender, uint action, string popupText, uint popupMoney, bool coded)
public static void AddGossipItemFor(Player player, GossipOptionIcon icon, string text, uint sender, uint action, string popupText, uint popupMoney, bool coded)
{
player.PlayerTalkClass.GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded);
}
// Uses gossip item info from DB
public void AddGossipItemFor(Player player, uint gossipMenuID, uint gossipMenuItemID, uint sender, uint action)
public static void AddGossipItemFor(Player player, uint gossipMenuID, uint gossipMenuItemID, uint sender, uint action)
{
player.PlayerTalkClass.GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action);
}
public void SendGossipMenuFor(Player player, uint npcTextID, ObjectGuid guid) { player.PlayerTalkClass.SendGossipMenu(npcTextID, guid); }
public void SendGossipMenuFor(Player player, uint npcTextID, Creature creature) { if (creature) SendGossipMenuFor(player, npcTextID, creature.GetGUID()); }
public void CloseGossipMenuFor(Player player) { player.PlayerTalkClass.SendCloseGossip(); }
public static void SendGossipMenuFor(Player player, uint npcTextID, ObjectGuid guid) { player.PlayerTalkClass.SendGossipMenu(npcTextID, guid); }
public static void SendGossipMenuFor(Player player, uint npcTextID, Creature creature) { if (creature) SendGossipMenuFor(player, npcTextID, creature.GetGUID()); }
public static void CloseGossipMenuFor(Player player) { player.PlayerTalkClass.SendCloseGossip(); }
string _name;
}
@@ -333,37 +333,11 @@ namespace Game.Scripting
public override bool IsDatabaseBound() { return true; }
// Called when a player opens a gossip dialog with the creature.
public virtual bool OnGossipHello(Player player, Creature creature) { return false; }
// Called when a player selects a gossip item in the creature's gossip menu.
public virtual bool OnGossipSelect(Player player, Creature creature, uint sender, uint action) { return false; }
// Called when a player selects a gossip with a code in the creature's gossip menu.
public virtual bool OnGossipSelectCode(Player player, Creature creature, uint sender, uint action, string code) { return false; }
// Called when a player accepts a quest from the creature.
public virtual bool OnQuestAccept(Player player, Creature creature, Quest quest) { return false; }
// Called when a player selects a quest in the creature's quest menu.
public virtual bool OnQuestSelect(Player player, Creature creature, Quest quest) { return false; }
// Called when a player completes a quest with the creature.
public virtual bool OnQuestComplete(Player player, Creature creature, Quest quest) { return false; }
// Called when a player selects a quest reward.
public virtual bool OnQuestReward(Player player, Creature creature, Quest quest, uint opt) { return false; }
// Called when the dialog status between a player and the creature is requested.
public virtual uint GetDialogStatus(Player player, Creature creature) { return (uint)QuestGiverStatus.ScriptedNoStatus; }
// Called when the creature tries to spawn. Return false to block spawn and re-evaluate on next tick.
public virtual bool CanSpawn(ulong spawnId, uint entry, CreatureTemplate baseTemplate, CreatureTemplate actTemplate, CreatureData cData, Map map) { return true; }
// Called when a CreatureAI object is needed for the creature.
public virtual CreatureAI GetAI(Creature creature) { return null; }
public virtual void OnUpdate(Creature obj, uint diff) { }
}
public class GameObjectScript : ScriptObject
@@ -375,40 +349,8 @@ namespace Game.Scripting
public override bool IsDatabaseBound() { return true; }
// Called when a player opens a gossip dialog with the gameobject.
public virtual bool OnGossipHello(Player player, GameObject go) { return false; }
// Called when a player selects a gossip item in the gameobject's gossip menu.
public virtual bool OnGossipSelect(Player player, GameObject go, uint sender, uint action) { return false; }
// Called when a player selects a gossip with a code in the gameobject's gossip menu.
public virtual bool OnGossipSelectCode(Player player, GameObject go, uint sender, uint action, string code) { return false; }
// Called when a player accepts a quest from the gameobject.
public virtual bool OnQuestAccept(Player player, GameObject go, Quest quest) { return false; }
// Called when a player selects a quest reward.
public virtual bool OnQuestReward(Player player, GameObject go, Quest quest, uint opt) { return false; }
// Called when the dialog status between a player and the gameobject is requested.
public virtual uint GetDialogStatus(Player player, GameObject go) { return 100; }
// Called when the game object is destroyed (destructible buildings only).
public virtual void OnDestroyed(GameObject go, Player player) { }
// Called when the game object is damaged (destructible buildings only).
public virtual void OnDamaged(GameObject go, Player player) { }
// Called when the game object loot state is changed.
public virtual void OnLootStateChanged(GameObject go, uint state, Unit unit) { }
// Called when the game object state is changed.
public virtual void OnGameObjectStateChanged(GameObject go, GameObjectState state) { }
// Called when a GameObjectAI object is needed for the gameobject.
public virtual GameObjectAI GetAI(GameObject go) { return null; }
public virtual void OnUpdate(GameObject obj, uint diff) { }
}
public class AreaTriggerScript : ScriptObject
-144
View File
@@ -749,68 +749,6 @@ namespace Game.Scripting
}
//CreatureScript
public bool OnGossipHello(Player player, Creature creature)
{
Cypher.Assert(player);
Cypher.Assert(creature);
return RunScriptRet<CreatureScript>(p => p.OnGossipHello(player, creature), creature.GetScriptId());
}
public bool OnGossipSelect(Player player, Creature creature, uint sender, uint action)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
return RunScriptRet<CreatureScript>(p => p.OnGossipSelect(player, creature, sender, action), creature.GetScriptId());
}
public bool OnGossipSelectCode(Player player, Creature creature, uint sender, uint action, string code)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
Cypher.Assert(code != null);
return RunScriptRet<CreatureScript>(p => p.OnGossipSelectCode(player, creature, sender, action, code), creature.GetScriptId());
}
public bool OnQuestAccept(Player player, Creature creature, Quest quest)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestAccept(player, creature, quest), creature.GetScriptId());
}
public bool OnQuestSelect(Player player, Creature creature, Quest quest)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestSelect(player, creature, quest), creature.GetScriptId());
}
public bool OnQuestComplete(Player player, Creature creature, Quest quest)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestComplete(player, creature, quest), creature.GetScriptId());
}
public bool OnQuestReward(Player player, Creature creature, Quest quest, uint opt)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
Cypher.Assert(quest != null);
return RunScriptRet<CreatureScript>(p => p.OnQuestReward(player, creature, quest, opt), creature.GetScriptId());
}
public uint GetDialogStatus(Player player, Creature creature)
{
Cypher.Assert(player != null);
Cypher.Assert(creature != null);
player.PlayerTalkClass.ClearMenus();
return RunScriptRet<CreatureScript, uint>(p => p.GetDialogStatus(player, creature), creature.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus);
}
public bool CanSpawn(ulong spawnId, uint entry, CreatureTemplate actTemplate, CreatureData cData, Map map)
{
Cypher.Assert(actTemplate != null);
@@ -826,90 +764,8 @@ namespace Game.Scripting
return RunScriptRet<CreatureScript, CreatureAI>(p => p.GetAI(creature), creature.GetScriptId());
}
public void OnCreatureUpdate(Creature creature, uint diff)
{
Cypher.Assert(creature != null);
RunScript<CreatureScript>(p => p.OnUpdate(creature, diff), creature.GetScriptId());
}
//GameObjectScript
public bool OnGossipHello(Player player, GameObject go)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
player.PlayerTalkClass.ClearMenus();
return RunScriptRet<GameObjectScript>(p => p.OnGossipHello(player, go), go.GetScriptId());
}
public bool OnGossipSelect(Player player, GameObject go, uint sender, uint action)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
return RunScriptRet<GameObjectScript>(p => p.OnGossipSelect(player, go, sender, action), go.GetScriptId());
}
public bool OnGossipSelectCode(Player player, GameObject go, uint sender, uint action, string code)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
Cypher.Assert(code != null);
return RunScriptRet<GameObjectScript>(p => p.OnGossipSelectCode(player, go, sender, action, code), go.GetScriptId());
}
public bool OnQuestAccept(Player player, GameObject go, Quest quest)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
Cypher.Assert(quest != null);
return RunScriptRet<GameObjectScript>(p => p.OnQuestAccept(player, go, quest), go.GetScriptId());
}
public bool OnQuestReward(Player player, GameObject go, Quest quest, uint opt)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
Cypher.Assert(quest != null);
return RunScriptRet<GameObjectScript>(p => p.OnQuestReward(player, go, quest, opt), go.GetScriptId());
}
public uint GetDialogStatus(Player player, GameObject go)
{
Cypher.Assert(player != null);
Cypher.Assert(go != null);
return RunScriptRet<GameObjectScript, uint>(p => p.GetDialogStatus(player, go), go.GetScriptId(), (uint)QuestGiverStatus.ScriptedNoStatus);
}
public void OnGameObjectDestroyed(GameObject go, Player player)
{
Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnDestroyed(go, player), go.GetScriptId());
}
public void OnGameObjectDamaged(GameObject go, Player player)
{
Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnDamaged(go, player), go.GetScriptId());
}
public void OnGameObjectLootStateChanged(GameObject go, uint state, Unit unit)
{
Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnLootStateChanged(go, state, unit), go.GetScriptId());
}
public void OnGameObjectStateChanged(GameObject go, GameObjectState state)
{
Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnGameObjectStateChanged(go, state), go.GetScriptId());
}
public void OnGameObjectUpdate(GameObject go, uint diff)
{
Cypher.Assert(go != null);
RunScript<GameObjectScript>(p => p.OnUpdate(go, diff), go.GetScriptId());
}
public GameObjectAI GetGameObjectAI(GameObject go)
{
Cypher.Assert(go != null);
+1 -3
View File
@@ -1321,9 +1321,7 @@ namespace Game.Spells
return;
}
if (Global.ScriptMgr.OnGossipHello(player, gameObjTarget))
return;
player.PlayerTalkClass.ClearMenus();
if (gameObjTarget.GetAI().GossipHello(player, false))
return;