Example #1
0
//Checks whether the Dragonkin racial should proc.
void PetHelper::CheckRacialsProc(PetStage *petStage, quint8 teamIndex)
{
	Pet *currentPet = petStage->GetTeam(teamIndex)->GetActivePet();

	//Check if active pet is Dragonkin type and has brought the other team's pet below 50%.
	if (currentPet->GetType() == PetType::Dragonkin
                && petStage->GetTeam((teamIndex%2)+1)->GetActivePet()->GetHealthPercentage() < 0.50
                && !currentPet->RacialUsed())
	{
		currentPet->RacialUsed(true);			//Racial now used.
		currentPet->AddAura(245, 1, true);		//Will replace persisting racial.
    }
}
Example #2
0
//Checks the damage dealt.
void PetHelper::CheckDamage(PetStage *petStage, quint8 teamIndex, quint8 petIndex, quint16 damage, bool mainAttack, bool useLightning)
{
	Pet *currentPet = petStage->GetTeam(teamIndex)->GetPet(petIndex);
	quint16 totalDamage = damage;
	quint16 currentHealth = currentPet->GetHealth();

	//Special exception is the use of Lightning Storm weather effect.
	if (useLightning && petStage->GetTeam(0)->GetPet(0)->GetNumAuras() > 0
			&& petStage->GetTeam(0)->GetPet(0)->GetAura(1)->GetAuraId() == 203)
		totalDamage += Round(2 + (float)petStage->GetTeam(0)->GetPet(0)->GetAura(1)->GetPower() * 0.10);

	//Use Magic racial if applicable.
	if (currentPet->GetType() == PetType::Magic && totalDamage > (int)(currentPet->GetMaxHealth() * 0.35))
		//Check if health is greater than 35%.
		if (currentPet->GetHealthPercentage() > 0.35)
			currentPet->SetHealth(currentPet->GetHealth() - currentPet->GetMaxHealth() * 0.35);
		else
		{	//Set health to 0 and check racial procs for attacking team.
			currentPet->SetHealth(0);
			CheckRacials(currentPet);
		}
	else
	{
		//Check if the pet can sustain the hit.
		if (currentPet->GetHealth() - totalDamage > 0)
			currentPet->SetHealth(currentPet->GetHealth() - totalDamage);
		else
		{	//Pet can't sustain the hit, set health to 0 and check racials.
			currentPet->SetHealth(0);
			CheckRacials(currentPet);
		}
	}

	//Special exception; pet is unkillable but health hits 0.
	if (currentPet->HasStatus(Pet::Unkillable) && currentPet->IsDead())
		currentPet->SetHealth(1);

	//Check if this is the main attack.
	if (mainAttack)
	{	//Check to see if racials have proc'd and set attack to true.
		CheckRacialsProc(petStage, (teamIndex%2)+1);
		petStage->GetTeam((teamIndex%2)+1)->GetActivePet()->AttackedThisRound(true);
	}

	//Scan over the auras for the current pet.
	for (quint8 i=1; i < currentPet->GetNumAuras()+1; i+=1)
		//Plague Blood.
		if (currentPet->GetAura(i)->GetAuraId() == 658)
		{
			quint16 normalHealing = Round(4 + (float)currentPet->GetAura(i)->GetPower() * 0.2);			

			if (mainAttack)
			{
				//Opponent's active pet is healed; check his healing modifiers.
				quint16 healing = Round(normalHealing * petStage->GetTeam((teamIndex%2)+1)->GetActivePet()->GetHealingModifier());
				CheckHealing(petStage, (teamIndex%2)+1, petStage->GetTeam((teamIndex%2)+1)->GetActivePetIndex(), healing, false);
			}
			else
			{
				//Originator of the aura is healed; check his healing modifiers.
				quint16 healing = Round(normalHealing * petStage->GetTeam(currentPet->GetAura(i)->GetOriginTeam())->GetPet(currentPet->GetAura(i)->GetOriginPet())->GetHealingModifier());
				CheckHealing(petStage, currentPet->GetAura(i)->GetOriginTeam(), currentPet->GetAura(i)->GetOriginPet(), normalHealing, false);
			}
		}
		//Asleep.
		else if (currentPet->GetAura(i)->GetAuraId() == 498 || currentPet->GetAura(i)->GetAuraId() == 926 || currentPet->GetAura(i)->GetAuraId() == 496)
		{
			currentPet->RemoveStatus(Pet::Asleep);
			currentPet->RemoveAura(i);
			i -= 1;
		}
		//Silk Cocoon.
		else if (currentPet->GetAura(i)->GetAuraId() == 505)
		{
			currentPet->SetSpeed(currentPet->GetNormalSpeed());
			currentPet->SetHealth(currentHealth);
			currentPet->RemoveAura(i);
			i -= 1;
		}
}