Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. /*######
  2. # npc_shadowfiend
  3. ######*/
  4. enum Shadowfiend
  5. {
  6. MANA_LEECH = 28305,
  7. GLYPH_OF_SHADOWFIEND_MANA = 58227,
  8. GLYPH_OF_SHADOWFIEND = 58228
  9. };
  10.  
  11. class npc_shadowfiend : public CreatureScript
  12. {
  13. public:
  14. npc_shadowfiend() : CreatureScript("npc_shadowfiend") { }
  15.  
  16. struct npc_shadowfiendAI : public ScriptedAI
  17. {
  18. npc_shadowfiendAI(Creature* creature) : ScriptedAI(creature) {}
  19.  
  20. void Reset()
  21. {
  22. if (me->IsSummon())
  23. if (Unit* owner = me->ToTempSummon()->GetSummoner())
  24. if (Unit* pet = owner->GetGuardianPet())
  25. pet->CastSpell(pet, MANA_LEECH, true);
  26. }
  27. void DamageTaken(Unit* /*killer*/, uint32& damage)
  28. {
  29. if (me->IsSummon())
  30. if (Unit* owner = me->ToTempSummon()->GetSummoner())
  31. if (owner->HasAura(GLYPH_OF_SHADOWFIEND) && damage >= me->GetHealth())
  32. owner->CastSpell(owner, GLYPH_OF_SHADOWFIEND_MANA, true);
  33. }
  34.  
  35. void UpdateAI(uint32 const /*diff*/)
  36. {
  37. if (!UpdateVictim())
  38. return;
  39.  
  40. DoMeleeAttackIfReady();
  41. }
  42. };
  43.  
  44. CreatureAI* GetAI(Creature* creature) const
  45. {
  46. return new npc_shadowfiendAI(creature);
  47. }
  48. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement