Skip to content

Commit

Permalink
Corrected row spell target selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Jul 26, 2021
1 parent 0056a80 commit b4629ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
51 changes: 32 additions & 19 deletions Ambermoon.Core/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,38 @@ public void Update(double deltaTime)
{
CurrentBattleTicks = UpdateTicks(CurrentBattleTicks, deltaTime);
UpdateBattle();

if (!currentBattle.RoundActive && currentPlayerBattleAction == PlayerBattleAction.PickEnemySpellTargetRow)
{
var y = renderView.ScreenToGame(GetMousePosition(lastMousePosition)).Y - Global.BattleFieldArea.Top;
int hoveredRow = y / Global.BattleFieldSlotHeight;
highlightBattleFieldSprites.ForEach(s => s?.Delete());
highlightBattleFieldSprites.Clear();
for (int row = 0; row < 4; ++row)
{
for (int column = 0; column < 6; ++column)
{
if (hoveredRow == row && currentBattle.GetCharacterAt(column, row)?.Type != CharacterType.PartyMember)
{
highlightBattleFieldSprites.Add
(
layout.AddSprite
(
Global.BattleFieldSlotArea(column + row * 6),
Graphics.GetCustomUIGraphicIndex(UICustomGraphic.BattleFieldGreenHighlight),
UIPaletteIndex
)
);
}
}
}
}
}
}
else
{
CurrentBattleTicks = 0;
}

if (!WindowActive && layout.ButtonGridPage == 0)
{
Expand Down Expand Up @@ -1081,6 +1109,8 @@ internal void Start3D(Map map, uint playerX, uint playerY, CharacterDirection di

void Cleanup()
{
highlightBattleFieldSprites.ForEach(s => s?.Delete());
highlightBattleFieldSprites.Clear();
currentBattle?.EndBattleCleanup();
outro?.Destroy();
layout.Reset();
Expand Down Expand Up @@ -8534,7 +8564,7 @@ void BattleFieldSlotClicked(int column, int row, MouseButtons mouseButtons)
if (currentPickingActionMember == CurrentPartyMember)
{
layout.ClearBattleFieldSlotColorsExcept(currentBattle.GetSlotFromCharacter(currentPickingActionMember));
SetBattleRowSlotColors(row, (c, r) => currentBattle.GetCharacterAt(c, r)?.Type == CharacterType.Monster, BattleFieldSlotColor.Orange);
SetBattleRowSlotColors(row, (c, r) => currentBattle.GetCharacterAt(c, r)?.Type != CharacterType.PartyMember, BattleFieldSlotColor.Orange);
}
CancelSpecificPlayerAction();
break;
Expand Down Expand Up @@ -8656,26 +8686,9 @@ void SetCurrentPlayerAction(PlayerBattleAction playerBattleAction)
}
case PlayerBattleAction.PickEnemySpellTargetRow:
{
// TODO: only show 1 row and only when hovering the row
var valuableRows = Enumerable.Range(0, 4).Where(r => Enumerable.Range(0, 6).Any(c => currentBattle.GetCharacterAt(c + r * 6)?.Type == CharacterType.Monster));
foreach (var row in valuableRows)
{
for (int column = 0; column < 6; ++column)
{
highlightBattleFieldSprites.Add
(
layout.AddSprite
(
Global.BattleFieldSlotArea(column + row * 6),
Graphics.GetCustomUIGraphicIndex(UICustomGraphic.BattleFieldGreenHighlight),
UIPaletteIndex
)
);
}
}
RemoveCurrentPlayerActionVisuals();
TrapMouse(Global.BattleFieldArea);
blinkingHighlight = true;
blinkingHighlight = false;
layout.SetBattleMessage(DataNameProvider.BattleMessageWhichMonsterRowAsTarget);
break;
}
Expand Down
1 change: 0 additions & 1 deletion ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
- Can't skip spell reflect message with space key
- Does spell reflect message use wrong color?
- Winddevil and windhowler end animation looks wrong.
- Row target selection should only show 1 highlighted row on hover (not blinking all rows).
- If monsters are in nearest row and can't attack anyone it should
- Either move diagonal up in direction of a player (best to attack him immediately)
- Or otherwise don't move at all
Expand Down

0 comments on commit b4629ad

Please sign in to comment.