From 325b7111810d7eef553f00e9617782e0194348eb Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 3 Aug 2012 02:58:48 -0300 Subject: [PATCH] Fix some issues in battle --- modules/game_battle/battle.lua | 14 ++++++++++---- modules/game_battle/battle.otui | 5 +++++ modules/game_battle/battlebutton.otui | 2 +- src/otclient/game.cpp | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index 86c4eb85..632814c0 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -179,8 +179,8 @@ function addCreature(creature) battleButton.creatureId = creatureId battleButton.creature = creature battleButton.isHovered = false - battleButton.isTarget = (g_game.getAttackingCreature() == creature) - battleButton.isFollowed = (g_game.getFollowingCreature() == creature) + battleButton.isTarget = false + battleButton.isFollowed = false labelWidget:setText(creature:getName()) creatureWidget:setCreature(creature) @@ -190,6 +190,14 @@ function addCreature(creature) checkCreatureSkull(battleButton.creature) checkCreatureEmblem(battleButton.creature) + + if creature == g_game.getAttackingCreature() then + onAttack(creature) + end + + if creature == g_game.getFollowingCreature() then + onFollow(creature) + end else setLifeBarPercent(battleButton, creature:getHealthPercent()) end @@ -301,7 +309,6 @@ function onbattleButtonHoverChange(widget, hovered) end function onAttack(creature) - checkCreatures(true) --Force recheck local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched if battleButton then battleButton.isTarget = creature and true or false @@ -310,7 +317,6 @@ function onAttack(creature) end function onFollow(creature) - checkCreatures(true) --Force recheck local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched if battleButton then battleButton.isFollowed = creature and true or false diff --git a/modules/game_battle/battle.otui b/modules/game_battle/battle.otui index 4aa57f65..f1a521bc 100644 --- a/modules/game_battle/battle.otui +++ b/modules/game_battle/battle.otui @@ -52,6 +52,7 @@ MiniWindow anchors.right: next.left margin-right: 5 margin-top: 3 + @onCheckChange: modules.game_battle.checkCreatures() BattleNPCs id: hideNPCs @@ -60,6 +61,7 @@ MiniWindow anchors.right: next.left margin-right: 5 margin-top: 3 + @onCheckChange: modules.game_battle.checkCreatures() BattleMonsters id: hideMonsters @@ -67,6 +69,7 @@ MiniWindow anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter margin-top: 3 + @onCheckChange: modules.game_battle.checkCreatures() BattleSkulls id: hideSkulls @@ -74,6 +77,7 @@ MiniWindow anchors.top: prev.top anchors.left: prev.right margin-left: 5 + @onCheckChange: modules.game_battle.checkCreatures() BattleParty id: hideParty @@ -81,6 +85,7 @@ MiniWindow anchors.top: prev.top anchors.left: prev.right margin-left: 5 + @onCheckChange: modules.game_battle.checkCreatures() HorizontalSeparator anchors.top: prev.bottom diff --git a/modules/game_battle/battlebutton.otui b/modules/game_battle/battlebutton.otui index df9317d2..67ff4ab9 100644 --- a/modules/game_battle/battlebutton.otui +++ b/modules/game_battle/battlebutton.otui @@ -1,7 +1,7 @@ BattleButton < UIButton height: 20 margin-top: 5 - fixed-size: true + margin-right: 4 &isBattleButton: true UICreature diff --git a/src/otclient/game.cpp b/src/otclient/game.cpp index e432fdfc..e645565a 100644 --- a/src/otclient/game.cpp +++ b/src/otclient/game.cpp @@ -477,7 +477,7 @@ void Game::walk(Otc::Direction direction) // check walk to another floor (e.g: when above 3 parcels) else { // check if can walk to a lower floor - auto canChangeFloorDown = [&] { + auto canChangeFloorDown = [&]() -> bool { Position pos = toPos; if(!pos.down()) return false; @@ -488,7 +488,7 @@ void Game::walk(Otc::Direction direction) }; // check if can walk to a higher floor - auto canChangeFloorUp = [&] { + auto canChangeFloorUp = [&]() -> bool { TilePtr fromTile = m_localPlayer->getTile(); if(!fromTile || !fromTile->hasElevation(3)) return false;