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

Public Member Functions

 npc_experience ()
 
bool OnGossipHello (Player *player, Creature *creature) override
 
bool OnGossipSelect (Player *player, Creature *, uint32, 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_experience()

npc_experience::npc_experience ( )
inline
1999: CreatureScript("npc_experience") { }
Definition: ScriptMgr.h:719

Member Function Documentation

◆ OnGossipHello()

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

Reimplemented from CreatureScript.

2002 {
2003 AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); // "I no longer wish to gain experience."
2004 AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); // "I wish to start gaining experience again."
2005 SendGossipMenuFor(player, player->GetGossipTextId(creature), creature);
2006 return true;
2007 }
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
@ GOSSIP_SENDER_MAIN
Definition: ScriptedGossip.h:70
@ GOSSIP_ACTION_INFO_DEF
Definition: ScriptedGossip.h:68
@ GOSSIP_MENU_EXP_NPC
Definition: npcs_special.cpp:1993
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition: PlayerGossip.cpp:405

References AddGossipItemFor(), Player::GetGossipTextId(), GOSSIP_ACTION_INFO_DEF, GOSSIP_MENU_EXP_NPC, GOSSIP_SENDER_MAIN, and SendGossipMenuFor().

◆ OnGossipSelect()

bool npc_experience::OnGossipSelect ( Player player,
Creature ,
uint32  ,
uint32  action 
)
inlineoverridevirtual

Reimplemented from CreatureScript.

2010 {
2011 ClearGossipMenuFor(player);
2012 bool noXPGain = player->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
2013 bool doSwitch = false;
2014 auto toggleXpCost = sWorld->getIntConfig(CONFIG_TOGGLE_XP_COST);
2015
2016 switch (action)
2017 {
2018 case GOSSIP_ACTION_INFO_DEF + 1://xp off
2019 {
2020 if (!noXPGain)//does gain xp
2021 doSwitch = true;//switch to don't gain xp
2022 }
2023 break;
2024 case GOSSIP_ACTION_INFO_DEF + 2://xp on
2025 {
2026 if (noXPGain)//doesn't gain xp
2027 doSwitch = true;//switch to gain xp
2028 }
2029 break;
2030 }
2031 if (doSwitch)
2032 {
2033 if (!player->HasEnoughMoney(toggleXpCost))
2034 {
2035 player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
2036 }
2037 else if (noXPGain)
2038 {
2039 player->ModifyMoney(-toggleXpCost);
2041 }
2042 else if (!noXPGain)
2043 {
2044 player->ModifyMoney(-toggleXpCost);
2046 }
2047 }
2049 return true;
2050 }
void ClearGossipMenuFor(Player *player)
Definition: ScriptedGossip.cpp:22
@ BUY_ERR_NOT_ENOUGHT_MONEY
Definition: Item.h:137
@ PLAYER_FLAGS_NO_XP_GAIN
Definition: Player.h:500
@ CONFIG_TOGGLE_XP_COST
Definition: IWorld.h:406
#define sWorld
Definition: World.h:451
void SendCloseGossip()
Definition: GossipDef.cpp:240
void SetPlayerFlag(PlayerFlags flags)
Definition: Player.h:1091
void RemovePlayerFlag(PlayerFlags flags)
Definition: Player.h:1092
bool ModifyMoney(int32 amount, bool sendError=true)
Definition: Player.cpp:11409
bool HasEnoughMoney(uint32 amount) const
Definition: Player.h:1569
void SendBuyError(BuyResult msg, Creature *creature, uint32 item, uint32 param)
Definition: PlayerStorage.cpp:4092
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:1090
PlayerMenu * PlayerTalkClass
Definition: Player.h:2188

References BUY_ERR_NOT_ENOUGHT_MONEY, ClearGossipMenuFor(), CONFIG_TOGGLE_XP_COST, GOSSIP_ACTION_INFO_DEF, Player::HasEnoughMoney(), Player::HasPlayerFlag(), Player::ModifyMoney(), PLAYER_FLAGS_NO_XP_GAIN, Player::PlayerTalkClass, Player::RemovePlayerFlag(), Player::SendBuyError(), PlayerMenu::SendCloseGossip(), Player::SetPlayerFlag(), and sWorld.