text: /**
   * ScriptDev3 is an extension for mangos providing enhanced features for
   * area triggers, creatures, game objects, instances, items, and spells beyond
   * the default database scripting in mangos.
   *
   * Copyright (C) 2006-2013  ScriptDev2 <http://www.scriptdev2.com/>
   * Copyright (C) 2014-2022 MaNGOS <https://getmangos.eu>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   *
   * World of Warcraft, and all World of Warcraft or Warcraft art, images,
   * and lore are copyrighted by Blizzard Entertainment, Inc.
   */
  
  /**
   * ScriptData
   * SDName:      Orgrimmar
   * SD%Complete: 100
   * SDComment:   Quest support: 2460, 6566
   * SDCategory:  Orgrimmar
   * EndScriptData
   */
  
  /**
   * ContentData
   * npc_shenthul
   * npc_thrall_warchief
   * EndContentData
   */
  
  #include "precompiled.h"
  
  /*######
  ## npc_shenthul
  ######*/
  
  enum
  {
      QUEST_SHATTERED_SALUTE  = 2460
  };
  
  struct npc_shenthul : public CreatureScript
  {
      npc_shenthul() : CreatureScript("npc_shenthul") {}
  
      struct npc_shenthulAI : public ScriptedAI
      {
          npc_shenthulAI(Creature* pCreature) : ScriptedAI(pCreature) { }
  
          uint32 m_uiSaluteTimer;
          uint32 m_uiResetTimer;
  
          ObjectGuid m_playerGuid;
  
          void Reset() override
          {
              m_uiSaluteTimer = 0;
              m_uiResetTimer = 0;
  
              m_playerGuid.Clear();
          }
  
          void ReceiveEmote(Player* pPlayer, uint32 uiTextEmote) override
          {
              if (m_uiResetTimer && uiTextEmote == TEXTEMOTE_SALUTE && pPlayer->GetQuestStatus(QUEST_SHATTERED_SALUTE) == QUEST_STATUS_INCOMPLETE)
              {
                  pPlayer->AreaExploredOrEventHappens(QUEST_SHATTERED_SALUTE);
                  EnterEvadeMode();
              }
          }
  
          void DoStartQuestEvent(Player* pPlayer)
          {
              m_playerGuid = pPlayer->GetObjectGuid();
              m_uiSaluteTimer = 6000;
          }
  
          void UpdateAI(const uint32 uiDiff) override
          {
              if (m_uiResetTimer)
              {
                  if (m_uiResetTimer <= uiDiff)
                  {
                      if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid))
                      {
                          if (pPlayer->GetTypeId() == TYPEID_PLAYER && pPlayer->GetQuestStatus(QUEST_SHATTERED_SALUTE) == QUEST_STATUS_INCOMPLETE)
                          {
                              pPlayer->FailQuest(QUEST_SHATTERED_SALUTE);
                          }
                      }
  
                      m_uiResetTimer = 0;
                      EnterEvadeMode();
                  }
                  else
                  {
                      m_uiResetTimer -= uiDiff;
                  }
              }
  
              if (m_uiSaluteTimer)
              {
                  if (m_uiSaluteTimer <= uiDiff)
                  {
                      m_creature->HandleEmote(EMOTE_ONESHOT_SALUTE);
                      m_uiResetTimer = 60000;
                      m_uiSaluteTimer = 0;
                  }
                  else
                  {
                      m_uiSaluteTimer -= uiDiff;
                  }
              }
  
              if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
              {
                  return;
              }
  
              DoMeleeAttackIfReady();
          }
      };
  
      CreatureAI* GetAI(Creature* pCreature) override
      {
          return new npc_shenthulAI(pCreature);
      }
  
      bool OnQuestAccept(Player* pPlayer, Creature* pCreature, const Quest* pQuest) override
      {
          if (pQuest->GetQuestId() == QUEST_SHATTERED_SALUTE)
          {
              if (npc_shenthulAI* pShenAI = dynamic_cast<npc_shenthulAI*>(pCreature->AI()))
              {
                  pShenAI->DoStartQuestEvent(pPlayer);
                  return true;
              }
          }
  
          return false;
      }
  };
  
  /*######
  ## npc_thrall_warchief
  ######*/
  
  enum
  {
      QUEST_ID_WHAT_THE_WIND_CARRIES      = 6566,
  };
  
  struct npc_thrall_warchief : public CreatureScript  //TODO localise
  {
      npc_thrall_warchief() : CreatureScript("npc_thrall_warchief") {}
  
      bool OnGossipHello(Player* pPlayer, Creature* pCreature) override
      {
          if (pCreature->IsQuestGiver())
          {
              pPlayer->PrepareQuestMenu(pCreature->GetObjectGuid());
          }
  
          if (pPlayer->GetQuestStatus(QUEST_ID_WHAT_THE_WIND_CARRIES) == QUEST_STATUS_INCOMPLETE)
          {
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Please share your wisdom with me, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
          }
  
          pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetObjectGuid());
          return true;
      }
  
      bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction) override
      {
          pPlayer->PlayerTalkClass->ClearMenus();
          switch (uiAction)
          {
          case GOSSIP_ACTION_INFO_DEF + 1:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "What discoveries?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
              pPlayer->SEND_GOSSIP_MENU(5733, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 2:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Usurper?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
              pPlayer->SEND_GOSSIP_MENU(5734, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 3:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "With all due respect, Warchief - why not allow them to be destroyed? Does this not strengthen our position?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
              pPlayer->SEND_GOSSIP_MENU(5735, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 4:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "I... I did not think of it that way, Warchief.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
              pPlayer->SEND_GOSSIP_MENU(5736, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 5:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "I live only to serve, Warchief! My life is empty and meaningless without your guidance.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
              pPlayer->SEND_GOSSIP_MENU(5737, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 6:
              pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Of course, Warchief!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
              pPlayer->SEND_GOSSIP_MENU(5738, pCreature->GetObjectGuid());
              break;
          case GOSSIP_ACTION_INFO_DEF + 7:
              pPlayer->CLOSE_GOSSIP_MENU();
              pPlayer->AreaExploredOrEventHappens(QUEST_ID_WHAT_THE_WIND_CARRIES);
              break;
          }
          return true;
      }
  };
  
  void AddSC_orgrimmar()
  {
      Script* s;
      s = new npc_shenthul();
      s->RegisterSelf();
      s = new npc_thrall_warchief();
      s->RegisterSelf();
  
      //pNewScript = new Script;
      //pNewScript->Name = "npc_shenthul";
      //pNewScript->GetAI = &GetAI_npc_shenthul;
      //pNewScript->pQuestAcceptNPC =  &QuestAccept_npc_shenthul;
      //pNewScript->RegisterSelf();
  
      //pNewScript = new Script;
      //pNewScript->Name = "npc_thrall_warchief";
      //pNewScript->pGossipHello =  &GossipHello_npc_thrall_warchief;
      //pNewScript->pGossipSelect = &GossipSelect_npc_thrall_warchief;
      //pNewScript->RegisterSelf();
  }
  