Exeus
Advanced OT User
- Joined
- Oct 8, 2012
- Messages
- 859
- Reaction score
- 198
So, we have Player:getDeathPenalty() (lua) which internally calls Player::getLostPercent() in player.cpp which returns double like 0.031804801590335649
and then cpp -> lua proxy multiplies it by 100 (which is fair) but then rounds it to uint32? why????
luascript.cpp
player.cpp
and then cpp -> lua proxy multiplies it by 100 (which is fair) but then rounds it to uint32? why????
luascript.cpp
Code:
int LuaScriptInterface::luaPlayerGetDeathPenalty(lua_State* L)
{
// player:getDeathPenalty()
Player* player = getUserdata<Player>(L, 1);
if (player) {
lua_pushnumber(L, static_cast<uint32_t>(player->getLostPercent() * 100)); // what the fuck
} else {
lua_pushnil(L);
}
return 1;
}
player.cpp
Code:
double Player::getLostPercent() const
{
int32_t blessingCount = std::bitset<5>(blessings).count();
// some bullshit removed to increase readability
double lossPercent;
if (level >= 25) {
double tmpLevel = level + (levelPercent / 100.);
lossPercent = static_cast<double>((tmpLevel + 50) * 50 * ((tmpLevel * tmpLevel) - (5 * tmpLevel) + 8)) / experience;
} else {
lossPercent = 10;
}
if (isPromoted()) {
lossPercent *= 0.7;
}
return lossPercent * pow(0.92, blessingCount) / 100;
}
Last edited: