Added new stats to the skills module, fixed minor market error.

* Added Offline Training information.
* Added Regeneration Time information.
* Added Speed information.
* Added base stats/skills information (will show the players increase in a skill e.g. magic level 43 = 40 + 3 bonus from an item).
* Fixed the game feature constants in const.lua.
* Fixed a market error when logging out.
* Added removeTooltip function.
This commit is contained in:
BeniS 2012-08-19 13:19:43 +12:00
parent 8222e85abd
commit d237087718
10 changed files with 294 additions and 27 deletions

View File

@ -92,6 +92,10 @@ function UIWidget:setTooltip(text)
self.tooltip = text self.tooltip = text
end end
function UIWidget:removeTooltip()
self.tooltip = nil
end
function UIWidget:getTooltip() function UIWidget:getTooltip()
return self.tooltip return self.tooltip
end end

View File

@ -467,7 +467,7 @@ local function onSelectSellOffer(table, selectedRow, previousSelectedRow)
if offer then if offer then
local price = offer:getPrice() local price = offer:getPrice()
if price > information.balance then if price > information.balance then
balanceLabel:setColor('#b22222') balanceLabel:setColor('#b22222') -- red
buyButton:setEnabled(false) buyButton:setEnabled(false)
else else
local slice = (information.balance / 2) local slice = (information.balance / 2)
@ -751,7 +751,9 @@ function Market.reset()
categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First)) categoryList:setCurrentOption(getMarketCategoryName(MarketCategory.First))
searchEdit:setText('') searchEdit:setText('')
clearFilters() clearFilters()
Market.updateCurrentItems() if information and not table.empty(information) then
Market.updateCurrentItems()
end
end end
function Market.clearSelectedItem() function Market.clearSelectedItem()

View File

@ -10,8 +10,18 @@ function init()
onSoulChange = onSoulChange, onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange, onFreeCapacityChange = onFreeCapacityChange,
onStaminaChange = onStaminaChange, onStaminaChange = onStaminaChange,
onOfflineTrainingChange = onOfflineTrainingChange,
onRegenerationChange = onRegenerationChange,
onSpeedChange = onSpeedChange,
onBaseSpeedChange = onBaseSpeedChange,
onMagicLevelChange = onMagicLevelChange, onMagicLevelChange = onMagicLevelChange,
onSkillChange = onSkillChange onBaseMagicLevelChange = onBaseMagicLevelChange,
onSkillChange = onSkillChange,
onBaseSkillChange = onBaseSkillChange
})
connect(g_game, {
onGameStart = update,
onGameEnd = update
}) })
skillsWindow = g_ui.loadUI('skills.otui', modules.game_interface.getRightPanel()) skillsWindow = g_ui.loadUI('skills.otui', modules.game_interface.getRightPanel())
@ -31,8 +41,18 @@ function terminate()
onSoulChange = onSoulChange, onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange, onFreeCapacityChange = onFreeCapacityChange,
onStaminaChange = onStaminaChange, onStaminaChange = onStaminaChange,
onOfflineTrainingChange = onOfflineTrainingChange,
onRegenerationChange = onRegenerationChange,
onSpeedChange = onSpeedChange,
onBaseSpeedChange = onBaseSpeedChange,
onMagicLevelChange = onMagicLevelChange, onMagicLevelChange = onMagicLevelChange,
onSkillChange = onSkillChange onBaseMagicLevelChange = onBaseMagicLevelChange,
onSkillChange = onSkillChange,
onBaseSkillChange = onBaseSkillChange
})
disconnect(g_game, {
onGameStart = update,
onGameEnd = update
}) })
g_keyboard.unbindKeyDown('Ctrl+S') g_keyboard.unbindKeyDown('Ctrl+S')
@ -40,12 +60,40 @@ function terminate()
skillsWindow:destroy() skillsWindow:destroy()
end end
function setSkillBase(id, value, baseValue)
local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
if value > baseValue then
widget:setColor('#008b00')
skill:setTooltip(baseValue .. ' + ' .. (value - baseValue))
elseif value < baseValue then
widget:setColor('#008b00')
skill:setTooltip(baseValue .. ' - ' .. (value - baseValue))
else
widget:setColor('#bbbbbb')
skill:removeTooltip()
end
end
function setSkillValue(id, value) function setSkillValue(id, value)
local skill = skillsWindow:recursiveGetChildById(id) local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value') local widget = skill:getChildById('value')
widget:setText(value) widget:setText(value)
end end
function setSkillColor(id, value)
local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setColor(value)
end
function setSkillTooltip(id, value)
local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
widget:setTooltip(value)
end
function setSkillPercent(id, percent, tooltip) function setSkillPercent(id, percent, tooltip)
local skill = skillsWindow:recursiveGetChildById(id) local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('percent') local widget = skill:getChildById('percent')
@ -56,6 +104,22 @@ function setSkillPercent(id, percent, tooltip)
end end
end end
function update()
local offlineTraining = skillsWindow:recursiveGetChildById('offlineTraining')
if not g_game.getFeature(GameOfflineTrainingTime) then
offlineTraining:hide()
else
offlineTraining:show()
end
local regenerationTime = skillsWindow:recursiveGetChildById('regenerationTime')
if not g_game.getFeature(GamePlayerRegenerationTime) then
regenerationTime:hide()
else
regenerationTime:show()
end
end
function refresh() function refresh()
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if not player then return end if not player then return end
@ -68,9 +132,15 @@ function refresh()
onFreeCapacityChange(player, player:getFreeCapacity()) onFreeCapacityChange(player, player:getFreeCapacity())
onStaminaChange(player, player:getStamina()) onStaminaChange(player, player:getStamina())
onMagicLevelChange(player, player:getMagicLevel(), player:getMagicLevelPercent()) onMagicLevelChange(player, player:getMagicLevel(), player:getMagicLevelPercent())
onOfflineTrainingChange(player, player:getOfflineTrainingTime())
onRegenerationChange(player, player:getRegenerationTime())
onSpeedChange(player, player:getSpeed())
onBaseSpeedChange(player, player:getBaseSpeed())
onBaseMagicLevelChange(player, player:getBaseMagicLevel())
for i=0,6 do for i=0,6 do
onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i)) onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i))
onBaseSkillChange(player, i, player:getSkillBaseLevel(i))
end end
end end
@ -137,13 +207,74 @@ function onStaminaChange(localPlayer, stamina)
setSkillPercent('stamina', percent, tr('You have %s percent', percent)) setSkillPercent('stamina', percent, tr('You have %s percent', percent))
end end
function onMagicLevelChange(localPlayer, value, percent) function onOfflineTrainingChange(localPlayer, offlineTrainingTime)
setSkillValue('magiclevel', value) local hours = math.floor(offlineTrainingTime / 60)
local minutes = offlineTrainingTime % 60
if minutes < 10 then
minutes = '0' .. minutes
end
local percent = 100 * offlineTrainingTime / (12 * 60) -- max is 12 hours
setSkillValue('offlineTraining', hours .. ":" .. minutes)
setSkillPercent('offlineTraining', percent, tr('You have %s percent', percent))
end
function onRegenerationChange(localPlayer, regenerationTime)
local hours = math.floor(regenerationTime / 60)
local minutes = regenerationTime % 60
if minutes < 10 then
minutes = '0' .. minutes
end
setSkillValue('regenerationTime', hours .. ":" .. minutes)
end
function onSpeedChange(localPlayer, speed)
setSkillValue('speed', speed)
setSkillBase('speed', speed, localPlayer:getBaseSpeed())
end
function onBaseSpeedChange(localPlayer, baseSpeed)
if baseSpeed < 1 then
return
end
local speed = localPlayer:getSpeed()
onSpeedChange(localPlayer, baseSpeed)
setSkillBase('speed', speed, baseSpeed)
end
function onMagicLevelChange(localPlayer, magiclevel, percent)
setSkillValue('magiclevel', magiclevel)
setSkillPercent('magiclevel', percent, tr('You have %s percent to go', 100 - percent)) setSkillPercent('magiclevel', percent, tr('You have %s percent to go', 100 - percent))
setSkillBase('magiclevel', magiclevel, localPlayer:getBaseMagicLevel())
end
function onBaseMagicLevelChange(localPlayer, baseMagicLevel)
if baseMagicLevel < 1 then
return
end
local magiclevel = localPlayer:getMagicLevel()
onMagicLevelChange(localPlayer, magiclevel, localPlayer:getMagicLevelPercent())
setSkillBase('magiclevel', magiclevel, baseMagicLevel)
end end
function onSkillChange(localPlayer, id, level, percent) function onSkillChange(localPlayer, id, level, percent)
setSkillValue('skillId' .. id, level) setSkillValue('skillId' .. id, level)
setSkillPercent('skillId' .. id, percent, tr('You have %s percent to go', 100 - percent)) setSkillPercent('skillId' .. id, percent, tr('You have %s percent to go', 100 - percent))
setSkillBase('skillId'..id, level, localPlayer:getSkillBaseLevel(id))
end end
function onBaseSkillChange(localPlayer, id, baseLevel)
if baseLevel < 1 then
return
end
local level = localPlayer:getSkillLevel(id)
onSkillChange(localPlayer, id, level, localPlayer:getSkillLevelPercent(id))
setSkillBase('skillId'..id, level, baseLevel)
end

View File

@ -85,6 +85,19 @@ MiniWindow
!text: tr('Capacity') !text: tr('Capacity')
SkillValueLabel SkillValueLabel
SkillButton
id: speed
height: 15
SkillNameLabel
!text: tr('Speed')
SkillValueLabel
SkillButton
id: regenerationTime
SkillNameLabel
!text: tr('Regeneration Time')
SkillValueLabel
SkillButton SkillButton
id: stamina id: stamina
SkillNameLabel SkillNameLabel
@ -92,6 +105,13 @@ MiniWindow
SkillValueLabel SkillValueLabel
SkillPercentPanel SkillPercentPanel
SkillButton
id: offlineTraining
SkillNameLabel
!text: tr('Offline Training')
SkillValueLabel
SkillPercentPanel
SkillButton SkillButton
id: magiclevel id: magiclevel
SkillNameLabel SkillNameLabel
@ -116,7 +136,6 @@ MiniWindow
SkillButton SkillButton
id: skillId2 id: skillId2
SkillNameLabel SkillNameLabel
!text: tr('Sword Fighting') !text: tr('Sword Fighting')
SkillValueLabel SkillValueLabel

View File

@ -41,30 +41,28 @@ FightDefensive = 3
DontChase = 0 DontChase = 0
ChaseOpponent = 1 ChaseOpponent = 1
GameExtendedOpcode = 0
GameProtocolChecksum = 1 GameProtocolChecksum = 1
GameAccountNames = 2 GameAccountNames = 2
GameChallangeOnLogin = 3 GameChallangeOnLogin = 3
GameStackposOnTileAddThing = 4
GamePenalityOnDeath = 5 GamePenalityOnDeath = 5
GameNameOnNpcTrade = 6 GameNameOnNpcTrade = 6
GameDoubleFreeCapacity = 7 GameDoubleFreeCapacity = 7
GameDoubleExperience = 8 GameDoubleExperience = 8
GameTotalCapacity = 9 GameTotalCapacity = 9
GameSkillsBase = 10 GameSkillsBase = 10
GameAdditionalPlayerStats = 11 GamePlayerRegenerationTime = 11
GameIdOnCancelAttack = 12
GameChannelPlayerList = 13 GameChannelPlayerList = 13
GamePlayerMounts = 14 GamePlayerMounts = 14
GameEnvironmentEffect = 15 GameEnvironmentEffect = 15
GameCreatureType = 16
GameCreatureEmblems = 17 GameCreatureEmblems = 17
GameCreaturePassableInfo = 18
GameItemAnimationPhase = 19 GameItemAnimationPhase = 19
GameTrucatedPingOpcode = 20
GameReverseCreatureStack = 21
GameMagicEffectU16 = 22 GameMagicEffectU16 = 22
GamePlayerMarket = 23 GamePlayerMarket = 23
GameSpritesU32 = 24
GameChargeableItems = 25
GameOfflineTrainingTime = 26
GamePurseSlot = 27
GameFormatCreatureName = 28
TextColors = { TextColors = {
red = '#f55e5e', --'#c83200' red = '#f55e5e', --'#c83200'

View File

@ -514,11 +514,14 @@ void Creature::setOutfit(const Outfit& outfit)
void Creature::setSpeed(uint16 speed) void Creature::setSpeed(uint16 speed)
{ {
uint16 oldSpeed = m_speed;
m_speed = speed; m_speed = speed;
// speed can change while walking (utani hur, paralyze, etc..) // speed can change while walking (utani hur, paralyze, etc..)
if(m_walking) if(m_walking)
nextWalkUpdate(); nextWalkUpdate();
callLuaField("onSpeedChange", speed, oldSpeed);
} }
void Creature::setSkull(uint8 skull) void Creature::setSkull(uint8 skull)

View File

@ -39,6 +39,7 @@ LocalPlayer::LocalPlayer()
m_walkLockExpiration = 0; m_walkLockExpiration = 0;
m_skillsLevel.fill(-1); m_skillsLevel.fill(-1);
m_skillsBaseLevel.fill(-1);
m_skillsLevelPercent.fill(-1); m_skillsLevelPercent.fill(-1);
m_health = -1; m_health = -1;
@ -51,8 +52,13 @@ LocalPlayer::LocalPlayer()
m_maxMana = -1; m_maxMana = -1;
m_magicLevel = -1; m_magicLevel = -1;
m_magicLevelPercent = -1; m_magicLevelPercent = -1;
m_baseMagicLevel = -1;
m_soul = -1; m_soul = -1;
m_stamina = -1; m_stamina = -1;
m_baseSpeed = -1;
m_regenerationTime = -1;
m_offlineTrainingTime = -1;
m_totalCapacity = -1;
} }
void LocalPlayer::lockWalk(int millis) void LocalPlayer::lockWalk(int millis)
@ -248,6 +254,21 @@ void LocalPlayer::setSkill(Otc::Skill skill, int level, int levelPercent)
} }
} }
void LocalPlayer::setBaseSkill(Otc::Skill skill, int baseLevel)
{
if(skill >= Otc::LastSkill) {
g_logger.traceError("invalid skill");
return;
}
int oldBaseLevel = m_skillsBaseLevel[skill];
if(baseLevel != oldBaseLevel) {
m_skillsBaseLevel[skill] = baseLevel;
callLuaField("onBaseSkillChange", skill, baseLevel, oldBaseLevel);
}
}
void LocalPlayer::setHealth(double health, double maxHealth) void LocalPlayer::setHealth(double health, double maxHealth)
{ {
if(m_health != health || m_maxHealth != maxHealth) { if(m_health != health || m_maxHealth != maxHealth) {
@ -277,6 +298,16 @@ void LocalPlayer::setFreeCapacity(double freeCapacity)
} }
} }
void LocalPlayer::setTotalCapacity(double totalCapacity)
{
if(m_totalCapacity != totalCapacity) {
double oldTotalCapacity = m_totalCapacity;
m_totalCapacity = totalCapacity;
callLuaField("onTotalCapacityChange", totalCapacity, oldTotalCapacity);
}
}
void LocalPlayer::setExperience(double experience) void LocalPlayer::setExperience(double experience)
{ {
if(m_experience != experience) { if(m_experience != experience) {
@ -323,6 +354,16 @@ void LocalPlayer::setMagicLevel(double magicLevel, double magicLevelPercent)
} }
} }
void LocalPlayer::setBaseMagicLevel(double baseMagicLevel)
{
if(m_baseMagicLevel != baseMagicLevel) {
double oldBaseMagicLevel = m_baseMagicLevel;
m_baseMagicLevel = baseMagicLevel;
callLuaField("onBaseMagicLevelChange", baseMagicLevel, oldBaseMagicLevel);
}
}
void LocalPlayer::setSoul(double soul) void LocalPlayer::setSoul(double soul)
{ {
if(m_soul != soul) { if(m_soul != soul) {
@ -377,6 +418,36 @@ void LocalPlayer::setPremium(bool premium)
} }
} }
void LocalPlayer::setBaseSpeed(double baseSpeed)
{
if(m_baseSpeed != baseSpeed) {
double oldBaseSpeed = m_baseSpeed;
m_baseSpeed = baseSpeed;
callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
}
}
void LocalPlayer::setRegenerationTime(double regenerationTime)
{
if(m_regenerationTime != regenerationTime) {
double oldRegenerationTime = m_regenerationTime;
m_regenerationTime = regenerationTime;
callLuaField("onRegenerationChange", regenerationTime, oldRegenerationTime);
}
}
void LocalPlayer::setOfflineTrainingTime(double offlineTrainingTime)
{
if(m_offlineTrainingTime != offlineTrainingTime) {
double oldOfflineTrainingTime = m_offlineTrainingTime;
m_offlineTrainingTime = offlineTrainingTime;
callLuaField("onOfflineTrainingChange", offlineTrainingTime, oldOfflineTrainingTime);
}
}
double LocalPlayer::getWalkPing() double LocalPlayer::getWalkPing()
{ {
if(m_lastWalkPings.empty()) if(m_lastWalkPings.empty())

View File

@ -41,27 +41,35 @@ public:
void setStates(int states); void setStates(int states);
void setSkill(Otc::Skill skill, int level, int levelPercent); void setSkill(Otc::Skill skill, int level, int levelPercent);
void setBaseSkill(Otc::Skill skill, int baseLevel);
void setHealth(double health, double maxHealth); void setHealth(double health, double maxHealth);
void setFreeCapacity(double freeCapacity); void setFreeCapacity(double freeCapacity);
void setTotalCapacity(double totalCapacity);
void setExperience(double experience); void setExperience(double experience);
void setLevel(double level, double levelPercent); void setLevel(double level, double levelPercent);
void setMana(double mana, double maxMana); void setMana(double mana, double maxMana);
void setMagicLevel(double magicLevel, double magicLevelPercent); void setMagicLevel(double magicLevel, double magicLevelPercent);
void setBaseMagicLevel(double baseMagicLevel);
void setSoul(double soul); void setSoul(double soul);
void setStamina(double stamina); void setStamina(double stamina);
void setKnown(bool known) { m_known = known; } void setKnown(bool known) { m_known = known; }
void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item); void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
void setVocation(int vocation); void setVocation(int vocation);
void setPremium(bool premium); void setPremium(bool premium);
void setBaseSpeed(double baseSpeed);
void setRegenerationTime(double regenerationTime);
void setOfflineTrainingTime(double offlineTrainingTime);
int getStates() { return m_states; } int getStates() { return m_states; }
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; } int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
int getSkillBaseLevel(Otc::Skill skill) { return m_skillsBaseLevel[skill]; }
int getSkillLevelPercent(Otc::Skill skill) { return m_skillsLevelPercent[skill]; } int getSkillLevelPercent(Otc::Skill skill) { return m_skillsLevelPercent[skill]; }
int getVocation() { return m_vocation; } int getVocation() { return m_vocation; }
double getWalkPing(); double getWalkPing();
double getHealth() { return m_health; } double getHealth() { return m_health; }
double getMaxHealth() { return m_maxHealth; } double getMaxHealth() { return m_maxHealth; }
double getFreeCapacity() { return m_freeCapacity; } double getFreeCapacity() { return m_freeCapacity; }
double getTotalCapacity() { return m_totalCapacity; }
double getExperience() { return m_experience; } double getExperience() { return m_experience; }
double getLevel() { return m_level; } double getLevel() { return m_level; }
double getLevelPercent() { return m_levelPercent; } double getLevelPercent() { return m_levelPercent; }
@ -69,8 +77,12 @@ public:
double getMaxMana() { return m_maxMana; } double getMaxMana() { return m_maxMana; }
double getMagicLevel() { return m_magicLevel; } double getMagicLevel() { return m_magicLevel; }
double getMagicLevelPercent() { return m_magicLevelPercent; } double getMagicLevelPercent() { return m_magicLevelPercent; }
double getBaseMagicLevel() { return m_baseMagicLevel; }
double getSoul() { return m_soul; } double getSoul() { return m_soul; }
double getStamina() { return m_stamina; } double getStamina() { return m_stamina; }
double getBaseSpeed() { return m_baseSpeed; }
double getRegenerationTime() { return m_regenerationTime; }
double getOfflineTrainingTime() { return m_offlineTrainingTime; }
ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; } ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; }
bool hasSight(const Position& pos); bool hasSight(const Position& pos);
@ -111,6 +123,7 @@ private:
std::deque<int> m_lastWalkPings; std::deque<int> m_lastWalkPings;
std::array<int, Otc::LastSkill> m_skillsLevel; std::array<int, Otc::LastSkill> m_skillsLevel;
std::array<int, Otc::LastSkill> m_skillsBaseLevel;
std::array<int, Otc::LastSkill> m_skillsLevelPercent; std::array<int, Otc::LastSkill> m_skillsLevelPercent;
bool m_known; bool m_known;
@ -121,6 +134,7 @@ private:
double m_health; double m_health;
double m_maxHealth; double m_maxHealth;
double m_freeCapacity; double m_freeCapacity;
double m_totalCapacity;
double m_experience; double m_experience;
double m_level; double m_level;
double m_levelPercent; double m_levelPercent;
@ -128,8 +142,12 @@ private:
double m_maxMana; double m_maxMana;
double m_magicLevel; double m_magicLevel;
double m_magicLevelPercent; double m_magicLevelPercent;
double m_baseMagicLevel;
double m_soul; double m_soul;
double m_stamina; double m_stamina;
double m_baseSpeed;
double m_regenerationTime;
double m_offlineTrainingTime;
}; };
#endif #endif

View File

@ -383,6 +383,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassMemberFunction<LocalPlayer>("setInventoryItem", &LocalPlayer::setInventoryItem); g_lua.bindClassMemberFunction<LocalPlayer>("setInventoryItem", &LocalPlayer::setInventoryItem);
g_lua.bindClassMemberFunction<LocalPlayer>("getStates", &LocalPlayer::getStates); g_lua.bindClassMemberFunction<LocalPlayer>("getStates", &LocalPlayer::getStates);
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevel", &LocalPlayer::getSkillLevel); g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevel", &LocalPlayer::getSkillLevel);
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillBaseLevel", &LocalPlayer::getSkillBaseLevel);
g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevelPercent", &LocalPlayer::getSkillLevelPercent); g_lua.bindClassMemberFunction<LocalPlayer>("getSkillLevelPercent", &LocalPlayer::getSkillLevelPercent);
g_lua.bindClassMemberFunction<LocalPlayer>("getHealth", &LocalPlayer::getHealth); g_lua.bindClassMemberFunction<LocalPlayer>("getHealth", &LocalPlayer::getHealth);
g_lua.bindClassMemberFunction<LocalPlayer>("getMaxHealth", &LocalPlayer::getMaxHealth); g_lua.bindClassMemberFunction<LocalPlayer>("getMaxHealth", &LocalPlayer::getMaxHealth);
@ -396,6 +397,11 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassMemberFunction<LocalPlayer>("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent); g_lua.bindClassMemberFunction<LocalPlayer>("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent);
g_lua.bindClassMemberFunction<LocalPlayer>("getSoul", &LocalPlayer::getSoul); g_lua.bindClassMemberFunction<LocalPlayer>("getSoul", &LocalPlayer::getSoul);
g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina); g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
g_lua.bindClassMemberFunction<LocalPlayer>("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getRegenerationTime", &LocalPlayer::getRegenerationTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseSpeed", &LocalPlayer::getBaseSpeed);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel);
g_lua.bindClassMemberFunction<LocalPlayer>("getTotalCapacity", &LocalPlayer::getTotalCapacity);
g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem); g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem);
g_lua.bindClassMemberFunction<LocalPlayer>("getVocation", &LocalPlayer::getVocation); g_lua.bindClassMemberFunction<LocalPlayer>("getVocation", &LocalPlayer::getVocation);
g_lua.bindClassMemberFunction<LocalPlayer>("isPremium", &LocalPlayer::isPremium); g_lua.bindClassMemberFunction<LocalPlayer>("isPremium", &LocalPlayer::isPremium);

