- Joined
- Aug 19, 2007
- Messages
- 4,941
- Solutions
- 11
- Reaction score
- 352
This was made by Umby
So, lets start.
in player.cpp
BELOW
ADD
Then find this:
and REPLACE with this:
At the BOTTOM of player.cpp add this
Now in player.h
BELOW
Add this
BELOW
Add this
In creature.cpp find this:
and REPLACE it with
In the luascript.cpp
BELOW
Add this
At the BOTTOM of luascript.cpp add this
And in luascript.h
BELOW
Add this
How does it work?
- It gets configs expRate and multiply it by functions expRate.
Simple example:
data/movements/scripts/booster.lua
data/movements/movements.xml
ID 2179 is a gold ring.
So if "Rat" on your server gives 35 exp for someone with booster on it will give 35 * 4 = 140 exp.
AND AGAIN - ALL CREDITS TO UMBY
So, lets start.
in player.cpp
BELOW
Code:
idleTime = 0;
Code:
expRate = 1;
Then find this:
Code:
return (result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE) );
and REPLACE with this:
Code:
return ((result * g_config.getNumber(ConfigManager::RATE_EXPERIENCE)) * expRate);
At the BOTTOM of player.cpp add this
Code:
void Player::changePlayerExpRate(uint32_t rate)
{
expRate = rate;
}
Now in player.h
BELOW
Code:
void resetIdleTime() {idleTime = 0;}
Add this
Code:
uint32_t getExpRate() const {return expRate;}
void changePlayerExpRate(uint32_t rate);
BELOW
Code:
int32_t idleTime;
Add this
Code:
uint32_t expRate;
In creature.cpp find this:
Code:
return attacker->getPlayer() ? ((uint64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_game.getExperienceStage(attacker->getPlayer()->getLevel()))) : ((uint64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE) ));
and REPLACE it with
Code:
return attacker->getPlayer() ? (((uint64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_game.getExperienceStage(attacker->getPlayer()->getLevel()))) * attacker->getPlayer()->getExpRate()) : ((uint64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE)));
In the luascript.cpp
BELOW
Code:
lua_register(m_luaState, "escapeString", LuaScriptInterface::luaEscapeString);
Add this
Code:
lua_register(m_luaState, "setPlayerExpRate", LuaScriptInterface::luaSetPlayerExpRate);
At the BOTTOM of luascript.cpp add this
Code:
int32_t LuaScriptInterface::luaSetPlayerExpRate(lua_State *L)
{
uint32_t rate = popNumber(L);
uint32_t cid = popNumber(L);
ScriptEnviroment* env = getScriptEnv();
Player* player = env->getPlayerByUID(cid);
if(player){
player->changePlayerExpRate(rate);
lua_pushnumber(L, LUA_ERROR);
}
else{
reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnumber(L, LUA_ERROR);
}
return 1;
}
And in luascript.h
BELOW
Code:
static int32_t luaEscapeString(lua_State* L);
Add this
Code:
static int32_t luaSetPlayerExpRate(lua_State* L);
How does it work?
- It gets configs expRate and multiply it by functions expRate.
Simple example:
data/movements/scripts/booster.lua
Code:
function onEquip(cid, item)
setPlayerExpRate(cid, 4)
end
function onDeEquip(cid, item)
setPlayerExpRate(cid, 1)
end
data/movements/movements.xml
Code:
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem" script="booster.lua"/>
<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem" script="booster.lua"/>
ID 2179 is a gold ring.
So if "Rat" on your server gives 35 exp for someone with booster on it will give 35 * 4 = 140 exp.
AND AGAIN - ALL CREDITS TO UMBY
Last edited: