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

C++ party share exp

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
457
Reaction score
17
hello guys i use 0.4
i use this system party share exp but this system make this bug
exp from player is very hight how i can make this system work on monster only.

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

double Player::getPartyBonus() {
    double multiplier = 1;
    double benefit = 0.25;
    bool vocations[] = {
        false, // Rook
        false, false, false, false, false, // Players, maybe new vocation tree?
        false, false, false, false, false, // Atomic new baselines at 4th promotion so a plateau of no backsliding?
        false, false, // Convergent Demigod paths?
        false // Something else? Did you create getBaseVoc() correctly? Is your vocations.xml sane?
    };
    if(Party* party = this->getParty()) {
        if(party->isSharedExperienceEnabled() && party->isSharedExperienceActive()) {
            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;
                    multiplier += std::max(benefit, 0.10);
                    benefit += -0.05;
                }
            }
        }
    }
    return multiplier;

player.h
Code:
uint32_t getBaseVoc();
double getPartyBonus();

creature.cpp
Code:
double Creature::getGainedExperience(Creature* attacker) {
            double bonus = 1;
            if(Player* player = attacker->getPlayer()) {
                bonus = player->getPartyBonus();
            }
            return getDamageRatio(attacker) * (double)getLostExperience() * bonus;
        }

creature.h
Code:
virtual double getGainedExperience(Creature* attacker);
 
Back
Top