Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class npc_silvermoon_harry : public CreatureScript
- {
- public:
- npc_silvermoon_harry() : CreatureScript("npc_silvermoon_harry") { }
- bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)
- {
- pPlayer->PlayerTalkClass->ClearMenus();
- switch (uiAction)
- {
- case GOSSIP_ACTION_TRADE:
- pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF:
- pCreature->setFaction(168);
- CAST_AI(npc_silvermoon_harry::npc_silvermoon_harryAI, pCreature->AI())->AttackStart(pPlayer);
- break;
- case GOSSIP_ACTION_INFO_DEF+1:
- pPlayer->AddItem(34115,1);
- CAST_AI(npc_silvermoon_harry::npc_silvermoon_harryAI, pCreature->AI())->m_owned = false;
- break;
- }//end switch
- return true;
- }
- bool OnGossipHello(Player* pPlayer, Creature* pCreature)
- {
- if ((pPlayer->GetQuestStatus(11476) == QUEST_STATUS_INCOMPLETE) && !CAST_AI(npc_silvermoon_harry::npc_silvermoon_harryAI, pCreature->AI())->m_owned && !pPlayer->HasItemCount(34115,1))
- {
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Слышь, ДОЛГ ВЕРНУЛ!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
- }
- else
- if ((pPlayer->GetQuestStatus(11476) == QUEST_STATUS_INCOMPLETE) && CAST_AI(npc_silvermoon_harry::npc_silvermoon_harryAI, pCreature->AI())->m_owned && !pPlayer->HasItemCount(34115,1))
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Забирай, только не бей!!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- else
- pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
- pPlayer->SEND_GOSSIP_MENU(7640, pCreature->GetGUID());
- return true;
- }
- CreatureAI* GetAI(Creature* pCreature) const
- {
- return new npc_silvermoon_harryAI(pCreature);
- }
- struct npc_silvermoon_harryAI : public ScriptedAI
- {
- npc_silvermoon_harryAI(Creature *c) : ScriptedAI(c)
- {
- m_uiNormalFaction = c->getFaction();
- m_owned = false;
- }
- bool m_owned;
- uint32 m_uiNormalFaction;
- void Reset()
- {
- if (me->getFaction() != m_uiNormalFaction)
- me->setFaction(m_uiNormalFaction);
- }
- void AttackedBy(Unit* pAttacker)
- {
- if (me->getVictim())
- return;
- if (me->IsFriendlyTo(pAttacker))
- return;
- AttackStart(pAttacker);
- }
- void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
- {
- if (me->HealthBelowPct(30))
- {
- m_owned = true;
- EnterEvadeMode();
- }
- }
- };// end struct ai
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement