Core/AI: segregate GameObject ReportUse from normal Use (lock open/normal click)

Port From (https://github.com/TrinityCore/TrinityCore/commit/5903a10a834b1198702b024182581799648540ff)
This commit is contained in:
hondacrx
2020-07-22 14:21:29 -04:00
parent 0ece69bf90
commit 61b6606dce
13 changed files with 58 additions and 50 deletions
+6 -1
View File
@@ -45,7 +45,7 @@ namespace Game.AI
/// <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 GossipHello(Player player) { return false; }
/// <summary>
/// Called when a player selects a gossip item in the gameobject's gossip menu.
@@ -71,6 +71,11 @@ namespace Game.AI
/// Called when the dialog status between a player and the gameobject is requested.
/// </summary>
public virtual uint GetDialogStatus(Player player) { return 100; }
// Called when a Player clicks a GameObject, before GossipHello
// prevents achievement tracking if returning true
public virtual bool OnReportUse(Player player) { return false; }
public virtual void Destroyed(Player player, uint eventId) { }
public virtual void Damaged(Player player, uint eventId) { }
+9 -2
View File
@@ -1069,10 +1069,17 @@ namespace Game.AI
GetScript().OnReset();
}
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
_gossipReturn = false;
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player, reportUse ? 1 : 0u, 0, false, null, me);
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player, 0, 0, false, null, me);
return _gossipReturn;
}
public override bool OnReportUse(Player player)
{
_gossipReturn = false;
GetScript().ProcessEventsFor(SmartEvents.GossipHello, player, 1, 0, false, null, me);
return _gossipReturn;
}
+1 -2
View File
@@ -2228,9 +2228,8 @@ namespace Game.AI
// We may want to execute action rarely and because of this if condition is not fulfilled the action will be rechecked in a long time
if (Global.ConditionMgr.IsObjectMeetingSmartEventConditions(e.entryOrGuid, e.event_id, e.source_type, unit, GetBaseObject()))
{
ProcessAction(e, unit, var0, var1, bvar, spell, gob, varString);
RecalcTimer(e, min, max);
ProcessAction(e, unit, var0, var1, bvar, spell, gob, varString);
}
else
RecalcTimer(e, Math.Min(min, 5000), Math.Min(min, 5000));
@@ -1306,7 +1306,7 @@ namespace Game.Entities
if (playerUser != null)
{
playerUser.PlayerTalkClass.ClearMenus();
if (GetAI().GossipHello(playerUser, false))
if (GetAI().GossipHello(playerUser))
return;
}
+1 -1
View File
@@ -259,7 +259,7 @@ namespace Game
GameObject go = GetPlayer().GetGameObjectIfCanInteractWith(packet.Guid);
if (go)
{
if (go.GetAI().GossipHello(GetPlayer(), true))
if (go.GetAI().GossipHello(GetPlayer()))
return;
GetPlayer().UpdateCriteria(CriteriaTypes.UseGameobject, go.GetEntry());
+1 -1
View File
@@ -1322,7 +1322,7 @@ namespace Game.Spells
}
player.PlayerTalkClass.ClearMenus();
if (gameObjTarget.GetAI().GossipHello(player, false))
if (gameObjTarget.GetAI().GossipHello(player))
return;
switch (gameObjTarget.GetGoType())
@@ -353,7 +353,7 @@ namespace Scripts.EasternKingdoms
{
public go_acherus_soul_prisonAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
Creature anchor = me.FindNearestCreature(29521, 15);
if (anchor)
+1 -1
View File
@@ -323,7 +323,7 @@ namespace Scripts.Kalimdor.ZoneAshenvale
{
public go_naga_brazierAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
Creature creature = ScriptedAI.GetClosestCreatureWithEntry(me, CreatureIds.Muglash, SharedConst.InteractionDistance * 2);
if (creature)
@@ -371,7 +371,7 @@ namespace Scripts.Northrend.AzjolNerub.Ahnkahet.PrinceTaldaram
instance = go.GetInstanceScript();
}
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
Creature PrinceTaldaram = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.PrinceTaldaram));
if (PrinceTaldaram && PrinceTaldaram.IsAlive())
@@ -429,7 +429,7 @@ namespace Scripts.Northrend.Gundrak
instance = go.GetInstanceScript();
}
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.AddFlag(GameObjectFlags.NotSelectable);
me.SetGoState(GameObjectState.Active);
@@ -201,7 +201,7 @@ namespace Scripts.Northrend.Nexus.Nexus
instance = go.GetInstanceScript();
}
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
Creature pKeristrasza = ObjectAccessor.GetCreature(me, instance.GetGuidData(DataTypes.Keristrasza));
if (pKeristrasza && pKeristrasza.IsAlive())
+1 -1
View File
@@ -1602,7 +1602,7 @@ namespace Scripts.Northrend.Ulduar
instance = go.GetInstanceScript();
}
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.HasFlag(GameObjectFlags.NotSelectable))
return true;
+33 -36
View File
@@ -260,7 +260,7 @@ namespace Scripts.World
{
public go_cat_figurineAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
player.CastSpell(player, GameobjectConst.SpellSummonGhostSaber, true);
return false;
@@ -282,7 +282,7 @@ namespace Scripts.World
{
public go_barov_journalAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.HasSkill(SkillType.Tailoring) && player.GetBaseSkillValue(SkillType.Tailoring) >= 280 && !player.HasSpell(26086))
player.CastSpell(player, 26095, false);
@@ -306,7 +306,7 @@ namespace Scripts.World
{
public go_gilded_brazierAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.Goober)
{
@@ -336,7 +336,7 @@ namespace Scripts.World
{
public go_orb_of_commandAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestRewardStatus(7761))
player.CastSpell(player, 23460, true);
@@ -360,7 +360,7 @@ namespace Scripts.World
{
public go_tablet_of_madnessAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.HasSkill(SkillType.Alchemy) && player.GetSkillValue(SkillType.Alchemy) >= 300 && !player.HasSpell(24266))
player.CastSpell(player, 24267, false);
@@ -385,7 +385,7 @@ namespace Scripts.World
public go_tablet_of_the_sevenAI(GameObject go) : base(go) { }
// @todo use gossip option ("Transcript the Tablet") instead, if Trinity adds support.
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() != GameObjectTypes.QuestGiver)
return true;
@@ -412,7 +412,7 @@ namespace Scripts.World
{
public go_jump_a_tronAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestStatus(10111) == QuestStatus.Incomplete)
player.CastSpell(player, 33382, true);
@@ -436,7 +436,7 @@ namespace Scripts.World
{
public go_ethereum_prisonAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
int Random = (int)(RandomHelper.Rand32() % (GameobjectConst.NpcPrisonEntry.Length / sizeof(uint)));
@@ -487,7 +487,7 @@ namespace Scripts.World
{
public go_ethereum_stasisAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
int Random = (int)(RandomHelper.Rand32() % GameobjectConst.NpcStasisEntry.Length / sizeof(uint));
@@ -513,7 +513,7 @@ namespace Scripts.World
{
public go_resonite_caskAI(GameObject go) : base(go) { }
public override bool GossipHello(Player Player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.Goober)
me.SummonCreature(GameobjectConst.NpcGoggeroc, 0.0f, 0.0f, 0.0f, 0.0f, TempSummonType.TimedDespawnOOC, 300000);
@@ -537,7 +537,7 @@ namespace Scripts.World
{
public go_sacred_fire_of_lifeAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.Goober)
player.SummonCreature(GameobjectConst.NpcArikara, -5008.338f, -2118.894f, 83.657f, 0.874f, TempSummonType.TimedDespawnOOC, 30000);
@@ -561,7 +561,7 @@ namespace Scripts.World
{
public go_shrine_of_the_birdsAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
uint BirdEntry = 0;
@@ -603,7 +603,7 @@ namespace Scripts.World
{
public go_southfury_moonstoneAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
//implicitTarget=48 not implemented as of writing this code, and manual summon may be just ok for our purpose
//player.CastSpell(player, SPELL_SUMMON_RIZZLE, false);
@@ -631,7 +631,7 @@ namespace Scripts.World
{
public go_tele_to_dalaran_crystalAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestRewardStatus(GameobjectConst.QuestTeleCrystalFlag))
return false;
@@ -657,7 +657,7 @@ namespace Scripts.World
{
public go_tele_to_violet_standAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestRewardStatus(GameobjectConst.QuestLearnLeaveReturn) || player.GetQuestStatus(GameobjectConst.QuestLearnLeaveReturn) == QuestStatus.Incomplete)
return false;
@@ -681,7 +681,7 @@ namespace Scripts.World
{
public go_fel_crystalforgeAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.QuestGiver) /* != GAMEOBJECT_TYPE_QUESTGIVER) */
player.PrepareQuestMenu(me.GetGUID()); /* return true*/
@@ -735,7 +735,7 @@ namespace Scripts.World
{
public go_bashir_crystalforgeAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.QuestGiver) /* != GAMEOBJECT_TYPE_QUESTGIVER) */
player.PrepareQuestMenu(me.GetGUID()); /* return true*/
@@ -789,7 +789,7 @@ namespace Scripts.World
{
public go_matrix_punchographAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
switch (me.GetEntry())
{
@@ -843,7 +843,7 @@ namespace Scripts.World
{
public go_scourge_cageAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
Creature pNearestPrisoner = me.FindNearestCreature(GameobjectConst.NpcScourgePrisoner, 5.0f, true);
@@ -872,7 +872,7 @@ namespace Scripts.World
{
public go_arcane_prisonAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestStatus(GameobjectConst.QuestPrisonBreak) == QuestStatus.Incomplete)
{
@@ -899,7 +899,7 @@ namespace Scripts.World
{
public go_blood_filled_orbAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (me.GetGoType() == GameObjectTypes.Goober)
player.SummonCreature(GameobjectConst.NpcZelemar, -369.746f, 166.759f, -21.50f, 5.235f, TempSummonType.TimedDespawnOOC, 30000);
@@ -923,7 +923,7 @@ namespace Scripts.World
{
public go_jotunheim_cageAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
Creature pPrisoner = me.FindNearestCreature(GameobjectConst.NpcEbonBladePrisonerHuman, 5.0f, true);
@@ -976,7 +976,7 @@ namespace Scripts.World
{
public go_table_thekaAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.GetQuestStatus(GameobjectConst.QuestSpiderGold) == QuestStatus.Incomplete)
player.AreaExploredOrEventHappens(GameobjectConst.QuestSpiderGold);
@@ -1002,7 +1002,7 @@ namespace Scripts.World
{
public go_inconspicuous_landmarkAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (player.HasItemCount(GameobjectConst.ItemCuergosKey))
return false;
@@ -1028,11 +1028,8 @@ namespace Scripts.World
{
public go_soulwellAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
if (!reportUse)
return true;
Unit owner = me.GetOwner();
if (!owner || !owner.IsTypeId(TypeId.Player) || !player.IsInSameRaidWith(owner.ToPlayer()))
return true;
@@ -1050,7 +1047,7 @@ namespace Scripts.World
{
public go_dragonflayer_cageAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
if (player.GetQuestStatus(GameobjectConst.QuestPrisonersOfWyrmskull) != QuestStatus.Incomplete)
@@ -1093,7 +1090,7 @@ namespace Scripts.World
{
public go_tadpole_cageAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
if (player.GetQuestStatus(GameobjectConst.QuestOhNoesTheTadpoles) == QuestStatus.Incomplete)
@@ -1125,7 +1122,7 @@ namespace Scripts.World
{
public go_amberpine_outhouseAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
QuestStatus status = player.GetQuestStatus(GameobjectConst.QuestDoingYourDuty);
if (status == QuestStatus.Incomplete || status == QuestStatus.Complete || status == QuestStatus.Rewarded)
@@ -1181,7 +1178,7 @@ namespace Scripts.World
{
public go_hive_podAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
player.SendLoot(me.GetGUID(), LootType.Corpse);
me.SummonCreature(GameobjectConst.NpcHiveAmbusher, me.GetPositionX() + 1, me.GetPositionY(), me.GetPositionZ(), me.GetAngle(player), TempSummonType.TimedOrDeadDespawn, 60000);
@@ -1205,7 +1202,7 @@ namespace Scripts.World
{
public go_massive_seaforium_chargeAI(GameObject go) : base(go) { }
public override bool GossipHello(Player Player, bool reportUse)
public override bool GossipHello(Player player)
{
me.SetLootState(LootState.JustDeactivated);
return true;
@@ -1227,7 +1224,7 @@ namespace Scripts.World
{
public go_veil_skith_cageAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton();
if (player.GetQuestStatus(GameobjectConst.QuestMissingFriends) == QuestStatus.Incomplete)
@@ -1262,7 +1259,7 @@ namespace Scripts.World
{
public go_frostblade_shrineAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
me.UseDoorOrButton(10);
if (!player.HasAura(GameobjectConst.SpellRecentMeditation))
@@ -1313,7 +1310,7 @@ namespace Scripts.World
{
public go_midsummer_ribbon_poleAI(GameObject go) : base(go) { }
public override bool GossipHello(Player player, bool reportUse)
public override bool GossipHello(Player player)
{
Creature creature = me.FindNearestCreature(GameobjectConst.NpcPoleRibbonBunny, 10.0f);
if (creature)