Fix some issues in battle

This commit is contained in:
Eduardo Bart 2012-08-03 02:58:48 -03:00
parent f397e6319c
commit 325b711181
4 changed files with 18 additions and 7 deletions

View File

@ -179,8 +179,8 @@ function addCreature(creature)
battleButton.creatureId = creatureId battleButton.creatureId = creatureId
battleButton.creature = creature battleButton.creature = creature
battleButton.isHovered = false battleButton.isHovered = false
battleButton.isTarget = (g_game.getAttackingCreature() == creature) battleButton.isTarget = false
battleButton.isFollowed = (g_game.getFollowingCreature() == creature) battleButton.isFollowed = false
labelWidget:setText(creature:getName()) labelWidget:setText(creature:getName())
creatureWidget:setCreature(creature) creatureWidget:setCreature(creature)
@ -190,6 +190,14 @@ function addCreature(creature)
checkCreatureSkull(battleButton.creature) checkCreatureSkull(battleButton.creature)
checkCreatureEmblem(battleButton.creature) checkCreatureEmblem(battleButton.creature)
if creature == g_game.getAttackingCreature() then
onAttack(creature)
end
if creature == g_game.getFollowingCreature() then
onFollow(creature)
end
else else
setLifeBarPercent(battleButton, creature:getHealthPercent()) setLifeBarPercent(battleButton, creature:getHealthPercent())
end end
@ -301,7 +309,6 @@ function onbattleButtonHoverChange(widget, hovered)
end end
function onAttack(creature) function onAttack(creature)
checkCreatures(true) --Force recheck
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
if battleButton then if battleButton then
battleButton.isTarget = creature and true or false battleButton.isTarget = creature and true or false
@ -310,7 +317,6 @@ function onAttack(creature)
end end
function onFollow(creature) function onFollow(creature)
checkCreatures(true) --Force recheck
local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched local battleButton = creature and battleButtonsByCreaturesList[creature:getId()] or lastBattleButtonSwitched
if battleButton then if battleButton then
battleButton.isFollowed = creature and true or false battleButton.isFollowed = creature and true or false

View File

@ -52,6 +52,7 @@ MiniWindow
anchors.right: next.left anchors.right: next.left
margin-right: 5 margin-right: 5
margin-top: 3 margin-top: 3
@onCheckChange: modules.game_battle.checkCreatures()
BattleNPCs BattleNPCs
id: hideNPCs id: hideNPCs
@ -60,6 +61,7 @@ MiniWindow
anchors.right: next.left anchors.right: next.left
margin-right: 5 margin-right: 5
margin-top: 3 margin-top: 3
@onCheckChange: modules.game_battle.checkCreatures()
BattleMonsters BattleMonsters
id: hideMonsters id: hideMonsters
@ -67,6 +69,7 @@ MiniWindow
anchors.top: parent.top anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
margin-top: 3 margin-top: 3
@onCheckChange: modules.game_battle.checkCreatures()
BattleSkulls BattleSkulls
id: hideSkulls id: hideSkulls
@ -74,6 +77,7 @@ MiniWindow
anchors.top: prev.top anchors.top: prev.top
anchors.left: prev.right anchors.left: prev.right
margin-left: 5 margin-left: 5
@onCheckChange: modules.game_battle.checkCreatures()
BattleParty BattleParty
id: hideParty id: hideParty
@ -81,6 +85,7 @@ MiniWindow
anchors.top: prev.top anchors.top: prev.top
anchors.left: prev.right anchors.left: prev.right
margin-left: 5 margin-left: 5
@onCheckChange: modules.game_battle.checkCreatures()
HorizontalSeparator HorizontalSeparator
anchors.top: prev.bottom anchors.top: prev.bottom

View File

@ -1,7 +1,7 @@
BattleButton < UIButton BattleButton < UIButton
height: 20 height: 20
margin-top: 5 margin-top: 5
fixed-size: true margin-right: 4
&isBattleButton: true &isBattleButton: true
UICreature UICreature

View File

@ -477,7 +477,7 @@ void Game::walk(Otc::Direction direction)
// check walk to another floor (e.g: when above 3 parcels) // check walk to another floor (e.g: when above 3 parcels)
else { else {
// check if can walk to a lower floor // check if can walk to a lower floor
auto canChangeFloorDown = [&] { auto canChangeFloorDown = [&]() -> bool {
Position pos = toPos; Position pos = toPos;
if(!pos.down()) if(!pos.down())
return false; return false;
@ -488,7 +488,7 @@ void Game::walk(Otc::Direction direction)
}; };
// check if can walk to a higher floor // check if can walk to a higher floor
auto canChangeFloorUp = [&] { auto canChangeFloorUp = [&]() -> bool {
TilePtr fromTile = m_localPlayer->getTile(); TilePtr fromTile = m_localPlayer->getTile();
if(!fromTile || !fromTile->hasElevation(3)) if(!fromTile || !fromTile->hasElevation(3))
return false; return false;