Rizz
Quited with Tibia/OT
This was made based by a script Umby, only did some minor changes (changed some math more or less only)
Warning! Not Tested! But it SHOULD work
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
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 (7x) for someone with booster on it will give 35 + 5 (exp in monster file) = 40 exp (8x).
AND AGAIN - BASED ON A SCRIPT BY UMBY
P.s. basicly copied the text too
P.p.s. You should be able to add BOTH codes ("Mine" and Umby's") to your source without any problem.
Warning! Not Tested! But it SHOULD work
So, lets start.
in player.cpp
BELOW
Code:
idleTime = 0;
Code:
extraExpRate = 0;
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) + extraExpRate));
At the BOTTOM of player.cpp add this
Code:
void Player::changePlayerExtraExpRate(uint32_t rate)
{
extraExpRate = rate;
}
Now in player.h
BELOW
Code:
void resetIdleTime() {idleTime = 0;}
Add this
Code:
uint32_t getExtraExpRate() const {return extraExpRate;}
void changePlayerExtraExpRate(uint32_t rate);
BELOW
Code:
int32_t idleTime;
Add this
Code:
uint32_t extraExpRate;
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()->getExtraExpRate())))
) : ((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, "setPlayerExtraExpRate", LuaScriptInterface::luaSetPlayerExtraExpRate);
At the BOTTOM of luascript.cpp add this
Code:
int LuaScriptInterface::luaSetPlayerExtraExpRate(lua_State *L)
{
uint32_t rate = popNumber(L);
uint32_t cid = popNumber(L);
ScriptEnviroment* env = getScriptEnv();
Player* player = env->getPlayerByUID(cid);
if(player){
player->changePlayerExtraExpRate(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 luaSetPlayerExtraExpRate(lua_State* L);
Simple example:
data/movements/scripts/booster.lua
Code:
function onEquip(cid, item)
setPlayerExtraExpRate(cid, 1)
end
function onDeEquip(cid, item)
setPlayerExtraExpRate(cid, 0)
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 (7x) for someone with booster on it will give 35 + 5 (exp in monster file) = 40 exp (8x).
AND AGAIN - BASED ON A SCRIPT BY UMBY
P.s. basicly copied the text too
P.p.s. You should be able to add BOTH codes ("Mine" and Umby's") to your source without any problem.