View File

@ -876,7 +876,7 @@ void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
else else
freeCapacity = msg->getU16() / 100.0; freeCapacity = msg->getU16() / 100.0;
double totalCapacity; double totalCapacity = 0;
if(g_game.getFeature(Otc::GameTotalCapacity)) if(g_game.getFeature(Otc::GameTotalCapacity))
totalCapacity = msg->getU32() / 100.0; totalCapacity = msg->getU32() / 100.0;
@ -892,42 +892,57 @@ void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
double maxMana = msg->getU16(); double maxMana = msg->getU16();
double magicLevel = msg->getU8(); double magicLevel = msg->getU8();
double baseMagicLevel;
if(g_game.getFeature(Otc::GameSkillsBase)) if(g_game.getFeature(Otc::GameSkillsBase))
msg->getU8(); // base magic level baseMagicLevel = msg->getU8();
else
baseMagicLevel = magicLevel;
double magicLevelPercent = msg->getU8(); double magicLevelPercent = msg->getU8();
double soul = msg->getU8(); double soul = msg->getU8();
double stamina = msg->getU16(); double stamina = msg->getU16();
double baseSpeed = 0;
if(g_game.getFeature(Otc::GameSkillsBase))
baseSpeed = msg->getU16();
double regeneration = 0;
if(g_game.getFeature(Otc::GamePlayerRegenerationTime))
regeneration = msg->getU16();
double training = 0;
if(g_game.getFeature(Otc::GameOfflineTrainingTime))
training = msg->getU16();
m_localPlayer->setHealth(health, maxHealth); m_localPlayer->setHealth(health, maxHealth);
m_localPlayer->setFreeCapacity(freeCapacity); m_localPlayer->setFreeCapacity(freeCapacity);
m_localPlayer->setTotalCapacity(totalCapacity);
m_localPlayer->setExperience(experience); m_localPlayer->setExperience(experience);
m_localPlayer->setLevel(level, levelPercent); m_localPlayer->setLevel(level, levelPercent);
m_localPlayer->setMana(mana, maxMana); m_localPlayer->setMana(mana, maxMana);
m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent); m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
m_localPlayer->setBaseMagicLevel(baseMagicLevel);
m_localPlayer->setStamina(stamina); m_localPlayer->setStamina(stamina);
m_localPlayer->setSoul(soul); m_localPlayer->setSoul(soul);
m_localPlayer->setBaseSpeed(baseSpeed);
if(g_game.getFeature(Otc::GameSkillsBase)) m_localPlayer->setRegenerationTime(regeneration);
msg->getU16(); // base speed m_localPlayer->setOfflineTrainingTime(training);
if(g_game.getFeature(Otc::GamePlayerRegenerationTime))
msg->getU16();
if(g_game.getFeature(Otc::GameOfflineTrainingTime))
msg->getU16();
} }
void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg) void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
{ {
for(int skill = 0; skill < Otc::LastSkill; skill++) { for(int skill = 0; skill < Otc::LastSkill; skill++) {
int level = msg->getU8(); int level = msg->getU8();
int baseLevel;
if(g_game.getFeature(Otc::GameSkillsBase)) if(g_game.getFeature(Otc::GameSkillsBase))
msg->getU8(); // base baseLevel = msg->getU8(); // base
else
baseLevel = level;
int levelPercent = msg->getU8(); int levelPercent = msg->getU8();
m_localPlayer->setSkill((Otc::Skill)skill, level, levelPercent); m_localPlayer->setSkill((Otc::Skill)skill, level, levelPercent);
m_localPlayer->setBaseSkill((Otc::Skill)skill, baseLevel);
} }
} }