Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //INSERT INTO spell_script_names VALUES (237772, 'freakz_aura_dark_wings_mage_tower');
- class freakz_aura_dark_wings_mage_tower : public SpellScriptLoader
- {
- public:
- freakz_aura_dark_wings_mage_tower() : SpellScriptLoader("freakz_aura_dark_wings_mage_tower") { }
- enum eMisc
- {
- //Creatures:
- NPC_DARK_VALKIR = 119696,
- //Spells:
- SPELL_VISUAL = 239089,
- SPELL_DASH_FORWAD = 237759,
- SPELL_DAMAGE = 237761
- };
- class freakz_aura_dark_wings_mage_tower_AuraScript : public AuraScript
- {
- PrepareAuraScript(freakz_aura_dark_wings_mage_tower_AuraScript);
- Position const Corners[4] =
- {
- { 3324.36f, 507.10f, 638.16f, 3.15f }, //north 0
- { 3273.88f, 505.36f, 638.16f, 0.0f }, //south 1
- { 3276.94f, 571.54f, 639.43f, 4.7f }, //west 2
- { 3275.42f, 484.43f, 639.43f, 1.55f }, //east 3
- };
- int randomDirection;
- void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
- {
- Unit* caster = GetCaster();
- std::vector<TempSummon*> valkirs;
- if (!caster)
- return;
- //generate random wall direction
- randomDirection = rand() % 4;
- //spawn the first one in the initial position
- TempSummon* firstValkir = caster->SummonCreature(NPC_DARK_VALKIR, Corners[randomDirection], TEMPSUMMON_TIMED_DESPAWN, 15000);
- valkirs.push_back(firstValkir);
- //spawn the other 9, omitting a random one to create a gap
- int randomOmittedIndex = rand() % 8 + 1; //neither first one, nor last
- for (int counter = 1; counter < 10; counter++)
- {
- if (counter == randomOmittedIndex)
- continue;
- Position offsetPosition = Corners[randomDirection];
- if (randomDirection == 0 || randomDirection == 3)
- offsetPosition.RelocateOffset(Position(0.0f, -5.0f * counter));
- else //if (randomDirection == 1 || randomDirection == 2)
- offsetPosition.RelocateOffset(Position(0.0f, 5.0f * counter));
- TempSummon* valkir = caster->SummonCreature(NPC_DARK_VALKIR, offsetPosition, TEMPSUMMON_TIMED_DESPAWN, 15000);
- valkirs.push_back(valkir);
- }
- //make the caster cast the visual on each valkir
- for (TempSummon* valkir : valkirs)
- caster->CastSpell(valkir, SPELL_VISUAL, true);
- }
- void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
- {
- Unit* caster = GetCaster();
- if (!caster)
- return;
- std::list<Creature*> valkirs;
- caster->GetCreatureListWithEntryInGrid(valkirs, NPC_DARK_VALKIR);
- for (Creature* valkir : valkirs)
- {
- float distance;
- float orientation = valkir->GetOrientation();
- randomDirection < 2 ? distance = 55.0f : distance = 95.0f;
- float posX = valkir->GetPositionX() + (distance * std::cos(orientation));
- float posY = valkir->GetPositionY() + (distance * std::sin(orientation));
- valkir->CastSpell(posX, posY, caster->GetPositionZ(), SPELL_DAMAGE, true);
- valkir->CastSpell(posX, posY, valkir->GetPositionZ(), SPELL_DASH_FORWAD, true);
- }
- }
- void Register() override
- {
- AfterEffectApply += AuraEffectApplyFn(freakz_aura_dark_wings_mage_tower_AuraScript::HandleApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
- AfterEffectRemove += AuraEffectRemoveFn(freakz_aura_dark_wings_mage_tower_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
- }
- };
- AuraScript* GetAuraScript() const override
- {
- return new freakz_aura_dark_wings_mage_tower_AuraScript();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement