Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. //INSERT INTO spell_script_names VALUES (237772, 'freakz_aura_dark_wings_mage_tower');
  2. class freakz_aura_dark_wings_mage_tower : public SpellScriptLoader
  3. {
  4. public:
  5. freakz_aura_dark_wings_mage_tower() : SpellScriptLoader("freakz_aura_dark_wings_mage_tower") { }
  6.  
  7. enum eMisc
  8. {
  9. //Creatures:
  10. NPC_DARK_VALKIR = 119696,
  11. //Spells:
  12. SPELL_VISUAL = 239089,
  13. SPELL_DASH_FORWAD = 237759,
  14. SPELL_DAMAGE = 237761
  15. };
  16.  
  17. class freakz_aura_dark_wings_mage_tower_AuraScript : public AuraScript
  18. {
  19. PrepareAuraScript(freakz_aura_dark_wings_mage_tower_AuraScript);
  20.  
  21. Position const Corners[4] =
  22. {
  23. { 3324.36f, 507.10f, 638.16f, 3.15f }, //north 0
  24. { 3273.88f, 505.36f, 638.16f, 0.0f }, //south 1
  25. { 3276.94f, 571.54f, 639.43f, 4.7f }, //west 2
  26. { 3275.42f, 484.43f, 639.43f, 1.55f }, //east 3
  27. };
  28.  
  29. int randomDirection;
  30.  
  31. void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  32. {
  33. Unit* caster = GetCaster();
  34. std::vector<TempSummon*> valkirs;
  35.  
  36. if (!caster)
  37. return;
  38.  
  39. //generate random wall direction
  40. randomDirection = rand() % 4;
  41.  
  42. //spawn the first one in the initial position
  43. TempSummon* firstValkir = caster->SummonCreature(NPC_DARK_VALKIR, Corners[randomDirection], TEMPSUMMON_TIMED_DESPAWN, 15000);
  44. valkirs.push_back(firstValkir);
  45.  
  46. //spawn the other 9, omitting a random one to create a gap
  47. int randomOmittedIndex = rand() % 8 + 1; //neither first one, nor last
  48. for (int counter = 1; counter < 10; counter++)
  49. {
  50. if (counter == randomOmittedIndex)
  51. continue;
  52.  
  53. Position offsetPosition = Corners[randomDirection];
  54.  
  55. if (randomDirection == 0 || randomDirection == 3)
  56. offsetPosition.RelocateOffset(Position(0.0f, -5.0f * counter));
  57. else //if (randomDirection == 1 || randomDirection == 2)
  58. offsetPosition.RelocateOffset(Position(0.0f, 5.0f * counter));
  59.  
  60. TempSummon* valkir = caster->SummonCreature(NPC_DARK_VALKIR, offsetPosition, TEMPSUMMON_TIMED_DESPAWN, 15000);
  61. valkirs.push_back(valkir);
  62. }
  63.  
  64. //make the caster cast the visual on each valkir
  65. for (TempSummon* valkir : valkirs)
  66. caster->CastSpell(valkir, SPELL_VISUAL, true);
  67. }
  68.  
  69. void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  70. {
  71. Unit* caster = GetCaster();
  72.  
  73. if (!caster)
  74. return;
  75.  
  76. std::list<Creature*> valkirs;
  77. caster->GetCreatureListWithEntryInGrid(valkirs, NPC_DARK_VALKIR);
  78.  
  79. for (Creature* valkir : valkirs)
  80. {
  81. float distance;
  82. float orientation = valkir->GetOrientation();
  83.  
  84. randomDirection < 2 ? distance = 55.0f : distance = 95.0f;
  85.  
  86. float posX = valkir->GetPositionX() + (distance * std::cos(orientation));
  87. float posY = valkir->GetPositionY() + (distance * std::sin(orientation));
  88.  
  89. valkir->CastSpell(posX, posY, caster->GetPositionZ(), SPELL_DAMAGE, true);
  90. valkir->CastSpell(posX, posY, valkir->GetPositionZ(), SPELL_DASH_FORWAD, true);
  91. }
  92. }
  93.  
  94. void Register() override
  95. {
  96. AfterEffectApply += AuraEffectApplyFn(freakz_aura_dark_wings_mage_tower_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  97. AfterEffectRemove += AuraEffectRemoveFn(freakz_aura_dark_wings_mage_tower_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  98. }
  99. };
  100.  
  101. AuraScript* GetAuraScript() const override
  102. {
  103. return new freakz_aura_dark_wings_mage_tower_AuraScript();
  104. }
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement