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

[TFS 0.4] Party Share EXP giving experience when kill player

secondlife

Active Member
Joined
Aug 1, 2009
Messages
302
Reaction score
25
Hi guys!

I recently implemented this @Mkalo system in my sources 0.4: Here

The system works as proposed, but I was doing some tests and I could see that when I kill another player (don't need to be at a party) the player gains experience, like as "enforced" mode.

is it possible to correct this problem and allow it to only gain experience of creatures?

player.cpp
Code:
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
Code:
uint32_t getBaseVoc();
double getPartyBonus();

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

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;
        }

Many thanks!!
 
Last edited:

Similar threads

Back
Top