Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class npc_wild_wyrm : public CreatureScript
- {
- public:
- npc_wild_wyrm() : CreatureScript("npc_wild_wyrm") { }
- struct npc_wild_wyrmAI : public VehicleAI
- {
- npc_wild_wyrmAI(Creature* creature) : VehicleAI(creature) { }
- void Reset() override
- {
- me->m_spells[0] = SPELL_GRAB_ON;
- me->m_spells[1] = SPELL_DODGE_CLAWS;
- me->m_spells[2] = SPELL_THRUST_SPEAR;
- me->m_spells[3] = SPELL_MIGHTY_SPEAR_THRUST;
- _IsPhase2 = false;
- _PlayerGUID = 0;
- me->RemoveAllAuras();
- if (me->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD))
- {
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
- me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
- me->Kill(me);
- }
- }
- void SpellHit(Unit* caster, SpellInfo const* spell) override
- {
- if (Vehicle* vehicle = me->GetVehicleKit())
- if (spell->Id == SPELL_SPEAR_OF_HODIR && !vehicle->GetPassenger(0) && !_PlayerGUID)
- {
- _PlayerGUID = caster->GetGUID();
- me->GetMotionMaster()->MoveFollow(caster, 3.0f, 0.0f);
- }
- }
- void PassengerBoarded(Unit* passenger, int8 /*seatid*/, bool apply) override
- {
- if (passenger->GetTypeId() == TYPEID_PLAYER && !apply && !_IsPhase2)
- me->DespawnOrUnsummon(1000);
- }
- void MovementInform(uint32 type, uint32 data) override
- {
- if (type == FOLLOW_MOTION_TYPE)
- {
- if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
- {
- player->CastSpell(me, SPELL_FIGHT_WYRM, false);
- me->CastCustomSpell(SPELL_GRIP, SPELLVALUE_AURA_STACK, 50, me, false);
- DoCast(SPELL_CLAW_SWIPE);
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MovePath(NPC_WILD_WYRM * 100, true);
- }
- }
- else if (type == POINT_MOTION_TYPE && _IsPhase2 && me->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD))
- {
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
- me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
- me->Kill(me);
- }
- }
- void DamageTaken(Unit* /*doneBy*/, uint32& damage) override
- {
- if (me->HealthBelowPctDamaged(25, damage) && !_IsPhase2)
- {
- me->RemoveAura(SPELL_GRIP);
- me->RemoveAura(SPELL_CLAW_SWIPE);
- DoCast(SPELL_JAWS_OF_DEATH);
- me->m_spells[0] = SPELL_PRY_JAWS_OPEN;
- me->m_spells[1] = 0;
- me->m_spells[2] = SPELL_FATAL_STRIKE;
- me->m_spells[3] = 0;
- _IsPhase2 = true;
- if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
- {
- player->EnterVehicle(me, 1);
- player->ToPlayer()->VehicleSpellInitialize();
- me->AI()->Talk(SAY_WILD_WYRM_3, player);
- }
- }
- else if (damage >= me->GetHealth() && _IsPhase2)
- {
- damage = 0;
- me->SetHealth(1);
- me->m_spells[0] = 0;
- me->m_spells[2] = 0;
- if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
- player->ToPlayer()->VehicleSpellInitialize();
- DoCast(SPELL_WYRM_KILL_CREDIT);
- me->RemoveAura(SPELL_JAWS_OF_DEATH);
- me->RemoveAura(SPELL_PRY_JAWS_OPEN);
- me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
- me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
- float floorZ = me->GetMap()->GetHeight(me->GetPhaseMask(), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
- me->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), floorZ, me->GetSpeed(MOVE_RUN), 0);
- }
- }
- private:
- bool _IsPhase2;
- uint64 _PlayerGUID;
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_wild_wyrmAI(creature);
- }
- };
- class spell_grip : public SpellScriptLoader
- {
- public:
- spell_grip() : SpellScriptLoader("spell_grip") { }
- class spell_grip_AuraScript : public AuraScript
- {
- PrepareAuraScript(spell_grip_AuraScript);
- void DummyTick(AuraEffect const* /*aurEff*/)
- {
- Unit* caster = GetCaster();
- if (!caster)
- return;
- caster->RemoveAuraFromStack(SPELL_GRIP);
- if (!caster->GetAuraCount(SPELL_GRIP))
- {
- if (Vehicle* vehicle = caster->GetVehicleKit())
- if (Unit* player = vehicle->GetPassenger(0))
- player->RemoveAura(SPELL_FIGHT_WYRM);
- caster->RemoveAura(SPELL_FIGHT_WYRM);
- if (caster->ToCreature() && caster->ToCreature()->AI())
- caster->ToCreature()->AI()->Reset();
- return;
- }
- if (!warning && caster->GetAuraCount(SPELL_GRIP) < 15)
- {
- if (Vehicle* vehicle = caster->GetVehicleKit())
- if (Unit* player = vehicle->GetPassenger(0))
- {
- if (caster->ToCreature() && caster->ToCreature()->AI())
- caster->ToCreature()->AI()->Talk(SAY_WILD_WYRM_4, player);
- warning = true;
- }
- }
- else if (caster->GetAuraCount(SPELL_GRIP) > 30)
- warning = false;
- }
- void Register() override
- {
- OnEffectPeriodic += AuraEffectPeriodicFn(spell_grip_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
- }
- private:
- bool warning;
- };
- AuraScript* GetAuraScript() const override
- {
- return new spell_grip_AuraScript();
- }
- };
- class spell_grab_on : public SpellScriptLoader
- {
- public:
- spell_grab_on() : SpellScriptLoader("spell_grab_on") { }
- class spell_grab_on_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_grab_on_SpellScript);
- void HandleScript(SpellEffIndex /*effIndex*/)
- {
- if (Unit* caster = GetCaster())
- caster->CastCustomSpell(SPELL_GRIP, SPELLVALUE_AURA_STACK, GetSpellInfo()->Effects[EFFECT_0].CalcValue(), caster, false);
- }
- void Register() override
- {
- OnEffectHitTarget += SpellEffectFn(spell_grab_on_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_grab_on_SpellScript();
- }
- };
- class spell_thrust_spear : public SpellScriptLoader
- {
- public:
- spell_thrust_spear() : SpellScriptLoader("spell_thrust_spear") { }
- class spell_thrust_spear_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_thrust_spear_SpellScript);
- void HandleScript(SpellEffIndex /*effIndex*/)
- {
- if (Unit* caster = GetCaster())
- if (Aura* grip = caster->GetAura(SPELL_GRIP))
- grip->ModStackAmount(-5);
- }
- void Register() override
- {
- OnEffectHitTarget += SpellEffectFn(spell_thrust_spear_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_thrust_spear_SpellScript();
- }
- };
- class spell_mighty_spear_thrust : public SpellScriptLoader
- {
- public:
- spell_mighty_spear_thrust() : SpellScriptLoader("spell_mighty_spear_thrust") { }
- class spell_mighty_spear_thrust_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_mighty_spear_thrust_SpellScript);
- void HandleScript(SpellEffIndex /*effIndex*/)
- {
- if (Unit* caster = GetCaster())
- if (Aura* grip = caster->GetAura(SPELL_GRIP))
- grip->ModStackAmount(-15);
- }
- void Register() override
- {
- OnEffectHitTarget += SpellEffectFn(spell_mighty_spear_thrust_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_mighty_spear_thrust_SpellScript();
- }
- };
- class spell_jaws_of_death_and_spell_claw_swipe_damage : public SpellScriptLoader
- {
- public:
- spell_jaws_of_death_and_spell_claw_swipe_damage() : SpellScriptLoader("spell_jaws_of_death_and_spell_claw_swipe_damage") { }
- class spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript);
- void HandleDamage(SpellEffIndex /*effIndex*/)
- {
- Unit* caster = GetCaster();
- Unit* target = GetHitUnit();
- if (!caster || !target)
- return;
- int32 value = int32(target->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster)));
- SetEffectValue(value);
- }
- void Register() override
- {
- OnEffectLaunchTarget += SpellEffectFn(spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript();
- }
- };
- class spell_claw_swipe_check : public SpellScriptLoader
- {
- public: spell_claw_swipe_check() : SpellScriptLoader("spell_claw_swipe_check") { }
- class spell_claw_swipe_check_AuraScript : public AuraScript
- {
- PrepareAuraScript(spell_claw_swipe_check_AuraScript);
- void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
- {
- if (Unit* caster = GetCaster())
- if (Vehicle* vehicle = caster->GetVehicleKit())
- if (Unit* player = vehicle->GetPassenger(0))
- if (caster->ToCreature() && caster->ToCreature()->AI())
- caster->ToCreature()->AI()->Talk(SAY_WILD_WYRM_1, player);
- }
- void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
- {
- if (Unit* caster = GetCaster())
- if (Creature* creature = caster->ToCreature())
- if (Vehicle* vehicle = creature->GetVehicleKit())
- if (Unit* player = vehicle->GetPassenger(0))
- {
- if (player->HasAura(SPELL_DODGE_CLAWS))
- creature->AI()->Talk(SAY_WILD_WYRM_2, player);
- else
- creature->AI()->DoCast(SPELL_CLAW_SWIPE_DAMAGE);
- }
- }
- void Register() override
- {
- AfterEffectApply += AuraEffectApplyFn(spell_claw_swipe_check_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
- AfterEffectRemove += AuraEffectApplyFn(spell_claw_swipe_check_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
- }
- };
- AuraScript* GetAuraScript() const override
- {
- return new spell_claw_swipe_check_AuraScript();
- }
- };
- class spell_fatal_strike : public SpellScriptLoader
- {
- public:
- spell_fatal_strike() : SpellScriptLoader("spell_fatal_strike") { }
- class spell_fatal_strike_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_fatal_strike_SpellScript);
- void HandleDamage(SpellEffIndex /*effIndex*/)
- {
- if (Unit* caster = GetCaster())
- if (Creature* creature = caster->ToCreature())
- {
- if ((urand(1, 100) > creature->GetAuraCount(SPELL_PRY_JAWS_OPEN) * 5))
- {
- if (Vehicle* vehicle = creature->GetVehicleKit())
- if (Unit* player = vehicle->GetPassenger(0))
- creature->AI()->Talk(SAY_WILD_WYRM_5, player);
- SetHitDamage(0);
- }
- creature->_AddCreatureSpellCooldown(SPELL_FATAL_STRIKE, time(NULL) + 3);
- creature->_AddCreatureSpellCooldown(SPELL_PRY_JAWS_OPEN, time(NULL) + 3);
- }
- }
- void Register() override
- {
- OnEffectHitTarget += SpellEffectFn(spell_fatal_strike_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_fatal_strike_SpellScript();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement