Core/Scripts: unified scripted gossip/quest api
Port From (https://github.com/TrinityCore/TrinityCore/commit/6604849716bc73d82a4cdbf8c66bb188086ceae4)
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user