Fix some issues in battle
This commit is contained in:
		
							parent
							
								
									f397e6319c
								
							
						
					
					
						commit
						325b711181
					
				|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| BattleButton < UIButton | ||||
|   height: 20 | ||||
|   margin-top: 5 | ||||
|   fixed-size: true | ||||
|   margin-right: 4 | ||||
|   &isBattleButton: true | ||||
| 
 | ||||
|   UICreature | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Eduardo Bart
						Eduardo Bart