• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Experience From Players

Nevalopo

Demigod
Joined
Jul 21, 2008
Messages
5,165
Reaction score
68
Location
Sweden, Landskrona
Ok so im wondering how do i change this? Currently this is what i want:

Player 1 (10) Kills players 2 (10) And gains exp

When player 1 reaches level (12) He gains 0 exp from killing player 2 (10)

I want player 1 (12) to keep gaining exp from player 2 (10)

Where do i change this?

I found this in players.cpp:



Code:
	if(!g_config.getBool(ConfigManager::EXPERIENCE_FROM_PLAYERS))
		return 0;

	Player* attackerPlayer = attacker->getPlayer();
	if(!attackerPlayer || attackerPlayer == this || !skillLoss)
		return 0;

	uint32_t a = (uint32_t)std::floor(attackerPlayer->getLevel() * 0.9);
	if(getLevel() >= a)
	{
		/*
			Formula
			a = attackers level * 0.9
			b = victims level
			c = victims experience

			result = (1 - (a / b)) * 0.05 * c
		*/

Can anyone tell me the formula or what to do to make him keep getting exp from the level 10 when he is level 12?
 
try this :)

Code:
uint64_t Player::getGainedExperience(Creature* attacker) const
{
	if(g_config.getBool(ConfigManager::EXPERIENCE_FROM_PLAYERS))
	{
		Player* attackerPlayer = attacker->getPlayer();
		if(attackerPlayer && attackerPlayer != this && skillLoss)
		{
			/*
				Formula
				a = attackers level * 0.9
				b = victims level
				c = victims experience

				y = (1 - (a / b)) * 0.05 * c
			*/

			uint32_t a = (uint32_t)std::floor(attackerPlayer->getLevel() * 0.9);
			uint32_t b = getLevel();
			uint64_t c = getExperience();

			uint64_t result = std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker) * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c));
			return (result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
		}
	}
	return 0;
}

It's not tested, but it should work :)

EDIT: Try this now, corrected a few things.
EDIT2: Full code now

@ Pitufo, he wants the difference, he want people to gain exp even if the other guy is under his lvl ;P
 
Last edited:
Simply heres the whole function:

Code:
uint64_t Player::getGainedExperience(Creature* attacker) const
{
	if(g_config.getBoolean(ConfigManager::EXPERIENCE_FROM_PLAYERS))
	{
		Player* attackerPlayer = attacker->getPlayer();
		if(attackerPlayer && attackerPlayer != this && skillLoss)
		{
			/*
				Formula
				a = attackers level * 0.9
				b = victims level
				c = victims experience

				y = (1 - (a / b)) * 0.05 * c
			*/

			uint32_t a = (uint32_t)std::floor(attackerPlayer->getLevel() * 0.9);
			uint32_t b = getLevel();
			uint64_t c = getExperience();

			uint64_t result = std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker) * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c));
			if(attacker->getLevel() > getLevel())
			return 0;
			else
			return (result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
		}
	}
	return 0;
}

So if the attacker is higher level than the target then he will receive 0 exp, else, he will gain the config.lua exp :D

PD: I dont know if this is what u whanted because it is very confusing...
 
Last edited:
Ah i tried messing around with this a bit... Too bad i cant really get it working :S I still want people to get exp if they are level 20.. I want them to get exp from a lvl 10 but if i go that high they get level 15 from 1 kill :S

Anyone know how to make a "steady" exp? Example:

Player 1 (10) kills player 2 (10) and Player 1 gets 500 exp
Player 3 (5000) kills player 4 (34737) and Player 3 gets 500 exp
 
So you whant to get always the same exp no matter the level from the target?

If so then just change this:

Code:
return (result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));

To this:

Code:
return 500;
 
here, this is a way shorter now :p

Code:
uint64_t Player::getGainedExperience(Creature* attacker) const
{
	if(g_config.getBool(ConfigManager::EXPERIENCE_FROM_PLAYERS))
	{
		Player* attackerPlayer = attacker->getPlayer();
		if(attackerPlayer && attackerPlayer != this && skillLoss)
		{
			return 500;
		}
	}
	return 0;
}
 
Back
Top