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

Public Member Functions

 item_dehta_trap_smasher ()
 
bool OnUse (Player *player, Item *, const SpellCastTargets &) override
 
- Public Member Functions inherited from ItemScript
virtual bool OnDummyEffect (Unit *, uint32, SpellEffIndex, Item *)
 
virtual bool OnQuestAccept (Player *, Item *, Quest const *)
 
virtual bool OnExpire (Player *, ItemTemplate const *)
 
virtual bool OnRemove (Player *, Item *)
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Additional Inherited Members

- Protected Member Functions inherited from ItemScript
 ItemScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

item_dehta_trap_smasher::item_dehta_trap_smasher ( )
inline
333 : ItemScript("item_dehta_trap_smasher") { }
ItemScript(const char *name)
Definition: ScriptMgr.cpp:1580

Member Function Documentation

bool item_dehta_trap_smasher::OnUse ( Player player,
Item ,
const SpellCastTargets  
)
inlineoverridevirtual

Reimplemented from ItemScript.

336  {
337  if (player->GetQuestStatus(QUEST_CANNOT_HELP_THEMSELVES) != QUEST_STATUS_INCOMPLETE)
338  return false;
339 
340  Creature* pMammoth = player->FindNearestCreature(NPC_TRAPPED_MAMMOTH_CALF, 5.0f);
341  if (!pMammoth)
342  return false;
343 
344  GameObject* pTrap = NULL;
345  for (uint8 i = 0; i < MammothTrapsNum; ++i)
346  {
347  pTrap = player->FindNearestGameObject(MammothTraps[i], 11.0f);
348  if (pTrap)
349  {
350  pMammoth->AI()->DoAction(1);
351  pTrap->SetGoState(GO_STATE_READY);
352  player->KilledMonsterCredit(NPC_TRAPPED_MAMMOTH_CALF);
353  return true;
354  }
355  }
356  return false;
357  }
GameObject * FindNearestGameObject(uint32 entry, float range) const
Definition: Object.cpp:2452
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition: Object.cpp:2443
Definition: item_scripts.cpp:294
const uint32 MammothTraps[MammothTrapsNum]
Definition: item_scripts.cpp:321
CreatureAI * AI() const
Definition: Creature.h:525
Definition: GameObject.h:880
virtual void DoAction(int32)
Definition: UnitAI.h:138
Definition: GameObject.h:823
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
#define MammothTrapsNum
Definition: item_scripts.cpp:320
Definition: QuestDef.h:113
Definition: item_scripts.cpp:295
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:


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