Hello OTLanders!
Don't know who still working on OTHire nowadays instead of new TFS 1.X, whatever, I want to release simple feature for this amazing "engine".
Special Thanks to @Qbazzz for optimization this.
Don't know who still working on OTHire nowadays instead of new TFS 1.X, whatever, I want to release simple feature for this amazing "engine".
Special Thanks to @Qbazzz for optimization this.
- What's this?
Simple pieces of C++ code, which adding "kinda famous nowadays feature on every OT's" - possibility to set-up difference between players levels in PVP-Enforced worldType (Player will receive experience after killing ONLY players that are in X% level range, for example: 100 level receive exp from players above 75+, if its set to 0.75).
- Let's code! (copy-paste)
1. In player.cpp, search for function:
C++:
uint64_t Player::getGainedExperience(Creature* attacker) const
And replace entire function with this:
C++:
uint64_t Player::getGainedExperience(Creature* attacker) const
{
if (g_game.getWorldType() == WORLD_TYPE_PVP_ENFORCED && g_config.getNumber(ConfigManager::RATE_EXPERIENCE_PVP) > 0) {
Player* attackerPlayer = attacker->getPlayer();
if(attackerPlayer && attackerPlayer != this && skillLoss) {
/* Experience Gain Formula
a = attackers level * 0.9
b = victims level
c = victims experience
Now: (1 - (Attacker Level / Victim Level)) * 0.05 * Victim Experience
*/
if (attackerPlayer->getParty() || getParty()) {
if (getParty() == attackerPlayer->getParty()) {
std::stringstream ss; ss << "You have not gained experience for killing "<< getName() <<" because you were in the same party.";
attackerPlayer->sendTextMessage(MSG_EVENT_DEFAULT, ss.str());
return 0;
}
}
uint32_t a = (uint32_t)std::floor(attackerPlayer->getLevel() * 0.9);
uint32_t b = getLevel();
uint64_t c = getExperience();
uint32_t attackerLevel = attackerPlayer->getLevel();
uint32_t victimLevel = getLevel();
if ( attackerLevel >= std::floor(victimLevel * 0.75) ) {
uint64_t result = std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker) * std::max((double)0, ((double)(2 - (((double)a / b))))) * 0.01 * c ));
std::stringstream ss; ss << "You killed "<< getName() <<" and received "<< (uint64_t)(result * 0.75) << " experience points.";
attackerPlayer->sendTextMessage(MSG_EVENT_DEFAULT, ss.str());
return (uint64_t)(result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE_PVP));
} else {
std::stringstream ss; ss << "You have not gained experience for killing "<< getName() <<" because you or your victim doesn't meet requirements [Difference between attacker level and victim is 75%.";
attackerPlayer->sendTextMessage(MSG_EVENT_DEFAULT, ss.str());
return 0;
}
}
}
return 0;
}
Thats all, enjoy.
Already known bugs:
- nothing, this script was tested on CLEAN OTHire.
Already known bugs:
- nothing, this script was tested on CLEAN OTHire.
Last edited: