diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-05-01 18:19:36 -0300 |
| commit | f913f3bb8977c127d200d5d4a608ab434b21bbcd (patch) | |
| tree | bb2d18ad5c0c23667271ca98bd6754cc745256a8 /src/server/scripts/EasternKingdoms/ScarletEnclave | |
| parent | e4481c016a86fe7db0b83a434ea08eb7ba50174f (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)
Diffstat (limited to 'src/server/scripts/EasternKingdoms/ScarletEnclave')
3 files changed, 102 insertions, 96 deletions
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index d4a17aca5be..8421c1658ab 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -23,6 +23,7 @@ #include "ScriptedEscortAI.h" #include "CombatAI.h" #include "PassiveAI.h" +#include "GameObjectAI.h" #include "Player.h" #include "SpellInfo.h" #include "CreatureTextMgr.h" @@ -319,19 +320,28 @@ 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)) - if (ObjectGuid prisonerGUID = anchor->AI()->GetGUID()) - if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID)) - ENSURE_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player); + struct go_acherus_soul_prisonAI : public GameObjectAI + { + go_acherus_soul_prisonAI(GameObject* go) : GameObjectAI(go) { } - return false; - } + bool GossipHello(Player* player, bool /*reportUse*/) override + { + if (Creature* anchor = me->FindNearestCreature(29521, 15)) + if (ObjectGuid prisonerGUID = anchor->AI()->GetGUID()) + 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); + } }; /*###### @@ -474,47 +484,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->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); - creature->RemoveFlag(UNIT_FIELD_FLAGS, 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) @@ -617,6 +586,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->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); + me->RemoveFlag(UNIT_FIELD_FLAGS, 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 @@ -750,13 +758,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 59f510ded28..1ad704b2495 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -199,18 +199,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) @@ -354,6 +342,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 396d5fb2fa1..24ead674f2b 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -270,38 +270,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) @@ -1636,8 +1604,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); + } }; /*###### |
