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

Sources & Exp -pvp

Onizuka

Member
Joined
Jul 5, 2008
Messages
2,291
Reaction score
14
Wondering if someone could tell me where is exp-pvp in sources? can't find it in game.cpp for some reason.


Regards,
Anco.
 
I'm not really good at math, So Sorry for asking you, any ideas how to edit these numbers to make it work this way

Exampple: if lvl 500 kills a lvl 100, gets exp

Lua:
	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))))) * 0.05 * c)) * rate;
}


Atm i think it works like this lvl 500- kills 449 no exp, kills 450 still exp. so it's 50 lvls lower atm. Want to make it like 300 lvls lower at least.
These numbers are co confusing :x

Kind Regards,
Anco.
 
The formula itself is made so that higher level will never get any experience from a lower level :/

Code:
	if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
		level > (uint32_t)std::floor(attackerLevel * max)))
		return 0;
Even if you remove this (^) part, I still doubt it would work ;/

hmm..
Code:
(1-(20*0.9/20))*0.05*98800
	494
(1-(21*0.9/20))*0.05*98800
	271.7
(1-(22*0.9/20))*0.05*98800
	49.4
(1-(23*0.9/20))*0.05*98800
	-172.9
If victim is level 20 and killer is level higher than 22, he wouldn't get any experience :/
 
That's the whole point why i want to edit it, i want players of higher lvls to gain exp from lower lvls. You realise there is no fun if higher lvls can't gain advantage of pvp-e aswell as low lvls.

The script that a friend wrote doesn't seem to work on tfs 0.4 for an unknown reason. No errors nothing.


Thanks again!
 
Okay, try it:
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;

	/*
		Formula
		c = victims experience

		result = 0.05 * c
		Not affected by special multipliers(!)
	*/
	uint64_t c = getExperience();
	return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
		* std::max((double)0, (double)0.05 * c))) * rate;
}
Gained experience would no longer depend on killer's level; it'll always be the same: 5% of victim's total experience, shared among the killers.
 
Last edited:
Lua:
player.cpp: In member function 'virtual double Player::getGainedExperience(Creature*) const':
player.cpp:3337: error: expected ')' before ';' token
cc1plus: warnings being treated as errors
player.cpp:3334: error: unused variable 'a'
player.cpp:3334: error: unused variable 'b'
make[1]: *** [player.o] Error 1
make[1]: Leaving directory `/home/trunk.r3671'
make: *** [all] Error 2

:<


Let's say we'd stick to lua

Why this doesn't seem to work on tfs 0.4?

Lua:
function onKill(cid, target, lastHit)
	local rate = 0
	if isPlayer(cid) then
		if isPlayer(target) then
			if (getPlayerLevel(cid) > getPlayerLevel(target)) or (getPlayerLevel(cid) < getPlayerLevel(target)) then
				rate = getExperienceForLevel(getPlayerLevel(target))
				return doPlayerAddExp(cid, math.min(rate * 5 / 3 ^ 7))
			end
		else
			return true
		end
	else
		return true
	end
end

Did add in login.lua and .xml ;o

No errors/ nothing. w
 
Lol, Can you be such a great guy and fix it up?:>


Edit: ww

Lua:
cc1plus: warnings being treated as errors
player.cpp: In member function 'virtual double Player::getGainedExperience(Creature*) const':
player.cpp:3323: error: unused variable 'attackerLevel'
make[1]: *** [player.o] Error 1
make[1]: Leaving directory `/home/trunk.r3671'
make: *** [all] Error 2
 
0_o read the error

You were supposed to remove this line:
Code:
	double attackerLevel = (double)attackerPlayer->getLevel();
 
Cyko,

how do I only player above the level 100 get experience?

exemple

Killer = level 100
Victi = level 99
Killer = No Gain EXP
OR
Killer = lvl 20 or 99
Victim = lvl 200

killer = No gain EXP too

its possible?
 
Code:
	if([B][COLOR="#FF0000"]level < 100 || attackerLevel < 100 || [/COLOR][/B](min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
		level > (uint32_t)std::floor(attackerLevel * max)))
		return 0;
 
Back
Top