TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
npc_wg_quest_giver Class Reference

Public Member Functions

 npc_wg_quest_giver ()
 
bool OnGossipHello (Player *player, Creature *creature) override
 
- Public Member Functions inherited from CreatureScript
virtual bool OnDummyEffect (Unit *, uint32, SpellEffIndex, 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 OnQuestReward (Player *, Creature *, Quest const *, uint32)
 
virtual uint32 GetDialogStatus (Player *, Creature *)
 
virtual CreatureAIGetAI (Creature *) const
 
- Public Member Functions inherited from UnitScript
virtual void OnHeal (Unit *, Unit *, uint32 &)
 
virtual void OnDamage (Unit *, Unit *, uint32 &)
 
virtual void ModifyPeriodicDamageAurasTick (Unit *, Unit *, uint32 &)
 
virtual void ModifyMeleeDamage (Unit *, Unit *, uint32 &)
 
virtual void ModifySpellDamageTaken (Unit *, Unit *, int32 &)
 
- Public Member Functions inherited from ScriptObject
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 UnitScript
 UnitScript (const char *name, bool addToScripts=true)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 
- Protected Member Functions inherited from UpdatableScript< Creature >
 UpdatableScript ()
 
virtual ~UpdatableScript ()
 

Constructor & Destructor Documentation

npc_wg_quest_giver::npc_wg_quest_giver ( )
inline
373 : CreatureScript("npc_wg_quest_giver") { }
CreatureScript(const char *name)
Definition: ScriptMgr.cpp:1586

Member Function Documentation

bool npc_wg_quest_giver::OnGossipHello ( Player player,
Creature creature 
)
inlineoverridevirtual
Todo:
: move this to conditions or something else

Reimplemented from CreatureScript.

376  {
377  Battlefield* wintergrasp = sBattlefieldMgr->GetBattlefieldByBattleId(BATTLEFIELD_BATTLEID_WG);
378  if (!wintergrasp)
379  return true;
380 
381  if (creature->IsVendor())
382  {
383  player->ADD_GOSSIP_ITEM_DB(Player::GetDefaultGossipMenuForSource(creature), 0, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_VENDOR);
384  player->PlayerTalkClass->GetGossipMenu().AddGossipMenuItemData(0, 0, 0);
385  }
386 
388 
389  // Player::PrepareQuestMenu(guid)
390  if (creature->IsQuestGiver())
391  {
392  QuestRelationBounds objectQR = sObjectMgr->GetCreatureQuestRelationBounds(creature->GetEntry());
393  QuestRelationBounds objectQIR = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(creature->GetEntry());
394 
395  QuestMenu& qm = player->PlayerTalkClass->GetQuestMenu();
396  qm.ClearMenu();
397 
398  for (QuestRelations::const_iterator i = objectQIR.first; i != objectQIR.second; ++i)
399  {
400  uint32 questId = i->second;
401  QuestStatus status = player->GetQuestStatus(questId);
402  if (status == QUEST_STATUS_COMPLETE)
403  qm.AddMenuItem(questId, 4);
404  else if (status == QUEST_STATUS_INCOMPLETE)
405  qm.AddMenuItem(questId, 4);
406  //else if (status == QUEST_STATUS_AVAILABLE)
407  // qm.AddMenuItem(quest_id, 2);
408  }
409 
410  for (QuestRelations::const_iterator i = objectQR.first; i != objectQR.second; ++i)
411  {
412  uint32 questId = i->second;
413  Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
414  if (!quest)
415  continue;
416 
417  if (!player->CanTakeQuest(quest, false))
418  continue;
419 
420  switch (questId)
421  {
422  // Horde attacker
429  if (wintergrasp->GetAttackerTeam() != TEAM_HORDE)
430  continue;
431  break;
432  // Horde defender
440  if (wintergrasp->GetDefenderTeam() != TEAM_HORDE)
441  continue;
442  break;
443  // Alliance attacker
449  if (wintergrasp->GetAttackerTeam() != TEAM_ALLIANCE)
450  continue;
451  break;
452  // Alliance defender
459  if (wintergrasp->GetDefenderTeam() != TEAM_ALLIANCE)
460  continue;
461  break;
462  default:
463  break;
464  }
465 
466  if (quest->IsAutoComplete())
467  qm.AddMenuItem(questId, 4);
468  else if (player->GetQuestStatus(questId) == QUEST_STATUS_NONE)
469  qm.AddMenuItem(questId, 2);
470  }
471  }
472 
473  player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
474  return true;
475  }
Definition: zone_wintergrasp.cpp:96
bool IsVendor() const
Definition: Unit.h:1564
Definition: QuestDef.h:111
bool IsAutoComplete() const
Definition: QuestDef.cpp:315
Definition: zone_wintergrasp.cpp:86
Definition: zone_wintergrasp.cpp:82
Definition: zone_wintergrasp.cpp:98
Definition: QuestDef.h:279
Definition: zone_wintergrasp.cpp:94
std::pair< QuestRelations::const_iterator, QuestRelations::const_iterator > QuestRelationBounds
Definition: ObjectMgr.h:442
QuestStatus
Definition: QuestDef.h:108
Definition: zone_wintergrasp.cpp:84
Definition: zone_wintergrasp.cpp:77
Definition: zone_wintergrasp.cpp:75
void AddMenuItem(uint32 QuestId, uint8 Icon)
Definition: GossipDef.cpp:303
Definition: zone_wintergrasp.cpp:85
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: QuestDef.h:110
Definition: zone_wintergrasp.cpp:101
Definition: zone_wintergrasp.cpp:78
Definition: zone_wintergrasp.cpp:79
bool IsQuestGiver() const
Definition: Unit.h:1566
Definition: zone_wintergrasp.cpp:97
Definition: zone_wintergrasp.cpp:90
Definition: zone_wintergrasp.cpp:99
Definition: zone_wintergrasp.cpp:92
Definition: zone_wintergrasp.cpp:80
uint32_t uint32
Definition: Define.h:150
Definition: Battlefield.h:196
Definition: zone_wintergrasp.cpp:93
Definition: SharedDefines.h:992
Definition: zone_wintergrasp.cpp:100
Definition: ScriptedGossip.h:73
Definition: zone_wintergrasp.cpp:88
Definition: zone_wintergrasp.cpp:91
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
ObjectGuid const & GetGUID() const
Definition: Object.h:105
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
Definition: zone_wintergrasp.cpp:76
Definition: Battlefield.h:33
Definition: zone_wintergrasp.cpp:83
Definition: QuestDef.h:113
Definition: GossipDef.h:37
uint32 GetEntry() const
Definition: Object.h:107
TeamId GetDefenderTeam() const
Definition: Battlefield.h:271
Definition: SharedDefines.h:993
Definition: GossipDef.h:219
Definition: zone_wintergrasp.cpp:87
void ClearMenu()
Definition: GossipDef.cpp:327

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: