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

Lua how to make a player gain exp from every player he kills?

xubeiga

New Member
Joined
Jun 17, 2009
Messages
137
Reaction score
1
hey guys...in my config.lua have this:

Experience from players
-- NOTE: min~Threshold* set to 0 will disable the minimum threshold:
-- player will gain experience from every lower leveled player.
-- max~Threshold* set to 0 will disable the maximum threshold:
-- player will gain experience from every higher leveled player.
minLevelThresholdForKilledPlayer = 0
maxLevelThresholdForKilledPlayer = 0

what values should i write there to make all players gain exp from all players, like lvl 8 gain exp from lvl 200 and a lvl 200 gain exp from a lvl 8?
thanks
 
Maybe the 0 option doesn't work. try using these:

Lua:
	minLevelThresholdForKilledPlayer = 0.1
	maxLevelThresholdForKilledPlayer = 10

It may not give experience with every lvl but for example a lvl 20 can kill a lvl 2 and a lvl 200 character and still gain experience
And a lvl 200 can kill a lvl 20 and a lvl 2000 (Lmao) and still gain experience.

Hope this works
 
Can you please let us know what distro & version you are running?
I encountered this same problem a year or so ago with TFS 0.3.6 and ended up disabling pvp exp in config and writing a script similar to any frag reward script to award players exp for anyone they killed.
 
Hey you found my original thread! Fair Effort!
Cycotitan suggests in that thread to remove the offending part of code (red text below), feel free to read the thread yourself of course and see my mind exploding!
http://otland.net/f132/exploraton-pvpe-threshold-65774/

player.cpp
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;

	[COLOR="#FF0000"]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;[/COLOR]

	/*
		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))))) * 0.05 * c)) * rate;
}
 
Yes player.cpp is a source file.

SonekaBR, you are running Avesta correct?
I believe you only need to set the following to achieve this -- PVP-E Thresholds did not exist back then!

Code:
-- world type
    -- options: pvp, no-pvp, pvp-enforced
    WorldType = "pvp-enforced"
 
Marencian,

I'm running it as a pvp-enforced, but the problem is if i'm a Druid lvl 140 i gain exp from a lvl 130 but from a lvl 120 not.

If the difference of lvl is not so great it will gain exp but if it isn't...
 
Mare~ i'll upload it and pass for you, from already thank you


A noob question... Where is the sources? hahaha
 
Last edited:
If you do not have a folder called "src" or "source" in your main directory, it should be released with the server where ever you downloaded it from originally!
Check your download history and see if you can find where you got it from =)
 
Back
Top