• 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!

Separation of exp for the damage inflicted - PVP-ENFO

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Hello!
I have a pvp-enfo serwer, for killing player we get experience. I try to give away experience by using this option in config:
Code:
rateExperienceFromPlayers = 110
When player with 50 level kill other player with the same level then he gets 7,5 lvl, all is good, but if it happens again and this player which killed before 50 and and he will have already 57,5 and kill player again with 50 level then system will not grant him any experience (min/maxLevelThresholdForKilledPlayer - I changed it but zero effect).
And if player with 50 level kill this player with 57,7 level it receives as many as 68 levels.
I don't have any idea how to give away experience. I try to do this in lua, but I haven't found the function that takes a number of players who attacked the character and then divides the exp for the damage inflicted.
If not lua then I go to search in sources, in sources I found this function:
Code:
double Player::getGainedExperience(Creature* attacker) const
, which is the only relates to
Code:
rateExperienceFromPlayers = 110
I started to modify it at this point:
Code:
	uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
	uint64_t c = getExperience();
	return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
		* std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c)) * rate;

I have tried many combinations, but always ended up on the fact that it does not matter whether a player whacked again with a rod or practically killed himself and so and so getting as much exp as the person who gave him such as 30 injured. Of course, the difference was minimal.
I would like to know if anyone has any idea how it scripted to run in a more or less like this:
50 attacks 50 and have 57...
57 attacks 50 and have 59...
...
50 attacks 57 and have 55...
50 attacks 68 and have 75...
...
If there is no idea how to write, it might know how to edit the source code that, for example 700000 exp away all attackers and split it depending on the damage inflicted.

The whole function of the code:
Code:
double Player::getGainedExperience(Creature* attacker) const
{
	if(!skillLoss)
		return 0;

	double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
	if(rate <= 0)
		return 0;

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

	double attackerLevel = (double)attackerPlayer->getLevel(), min = g_config.getDouble(
		ConfigManager::EFP_MIN_THRESHOLD), max = g_config.getDouble(ConfigManager::EFP_MAX_THRESHOLD);
	if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
		level > (uint32_t)std::floor(attackerLevel * max)))
		return 0;

	/*
		Formula
		a = attackers level * 0.9
		b = victims level
		c = victims experience

		result = (1 - (a / b)) * 0.05 * c
		Not affected by special multipliers(!)
	*/
	uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
	uint64_t c = getExperience();
	return (double)std::max((uint64_t)0, (uint64_t)std::floor((getDamageRatio(attacker)
		* std::max(((double)0, ((double)(1 - (((double)a / b))))) + 100000) * 0.05 * c) * rate)) + 183;
}

Please help, thanks in advance ; )
//Sorry for my english...
 
Back
Top