• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Compiling Bonus Sharing EXP

icekis

Member
Joined
Jan 18, 2018
Messages
97
Reaction score
6
I am trying to use the sharing exp bonus from this topic:

Lua - Is possible check sharing exp

@Mkalo was coded this feature and works perfect, but if i kill another player still gain exp

Could someone help me?

I am using TFS 0.4 REV 3777

player.cpp
C++:
uint32_t Player::getBaseVoc() {
    uint32_t curVoc = vocation_id;
    Vocation* voc = Vocations::getInstance()->getVocation(curVoc);
    while(voc->getFromVocation() != curVoc) {
        curVoc = voc->getFromVocation();
        voc = Vocations::getInstance()->getVocation(curVoc);
    }
    return curVoc;
}

double Player::getPartyBonus() {
    double bonus = 1;
    bool vocations[10];
    if(Party* party = this->getParty()) {
        PlayerVector list = party->getMembers();
        list.push_back(party->getLeader());
        for(PlayerVector::const_iterator it = list.begin(); it != list.end(); ++it) {
            uint32_t vocId = (*it)->getBaseVoc();
            if(!vocations[vocId]) {
                vocations[vocId] = true;
                bonus += 0.125;
            }
        }
    }
    return bonus;
}

player.h
C++:
uint32_t getBaseVoc();
double getPartyBonus();

creature.h
C++:
virtual double getGainedExperience(Creature* attacker);

creature.cpp
C++:
double Creature::getGainedExperience(Creature* attacker) {
            double bonus = 1;
            if(Player* player = attacker->getPlayer()) {
                bonus = player->getPartyBonus();
            }
            return getDamageRatio(attacker) * (double)getLostExperience() * bonus;
        }
 
Last edited:
Back
Top