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

Tfs 1.0 shared experience bonus

ATT3

Intermediate OT User
Joined
Sep 22, 2010
Messages
512
Reaction score
100
Shared experience bonus =

Cave rat gives 10 exp (1 guy)
for 2 guys with shared exp it gives 5x for both (normal)
but with X% bonus
it would give 7 exp for both.

Currently it has 20% experience bonus when shared exp enabled but I can find the file/way to edit it ;o!

Updated:
You can edit it at party.cpp line 400~
 
Last edited:
register that in creaturescripts.xml and login.lua and volia
Code:
  function hasPlayerRealParty(cid)
     if Player(cid):getParty() ~= nil then
       if Player(cid):getParty():getMemberCount() > 0 then
         return true
       end
     end
   return false
   end

   function useExpRate(player, experience, stamina)
     local k = Game.getExperienceStage(player:getLevel())
     local st = player:getStamina()

     if stamina then
       if isPremium(cid) and st > 2400 then
         return experience * k * 1.5
       elseif st < 1 then
         return 0
       elseif st < 841 then
         return experience * k * 0.5
       end
     end

     return experience * k
   end

   function onKill(cid, target, damage, flags)
   local p = Player(cid)
   local percentbonus = 10 -- +10% more exp
   if not isMonster(target) then
     return true
   end

   if hasPlayerRealParty(cid) then
     local party = p:getParty()
     local leader = party:getLeader()
     if party:isSharedExperienceEnabled() then
       local xp = useExpRate(leader, MonsterType(getCreatureName(target):lower()):getExperience(), true) * (percentbonus / 100)
       -- leader
       leader:addExperience(xp, true, true)
       -- other members
       local member = leader:getParty():getMembers()
       for i = 1,party:getMemberCount() do
         local xp = useExpRate(member[i], MonsterType(getCreatureName(target):lower()):getExperience(), true) * (percentbonus / 100)
         member[i]:addExperience(xp, true, true)
       end
     end
   end
return true
end

I still don't get it
This has to be some sort of a bug. Even without my script, when I enable shared exp there is engine-sided extra exp already. I can't calculate it's % so it has to be complex formula.
#629

Edit: still can't calculate it this way
 
Last edited:
Maybe the config for tfs just doesn't have it included, but it's still somehow coded? Maybe copy/pasting a previous party exp area from another config file will do the job..?

Btw, thanks for the script.
 
Shared experience bonus =

Cave rat gives 10 exp (1 guy)
for 2 guys with shared exp it gives 5x for both (normal)
but with X% bonus
it would give 7 exp for both.

Currently it has 20% experience bonus when shared exp enabled but I can find the file/way to edit it ;o!

Updated:
You can edit it at party.cpp line 400~
Bro how i can put 0% shared exp bonus? I don't like bonus exp for my ot.

My code on line 400~:
Code:
bool Party::canUseSharedExperience(const Player* player) const
{
    if (memberList.empty()) {
        return false;
    }

    uint32_t highestLevel = leader->getLevel();
    for (Player* member : memberList) {
        if (member->getLevel() > highestLevel) {
            highestLevel = member->getLevel();
        }
    }

    uint32_t minLevel = static_cast<int32_t>(std::ceil((static_cast<float>(highestLevel) * 2) / 3));
    if (player->getLevel() < minLevel) {
        return false;
    }

    if (!Position::areInRange<30, 30, 1>(leader->getPosition(), player->getPosition())) {
        return false;
    }

    if (!player->hasFlag(PlayerFlag_NotGainInFight)) {
        //check if the player has healed/attacked anything recently
        auto it = ticksMap.find(player->getID());
        if (it == ticksMap.end()) {
            return false;
        }

        uint64_t timeDiff = OTSYS_TIME() - it->second;
        if (timeDiff > static_cast<uint64_t>(g_config.getNumber(ConfigManager::PZ_LOCKED))) {
            return false;
        }
    }
    return true;
}
 
Back
Top