Finalized the mount system and the recently new skills/stats.
* Added mount options to the thing menu. * Reworked the mounting/dismounting. * Fixed up some skill module bugs. * Added alerts to stats like health, mana, capacity, and regeneration time (need to revise this one as it currently has no maximum).
This commit is contained in:
parent
f4cc942c85
commit
1d20cc9e4b
|
@ -251,12 +251,19 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
|||
end
|
||||
|
||||
if creatureThing then
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
menu:addSeparator()
|
||||
|
||||
if creatureThing:isLocalPlayer() then
|
||||
menu:addOption(tr('Set Outfit'), function() g_game.requestOutfit() end)
|
||||
|
||||
if creatureThing:isPartyMember() --[[and not fighting]] then
|
||||
if not localPlayer:isMounted() then
|
||||
menu:addOption(tr('Mount'), function() localPlayer:mount() end)
|
||||
else
|
||||
menu:addOption(tr('Dismount'), function() localPlayer:dismount() end)
|
||||
end
|
||||
|
||||
if creatureThing:isPartyMember() then
|
||||
if creatureThing:isPartyLeader() then
|
||||
if creatureThing:isPartySharedExperienceActive() then
|
||||
menu:addOption(tr('Disable Shared Experience'), function() g_game.partyShareExperience(false) end)
|
||||
|
@ -268,7 +275,6 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
|||
end
|
||||
|
||||
else
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
if g_game.getAttackingCreature() ~= creatureThing then
|
||||
menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end)
|
||||
else
|
||||
|
|
|
@ -7,13 +7,22 @@ function terminate()
|
|||
end
|
||||
|
||||
function toggleMount()
|
||||
if g_game.getFeature(GamePlayerMounts) then
|
||||
g_game.mount(not g_game.isMounted())
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
player:toggleMount()
|
||||
end
|
||||
end
|
||||
|
||||
function mount()
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
player:mount()
|
||||
end
|
||||
end
|
||||
|
||||
function dismount()
|
||||
if g_game.getFeature(GamePlayerMounts) then
|
||||
g_game.mount(false)
|
||||
local player = g_game.getLocalPlayer()
|
||||
if player then
|
||||
player:dismount()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ function init()
|
|||
onManaChange = onManaChange,
|
||||
onSoulChange = onSoulChange,
|
||||
onFreeCapacityChange = onFreeCapacityChange,
|
||||
onTotalCapacityChange = onTotalCapacityChange,
|
||||
onStaminaChange = onStaminaChange,
|
||||
onOfflineTrainingChange = onOfflineTrainingChange,
|
||||
onRegenerationChange = onRegenerationChange,
|
||||
|
@ -20,8 +21,7 @@ function init()
|
|||
onBaseSkillChange = onBaseSkillChange
|
||||
})
|
||||
connect(g_game, {
|
||||
onGameStart = refresh,
|
||||
onGameEnd = refresh
|
||||
onGameStart = refresh
|
||||
})
|
||||
|
||||
skillsWindow = g_ui.loadUI('skills.otui', modules.game_interface.getRightPanel())
|
||||
|
@ -40,6 +40,7 @@ function terminate()
|
|||
onManaChange = onManaChange,
|
||||
onSoulChange = onSoulChange,
|
||||
onFreeCapacityChange = onFreeCapacityChange,
|
||||
onTotalCapacityChange = onTotalCapacityChange,
|
||||
onStaminaChange = onStaminaChange,
|
||||
onOfflineTrainingChange = onOfflineTrainingChange,
|
||||
onRegenerationChange = onRegenerationChange,
|
||||
|
@ -60,6 +61,12 @@ function terminate()
|
|||
skillsWindow:destroy()
|
||||
end
|
||||
|
||||
function resetSkillColor(id)
|
||||
local skill = skillsWindow:recursiveGetChildById(id)
|
||||
local widget = skill:getChildById('value')
|
||||
widget:setColor('#bbbbbb')
|
||||
end
|
||||
|
||||
function setSkillBase(id, value, baseValue)
|
||||
if baseValue < 1 or value < 1 then
|
||||
return
|
||||
|
@ -68,13 +75,13 @@ function setSkillBase(id, value, baseValue)
|
|||
local widget = skill:getChildById('value')
|
||||
|
||||
if value > baseValue then
|
||||
widget:setColor('#008b00')
|
||||
widget:setColor('#008b00') -- green
|
||||
skill:setTooltip(baseValue .. ' + ' .. (value - baseValue))
|
||||
elseif value < baseValue then
|
||||
widget:setColor('#008b00')
|
||||
widget:setColor('#b22222') -- red
|
||||
skill:setTooltip(baseValue .. ' - ' .. (value - baseValue))
|
||||
else
|
||||
widget:setColor('#bbbbbb')
|
||||
widget:setColor('#bbbbbb') -- default
|
||||
skill:removeTooltip()
|
||||
end
|
||||
end
|
||||
|
@ -107,6 +114,18 @@ function setSkillPercent(id, percent, tooltip)
|
|||
end
|
||||
end
|
||||
|
||||
function checkAlert(id, value, maxValue, threshold)
|
||||
if value > maxValue or maxValue < 1 then
|
||||
return
|
||||
end
|
||||
local percent = math.floor((value / maxValue) * 100)
|
||||
if percent < threshold then
|
||||
setSkillColor(id, '#b22222') -- red
|
||||
else
|
||||
resetSkillColor(id)
|
||||
end
|
||||
end
|
||||
|
||||
function update()
|
||||
local offlineTraining = skillsWindow:recursiveGetChildById('offlineTraining')
|
||||
if not g_game.getFeature(GameOfflineTrainingTime) then
|
||||
|
@ -138,8 +157,6 @@ function refresh()
|
|||
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
|
||||
onSkillChange(player, i, player:getSkillLevel(i), player:getSkillLevelPercent(i))
|
||||
|
@ -186,10 +203,12 @@ end
|
|||
|
||||
function onHealthChange(localPlayer, health, maxHealth)
|
||||
setSkillValue('health', tr(health))
|
||||
checkAlert('health', health, maxHealth, 30)
|
||||
end
|
||||
|
||||
function onManaChange(localPlayer, mana, maxMana)
|
||||
setSkillValue('mana', tr(mana))
|
||||
checkAlert('mana', mana, maxMana, 30)
|
||||
end
|
||||
|
||||
function onSoulChange(localPlayer, soul)
|
||||
|
@ -198,6 +217,11 @@ end
|
|||
|
||||
function onFreeCapacityChange(localPlayer, freeCapacity)
|
||||
setSkillValue('capacity', freeCapacity)
|
||||
checkAlert('capacity', freeCapacity, localPlayer:getTotalCapacity(), 20)
|
||||
end
|
||||
|
||||
function onTotalCapacityChange(localPlayer, totalCapacity)
|
||||
checkAlert('capacity', localPlayer:getFreeCapacity(), totalCapacity, 20)
|
||||
end
|
||||
|
||||
function onStaminaChange(localPlayer, stamina)
|
||||
|
@ -228,7 +252,7 @@ function onOfflineTrainingChange(localPlayer, offlineTrainingTime)
|
|||
end
|
||||
|
||||
function onRegenerationChange(localPlayer, regenerationTime)
|
||||
if not g_game.getFeature(GamePlayerRegenerationTime) then
|
||||
if not g_game.getFeature(GamePlayerRegenerationTime) or regenerationTime < 0 then
|
||||
return
|
||||
end
|
||||
local hours = math.floor(regenerationTime / 60)
|
||||
|
@ -238,45 +262,37 @@ function onRegenerationChange(localPlayer, regenerationTime)
|
|||
end
|
||||
|
||||
setSkillValue('regenerationTime', hours .. ":" .. minutes)
|
||||
checkAlert('regenerationTime', regenerationTime, 30, 20) -- what is max regeneration?
|
||||
end
|
||||
|
||||
function onSpeedChange(localPlayer, speed)
|
||||
setSkillValue('speed', speed)
|
||||
|
||||
setSkillBase('speed', speed, localPlayer:getBaseSpeed())
|
||||
onBaseSpeedChange(localPlayer, localPlayer:getBaseSpeed())
|
||||
end
|
||||
|
||||
function onBaseSpeedChange(localPlayer, baseSpeed)
|
||||
local speed = localPlayer:getSpeed()
|
||||
onSpeedChange(localPlayer, baseSpeed)
|
||||
|
||||
setSkillBase('speed', speed, baseSpeed)
|
||||
setSkillBase('speed', localPlayer:getSpeed(), baseSpeed)
|
||||
end
|
||||
|
||||
function onMagicLevelChange(localPlayer, magiclevel, percent)
|
||||
setSkillValue('magiclevel', magiclevel)
|
||||
setSkillPercent('magiclevel', percent, tr('You have %s percent to go', 100 - percent))
|
||||
|
||||
setSkillBase('magiclevel', magiclevel, localPlayer:getBaseMagicLevel())
|
||||
onBaseMagicLevelChange(localPlayer, localPlayer:getBaseMagicLevel())
|
||||
end
|
||||
|
||||
function onBaseMagicLevelChange(localPlayer, baseMagicLevel)
|
||||
local magiclevel = localPlayer:getMagicLevel()
|
||||
onMagicLevelChange(localPlayer, magiclevel, localPlayer:getMagicLevelPercent())
|
||||
|
||||
setSkillBase('magiclevel', magiclevel, baseMagicLevel)
|
||||
setSkillBase('magiclevel', localPlayer:getMagicLevel(), baseMagicLevel)
|
||||
end
|
||||
|
||||
function onSkillChange(localPlayer, id, level, percent)
|
||||
setSkillValue('skillId' .. id, level)
|
||||
setSkillPercent('skillId' .. id, percent, tr('You have %s percent to go', 100 - percent))
|
||||
|
||||
setSkillBase('skillId'..id, level, localPlayer:getSkillBaseLevel(id))
|
||||
onBaseSkillChange(localPlayer, id, localPlayer:getSkillBaseLevel(id))
|
||||
end
|
||||
|
||||
function onBaseSkillChange(localPlayer, id, baseLevel)
|
||||
local level = localPlayer:getSkillLevel(id)
|
||||
onSkillChange(localPlayer, id, level, localPlayer:getSkillLevelPercent(id))
|
||||
|
||||
setSkillBase('skillId'..id, level, baseLevel)
|
||||
setSkillBase('skillId'..id, localPlayer:getSkillLevel(id), baseLevel)
|
||||
end
|
|
@ -54,3 +54,26 @@ function Player:hasVip(creatureName)
|
|||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function Player:isMounted()
|
||||
local outfit = self:getOutfit()
|
||||
return outfit.mount ~= nil and outfit.mount > 0
|
||||
end
|
||||
|
||||
function Player:toggleMount()
|
||||
if g_game.getFeature(GamePlayerMounts) then
|
||||
g_game.mount(not self:isMounted())
|
||||
end
|
||||
end
|
||||
|
||||
function Player:mount()
|
||||
if g_game.getFeature(GamePlayerMounts) then
|
||||
g_game.mount(true)
|
||||
end
|
||||
end
|
||||
|
||||
function Player:dismount()
|
||||
if g_game.getFeature(GamePlayerMounts) then
|
||||
g_game.mount(false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,6 @@ void Game::resetGameStates()
|
|||
m_online = false;
|
||||
m_denyBotCall = false;
|
||||
m_dead = false;
|
||||
m_mounted = false;
|
||||
m_serverBeat = 50;
|
||||
m_seq = 0;
|
||||
m_canReportBugs = false;
|
||||
|
@ -1079,7 +1078,6 @@ void Game::mount(bool mount)
|
|||
return;
|
||||
|
||||
m_protocolGame->sendMountStatus(mount);
|
||||
m_mounted = mount;
|
||||
}
|
||||
|
||||
void Game::requestItemInfo(const ItemPtr& item, int index)
|
||||
|
|
|
@ -251,7 +251,6 @@ public:
|
|||
bool isDead() { return m_dead; }
|
||||
bool isAttacking() { return !!m_attackingCreature; }
|
||||
bool isFollowing() { return !!m_followingCreature; }
|
||||
bool isMounted() { return m_mounted; }
|
||||
|
||||
ContainerPtr getContainer(int index) { return m_containers[index]; }
|
||||
std::map<int, ContainerPtr> getContainers() { return m_containers; }
|
||||
|
@ -288,7 +287,6 @@ private:
|
|||
bool m_online;
|
||||
bool m_denyBotCall;
|
||||
bool m_dead;
|
||||
bool m_mounted;
|
||||
int m_serverBeat;
|
||||
uint m_seq;
|
||||
Otc::FightModes m_fightMode;
|
||||
|
|
|
@ -199,7 +199,6 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindSingletonFunction("g_game", "isDead", &Game::isDead, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "isAttacking", &Game::isAttacking, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "isFollowing", &Game::isFollowing, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "isMounted", &Game::isMounted, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getContainer", &Game::getContainer, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getContainers", &Game::getContainers, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "getVips", &Game::getVips, &g_game);
|
||||
|
@ -380,6 +379,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<LocalPlayer>("setStates", &LocalPlayer::setStates);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setSkill", &LocalPlayer::setSkill);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setHealth", &LocalPlayer::setHealth);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setTotalCapacity", &LocalPlayer::setTotalCapacity);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setFreeCapacity", &LocalPlayer::setFreeCapacity);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setExperience", &LocalPlayer::setExperience);
|
||||
g_lua.bindClassMemberFunction<LocalPlayer>("setLevel", &LocalPlayer::setLevel);
|
||||
|
|
|
@ -1465,7 +1465,7 @@ Outfit ProtocolGame::getOutfit(const InputMessagePtr& msg)
|
|||
}
|
||||
|
||||
if(g_game.getFeature(Otc::GamePlayerMounts)) {
|
||||
int mount = msg->getU16(); // mount
|
||||
int mount = msg->getU16();
|
||||
outfit.setMount(mount);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue