AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
npc_prof_alchemy Class Reference
Inheritance diagram for npc_prof_alchemy:
CreatureScript ScriptObject UpdatableScript< Creature >

Public Member Functions

 npc_prof_alchemy ()
 
bool HasAlchemySpell (Player *player)
 
bool OnGossipHello (Player *player, Creature *creature) override
 
void SendActionMenu (Player *player, Creature *creature, uint32 action)
 
void SendConfirmLearn (Player *player, Creature *creature, uint32 action)
 
void SendConfirmUnlearn (Player *player, Creature *creature, uint32 action)
 
bool OnGossipSelect (Player *player, Creature *creature, uint32 sender, uint32 action) override
 
- Public Member Functions inherited from CreatureScript
bool IsDatabaseBound () const override
 
virtual bool OnGossipHello (Player *, Creature *)
 
virtual bool OnGossipSelect (Player *, Creature *, uint32, uint32)
 
virtual bool OnGossipSelectCode (Player *, Creature *, uint32, uint32, const char *)
 
virtual bool OnQuestAccept (Player *, Creature *, Quest const *)
 
virtual bool OnQuestSelect (Player *, Creature *, Quest const *)
 
virtual bool OnQuestComplete (Player *, Creature *, Quest const *)
 
virtual bool OnQuestReward (Player *, Creature *, Quest const *, uint32)
 
virtual uint32 GetDialogStatus (Player *, Creature *)
 
virtual CreatureAIGetAI (Creature *) const
 
virtual void OnFfaPvpStateUpdate (Creature *, bool)
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
- Public Member Functions inherited from UpdatableScript< Creature >
virtual void OnUpdate (Creature *, uint32)
 

Additional Inherited Members

- Protected Member Functions inherited from CreatureScript
 CreatureScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 
- Protected Member Functions inherited from UpdatableScript< Creature >
 UpdatableScript ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ npc_prof_alchemy()

npc_prof_alchemy::npc_prof_alchemy ( )
inline
471: CreatureScript("npc_prof_alchemy") { }
Definition: ScriptMgr.h:718

Member Function Documentation

◆ HasAlchemySpell()

bool npc_prof_alchemy::HasAlchemySpell ( Player player)
inline
474 {
475 return (player->HasSpell(S_TRANSMUTE) || player->HasSpell(S_ELIXIR) || player->HasSpell(S_POTION));
476 }
@ S_ELIXIR
Definition: npc_professions.cpp:171
@ S_TRANSMUTE
Definition: npc_professions.cpp:170
@ S_POTION
Definition: npc_professions.cpp:172
bool HasSpell(uint32 spell) const override
Definition: Player.cpp:3812

References Player::HasSpell(), S_ELIXIR, S_POTION, and S_TRANSMUTE.

Referenced by OnGossipHello().

◆ OnGossipHello()

bool npc_prof_alchemy::OnGossipHello ( Player player,
Creature creature 
)
inlineoverridevirtual

Reimplemented from CreatureScript.

479 {
480 if (creature->IsQuestGiver())
481 player->PrepareQuestMenu(creature->GetGUID());
482
483 if (creature->IsVendor())
485
486 if (creature->IsTrainer())
488
489 if (player->HasSkill(SKILL_ALCHEMY) && player->GetBaseSkillValue(SKILL_ALCHEMY) >= 350 && player->getLevel() > 67)
490 {
492 {
493 switch (creature->GetEntry())
494 {
495 case N_TRAINER_TRANSMUTE: //Zarevhi
496 if (!HasAlchemySpell(player))
498 if (player->HasSpell(S_TRANSMUTE))
500 break;
501 case N_TRAINER_ELIXIR: //Lorokeem
502 if (!HasAlchemySpell(player))
504 if (player->HasSpell(S_ELIXIR))
506 break;
507 case N_TRAINER_POTION: //Lauranna Thar'well
508 if (!HasAlchemySpell(player))
510 if (player->HasSpell(S_POTION))
512 break;
513 }
514 }
515 }
516
517 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
518 return true;
519 }
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const guid)
Definition: ScriptedGossip.cpp:45
void AddGossipItemFor(Player *player, uint32 icon, std::string const &text, uint32 sender, uint32 action)
Definition: ScriptedGossip.cpp:28
#define GOSSIP_TEXT_TRAIN
Definition: ScriptedGossip.h:26
#define GOSSIP_TEXT_BROWSE_GOODS
Definition: ScriptedGossip.h:25
@ GOSSIP_SENDER_MAIN
Definition: ScriptedGossip.h:70
@ GOSSIP_ACTION_TRADE
Definition: ScriptedGossip.h:56
@ GOSSIP_ACTION_TRAIN
Definition: ScriptedGossip.h:57
@ GOSSIP_ACTION_INFO_DEF
Definition: ScriptedGossip.h:68
@ GOSSIP_ICON_CHAT
Definition: GossipDef.h:60
@ GOSSIP_ICON_TRAINER
Definition: GossipDef.h:63
@ GOSSIP_ICON_VENDOR
Definition: GossipDef.h:61
#define GOSSIP_LEARN_POTION
Definition: npc_professions.cpp:63
#define GOSSIP_UNLEARN_POTION
Definition: npc_professions.cpp:64
#define GOSSIP_SENDER_LEARN
Definition: npc_professions.cpp:55
#define GOSSIP_LEARN_ELIXIR
Definition: npc_professions.cpp:67
#define GOSSIP_UNLEARN_ELIXIR
Definition: npc_professions.cpp:68
@ Q_MASTER_POTION
Definition: npc_professions.cpp:226
@ Q_MASTER_TRANSMUTE
Definition: npc_professions.cpp:224
@ Q_MASTER_ELIXIR
Definition: npc_professions.cpp:225
#define GOSSIP_SENDER_UNLEARN
Definition: npc_professions.cpp:56
@ N_TRAINER_TRANSMUTE
Definition: npc_professions.cpp:189
@ N_TRAINER_ELIXIR
Definition: npc_professions.cpp:190
@ N_TRAINER_POTION
Definition: npc_professions.cpp:191
#define GOSSIP_LEARN_TRANSMUTE
Definition: npc_professions.cpp:65
#define GOSSIP_UNLEARN_TRANSMUTE
Definition: npc_professions.cpp:66
@ SKILL_ALCHEMY
Definition: SharedDefines.h:2883
uint32 GetEntry() const
Definition: Object.h:109
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
bool GetQuestRewardStatus(uint32 quest_id) const
Definition: PlayerQuest.cpp:1392
bool HasSkill(uint32 skill) const
Definition: Player.cpp:5319
uint16 GetBaseSkillValue(uint32 skill) const
Definition: Player.cpp:5391
void PrepareQuestMenu(ObjectGuid guid)
Definition: PlayerQuest.cpp:38
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition: PlayerGossip.cpp:405
bool IsTrainer() const
Definition: Unit.h:1688
bool IsQuestGiver() const
Definition: Unit.h:1689
bool IsVendor() const
Definition: Unit.h:1687
uint8 getLevel() const
Definition: Unit.h:1418
bool HasAlchemySpell(Player *player)
Definition: npc_professions.cpp:473

References AddGossipItemFor(), Player::GetBaseSkillValue(), Object::GetEntry(), Player::GetGossipTextId(), Object::GetGUID(), Unit::getLevel(), Player::GetQuestRewardStatus(), GOSSIP_ACTION_INFO_DEF, GOSSIP_ACTION_TRADE, GOSSIP_ACTION_TRAIN, GOSSIP_ICON_CHAT, GOSSIP_ICON_TRAINER, GOSSIP_ICON_VENDOR, GOSSIP_LEARN_ELIXIR, GOSSIP_LEARN_POTION, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_UNLEARN, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_TEXT_TRAIN, GOSSIP_UNLEARN_ELIXIR, GOSSIP_UNLEARN_POTION, GOSSIP_UNLEARN_TRANSMUTE, HasAlchemySpell(), Player::HasSkill(), Player::HasSpell(), Unit::IsQuestGiver(), Unit::IsTrainer(), Unit::IsVendor(), N_TRAINER_ELIXIR, N_TRAINER_POTION, N_TRAINER_TRANSMUTE, Player::PrepareQuestMenu(), Q_MASTER_ELIXIR, Q_MASTER_POTION, Q_MASTER_TRANSMUTE, S_ELIXIR, S_POTION, S_TRANSMUTE, SendGossipMenuFor(), and SKILL_ALCHEMY.

◆ OnGossipSelect()

bool npc_prof_alchemy::OnGossipSelect ( Player player,
Creature creature,
uint32  sender,
uint32  action 
)
inlineoverridevirtual

Reimplemented from CreatureScript.

605 {
606 ClearGossipMenuFor(player);
607 switch (sender)
608 {
610 SendActionMenu(player, creature, action);
611 break;
612
614 SendConfirmLearn(player, creature, action);
615 break;
616
618 SendConfirmUnlearn(player, creature, action);
619 break;
620
622 SendActionMenu(player, creature, action);
623 break;
624 }
625 return true;
626 }
void ClearGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:22
#define GOSSIP_SENDER_CHECK
Definition: npc_professions.cpp:57
void SendActionMenu(Player *player, Creature *creature, uint32 action)
Definition: npc_professions.cpp:521
void SendConfirmLearn(Player *player, Creature *creature, uint32 action)
Definition: npc_professions.cpp:554
void SendConfirmUnlearn(Player *player, Creature *creature, uint32 action)
Definition: npc_professions.cpp:579

References ClearGossipMenuFor(), GOSSIP_SENDER_CHECK, GOSSIP_SENDER_LEARN, GOSSIP_SENDER_MAIN, GOSSIP_SENDER_UNLEARN, SendActionMenu(), SendConfirmLearn(), and SendConfirmUnlearn().

◆ SendActionMenu()

void npc_prof_alchemy::SendActionMenu ( Player player,
Creature creature,
uint32  action 
)
inline
522 {
523 switch (action)
524 {
526 player->GetSession()->SendListInventory(creature->GetGUID());
527 break;
529 player->GetSession()->SendTrainerList(creature->GetGUID());
530 break;
531 //Learn Alchemy
532 case GOSSIP_ACTION_INFO_DEF + 1:
533 ProcessCastaction(player, creature, S_TRANSMUTE, S_LEARN_TRANSMUTE, DoLearnCost(player));
534 break;
535 case GOSSIP_ACTION_INFO_DEF + 2:
536 ProcessCastaction(player, creature, S_ELIXIR, S_LEARN_ELIXIR, DoLearnCost(player));
537 break;
538 case GOSSIP_ACTION_INFO_DEF + 3:
539 ProcessCastaction(player, creature, S_POTION, S_LEARN_POTION, DoLearnCost(player));
540 break;
541 //Unlearn Alchemy
542 case GOSSIP_ACTION_INFO_DEF + 4:
543 ProcessUnlearnAction(player, creature, S_UNLEARN_TRANSMUTE, 0, DoHighUnlearnCost(player));
544 break;
545 case GOSSIP_ACTION_INFO_DEF + 5:
546 ProcessUnlearnAction(player, creature, S_UNLEARN_ELIXIR, 0, DoHighUnlearnCost(player));
547 break;
548 case GOSSIP_ACTION_INFO_DEF + 6:
549 ProcessUnlearnAction(player, creature, S_UNLEARN_POTION, 0, DoHighUnlearnCost(player));
550 break;
551 }
552 }
@ S_LEARN_POTION
Definition: npc_professions.cpp:176
@ S_UNLEARN_TRANSMUTE
Definition: npc_professions.cpp:178
@ S_LEARN_ELIXIR
Definition: npc_professions.cpp:175
@ S_LEARN_TRANSMUTE
Definition: npc_professions.cpp:174
@ S_UNLEARN_ELIXIR
Definition: npc_professions.cpp:179
@ S_UNLEARN_POTION
Definition: npc_professions.cpp:180
int32 DoHighUnlearnCost(Player *)
Definition: npc_professions.cpp:269
void ProcessCastaction(Player *player, Creature *creature, uint32 spellId, uint32 triggeredSpellId, int32 cost)
Definition: npc_professions.cpp:426
void ProcessUnlearnAction(Player *player, Creature *creature, uint32 spellId, uint32 alternativeSpellId, int32 cost)
Definition: npc_professions.cpp:441
int32 DoLearnCost(Player *)
Definition: npc_professions.cpp:264
WorldSession * GetSession() const
Definition: Player.h:1947
void SendListInventory(ObjectGuid guid, uint32 vendorEntry=0)
Definition: ItemHandler.cpp:992
void SendTrainerList(ObjectGuid guid)
Definition: NPCHandler.cpp:87

