Advertisement
KolumbPL

Untitled

Mar 4th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.26 KB | None | 0 0
  1. class npc_wild_wyrm : public CreatureScript
  2. {
  3. public:
  4.     npc_wild_wyrm() : CreatureScript("npc_wild_wyrm") { }
  5.  
  6.     struct npc_wild_wyrmAI : public VehicleAI
  7.     {
  8.         npc_wild_wyrmAI(Creature* creature) : VehicleAI(creature) { }
  9.  
  10.         void Reset() override
  11.         {
  12.            
  13.             me->m_spells[0] = SPELL_GRAB_ON;
  14.             me->m_spells[1] = SPELL_DODGE_CLAWS;
  15.             me->m_spells[2] = SPELL_THRUST_SPEAR;
  16.             me->m_spells[3] = SPELL_MIGHTY_SPEAR_THRUST;
  17.  
  18.             _IsPhase2 = false;
  19.             _PlayerGUID = 0;
  20.  
  21.             me->RemoveAllAuras();
  22.  
  23.             if (me->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD))
  24.             {
  25.                 me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
  26.                 me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
  27.                 me->Kill(me);
  28.             }
  29.         }
  30.  
  31.         void SpellHit(Unit* caster, SpellInfo const* spell) override
  32.         {
  33.             if (Vehicle* vehicle = me->GetVehicleKit())
  34.                 if (spell->Id == SPELL_SPEAR_OF_HODIR && !vehicle->GetPassenger(0) && !_PlayerGUID)
  35.                 {
  36.                     _PlayerGUID = caster->GetGUID();
  37.                     me->GetMotionMaster()->MoveFollow(caster, 3.0f, 0.0f);
  38.                 }
  39.         }
  40.  
  41.         void PassengerBoarded(Unit* passenger, int8 /*seatid*/, bool apply) override
  42.         {
  43.             if (passenger->GetTypeId() == TYPEID_PLAYER && !apply && !_IsPhase2)
  44.                 me->DespawnOrUnsummon(1000);
  45.         }
  46.  
  47.         void MovementInform(uint32 type, uint32 data) override
  48.         {
  49.             if (type == FOLLOW_MOTION_TYPE)
  50.             {
  51.                 if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
  52.                 {
  53.                     player->CastSpell(me, SPELL_FIGHT_WYRM, false);
  54.                     me->CastCustomSpell(SPELL_GRIP, SPELLVALUE_AURA_STACK, 50, me, false);
  55.                     DoCast(SPELL_CLAW_SWIPE);
  56.  
  57.                     me->GetMotionMaster()->Clear();
  58.                     me->GetMotionMaster()->MovePath(NPC_WILD_WYRM * 100, true);
  59.                 }
  60.             }
  61.             else if (type == POINT_MOTION_TYPE && _IsPhase2 && me->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD))
  62.             {
  63.                 me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
  64.                 me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
  65.                 me->Kill(me);
  66.             }
  67.         }
  68.  
  69.         void DamageTaken(Unit* /*doneBy*/, uint32& damage) override
  70.         {
  71.             if (me->HealthBelowPctDamaged(25, damage) && !_IsPhase2)
  72.             {
  73.                 me->RemoveAura(SPELL_GRIP);
  74.                 me->RemoveAura(SPELL_CLAW_SWIPE);
  75.                 DoCast(SPELL_JAWS_OF_DEATH);
  76.  
  77.                 me->m_spells[0] = SPELL_PRY_JAWS_OPEN;
  78.                 me->m_spells[1] = 0;
  79.                 me->m_spells[2] = SPELL_FATAL_STRIKE;
  80.                 me->m_spells[3] = 0;
  81.  
  82.                 _IsPhase2 = true;
  83.  
  84.                 if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
  85.                 {
  86.                     player->EnterVehicle(me, 1);
  87.                     player->ToPlayer()->VehicleSpellInitialize();
  88.                     me->AI()->Talk(SAY_WILD_WYRM_3, player);
  89.                 }
  90.             }
  91.             else if (damage >= me->GetHealth() && _IsPhase2)
  92.             {
  93.                 damage = 0;
  94.                 me->SetHealth(1);
  95.  
  96.                 me->m_spells[0] = 0;
  97.                 me->m_spells[2] = 0;
  98.  
  99.                 if (Player* player = ObjectAccessor::GetPlayer(*me, _PlayerGUID))
  100.                     player->ToPlayer()->VehicleSpellInitialize();
  101.  
  102.                 DoCast(SPELL_WYRM_KILL_CREDIT);
  103.  
  104.                 me->RemoveAura(SPELL_JAWS_OF_DEATH);
  105.                 me->RemoveAura(SPELL_PRY_JAWS_OPEN);
  106.                 me->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
  107.                 me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
  108.  
  109.                 float floorZ = me->GetMap()->GetHeight(me->GetPhaseMask(), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ());
  110.                 me->GetMotionMaster()->MoveCharge(me->GetPositionX(), me->GetPositionY(), floorZ, me->GetSpeed(MOVE_RUN), 0);
  111.             }
  112.         }
  113.  
  114.     private:
  115.         bool _IsPhase2;
  116.         uint64 _PlayerGUID;
  117.     };
  118.  
  119.     CreatureAI* GetAI(Creature* creature) const override
  120.     {
  121.         return new npc_wild_wyrmAI(creature);
  122.     }
  123. };
  124.  
  125. class spell_grip : public SpellScriptLoader
  126. {
  127. public:
  128.     spell_grip() : SpellScriptLoader("spell_grip") { }
  129.  
  130.     class spell_grip_AuraScript : public AuraScript
  131.     {
  132.         PrepareAuraScript(spell_grip_AuraScript);
  133.  
  134.         void DummyTick(AuraEffect const* /*aurEff*/)
  135.         {
  136.             Unit* caster = GetCaster();
  137.             if (!caster)
  138.                 return;
  139.  
  140.             caster->RemoveAuraFromStack(SPELL_GRIP);
  141.  
  142.             if (!caster->GetAuraCount(SPELL_GRIP))
  143.             {
  144.                 if (Vehicle* vehicle = caster->GetVehicleKit())
  145.                     if (Unit* player = vehicle->GetPassenger(0))
  146.                         player->RemoveAura(SPELL_FIGHT_WYRM);
  147.  
  148.                 caster->RemoveAura(SPELL_FIGHT_WYRM);
  149.                 if (caster->ToCreature() && caster->ToCreature()->AI())
  150.                     caster->ToCreature()->AI()->Reset();
  151.                 return;
  152.             }
  153.  
  154.             if (!warning && caster->GetAuraCount(SPELL_GRIP) < 15)
  155.             {
  156.                 if (Vehicle* vehicle = caster->GetVehicleKit())
  157.                     if (Unit* player = vehicle->GetPassenger(0))
  158.                     {
  159.                         if (caster->ToCreature() && caster->ToCreature()->AI())
  160.                             caster->ToCreature()->AI()->Talk(SAY_WILD_WYRM_4, player);
  161.                         warning = true;
  162.                     }
  163.             }
  164.             else if (caster->GetAuraCount(SPELL_GRIP) > 30)
  165.                 warning = false;
  166.         }
  167.  
  168.         void Register() override
  169.         {
  170.             OnEffectPeriodic += AuraEffectPeriodicFn(spell_grip_AuraScript::DummyTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
  171.         }
  172.  
  173.     private:
  174.         bool warning;
  175.     };
  176.  
  177.     AuraScript* GetAuraScript() const override
  178.     {
  179.         return new spell_grip_AuraScript();
  180.     }
  181. };
  182.  
  183. class spell_grab_on : public SpellScriptLoader
  184. {
  185. public:
  186.     spell_grab_on() : SpellScriptLoader("spell_grab_on") { }
  187.  
  188.     class spell_grab_on_SpellScript : public SpellScript
  189.     {
  190.         PrepareSpellScript(spell_grab_on_SpellScript);
  191.  
  192.         void HandleScript(SpellEffIndex /*effIndex*/)
  193.         {
  194.             if (Unit* caster = GetCaster())
  195.                 caster->CastCustomSpell(SPELL_GRIP, SPELLVALUE_AURA_STACK, GetSpellInfo()->Effects[EFFECT_0].CalcValue(), caster, false);
  196.         }
  197.  
  198.         void Register() override
  199.         {
  200.             OnEffectHitTarget += SpellEffectFn(spell_grab_on_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
  201.         }
  202.     };
  203.  
  204.     SpellScript* GetSpellScript() const override
  205.     {
  206.         return new spell_grab_on_SpellScript();
  207.     }
  208. };
  209.  
  210. class spell_thrust_spear : public SpellScriptLoader
  211. {
  212. public:
  213.     spell_thrust_spear() : SpellScriptLoader("spell_thrust_spear") { }
  214.  
  215.     class spell_thrust_spear_SpellScript : public SpellScript
  216.     {
  217.         PrepareSpellScript(spell_thrust_spear_SpellScript);
  218.  
  219.         void HandleScript(SpellEffIndex /*effIndex*/)
  220.         {
  221.             if (Unit* caster = GetCaster())
  222.                 if (Aura* grip = caster->GetAura(SPELL_GRIP))
  223.                     grip->ModStackAmount(-5);
  224.         }
  225.  
  226.         void Register() override
  227.         {
  228.             OnEffectHitTarget += SpellEffectFn(spell_thrust_spear_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
  229.         }
  230.     };
  231.  
  232.     SpellScript* GetSpellScript() const override
  233.     {
  234.         return new spell_thrust_spear_SpellScript();
  235.     }
  236. };
  237.  
  238. class spell_mighty_spear_thrust : public SpellScriptLoader
  239. {
  240. public:
  241.     spell_mighty_spear_thrust() : SpellScriptLoader("spell_mighty_spear_thrust") { }
  242.  
  243.     class spell_mighty_spear_thrust_SpellScript : public SpellScript
  244.     {
  245.         PrepareSpellScript(spell_mighty_spear_thrust_SpellScript);
  246.  
  247.         void HandleScript(SpellEffIndex /*effIndex*/)
  248.         {
  249.             if (Unit* caster = GetCaster())
  250.                 if (Aura* grip = caster->GetAura(SPELL_GRIP))
  251.                     grip->ModStackAmount(-15);
  252.         }
  253.  
  254.         void Register() override
  255.         {
  256.             OnEffectHitTarget += SpellEffectFn(spell_mighty_spear_thrust_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
  257.         }
  258.     };
  259.  
  260.     SpellScript* GetSpellScript() const override
  261.     {
  262.         return new spell_mighty_spear_thrust_SpellScript();
  263.     }
  264. };
  265.  
  266. class spell_jaws_of_death_and_spell_claw_swipe_damage : public SpellScriptLoader
  267. {
  268. public:
  269.     spell_jaws_of_death_and_spell_claw_swipe_damage() : SpellScriptLoader("spell_jaws_of_death_and_spell_claw_swipe_damage") { }
  270.  
  271.     class spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript : public SpellScript
  272.     {
  273.         PrepareSpellScript(spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript);
  274.  
  275.         void HandleDamage(SpellEffIndex /*effIndex*/)
  276.         {
  277.             Unit* caster = GetCaster();
  278.             Unit* target = GetHitUnit();
  279.             if (!caster || !target)
  280.                 return;
  281.  
  282.             int32 value = int32(target->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster)));
  283.             SetEffectValue(value);
  284.         }
  285.  
  286.         void Register() override
  287.         {
  288.             OnEffectLaunchTarget += SpellEffectFn(spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  289.         }
  290.  
  291.     };
  292.  
  293.     SpellScript* GetSpellScript() const override
  294.     {
  295.         return new spell_jaws_of_death_and_spell_claw_swipe_damage_SpellScript();
  296.     }
  297. };
  298.  
  299. class spell_claw_swipe_check : public SpellScriptLoader
  300. {
  301.     public: spell_claw_swipe_check() : SpellScriptLoader("spell_claw_swipe_check") { }
  302.  
  303.         class spell_claw_swipe_check_AuraScript : public AuraScript
  304.         {
  305.             PrepareAuraScript(spell_claw_swipe_check_AuraScript);
  306.  
  307.             void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  308.             {
  309.                 if (Unit* caster = GetCaster())
  310.                     if (Vehicle* vehicle = caster->GetVehicleKit())
  311.                         if (Unit* player = vehicle->GetPassenger(0))
  312.                         if (caster->ToCreature() && caster->ToCreature()->AI())
  313.                             caster->ToCreature()->AI()->Talk(SAY_WILD_WYRM_1, player);
  314.             }
  315.  
  316.             void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  317.             {
  318.                 if (Unit* caster = GetCaster())
  319.                     if (Creature* creature = caster->ToCreature())
  320.                         if (Vehicle* vehicle = creature->GetVehicleKit())
  321.                             if (Unit* player = vehicle->GetPassenger(0))
  322.                             {
  323.                                 if (player->HasAura(SPELL_DODGE_CLAWS))
  324.                                     creature->AI()->Talk(SAY_WILD_WYRM_2, player);
  325.                                 else
  326.                                     creature->AI()->DoCast(SPELL_CLAW_SWIPE_DAMAGE);
  327.                             }
  328.             }
  329.  
  330.             void Register() override
  331.             {
  332.                 AfterEffectApply += AuraEffectApplyFn(spell_claw_swipe_check_AuraScript::OnApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  333.                 AfterEffectRemove += AuraEffectApplyFn(spell_claw_swipe_check_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
  334.             }
  335.         };
  336.  
  337.         AuraScript* GetAuraScript() const override
  338.         {
  339.             return new spell_claw_swipe_check_AuraScript();
  340.         }
  341. };
  342.  
  343. class spell_fatal_strike : public SpellScriptLoader
  344. {
  345. public:
  346.     spell_fatal_strike() : SpellScriptLoader("spell_fatal_strike") { }
  347.  
  348.     class spell_fatal_strike_SpellScript : public SpellScript
  349.     {
  350.         PrepareSpellScript(spell_fatal_strike_SpellScript);
  351.  
  352.         void HandleDamage(SpellEffIndex /*effIndex*/)
  353.         {
  354.             if (Unit* caster = GetCaster())
  355.                 if (Creature* creature = caster->ToCreature())
  356.                 {
  357.                     if ((urand(1, 100) > creature->GetAuraCount(SPELL_PRY_JAWS_OPEN) * 5))
  358.                     {
  359.                         if (Vehicle* vehicle = creature->GetVehicleKit())
  360.                             if (Unit* player = vehicle->GetPassenger(0))
  361.                                 creature->AI()->Talk(SAY_WILD_WYRM_5, player);
  362.  
  363.                         SetHitDamage(0);
  364.                     }
  365.                     creature->_AddCreatureSpellCooldown(SPELL_FATAL_STRIKE, time(NULL) + 3);
  366.                     creature->_AddCreatureSpellCooldown(SPELL_PRY_JAWS_OPEN, time(NULL) + 3);
  367.                 }
  368.         }
  369.  
  370.         void Register() override
  371.         {
  372.             OnEffectHitTarget += SpellEffectFn(spell_fatal_strike_SpellScript::HandleDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  373.         }
  374.  
  375.     };
  376.  
  377.     SpellScript* GetSpellScript() const override
  378.     {
  379.         return new spell_fatal_strike_SpellScript();
  380.     }
  381. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement