All pastes #911013 Raw Edit

Something

public text v1 · immutable
·published 2008-02-20 12:29 UTC
rendered paste body

#include "../../sc_defines.h"
#include "../../../../../game/Pet.h"
#include "../../../../../game/GameObject.h"

/* ##### SPELLS ##### */

#define SPELL_ENRAGE                    8269 /* Agathelos the Raging */

/* ##### QUOTES(TEXT) ##### */

#define SAY_TECH1                     "I am a BOT. I have tons of information. To find out what I know whisper me."

/* ##### QUOTES(SOUND) ##### */

#define SOUND_ALERT                     5805

int ScenarioRFK = 0;
GameObject *RFKDoor = NULL;
/* 
Razorfen Kraul
*/
struct MANGOS_DLL_DECL razorfen_kraulAI : public ScriptedAI
{
    razorfen_kraulAI(Creature *c) : ScriptedAI(c) {
    friend1 = NULL;
    friend2 = NULL;
    friend3 = NULL;
    friend4 = NULL;  
    Aggro = NULL;
    EnterEvadeMode();}

	uint32 Cast1_Timer;
	uint32 Cast2_Timer;
        uint32 OffHand;
	int Aggro;
	int Entry;
	int zapominalka;
	float temp;
	float temp2;
	float x;
	float y;
	float z;
    Unit* friend1;
    Unit* friend2;
    Unit* friend3;
    Unit* friend4;
	Pet* pet;
    Creature* Summoned;
	bool triggered;
    bool InCombat;

    void EnterEvadeMode()
    {
		Aggro = NULL;
        Cast1_Timer = 5000;
        Cast2_Timer = 10000;
        OffHand = 0;
		pet = m_creature->GetPet();
		if(pet)
		 if(!pet->isAlive())
		  zapominalka = NULL;
        InCombat = false;
        m_creature->RemoveAllAuras();
        m_creature->DeleteThreatList();
        m_creature->CombatStop();
        DoGoHome();
    }

	void AttackStart(Unit *who)
    {
        if (!who)
            return;

        if (who->isTargetableForAttack() && who!= m_creature)
        {
            if(!InCombat)
            {   
                InCombat = true;
			}
             DoStartMeleeAttack(who);
		}
	}

	void MoveInLineOfSight(Unit *who)
    {
		if(!who)
                    return;

		 if(m_creature->IsFriendlyTo(who) && who->IsFriendlyTo(m_creature) && who != m_creature && who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsWithinDistInMap(who, 15))
                 {
                     if(!friend1 && friend2 != who && friend3 != who && friend4 != who)
                         friend1 = who;
                     if(!friend2 && friend1 != who && friend3 != who && friend4 != who)
                         friend2 = who;
                     if(!friend3 && friend1 != who && friend2 != who && friend4 != who)
                         friend3 = who;
                     if(!friend4 && friend1 != who && friend2 != who && friend3 != who)
                         friend4 = who;
                 }

        if (m_creature->getVictim())
            return;

        if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))
		{
            float attackRadius = m_creature->GetAttackDistance(who);
            if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who))
            {
				
                if(who->HasStealthAura())
                    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);

                 DoStartMeleeAttack(who);
            }
        }
    }
	void KilledUnit(Unit *who)
	{
	   /* Charlga Razorflank */
       if(m_creature->GetEntry() == 4421)
	     {
            DoYell("Who is next?!",LANG_UNIVERSAL,NULL);
            DoPlaySoundToSet(m_creature,5814);
	     }
	}

	void JustDied(Unit*)
	{
		Aggro = NULL;
		zapominalka = NULL;
		friend1 = NULL;
		friend2 = NULL;
		friend3 = NULL;
		friend4 = NULL;
        Cast1_Timer = 5000;
        Cast2_Timer = 10000;
        OffHand = 0;	
		if(m_creature->GetEntry() == 4625)
		{
           ScenarioRFK += 1;
		   if(ScenarioRFK == 2)
		   {
	        ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData());
            pInstance->SetData(NULL,1);
            ScenarioRFK = 0;
		   }
		}
	}

    void DamageDeal(Unit *done_to, uint32 &damage)
	{
	 if(m_creature->GetEntry() == 4420 || (m_creature->GetEntry() == 4436 || m_creature->GetEntry() == 4623))
	  {
		temp = m_creature->GetPower(POWER_RAGE);
		temp2 = 0;
		temp2 = temp;
		switch(rand()%4)
		 {
		  case 0:temp = temp2 + 80;break;
		  case 1:temp = temp2 + 90;break;
		  case 2:temp = temp2 + 100;break;
		  case 3:temp = temp2 + 110;break;
		 }
                if(temp < 1001)
		 m_creature->SetPower(POWER_RAGE,temp);
                else   
		 m_creature->SetPower(POWER_RAGE,1000);    
	  }
	}

	void DamageTaken(Unit *done_by, uint32 &damage)
	{
	 if(m_creature->GetEntry() == 4420 || (m_creature->GetEntry() == 4436 || m_creature->GetEntry() == 4623))
	  {
		temp = m_creature->GetPower(POWER_RAGE);
		temp2 = 0;
		temp2 = temp;
		switch(rand()%4)
		 {
		  case 0:temp = temp2 + 40;break;
		  case 1:temp = temp2 + 50;break;
		  case 2:temp = temp2 + 60;break;
		  case 3:temp = temp2 + 70;break;
		 }
                if(temp < 1001)
		 m_creature->SetPower(POWER_RAGE,temp);
                else   
		 m_creature->SetPower(POWER_RAGE,1000);         
	  }	
	}
    void UpdateAI(const uint32 diff)
	{
	   Entry = m_creature->GetEntry();

       if(m_creature->getVictim() && m_creature->IsNonMeleeSpellCasted(false))
           if(!m_creature->getVictim()->isAlive() || !m_creature->IsWithinDistInMap(m_creature->getVictim(), 20))
               m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);

       if(!m_creature->isAlive())
		   return;

       if(Entry == 4625 && zapominalka != 1)
	   {
          m_creature->HandleEmoteCommand(EMOTE_STATE_SPELLPRECAST);	   
		  zapominalka = 1;
	   }

       if(Entry == 6035 && !m_creature->HasAura(22766,0) && !InCombat)
	   {
          DoCast(m_creature,22766);	   
	   }

	   /* Razorfen Handler */
       if(Entry == 4530 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,8274);
	    }

	   /* Razorfen Beast Trainer */
       if(Entry == 4531 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,8274);
	    }

	   /* Razorfen Geomancer */
       if(Entry == 4520 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,8270);
	    }

	   /* Razorfen Beastmaster */
       if(Entry == 4532 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,8276);
	    }

	   /* Razorfen Beastmaster */
       if(Entry == 4842 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,7144);
	    }

	   /* Razorfen Dustweaver */
       if(Entry == 4522 && zapominalka != 1)
	    {
		 zapominalka = 1;
         DoCast(m_creature,8271);
	    }

	   /* Overlord Ramtusk */
       if((Entry == 4420  || Entry == 4436) && m_creature->GetPower(POWER_RAGE) > 0)
	    if(!m_creature->SelectHostilTarget() && !m_creature->getVictim())
		 {
		  temp = m_creature->GetPower(POWER_RAGE);
                  temp -= 3;
                  if(temp > 0)
		   m_creature->SetPower(POWER_RAGE,temp);
                  else
		   m_creature->SetPower(POWER_RAGE,0);
		  m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FEAR, true);
		 }

	   /* Charlga Razorflank */
       if(Entry == 4421  && zapominalka != 1)
	    {
		 zapominalka = 1;
		 m_creature->ApplySpellImmune(0, IMMUNITY_SCHOOL, IMMUNE_SCHOOL_SHADOW, true);
		 m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_STUN, true);
		 m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SILENCE, true);
	    }

		   if((Entry == 4436 || Entry == 4623) && !m_creature->HasAura(1032,0) && !m_creature->IsNonMeleeSpellCasted(false))
			   DoCast(m_creature,1032);

        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
            return;

    if (OffHand > diff)
        OffHand -= diff;
    else OffHand = 0;

            if(OffHand > 0 && OffHand < 500 && m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
			{
			    m_creature->HandleEmoteCommand(EMOTE_ONESHOT_ATTACKOFF);
			    m_creature->AttackerStateUpdate(m_creature->getVictim());
                            m_creature->resetAttackTimer();
				OffHand = 0;
			}

       if(Entry == 4531)
	   {
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),6984);
			  Cast1_Timer = 9000;
			 }else Cast1_Timer -= diff;	         
	   }

       if(Entry == 6035)
	   {
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature,7159);
			  Cast1_Timer = 9000;
			 }else Cast1_Timer -= diff;	   
	   }

		   if(Entry == 4442)
		   {
			   if(zapominalka != 1)
			   {
			    DoCast(m_creature,3248);
                zapominalka = 1;
			   }
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),11972);
			  Cast1_Timer = 9000 + rand()%5000;
			 }else Cast1_Timer -= diff;
		   }

	   /* Razorfen Quilguard, Champion */
       if(Entry == 4436 || Entry == 4623)
	    {
		  if(Aggro != 1 && Aggro != 2)
		  {
		   Aggro = 1;
            m_creature->setPowerType(POWER_RAGE); 
			m_creature->SetMaxPower(POWER_RAGE,1000);
			m_creature->SetPower(POWER_RAGE,0);
		  }
		   if(!m_creature->HasAura(71,0))
			   DoCast(m_creature,71);

		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  if(Entry == 4436)
			   DoCast(m_creature->getVictim(),8205);
			  else DoCast(m_creature->getVictim(),11596);
			  Cast1_Timer = 9000;
			 }else Cast1_Timer -= diff;
	   }

	   /* Razorfen Handler */
       if(Entry == 4530)
	    {
		 pet = m_creature->GetPet();
		 if(pet)
		  if(pet->isAlive() && !pet->getVictim())
           ((CreatureAI*)pet->AI())->AttackStart(m_creature->getVictim()); 
	    }

	   /* Aggem thorn curse */
       if(Entry == 4424)
	    {
		 if(Cast1_Timer > diff)
			 Cast1_Timer -= diff;
		 else Cast1_Timer = 0;

		 if(Cast2_Timer > diff)
			 Cast2_Timer -= diff;
		 else Cast2_Timer = 0;

	      if(friend1 && friend1->IsInWorld())
               {
		   if(!friend1->isAlive() || !friend1->isInCombat())
	             friend1 = NULL;
               }else friend1 = NULL;
	      if(friend2 && friend2->IsInWorld())
               {
		   if(!friend2->isAlive() || !friend2->isInCombat())
	             friend2 = NULL;
               }else friend2 = NULL;
	      if(friend3 && friend3->IsInWorld())
               {
		   if(!friend3->isAlive() || !friend3->isInCombat())
	             friend3 = NULL;
               }else friend3 = NULL;
	      if(friend4 && friend4->IsInWorld())
               {
		   if(!friend4->isAlive() || !friend4->isInCombat())
	             friend4 = NULL;
               }else friend4 = NULL;

		 if(friend1 && Aggro != 1)
		 {
			 if(friend1->GetEntry() == 6021)
			 {
			  friend1->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND,BASE_VALUE,+50,true);
			  Aggro = 1;
			 }
                         if(friend2)
			 if(friend2->GetEntry() == 6021)
			 {
			  friend2->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND,BASE_VALUE,+50,true);
			  Aggro = 1;
			 }
                         if(friend3)
			 if(friend3->GetEntry() == 6021)
			 {
			  friend3->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND,BASE_VALUE,+50,true);
			  Aggro = 1;
			 }
                         if(friend4)
			 if(friend4->GetEntry() == 6021)
			 {
			  friend4->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND,BASE_VALUE,+50,true);
			  Aggro = 1;
			 }
		 }

		 if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
		   DoCast(m_creature,8286);
		   Cast1_Timer = 60000;
		 }

		 if(!m_creature->HasAura(6192,0))
		 {
			 m_creature->SetMaxPower(POWER_RAGE,100);
			 m_creature->SetPower(POWER_RAGE,100);
			 DoCast(m_creature,6192);
		 }
		 if(m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 60 && Cast2_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
		  DoCast(m_creature,10622);
		  Cast2_Timer = 5000;
		 }
		 else
                 {
			  if(friend1)
                           if(friend1->GetMaxHealth() > 0)
                            if(friend1->GetHealth()*100 / friend1->GetMaxHealth() < 60 && m_creature->IsWithinDistInMap(friend1, 15))
			    {
		 		  DoCast(friend1,10622);
		          Cast2_Timer = 5000;	 	 
			 }
			  if(friend2)
                           if(friend2->GetMaxHealth() > 0)
                            if(friend2->GetHealth()*100 / friend2->GetMaxHealth() < 60 && m_creature->IsWithinDistInMap(friend2, 15))
			    {
		 		  DoCast(friend2,10622);
		          Cast2_Timer = 5000;	 	 
			 }
			  if(friend3)
                           if(friend3->GetMaxHealth() > 0)
                            if(friend3->GetHealth()*100 / friend3->GetMaxHealth() < 60 && m_creature->IsWithinDistInMap(friend3, 15))
			    {
		 		  DoCast(friend3,10622);
		          Cast2_Timer = 5000;	 	 
			 }
			  if(friend4)
                           if(friend4->GetMaxHealth() > 0)
                            if(friend4->GetHealth()*100 / friend4->GetMaxHealth() < 60 && m_creature->IsWithinDistInMap(friend4, 15))
			    {
		 		  DoCast(friend4,10622);
		          Cast2_Timer = 5000;	 	 
			 }
                 }
	    }

	   /* Razorfen Geomancer */
       if(Entry == 4520)
	    {
		 pet = m_creature->GetPet();
		 if(pet)
		  if(pet->isAlive() && !pet->getVictim())
           ((CreatureAI*)pet->AI())->AttackStart(m_creature->getVictim()); 
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),943);
			  Cast1_Timer = 9000 + rand()%5000;
			 }else Cast1_Timer -= diff;
	    }

	   /* Agam`an, Rooting, Ragging */
       if((Entry == 4511 || Entry == 4512) || Entry == 4514)
	   {
	    if(Entry == 4511 && !m_creature->HasAura(8260,0))
			DoCast(m_creature,8260);
	    if(Entry == 4512 && !m_creature->getVictim()->HasAura(8267,0))
			DoCast(m_creature->getVictim(),8267);
	    if(Entry == 4514 && !m_creature->HasAura(8269,0))
			DoCast(m_creature,8269);
	   }

	   /* Razorfen Spearhide */
       if(Entry == 4438)
	   {
	     if(!m_creature->HasAura(16610,0))
			 DoCast(m_creature,16610);

		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature,8259);
			  Cast1_Timer = 9000;
			 }else Cast1_Timer -= diff;
	   }

	   /* Death's Head Priest, Ward Guardian */
       if(Entry == 4517 || Entry == 4427)
	     {
	      if(friend1 && friend1->IsInWorld())
               {
		   if(!friend1->isAlive() || !friend1->isInCombat())
	             friend1 = NULL;
               }else friend1 = NULL;
	      if(friend2 && friend2->IsInWorld())
               {
		   if(!friend2->isAlive() || !friend2->isInCombat())
	             friend2 = NULL;
               }else friend2 = NULL;
	      if(friend3 && friend3->IsInWorld())
               {
		   if(!friend3->isAlive() || !friend3->isInCombat())
	             friend3 = NULL;
               }else friend3 = NULL;
	      if(friend4 && friend4->IsInWorld())
               {
		   if(!friend4->isAlive() || !friend4->isInCombat())
	             friend4 = NULL;
               }else friend4 = NULL;

          if( (int) (m_creature->GetHealth()*2 / m_creature->GetMaxHealth() +1) > 1)
		   {
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
		     {
			  if(friend1)
                           if(friend1->GetMaxHealth() > 0)
                            if(friend1->GetHealth()*100 / friend1->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend1, 15))
			    {
                               if(Entry == 4517)
				DoCast(friend1,2055);
			       else DoCast(friend1,939);
		               Cast1_Timer = 3000;
			    }else
			     {
			      if(friend2)
                               if(friend2->GetMaxHealth() > 0)
                                if(friend2->GetHealth()*100 / friend2->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend2, 15)) 
			        {
                                  if(Entry == 4517)
				     DoCast(friend2,2055);
				  else DoCast(friend2,939);

		                  Cast1_Timer = 3000;
			        }else
                                 {
			         if(friend3)
                                  if(friend3->GetMaxHealth() > 0)
                                   if(friend3->GetHealth()*100 / friend3->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend3, 15))
			            {
                                     if(Entry == 4517)
					      DoCast(friend3,2055);
				      else DoCast(friend3,939);
		                      Cast1_Timer = 3000;
                                    }else
                                     {
			             if(friend4)
                                      if(friend4->GetMaxHealth() > 0)
                                       if(friend4->GetHealth()*100 / friend4->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend4, 15))
			               {
                                        if(Entry == 4517)
					  DoCast(friend4,2055);
				        else DoCast(friend4,939);
		                        Cast1_Timer = 3000;
                                       }else
				        if(Entry == 4517)
				        {
                                         DoCast(m_creature->getVictim(),11659);
				        }
                                     }//end friend 4
                                  }//end friend 3					   
			     }//end friend 2
		     }else Cast1_Timer -= diff;
		  }else
		   {
		    if(Cast1_Timer < diff  && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
			{
                         if(Entry == 4517)
					   DoCast(m_creature,2055);
				   else DoCast(m_creature,939);
		         Cast1_Timer = 3000;
			}else Cast1_Timer -= diff;
		   }
	   }

	   /* Death`s head acolyte */
       if(Entry == 4515)
	     {
	      if(friend1 && friend1->IsInWorld())
               {
		   if(!friend1->isAlive() || !friend1->isInCombat())
	             friend1 = NULL;
               }else friend1 = NULL;
	      if(friend2 && friend2->IsInWorld())
               {
		   if(!friend2->isAlive() || !friend2->isInCombat())
	             friend2 = NULL;
               }else friend2 = NULL;
	      if(friend3 && friend3->IsInWorld())
               {
		   if(!friend3->isAlive() || !friend3->isInCombat())
	             friend3 = NULL;
               }else friend3 = NULL;
	      if(friend4 && friend4->IsInWorld())
               {
		   if(!friend4->isAlive() || !friend4->isInCombat())
	             friend4 = NULL;
               }else friend4 = NULL;

          if( (int) (m_creature->GetHealth()*2 / m_creature->GetMaxHealth() +1) > 1)
		   {
		    if(Cast1_Timer < diff) 
		     {
			  if(friend1)
                           if(friend1->GetMaxHealth() > 0)
                            if(friend1->GetHealth()*100 / friend1->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend1, 15))
			    {
                             DoCast(friend1,6077);
		             Cast1_Timer = 3000;
			   }else
			     {
			      if(friend2)
                               if(friend2->GetMaxHealth() > 0)
                                if(friend2->GetHealth()*100 / friend2->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend2, 15))
			        {
                                 DoCast(friend2,6077);
		                 Cast1_Timer = 3000;
			        }else
			         {
			          if(friend3)
                                   if(friend3->GetMaxHealth() > 0)
                                    if(friend3->GetHealth()*100 / friend3->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend3, 15))
			            {
                                     DoCast(friend3,6077);
		                     Cast1_Timer = 3000;
			            }else
			         {
			          if(friend4)
                                   if(friend4->GetMaxHealth() > 0)
                                    if(friend4->GetHealth()*100 / friend4->GetMaxHealth() < 50 && m_creature->IsWithinDistInMap(friend4, 15))
			            {
                                     DoCast(friend4,6077);
		                     Cast1_Timer = 3000;
			            }
				     else
				     {
				      for(int i = 0; i < 6;i++)
				      {
				      Unit *target = SelectUnit(SELECT_TARGET_TOPAGGRO,i);
				      if(target && target->isAlive())
					     if(target->GetPower(POWER_MANA) > 300)
					     {
						     DoCast(target,10876);
						     Cast1_Timer = 8000;
						     return;
					     }
				     }				    
				   }
                               }//end friend 4
                              }//end friend 3
			     }//end friend 2
		     }else Cast1_Timer -= diff;
		  }else
		   {
		    if(Cast1_Timer < diff && !m_creature->HasAura(6077,0) && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
			{
                   DoCast(m_creature,6077);
		         Cast1_Timer = 3000;
			}else Cast1_Timer -= diff;
		   }
	   }

	   /* Razorfen Totemic, Death's Head Sage, Seer, Earthcaller halmgar */
       if((Entry == 4440 || Entry == 4518) || (Entry == 4519 || Entry == 4842))
	   {
        if (Cast2_Timer > diff)
            Cast2_Timer -= diff;
        else Cast2_Timer = 0;

        if (Cast1_Timer > diff)
            Cast1_Timer -= diff;
        else Cast1_Timer = 0;

		 if(Entry == 4440 && Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
			 DoCast(m_creature,8376);
			 Cast1_Timer = 15000;
		 }

		 if(Entry == 4842 && Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
			 DoCast(m_creature->getVictim(),943);
			 Cast1_Timer = 15000;
		 }

		 if(Entry == 4518 && Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
			 DoCast(m_creature,8262);
			 Cast1_Timer = 15000;
		 }

		 if(Entry == 4519 && Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
		 {
			 DoCast(m_creature,8264);
			 Cast1_Timer = 15000;
		 }

			if(Cast2_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
			{
				if(Entry != 4842)DoCast(m_creature,4971);
				else DoCast(m_creature,2484);
				Cast2_Timer = 30000;
			}
	   }

	   /* Razorfen Beastmaster */
       if(Entry == 4532)
	    {
		 pet = m_creature->GetPet();
		 if(pet)
		  if(pet->isAlive() && !pet->getVictim())
           ((CreatureAI*)pet->AI())->AttackStart(m_creature->getVictim()); 
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),8275);
			  Cast1_Timer = 9000 + rand()%5000;
			 }else Cast1_Timer -= diff;
	    }

	   /* Razorfen Dustweaver */
       if(Entry == 4522)
	    {
		 pet = m_creature->GetPet();
		 if(pet)
		  if(pet->isAlive() && !pet->getVictim())
           ((CreatureAI*)pet->AI())->AttackStart(m_creature->getVictim()); 
	    }

	   /* Greater Kraul Bat */
       if(Entry == 4539)
	   {
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature,8281);
			  Cast1_Timer = 12000;
			 }else Cast1_Timer -= diff;	   
	   }

	   /* Agathelos the Raging */
       if(Entry == 4422)
	     {
        if (Cast2_Timer > diff)
            Cast2_Timer -= diff;
        else Cast2_Timer = 0;

		  if(Aggro != 1 && Aggro != 2)
		  {
		   Aggro = 1;
           m_creature->SetArmor(3493);
		  }
          if( (int) (m_creature->GetHealth()*5 / m_creature->GetMaxHealth() +1) < 4 && Aggro != 2)
		   {
	        Aggro = 2;
			DoCast(m_creature,SPELL_ENRAGE);
	       }
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature,8285);
			  Cast1_Timer = 12000;
			 }else Cast1_Timer -= diff;	  

		    if(Cast2_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),8555);
			  Cast2_Timer = 10000;
			 }
	     }

	   /* Death Speaker Jargba */
       if(Entry == 4428)
	     {
          if (Cast2_Timer > diff)
              Cast2_Timer -= diff;
          else Cast2_Timer = 0;

		    if(Cast2_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
			 {
				     for(int i = 0; i < 6;i++)
				     {
				     Unit *target = SelectUnit(SELECT_TARGET_TOPAGGRO,i);
				     if(target && target->isAlive())
					     if(!target->HasAura(14515,0))
					     {
						     DoCast(target,14515);
						     Cast2_Timer = 10000;
						     return;
					     }
				     }
			 }

          if( (int) (m_creature->GetHealth()*2 / m_creature->GetMaxHealth() +1) > 1)
		   {
		    if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady() )
			 {
              DoCast(m_creature->getVictim(),11659);
              Cast1_Timer = 9000;
			 }else Cast1_Timer -= diff;    
		   }else
		     {
		    if(Cast1_Timer < diff  && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady())
			 {
              DoCast(m_creature,6063);
              Cast1_Timer = 3000;
			 }else Cast1_Timer -= diff;               
		     }
	     }

	   /* Overlord Ramtusk */
       if(Entry == 4420)
	    {
		  if(Aggro != 1 && Aggro != 2)
		  {
		   Aggro = 1;
            m_creature->setPowerType(POWER_RAGE); 
			m_creature->SetMaxPower(POWER_RAGE,1000);
			m_creature->SetPower(POWER_RAGE,0);
			DoCast(m_creature,2457);
           DoYell("For Victory! For Agamaggan!",LANG_UNIVERSAL,NULL);
           DoPlaySoundToSet(m_creature,5812);
		  }
		  if(!m_creature->HasAura(11550,0))
			  DoCast(m_creature,11550);

		    if(Cast1_Timer < diff && m_creature->GetPower(POWER_RAGE) > 100 && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
			 {
			  DoCast(m_creature->getVictim(),8205);
			  Cast1_Timer = 8000;
			 }else Cast1_Timer -= diff;
          //Two-Hand Fight
          if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
          {
           if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
            {
               m_creature->AttackerStateUpdate(m_creature->getVictim());
               m_creature->resetAttackTimer();
               OffHand = 1000;
		     }
		    }
		    //End Two-Hand Fight         
	    }

	   /* Charlga Razorflank */
       if(Entry == 4421)
	    { 
		  if(Aggro != 1 && Aggro != 2 && Aggro != 3 && Aggro != 4)
		  {
		   Aggro = 1;
           DoYell("Troublesome whelp.I`ll teach you to interfere!",LANG_UNIVERSAL,NULL);
           DoPlaySoundToSet(m_creature,5813);
		  }
		 if(m_creature->GetPower(POWER_MANA) < 500)
		  {
		   DoCast(m_creature,29166);
           m_creature->SetPower(POWER_MANA,2889);
		  }
         if( (int) (m_creature->GetHealth()*4 / m_creature->GetMaxHealth() +1) > 4)
		 {
		 if(Cast1_Timer < diff && !m_creature->IsNonMeleeSpellCasted(false) && m_creature->isAttackReady()) 
		  {
		   switch(rand()%2)
		   {
		   case 0:
		   DoCast(m_creature->getVictim(),2860);//29166
		   Cast1_Timer = 8000;
		   break;
		   case 1:
		   DoCast(m_creature,8361);//29166
		   Cast1_Timer = 3000;
		   break;
		   }
		  }else Cast1_Timer -= diff;	
		 }else
		  {
           if( (int) (m_creature->GetHealth()*4 / m_creature->GetMaxHealth() +1) > 3)
		   {
		   if(Aggro < 2)
		    {
		     Aggro = 2;
             DoYell("Your outsiders will pay for encroaching on our land!",LANG_UNIVERSAL,NULL);
             DoPlaySoundToSet(m_creature,5815);
		    }
	   if(Cast2_Timer < diff && !m_creature->HasAura(25222,0)) 
		    {
		     DoCast(m_creature,25222);
		     Cast2_Timer = 10000;
		    }else Cast2_Timer -= diff;
		 if(Cast1_Timer < diff) 
		  {
		   switch(rand()%2)
		   {
		   case 0:
		   DoCast(m_creature->getVictim(),2860);//29166
		   Cast1_Timer = 8000;
		   break;
		   case 1:
		   DoCast(m_creature,8361);//29166
		   Cast1_Timer = 3000;
		   break;
		   }
		  }else Cast1_Timer -= diff;
		   }else{
		   if(Aggro < 3)
		    {
		     Aggro = 3;
             DoYell("Bah!My power rules here!",LANG_UNIVERSAL,NULL);
             DoPlaySoundToSet(m_creature,5816);
		    }
		   if( (int) (m_creature->GetHealth()*4 / m_creature->GetMaxHealth() +1) > 2)
		   {
		   if(Cast2_Timer < diff && !m_creature->HasAura(25222,0)) 
		    {
		     DoCast(m_creature,25222);
		     Cast2_Timer = 10000;
		    }else Cast2_Timer -= diff;
		 if(Cast1_Timer < diff) 
		  {
		   switch(rand()%2)
		   {
		   case 0:
		   DoCast(m_creature->getVictim(),2860);//29166
		   Cast1_Timer = 8000;
		   break;
		   case 1:
		   DoCast(m_creature,8361);//29166
		   Cast1_Timer = 3000;
		   break;
		   }
		  }else Cast1_Timer -= diff;
		   }else
		   {
		   if(Aggro < 4)
		    {
		     Aggro = 4;
             DoYell("Our new allies will avenge us!",LANG_UNIVERSAL,NULL);
             DoPlaySoundToSet(m_creature,5818);
		    }
		   if(Cast2_Timer < diff && !m_creature->HasAura(25222,0)) 
		    {
		     DoCast(m_creature,25222);
		     Cast2_Timer = 10000;
		    }else Cast2_Timer -= diff;
		 if(Cast1_Timer < diff) 
		  {
		   switch(rand()%2)
		   {
		   case 0:
		   DoCast(m_creature->getVictim(),2860);//29166
		   Cast1_Timer = 8000;
		   break;
		   case 1:
		   DoCast(m_creature,8361);//29166
		   Cast1_Timer = 3000;
		   break;
		   }
		  }else Cast1_Timer -= diff;		   		   
		   }
		   }
		  }
	   }

    if(Entry != 4420)
	 DoMeleeAttackIfReady();
 }
};
struct MANGOS_DLL_DECL scenario_rfk : public ScriptedInstance
{
   scenario_rfk(Map *Map) : ScriptedInstance(Map) {
        Initialize();
		ScenarioRFK = 0;

};

void OnObjectCreate (GameObject* go) 
{
   switch(go->GetEntry())
   {
      case 21099:
       RFKDoor = go;
       RFKDoor->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
       RFKDoor->SetUInt32Value(GAMEOBJECT_STATE, 1);
	   break;
   }
}

void OpenDoor() 
{
  RFKDoor->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
  RFKDoor->SetUInt32Value(GAMEOBJECT_STATE, 0);
}
void SetData (char *type, uint32 data) 
{
        if(data==1)
			OpenDoor();
}
};
CreatureAI* GetAI_razorfen_kraul(Creature *_Creature)
{
    return new razorfen_kraulAI (_Creature);
}
InstanceData* GetInstanceData_scenario_rfk(Map* map)
{
    return new scenario_rfk(map);
}
void AddSC_razorfen_kraul()
{   
	Script *newscript;

	newscript = new Script;
    newscript->Name="razorfen_kraul";
    newscript->GetAI = GetAI_razorfen_kraul;
    m_scripts[nrscripts++] = newscript;

    newscript = new Script;
    newscript->Name = "scenario_rfk";
    newscript->GetInstanceData = GetInstanceData_scenario_rfk;
    m_scripts[nrscripts++] = newscript;
}