Exemplo n.º 1
0
	void OnDied( UnitPointer pKiller )
	{
		PlayerPointer QuestHolder = NULLPLR;
		if ( pKiller->IsPlayer() )
			QuestHolder = TO_PLAYER( pKiller );
		else if ( pKiller->IsPet() && TO_PET( pKiller )->GetPetOwner() != NULLPLR )
			QuestHolder = TO_PET( pKiller )->GetPetOwner();

		if ( QuestHolder == NULLPLR )
			return;

		// M4ksiu: I don't think the method is correct, but it can stay the way it was until someone gives proper infos
		QuestLogEntry* Quest = QuestHolder->GetQuestLogForEntry( 9670 );
		CreaturePointer RandomCreature = NULLCREATURE;
		if ( Quest == NULL )
		{
			// Creatures from Bloodmyst Isle
			uint32 Id[ 51 ] = { 17681, 17887, 17550, 17323, 17338, 17341, 17333, 17340, 17353, 17320, 17339, 17337, 17715, 17322, 17494, 17654, 17342, 17328, 17331, 17325, 17321, 17330, 17522, 17329, 17524, 17327, 17661, 17352, 17334, 17326, 17324, 17673, 17336, 17346, 17589, 17609, 17608, 17345, 17527, 17344, 17347, 17525, 17713, 17523, 17348, 17606, 17604, 17607, 17610, 17358, 17588 };
			RandomCreature = _unit->GetMapMgr()->GetInterface()->SpawnCreature( Id[ RandomUInt( 50 ) ], _unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation(), true, false, 0, 0 );
			if ( RandomCreature != NULLCREATURE )
			{
				RandomCreature->m_noRespawn = true;
				RandomCreature->Despawn( 60000, 0 );
			};

			return;
		}
		else
		{
			uint32 Id[ 8 ] = { 17681, 17321, 17330, 17522, 17673, 17336, 17346, 17589 };
			RandomCreature = _unit->GetMapMgr()->GetInterface()->SpawnCreature( Id[ RandomUInt( 7 ) ], _unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation(), true, false, 0, 0 );
			if ( RandomCreature != NULLCREATURE )
			{
				RandomCreature->m_noRespawn = true;
				RandomCreature->Despawn( 60000, 0 );
				if ( RandomCreature->GetEntry() == 17681 && Quest->GetMobCount( 0 ) < Quest->GetQuest()->required_mobcount[ 0 ] )
				{
					Quest->SetMobCount( 0, Quest->GetMobCount( 0 ) + 1 );
					Quest->SendUpdateAddKill( 0 );
					Quest->UpdatePlayerFields();
				};
			};
		};
	};