References DoHighUnlearnCost(), DoLearnCost(), Object::GetGUID(), Player::GetSession(), GOSSIP_ACTION_INFO_DEF, GOSSIP_ACTION_TRADE, GOSSIP_ACTION_TRAIN, ProcessCastaction(), ProcessUnlearnAction(), S_ELIXIR, S_LEARN_ELIXIR, S_LEARN_POTION, S_LEARN_TRANSMUTE, S_POTION, S_TRANSMUTE, S_UNLEARN_ELIXIR, S_UNLEARN_POTION, S_UNLEARN_TRANSMUTE, WorldSession::SendListInventory(), and WorldSession::SendTrainerList().

Referenced by OnGossipSelect().

◆ SendConfirmLearn()

void npc_prof_alchemy::SendConfirmLearn ( Player player,
Creature creature,
uint32  action 
)
inline
555 {
556 if (action)
557 {
558 switch (creature->GetEntry())
559 {
562 //unknown textID ()
563 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
564 break;
565 case N_TRAINER_ELIXIR:
567 //unknown textID ()
568 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
569 break;
570 case N_TRAINER_POTION:
572 //unknown textID ()
573 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
574 break;
575 }
576 }
577 }

References AddGossipItemFor(), Object::GetEntry(), Player::GetGossipTextId(), Object::GetGUID(), GOSSIP_ICON_CHAT, GOSSIP_LEARN_ELIXIR, GOSSIP_LEARN_POTION, GOSSIP_LEARN_TRANSMUTE, GOSSIP_SENDER_CHECK, N_TRAINER_ELIXIR, N_TRAINER_POTION, N_TRAINER_TRANSMUTE, and SendGossipMenuFor().

Referenced by OnGossipSelect().

◆ SendConfirmUnlearn()

void npc_prof_alchemy::SendConfirmUnlearn ( Player player,
Creature creature,
uint32  action 
)
inline
580 {
581 if (action)
582 {
583 switch (creature->GetEntry())
584 {
585 case N_TRAINER_TRANSMUTE: //Zarevhi
587 //unknown textID ()
588 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
589 break;
590 case N_TRAINER_ELIXIR: //Lorokeem
592 //unknown textID ()
593 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
594 break;
595 case N_TRAINER_POTION: //Lauranna Thar'well
597 //unknown textID ()
598 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID());
599 break;
600 }
601 }
602 }
#define BOX_UNLEARN_ALCHEMY_SPEC
Definition: npc_professions.cpp:70

References AddGossipItemFor(), BOX_UNLEARN_ALCHEMY_SPEC, DoHighUnlearnCost(), Object::GetEntry(), Player::GetGossipTextId(), Object::GetGUID(), GOSSIP_SENDER_CHECK, GOSSIP_UNLEARN_ELIXIR, GOSSIP_UNLEARN_POTION, GOSSIP_UNLEARN_TRANSMUTE, N_TRAINER_ELIXIR, N_TRAINER_POTION, N_TRAINER_TRANSMUTE, and SendGossipMenuFor().

Referenced by OnGossipSelect().