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

Lua Is possible check sharing exp

newby

Active Member
Joined
Jun 11, 2016
Messages
183
Reaction score
43
Is possible check if players in party have share exp?

I want add bonus exp 12.5% per vocation
Exemple:
If have:
Code:
knight+paladin 25% bonus exp
knight+paladin+paladin 25% bonus exp
knight+paladin+sorcerer 37.5% bonus exp
knight+paladin+sorcerer+druid 50.0% bonus exp

I'm using 0.4 sources (3777)
 
Last edited:
Im new, idk... I make it, but i have sure it not will work...

Code:
function X()
  local bonus = 12.5 -- 12.5 per vocation... 4 vocation = 50%
  local totalbonus
  local ed, ms, rp, ek = false, false, false, false

  function getBaseVocations(vocation)
  if vocation >= 5 and vocation <= 8 then
  return vocation - 4
  elseif vocation >= 9 and vocation <= 12 then
  return vocation - 8
  elseif vocation >= 13 and vocation <= 14 then
  return vocation 0
  end
  return vocation
  end

  function getTotalBonus(totalbonus)
  -- loop party members
  -- check vocation
  if(ed == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(ms == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(rp == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(ek == true)
  {
  totalbonus = totalbonus + bonus
  }
  doPlayerSetExperienceRate(player, totalbonus)
  --
  -- end loop
  return totalbonus
  end

  if(isSharedExperienceEnabled()) then
  getTotalBonus()
  end

  function party:addMember(player)
  getTotalBonus()
  end

  function Party:onJoin(player)
  getTotalBonus()
  end

  function party:disband()
  getTotalBonus()
  end
  function party:removeMember(player)
  getTotalBonus()
  end
  return true
end

Someone could help me?
 
Im new, idk... I make it, but i have sure it not will work...

Code:
function X()
  local bonus = 12.5 -- 12.5 per vocation... 4 vocation = 50%
  local totalbonus
  local ed, ms, rp, ek = false, false, false, false

  function getBaseVocations(vocation)
  if vocation >= 5 and vocation <= 8 then
  return vocation - 4
  elseif vocation >= 9 and vocation <= 12 then
  return vocation - 8
  elseif vocation >= 13 and vocation <= 14 then
  return vocation 0
  end
  return vocation
  end

  function getTotalBonus(totalbonus)
  -- loop party members
  -- check vocation
  if(ed == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(ms == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(rp == true)
  {
  totalbonus = totalbonus + bonus
  }
  if(ek == true)
  {
  totalbonus = totalbonus + bonus
  }
  doPlayerSetExperienceRate(player, totalbonus)
  --
  -- end loop
  return totalbonus
  end

  if(isSharedExperienceEnabled()) then
  getTotalBonus()
  end

  function party:addMember(player)
  getTotalBonus()
  end

  function Party:onJoin(player)
  getTotalBonus()
  end

  function party:disband()
  getTotalBonus()
  end
  function party:removeMember(player)
  getTotalBonus()
  end
  return true
end

Someone could help me?
Whatever you're trying to do, it's better done in sources as there is no method for party events and barely functions for party in 0.4
 
Easy guys! Don't fight pls, just help your friend noob here ;):

creature.h
http://pastebin.com/5vguLws7

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

Add those to Player class:
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;
}

If it doesn't work, sadly you will have to fix it yourself.
 
Last edited:
Code:
virtual double getGainedExperience(Creature* attacker) const {
    double bonus = 1;
    if(const Player* player = attacker->getPlayer()) {
        bonus = player->getPartyBonus();
    }
    return getDamageRatio(attacker) * (double)getLostExperience() * bonus;
}

Add those to Player class:
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 = player->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;
}

If it doesn't work, sadly you will have to fix it yourself.

Changes lines: 3538 to 3603

player.cpp
http://pastebin.com/t8si6MsT

I added something worng?
I'm sorry its my first time editing sources, like i said to you i'm studdyng...

Code:
layer.Tpo -c -o player.o player.cpp
player.cpp:3538:29: error: no ‘uint32_t Player::getBaseVoc()’ member function declared in class ‘Player’
uint32_t Player::getBaseVoc() {
  ^
player.cpp:3548:30: error: no ‘double Player::getPartyBonus()’ member function declared in class ‘Player’
double Player::getPartyBonus() {
  ^
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3596:25: error: ‘const class Player’ has no member named ‘getPartyBonus’
  bonus = player->getPartyBonus();
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
 
Changes lines: 3538 to 3603

player.cpp
http://pastebin.com/t8si6MsT

I added something worng?
I'm sorry its my first time editing sources, like i said to you i'm studdyng...

Code:
layer.Tpo -c -o player.o player.cpp
player.cpp:3538:29: error: no ‘uint32_t Player::getBaseVoc()’ member function declared in class ‘Player’
uint32_t Player::getBaseVoc() {
  ^
player.cpp:3548:30: error: no ‘double Player::getPartyBonus()’ member function declared in class ‘Player’
double Player::getPartyBonus() {
  ^
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3596:25: error: ‘const class Player’ has no member named ‘getPartyBonus’
  bonus = player->getPartyBonus();
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
You have to add the definitions to player.h too.
 
What i made worng?

Code:
g++ -DHAVE_CONFIG_H -I.  -I/usr/include/libxml2  -I/usr/include/lua5.1  -O2 -fomit-frame-pointer -D__USE_MYSQL__  -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pthread -pipe -MT protocolgame.o -MD -MP -MF .deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
player.cpp: In member function ‘uint32_t Player::getBaseVoc()’:
player.cpp:3539:23: error: ‘vocation_id’ was not declared in this scope
  uint32_t curVoc = vocation_id;
  ^
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3596:37: error: passing ‘const Player’ as ‘this’ argument discards qualifiers [-fpermissive]
  bonus = this->getPartyBonus();
  ^
player.cpp:3548:8: note:  in call to ‘double Player::getPartyBonus()’
double Player::getPartyBonus() {
  ^
player.cpp:3595:22: warning: unused variable ‘player’ [-Wunused-variable]
  if(const Player* player = attacker->getPlayer()) {
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: ** Esperando que outros processos terminem.
mv -f .deps/party.Tpo .deps/party.Po
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocolgame.Tpo .deps/protocolgame.Po
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
ubuntu@ubuntu-DC8CU41:~/Documentos/server/3777/src$

player.cpp
http://pastebin.com/a4PufsMx

player.h
http://pastebin.com/eU4rWtb2
 
What i made worng?

Code:
g++ -DHAVE_CONFIG_H -I.  -I/usr/include/libxml2  -I/usr/include/lua5.1  -O2 -fomit-frame-pointer -D__USE_MYSQL__  -D__ENABLE_SERVER_DIAGNOSTIC__ -D__ROOT_PERMISSION__ -D_THREAD_SAFE -D_REENTRANT -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-array-bounds -pthread -pipe -MT protocolgame.o -MD -MP -MF .deps/protocolgame.Tpo -c -o protocolgame.o protocolgame.cpp
player.cpp: In member function ‘uint32_t Player::getBaseVoc()’:
player.cpp:3539:23: error: ‘vocation_id’ was not declared in this scope
  uint32_t curVoc = vocation_id;
  ^
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3596:37: error: passing ‘const Player’ as ‘this’ argument discards qualifiers [-fpermissive]
  bonus = this->getPartyBonus();
  ^
player.cpp:3548:8: note:  in call to ‘double Player::getPartyBonus()’
double Player::getPartyBonus() {
  ^
player.cpp:3595:22: warning: unused variable ‘player’ [-Wunused-variable]
  if(const Player* player = attacker->getPlayer()) {
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: ** Esperando que outros processos terminem.
mv -f .deps/party.Tpo .deps/party.Po
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocolgame.Tpo .deps/protocolgame.Po
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
ubuntu@ubuntu-DC8CU41:~/Documentos/server/3777/src$

player.cpp
http://pastebin.com/a4PufsMx

player.h
http://pastebin.com/eU4rWtb2
Change vocation_id to vocationId.
Remove const from "const Player* player = attacker->getPlayer()"
 
Change vocation_id to vocationId.
Remove const from "const Player* player = attacker->getPlayer()"

You mean this?
Code:
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 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;
}

double Player::getGainedExperience(Creature* attacker) const
{
   if(!skillLoss)
     return 0;

   double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
   if(rate <= 0)
     return 0;

   Player* attackerPlayer = attacker->getPlayer();
   if(!attackerPlayer || attackerPlayer == this)
     return 0;

   double attackerLevel = (double)attackerPlayer->getLevel(), min = g_config.getDouble(
     ConfigManager::EFP_MIN_THRESHOLD), max = g_config.getDouble(ConfigManager::EFP_MAX_THRESHOLD);
   if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
     level > (uint32_t)std::floor(attackerLevel * max)))
     return 0;

   /*
     Formula
     a = attackers level * 0.9
     b = victims level
     c = victims experience

     result = (1 - (a / b)) * 0.05 * c
     Not affected by special multipliers(!)
   */

  double bonus = 1;
  if(player = attacker->getPlayer()) {
  bonus = this->getPartyBonus();
  }

   uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
   uint64_t c = getExperience();
   return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
     * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c)) * rate * bonus;
}

Full code:
http://pastebin.com/4GZT2ZAs

Error again :(
Code:
.deps/protocollogin.Tpo -c -o protocollogin.o protocollogin.cpp
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3595:8: error: ‘player’ was not declared in this scope
  if(player = attacker->getPlayer()) {
  ^
player.cpp:3596:37: error: passing ‘const Player’ as ‘this’ argument discards qualifiers [-fpermissive]
  bonus = this->getPartyBonus();
  ^
player.cpp:3548:8: note:  in call to ‘double Player::getPartyBonus()’
double Player::getPartyBonus() {
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: ** Esperando que outros processos terminem.
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocollogin.Tpo .deps/protocollogin.Po
mv -f .deps/protocolgame.Tpo .deps/protocolgame.Po
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
 
You mean this?
Code:
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 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;
}

double Player::getGainedExperience(Creature* attacker) const
{
   if(!skillLoss)
     return 0;

   double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
   if(rate <= 0)
     return 0;

   Player* attackerPlayer = attacker->getPlayer();
   if(!attackerPlayer || attackerPlayer == this)
     return 0;

   double attackerLevel = (double)attackerPlayer->getLevel(), min = g_config.getDouble(
     ConfigManager::EFP_MIN_THRESHOLD), max = g_config.getDouble(ConfigManager::EFP_MAX_THRESHOLD);
   if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
     level > (uint32_t)std::floor(attackerLevel * max)))
     return 0;

   /*
     Formula
     a = attackers level * 0.9
     b = victims level
     c = victims experience

     result = (1 - (a / b)) * 0.05 * c
     Not affected by special multipliers(!)
   */

  double bonus = 1;
  if(player = attacker->getPlayer()) {
  bonus = this->getPartyBonus();
  }

   uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
   uint64_t c = getExperience();
   return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
     * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c)) * rate * bonus;
}

Full code:
http://pastebin.com/4GZT2ZAs

Error again :(
Code:
.deps/protocollogin.Tpo -c -o protocollogin.o protocollogin.cpp
player.cpp: In member function ‘virtual double Player::getGainedExperience(Creature*) const’:
player.cpp:3595:8: error: ‘player’ was not declared in this scope
  if(player = attacker->getPlayer()) {
  ^
player.cpp:3596:37: error: passing ‘const Player’ as ‘this’ argument discards qualifiers [-fpermissive]
  bonus = this->getPartyBonus();
  ^
player.cpp:3548:8: note:  in call to ‘double Player::getPartyBonus()’
double Player::getPartyBonus() {
  ^
Makefile:546: recipe for target 'player.o' failed
make[1]: *** [player.o] Error 1
make[1]: ** Esperando que outros processos terminem.
protocolgame.cpp: In member function ‘void ProtocolGame::AddCreatureSpeak(NetworkMessage_ptr, const Creature*, SpeakClasses, std::__cxx11::string, uint16_t, uint32_t, Position*, ProtocolGame*)’:
protocolgame.cpp:2962:158: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
  if(speaker && type != SPEAK_RVR_ANSWER && !speaker->isAccountManager() && !speaker->hasCustomFlag(PlayerCustomFlag_HideLevel) && (pg == NULL || pg != NULL && !pg->getIsCast()))
  ^
mv -f .deps/protocollogin.Tpo .deps/protocollogin.Po
mv -f .deps/protocolgame.Tpo .deps/protocolgame.Po
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
why the hell did you edit this function anyway, i said to edit:
https://github.com/peonso/forgottenserver036pl1/blob/master/src/creature.h#L339
https://github.com/peonso/forgottenserver036pl1/blob/master/src/creature.h#L339
Not in player.cpp.

And there you should remove the const:
Code:
virtual double getGainedExperience(Creature* attacker) const {
    double bonus = 1;
    if(Player* player = attacker->getPlayer()) {
        bonus = player->getPartyBonus();
    }
    return getDamageRatio(attacker) * (double)getLostExperience() * bonus;
}
 
I'm sorry, my name not lie... Im newbie... I trought it...

So its
player.cpp
Code:
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 bonus = 1;
  bool vocations[10];
  if(Party* party = player->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;
}

double Player::getGainedExperience(Creature* attacker) const
{
   if(!skillLoss)
     return 0;

   double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
   if(rate <= 0)
     return 0;

   Player* attackerPlayer = attacker->getPlayer();
   if(!attackerPlayer || attackerPlayer == this)
     return 0;

   double attackerLevel = (double)attackerPlayer->getLevel(), min = g_config.getDouble(
     ConfigManager::EFP_MIN_THRESHOLD), max = g_config.getDouble(ConfigManager::EFP_MAX_THRESHOLD);
   if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
     level > (uint32_t)std::floor(attackerLevel * max)))
     return 0;

   /*
     Formula
     a = attackers level * 0.9
     b = victims level
     c = victims experience

     result = (1 - (a / b)) * 0.05 * c
     Not affected by special multipliers(!)
   */

  double bonus = 1;
  if(const Player* player = attacker->getPlayer()) {
  bonus = player->getPartyBonus();
  }

   uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
   uint64_t c = getExperience();
   return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
     * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c)) * rate * bonus;
}

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

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


Right?

I got some errors doing it
Code:
used-parameter -Wno-array-bounds -pthread -pipe -MT chat.o -MD -MP -MF .deps/chat.Tpo -c -o chat.o chat.cpp
In file included from player.h:23:0,
  from actions.cpp:23:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from actions.h:20,
  from actions.cpp:20:
luascript.h:72:7: note: forward declaration of ‘class Player’
 class Player;
  ^
In file included from player.h:23:0,
  from party.h:20,
  from chat.h:24,
  from chat.cpp:18:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from raids.h:26,
  from item.h:29,
  from tile.h:23,
  from map.h:26,
  from creature.h:28,
  from player.h:23,
  from party.h:20,
  from chat.h:24,
  from chat.cpp:18:
luascript.h:72:7: note: forward declaration of ‘class Player’
 class Player;
  ^
In file included from player.h:23:0,
  from house.h:27,
  from beds.cpp:20:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from raids.h:26,
  from item.h:29,
  from beds.h:20,
  from beds.cpp:19:
luascript.h:72:7: note: forward declaration of ‘class Player’
 class Player;
  ^
Makefile:546: recipe for target 'actions.o' failed
make[1]: *** [actions.o] Error 1
make[1]: ** Esperando que outros processos terminem.
Makefile:546: recipe for target 'chat.o' failed
make[1]: *** [chat.o] Error 1
Makefile:546: recipe for target 'beds.o' failed
make[1]: *** [beds.o] Error 1
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
ubuntu@ubuntu-DC8CU41:~/Documentos/server/3777/src$
 
I'm sorry, my name not lie... Im newbie... I trought it...

So its
player.cpp
Code:
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 bonus = 1;
  bool vocations[10];
  if(Party* party = player->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;
}

double Player::getGainedExperience(Creature* attacker) const
{
   if(!skillLoss)
     return 0;

   double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
   if(rate <= 0)
     return 0;

   Player* attackerPlayer = attacker->getPlayer();
   if(!attackerPlayer || attackerPlayer == this)
     return 0;

   double attackerLevel = (double)attackerPlayer->getLevel(), min = g_config.getDouble(
     ConfigManager::EFP_MIN_THRESHOLD), max = g_config.getDouble(ConfigManager::EFP_MAX_THRESHOLD);
   if((min > 0 && level < (uint32_t)std::floor(attackerLevel * min)) || (max > 0 &&
     level > (uint32_t)std::floor(attackerLevel * max)))
     return 0;

   /*
     Formula
     a = attackers level * 0.9
     b = victims level
     c = victims experience

     result = (1 - (a / b)) * 0.05 * c
     Not affected by special multipliers(!)
   */

  double bonus = 1;
  if(const Player* player = attacker->getPlayer()) {
  bonus = player->getPartyBonus();
  }

   uint32_t a = (uint32_t)std::floor(attackerLevel * 0.9), b = level;
   uint64_t c = getExperience();
   return (double)std::max((uint64_t)0, (uint64_t)std::floor(getDamageRatio(attacker)
     * std::max((double)0, ((double)(1 - (((double)a / b))))) * 0.05 * c)) * rate * bonus;
}

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

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


Right?

I got some errors doing it
Code:
used-parameter -Wno-array-bounds -pthread -pipe -MT chat.o -MD -MP -MF .deps/chat.Tpo -c -o chat.o chat.cpp
In file included from player.h:23:0,
  from actions.cpp:23:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from actions.h:20,
  from actions.cpp:20:
luascript.h:72:7: note: forward declaration of ‘class Player’
class Player;
  ^
In file included from player.h:23:0,
  from party.h:20,
  from chat.h:24,
  from chat.cpp:18:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from raids.h:26,
  from item.h:29,
  from tile.h:23,
  from map.h:26,
  from creature.h:28,
  from player.h:23,
  from party.h:20,
  from chat.h:24,
  from chat.cpp:18:
luascript.h:72:7: note: forward declaration of ‘class Player’
class Player;
  ^
In file included from player.h:23:0,
  from house.h:27,
  from beds.cpp:20:
creature.h: In member function ‘virtual double Creature::getGainedExperience(Creature*)’:
creature.h:356:25: error: invalid use of incomplete type ‘class Player’
  bonus = player->getPartyBonus();
  ^
In file included from baseevents.h:22:0,
  from raids.h:26,
  from item.h:29,
  from beds.h:20,
  from beds.cpp:19:
luascript.h:72:7: note: forward declaration of ‘class Player’
class Player;
  ^
Makefile:546: recipe for target 'actions.o' failed
make[1]: *** [actions.o] Error 1
make[1]: ** Esperando que outros processos terminem.
Makefile:546: recipe for target 'chat.o' failed
make[1]: *** [chat.o] Error 1
Makefile:546: recipe for target 'beds.o' failed
make[1]: *** [beds.o] Error 1
make[1]: Leaving directory '/home/ubuntu/Documentos/server/3777/src'
Makefile:403: recipe for target 'all' failed
make: *** [all] Error 2
ubuntu@ubuntu-DC8CU41:~/Documentos/server/3777/src$
First remove bonus things from that getexperience in player.cpp

And you might need to put that bit of code inside creature.cpp.
 
Back
Top