diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
|---|---|---|
| committer | funjoker <funjoker109@gmail.com> | 2020-05-03 03:04:32 +0200 |
| commit | 6604849716bc73d82a4cdbf8c66bb188086ceae4 (patch) | |
| tree | bd293ee1fdac3baf8bef0a55aa854fe8bf793bc2 /src/server/scripts/EasternKingdoms/ScarletEnclave | |
| parent | e3489c48ee6929018618322571adbb8dc59e11b1 (diff) | |
Core/Scripts: unified scripted gossip/quest api
- Changed self-accessor on GameObjectAI to "me", like UnitAI
- Moved all related functions to AI, now Unit and GameObject have the same function names with identical behaviour
- Remove "OnUpdate" from CreatureScript/GameObjectScript, was never used and we already have AI Update method
- Quest methods no longer return a bool, the return value was used to call the AI version if the ScriptMgr one returned false
- Implemented GameObjectAI::Destroyed hook (was never called), implemented Damaged method
- Rename OnStateChanged to OnLootStateChanged to reflect when it's really called, and created a new hook OnStateChanged that only gets called on GOState change
- Since the functions are now only getting called from AI, made GetAI methods full virtual. (CanSpawn method is anyways going to be used on creatures with AI)
(cherry picked from commit f913f3bb8977c127d200d5d4a608ab434b21bbcd)
Diffstat (limited to 'src/server/scripts/EasternKingdoms/ScarletEnclave')
3 files changed, 104 insertions, 98 deletions
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 89d8c159194..d7e50807867 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -24,6 +24,7 @@ #include "MoveSplineInit.h" #include "ObjectAccessor.h" #include "PassiveAI.h" +#include "GameObjectAI.h" #include "Player.h" #include "ScriptedEscortAI.h" #include "ScriptedGossip.h" @@ -322,22 +323,31 @@ public: class go_acherus_soul_prison : public GameObjectScript { -public: - go_acherus_soul_prison() : GameObjectScript("go_acherus_soul_prison") { } + public: + go_acherus_soul_prison() : GameObjectScript("go_acherus_soul_prison") { } - bool OnGossipHello(Player* player, GameObject* go) override - { - if (Creature* anchor = go->FindNearestCreature(29521, 15)) + struct go_acherus_soul_prisonAI : public GameObjectAI { - ObjectGuid prisonerGUID = anchor->AI()->GetGUID(); - if (!prisonerGUID.IsEmpty()) - if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID)) - ENSURE_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player); - } + go_acherus_soul_prisonAI(GameObject* go) : GameObjectAI(go) { } - return false; - } + bool GossipHello(Player* player, bool /*reportUse*/) override + { + if (Creature* anchor = me->FindNearestCreature(29521, 15)) + { + ObjectGuid prisonerGUID = anchor->AI()->GetGUID(); + if (!prisonerGUID.IsEmpty()) + if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID)) + ENSURE_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player); + } + + return false; + } + }; + GameObjectAI* GetAI(GameObject* go) const override + { + return new go_acherus_soul_prisonAI(go); + } }; /*###### @@ -483,47 +493,6 @@ class npc_death_knight_initiate : public CreatureScript public: npc_death_knight_initiate() : CreatureScript("npc_death_knight_initiate") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - ClearGossipMenuFor(player); - if (action == GOSSIP_ACTION_INFO_DEF) - { - CloseGossipMenuFor(player); - - if (player->IsInCombat() || creature->IsInCombat()) - return true; - - if (npc_death_knight_initiateAI* pInitiateAI = CAST_AI(npc_death_knight_initiate::npc_death_knight_initiateAI, creature->AI())) - { - if (pInitiateAI->m_bIsDuelInProgress) - return true; - } - - creature->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); - creature->RemoveUnitFlag(UNIT_FLAG_UNK_15); - - player->CastSpell(creature, SPELL_DUEL, false); - player->CastSpell(player, SPELL_DUEL_FLAG, true); - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - if (player->GetQuestStatus(QUEST_DEATH_CHALLENGE) == QUEST_STATUS_INCOMPLETE && creature->IsFullHealth()) - { - if (player->HealthBelowPct(10)) - return true; - - if (player->IsInCombat() || creature->IsInCombat()) - return true; - - AddGossipItemFor(player, Player::GetDefaultGossipMenuForSource(creature), 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); - } - return true; - } - struct npc_death_knight_initiateAI : public CombatAI { npc_death_knight_initiateAI(Creature* creature) : CombatAI(creature) @@ -626,6 +595,45 @@ public: CombatAI::UpdateAI(uiDiff); } + + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId); + ClearGossipMenuFor(player); + if (action == GOSSIP_ACTION_INFO_DEF) + { + CloseGossipMenuFor(player); + + if (player->IsInCombat() || me->IsInCombat()) + return true; + + if (m_bIsDuelInProgress) + return true; + + me->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); + me->RemoveUnitFlag(UNIT_FLAG_UNK_15); + + player->CastSpell(me, SPELL_DUEL, false); + player->CastSpell(player, SPELL_DUEL_FLAG, true); + } + return true; + } + + bool GossipHello(Player* player) override + { + if (player->GetQuestStatus(QUEST_DEATH_CHALLENGE) == QUEST_STATUS_INCOMPLETE && me->IsFullHealth()) + { + if (player->HealthBelowPct(10)) + return true; + + if (player->IsInCombat() || me->IsInCombat()) + return true; + + AddGossipItemFor(player, Player::GetDefaultGossipMenuForSource(me), 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID()); + } + return true; + } }; CreatureAI* GetAI(Creature* creature) const override @@ -759,13 +767,14 @@ public: { npc_salanar_the_horsemanAI(Creature* creature) : ScriptedAI(creature) { } - void sGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override + bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override { if (menuId == GOSSIP_SALANAR_MENU && gossipListId == GOSSIP_SALANAR_OPTION) { player->CastSpell(player, SPELL_REALM_OF_SHADOWS, true); player->PlayerTalkClass->SendCloseGossip(); } + return false; } void SpellHit(Unit* caster, const SpellInfo* spell) override diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index 2733669aa9d..ba35f642194 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -201,18 +201,6 @@ class npc_koltira_deathweaver : public CreatureScript public: npc_koltira_deathweaver() : CreatureScript("npc_koltira_deathweaver") { } - bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) override - { - if (quest->GetQuestId() == QUEST_BREAKOUT) - { - creature->SetStandState(UNIT_STAND_STATE_STAND); - - if (npc_escortAI* escortAI = CAST_AI(npc_koltira_deathweaver::npc_koltira_deathweaverAI, creature->AI())) - escortAI->Start(false, false, player->GetGUID()); - } - return true; - } - struct npc_koltira_deathweaverAI : public npc_escortAI { npc_koltira_deathweaverAI(Creature* creature) : npc_escortAI(creature) @@ -356,6 +344,15 @@ public: } } + void QuestAccept(Player* player, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_BREAKOUT) + { + me->SetStandState(UNIT_STAND_STATE_STAND); + Start(false, false, player->GetGUID()); + } + } + private: uint8 wave; uint32 waveTimer; diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index 97c0296df30..255e709ae90 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -274,38 +274,6 @@ class npc_highlord_darion_mograine : public CreatureScript public: npc_highlord_darion_mograine() : CreatureScript("npc_highlord_darion_mograine") { } - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override - { - ClearGossipMenuFor(player); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF+1: - CloseGossipMenuFor(player); - ENSURE_AI(npc_highlord_darion_mograine::npc_highlord_darion_mograineAI, creature->AI())->uiStep = 1; - ENSURE_AI(npc_highlord_darion_mograine::npc_highlord_darion_mograineAI, creature->AI())->Start(true, false, player->GetGUID()); - break; - } - return true; - } - - bool OnGossipHello(Player* player, Creature* creature) override - { - if (creature->IsQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); - - if (player->GetQuestStatus(12801) == QUEST_STATUS_INCOMPLETE) - AddGossipItemFor(player, 0, "I am ready.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1); - - SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); - - return true; - } - - CreatureAI* GetAI(Creature* creature) const override - { - return new npc_highlord_darion_mograineAI(creature); - } - struct npc_highlord_darion_mograineAI : public npc_escortAI { npc_highlord_darion_mograineAI(Creature* creature) : npc_escortAI(creature) @@ -1640,8 +1608,40 @@ public: temp->KillSelf(); } } + + bool GossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override + { + uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId); + ClearGossipMenuFor(player); + switch (action) + { + case GOSSIP_ACTION_INFO_DEF + 1: + CloseGossipMenuFor(player); + uiStep = 1; + Start(true, false, player->GetGUID()); + break; + } + return true; + } + + bool GossipHello(Player* player) override + { + if (me->IsQuestGiver()) + player->PrepareQuestMenu(me->GetGUID()); + + if (player->GetQuestStatus(12801) == QUEST_STATUS_INCOMPLETE) + AddGossipItemFor(player, 0, "I am ready.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + + SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID()); + + return true; + } }; + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_highlord_darion_mograineAI(creature); + } }; /*###### |
