Guest User

Untitled

a guest
Jan 25th, 2020
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. npc_sk_undying_shadows(Creature* cre) : ScriptedAI(cre)
  2. {
  3. instance = me->GetInstanceScript();
  4. me->SetReactState(REACT_PASSIVE);
  5. }
  6.  
  7. ObjectGuid fixateGuid;
  8. InstanceScript* instance;
  9. uint32 checkTimer = 0;
  10. bool isDead = false;
  11.  
  12. void IsSummonedBy(Unit* summoner) override
  13. {
  14. if (instance->GetBossState(DATA_SPIRIT_KINGS) != IN_PROGRESS)
  15. {
  16. me->DespawnOrUnsummon(500);
  17. return;
  18. }
  19.  
  20. if (summoner && summoner->isAlive())
  21. {
  22. fixateGuid = summoner->GetGUID();
  23. me->AddAura(SPELL_UNDYING_SHADOWS_FIXATE, summoner);
  24. }
  25.  
  26. checkTimer = 500;
  27. DoCast(me, SPELL_UNDYING_SHADOWS_VISUAL_IS_ALIVE, true);
  28. }
  29.  
  30. void SpellHitTarget(Unit* target, const SpellInfo* spell) override
  31. {
  32. if (target && spell->Id == SPELL_UNDYING_SHADOWS_FIXATE)
  33. fixateGuid = target->GetGUID();
  34. }
  35.  
  36. void DamageTaken(Unit* attacker, uint32& damage) override
  37. {
  38. if (damage >= me->GetHealth())
  39. {
  40. damage = 0;
  41.  
  42. if (!isDead)
  43. {
  44. isDead = true;
  45.  
  46. if (auto plr = me->GetPlayer(*me, fixateGuid))
  47. plr->RemoveAura(SPELL_UNDYING_SHADOWS_FIXATE);
  48.  
  49. me->SetHealth(1);
  50. me->RemoveAura(SPELL_UNDYING_SHADOWS_VISUAL_IS_ALIVE);
  51. me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  52. me->GetMotionMaster()->Clear();
  53.  
  54. me->AddDelayedEvent(500, [=]()-> void
  55. {
  56. DoCast(me, SPELL_UNDYING_SHADOWS_VISUAL_IS_DEAD, true);
  57. DoCast(me, SPELL_COALESCING_SHADOWS, true);
  58. DoCast(me, SPELL_SHRINK_STACKER, true);
  59. });
  60. }
  61. }
  62. }
  63.  
  64. void UpdateAI(uint32 diff) override
  65. {
  66. if (checkTimer)
  67. if (checkTimer <= diff)
  68. {
  69. if (instance->GetBossState(DATA_SPIRIT_KINGS) == IN_PROGRESS)
  70. {
  71. checkTimer = 500;
  72.  
  73. if (!isDead)
  74. {
  75. auto plr = me->GetPlayer(*me, fixateGuid);
  76.  
  77. if (!plr || !plr->isAlive() || !plr->HasAura(SPELL_UNDYING_SHADOWS_FIXATE))
  78. {
  79. checkTimer = 1000;
  80. DoCast(me, SPELL_UNDYING_SHADOWS_FIXATE, true);
  81. }
  82. else
  83. me->GetMotionMaster()->MovePoint(1, plr->GetPosition(), false);
  84. }
  85. }
  86. else
  87. {
  88. checkTimer = 0;
  89. me->DespawnOrUnsummon(500);
  90. }
  91. }
  92. else
  93. checkTimer -= diff;
  94. }
RAW Paste Data