Exemplo n.º 2
0
uint32 CalculateXpToGive(UnitPointer pVictim, UnitPointer pAttacker)
{
	if(pVictim->IsPlayer())
		return 0;

	if( TO_CREATURE(pVictim)->IsTotem())
		return 0;

	CreatureInfo *victimI;
	victimI = TO_CREATURE(pVictim)->GetCreatureInfo();

	if(victimI)
		if(victimI->Type == CRITTER)
			return 0;
	uint32 VictimLvl = pVictim->getLevel();
	uint32 AttackerLvl = pAttacker->getLevel();

	if( pAttacker->IsPet() && TO_PET(pAttacker)->GetPetOwner() )
	{
		// based on: http://www.wowwiki.com/Talk:Formulas:Mob_XP#Hunter.27s_pet_XP (2008/01/12)
		uint32 ownerLvl = TO_PET( pAttacker )->GetPetOwner()->getLevel();
		VictimLvl += ownerLvl - AttackerLvl;
		AttackerLvl = ownerLvl;
	}
	else if( (int32)VictimLvl - (int32)AttackerLvl > 10 ) //not wowwikilike but more balanced
		return 0;

	// Partha: this screws things up for pets and groups
	// No need for it here - it does this later in Player::GiveXP 
	/*
	uint32 max_level = 70;
	if(pAttacker->IsPlayer())
	max_level = pAttacker->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL);
	else if(pAttacker->IsPet())
	max_level = TO_PET( pAttacker )->GetPetOwner()->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL);

	if(pAttacker->getLevel() >= max_level)
	return 0;
	*/


	/*if(VictimLvl+7>AttackerLvl)
	VictimLvl = AttackerLvl + 7;*/

	float zd = 5;
	float g = 5;

	// get zero diff
	// get grey diff

	if(AttackerLvl >= 70)
	{
		zd = 19;
		g = 15;
	}
	else if(AttackerLvl >= 65)
	{
		zd = 18;
		g = 13;
	}
	else if(AttackerLvl >= 60)
	{
		zd = 17;
		g = 14;
	}
	else if(AttackerLvl >= 55)
	{
		zd = 16;
		g = 12;
	}
	else if(AttackerLvl >= 50)
	{
		zd = 15;
		g = 11;
	}
	else if(AttackerLvl >= 45)
	{
		zd = 14;
		g = 10;
	}
	else if(AttackerLvl >= 40)
	{
		zd = 13;
		g = 9;
	}
	else if(AttackerLvl >= 30)
	{
		zd = 12;
		g = 8;
	}
	else if(AttackerLvl >= 20)
	{
		zd = 11;
		g = 7;
	}
	else if(AttackerLvl >= 16)
	{
		zd = 9;
		g = 6;
	}
	else if(AttackerLvl >= 12)
	{
		zd = 8;
		g = 6;
	}
	else if(AttackerLvl >= 10)
	{
		zd = 7;
		g = 6;
	}
	else if(AttackerLvl >= 8)
	{
		zd = 6;
		g = 5;
	}
	else
	{
		zd = 5;
		g = 5;
	}

	float xp = 0.0f;
	float fVictim = float(VictimLvl);
	float fAttacker = float(AttackerLvl);

	if(VictimLvl == AttackerLvl)
		xp = float( ((fVictim * 5.0f) + 45.0f) );
	else if(VictimLvl > AttackerLvl)
	{
		float j = 1.0f + (0.25f * (fVictim - fAttacker));
		xp = float( ((AttackerLvl * 5.0f) + 45.0f) * j );
	}
	else
	{
		if((AttackerLvl - VictimLvl) < g)
		{
			float j = (1.0f - float((fAttacker - fVictim) / zd));
			xp = (AttackerLvl * 5.0f + 45.0f) * j;
		}
	}

	// multiply by global XP rate
	if(xp == 0.0f)
		return 0;

	xp *= sWorld.getRate(RATE_XP);

	// elite boss multiplier
	if(victimI)
	{
		switch(victimI->Rank)
		{
		case 0: // normal mob
			break;
		case 1: // elite
			xp *= 2.0f;
			break;
		case 2: // rare elite
			xp *= 2.0f;
			break;
		case 3: // world boss
			xp *= 2.5f;
			break;
		default:	// rare or higher
			//			xp *= 7.0f;
			break;
		}
	}
	if( xp < 0 )//probably caused incredible wrong exp
		xp = 0;

	return (uint32)xp;
	/*const float ZD[PLAYER_LEVEL_CAP+1] = {1,5,5,5,5,5,5,5,6,6,7,7,8,8,8,9,9,9,9,9,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,14,14,14,14,14,15,15,15,15,15,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17};
	float temp = 0;
	float tempcap = 0;
	float xp = 0;

	if(VictimLvl >= AttackerLvl)
	{
	temp = ((AttackerLvl * 5) + 45) * (1 + 0.05 * (VictimLvl - AttackerLvl));
	tempcap = ((AttackerLvl * 5) + 45) * 1.2;
	if(temp > tempcap)
	{
	if( tempcap < 0 )
	tempcap = 0;
	else
	tempcap *= sWorld.getRate(RATE_XP);

	xp = tempcap;
	}
	else
	{
	if( temp < 0 )
	temp = 0;
	else
	temp *= sWorld.getRate(RATE_XP);

	xp = temp;
	}
	}
	else
	{
	if(getConColor(AttackerLvl, VictimLvl) == 0)
	{
	return (uint32)0;
	}
	else
	{
	if(AttackerLvl < PLAYER_LEVEL_CAP)
	temp = (((AttackerLvl * 5) + 45) * (1 - (AttackerLvl - VictimLvl)/ZD[AttackerLvl]));
	else
	temp = (((AttackerLvl * 5) + 45) * (1 - (AttackerLvl - VictimLvl)/17));
	if( temp < 0 )
	temp = 0;
	else
	temp *= sWorld.getRate(RATE_XP);

	xp = temp;
	}
	}

	if(victimI)
	{
	switch(victimI->Rank)
	{
	case 0: // normal mob
	break;
	case 1: // elite
	xp *= 1.5f;
	break;
	case 2: // rare elite
	xp *= 3.0f;
	break;
	case 3: // world boss
	xp *= 10.0f;
	break;
	default:	// rare or higher
	xp *= 7.0f;
	break;
	}
	}

	return (uint32)(xp);*/
}