Skip to content

Commit

Permalink
Merge pull request #383 from besteon/dev
Browse files Browse the repository at this point in the history
7.5.4 Patch
  • Loading branch information
UTDZac authored May 24, 2023
2 parents 4dd7d19 + 4a5ad97 commit e9e83b2
Show file tree
Hide file tree
Showing 11 changed files with 1,535 additions and 179 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

## General Information

Ironmon-Tracker is a collection of lua scripts for the [Bizhawk emulator](https://tasvideos.org/BizHawk/ReleaseHistory) (v2.8 or higher) or [mGBA emulator](https://mgba.io/downloads.html)* (v0.10.0 or higher) used to track IronMon attempts.
> *mGBA's lua scripting is currently limited and doesn't provide any drawing functionality, this means the tracker on mGBA is purely text-based in the scripting window as we can't draw images/screens like on Bizhawk.
Ironmon-Tracker is a collection of lua scripts for the [Bizhawk emulator](https://tasvideos.org/BizHawk/ReleaseHistory) (v2.8 or higher) or [mGBA emulator](https://mgba.io/downloads.html)\* (v0.10.0 or higher) used to track IronMon attempts.
> \*mGBA's lua scripting is currently limited and doesn't provide any drawing functionality, this means the tracker on mGBA is purely text-based in the scripting window as we can't draw images/screens like on Bizhawk.
For more information on IronMon, see <http://ironmon.gg>

Expand All @@ -23,14 +23,13 @@ For NDS (gen 4/5) games, please use the [NDS IronMon Tracker](https://github.com

Currently supported Pokémon games / languages:

| Version | Ruby | Sapphire | Emerald | FireRed | LeafGreen |
| :------: | :----------: | :--------------: | :-------------: | :-------------: | :---------------: |
| English | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Spanish |||| ✔️ ||
| French |||| ✔️ ||
| Italian |||| ✔️ ||
| German |||| ✔️ ||
| Japanese ||||||
| Version | Ruby | Sapphire | Emerald | FireRed | LeafGreen |
| :-------: | :--: | :------: | :-----: | :-----: | :-------: |
| English | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Spanish |||| ✔️ ||
| French |||| ✔️ ||
| Italian |||| ✔️ ||
| German |||| ✔️ ||

We'd ideally like to support all non-English versions if we can, progress updates can be found [here](https://github.com/besteon/Ironmon-Tracker/issues/62).

Expand All @@ -40,9 +39,9 @@ We'd ideally like to support all non-English versions if we can, progress update
- You can get the latest project release from the [Releases](https://github.com/besteon/Ironmon-Tracker/releases/latest) section of this Github repository.
2. **Get a Supported Emulator**
- We recommend using the Bizhawk emulator (Windows/Linux only)
- [Download Bizhawk](https://tasvideos.org/BizHawk/ReleaseHistory) (v2.8 or higher)
- If you are on Windows, make sure to also download and run the [prereq installer](https://github.com/TASEmulators/BizHawk-Prereqs/releases) first
- If you are on Linux, we recommend using Bizhawk 2.9 or higher
- [Download Bizhawk](https://tasvideos.org/BizHawk/ReleaseHistory) (v2.8 or higher)
- If you are on Windows, make sure to also download and run the [prereq installer](https://github.com/TASEmulators/BizHawk-Prereqs/releases) first
- If you are on Linux, we recommend using Bizhawk 2.9 or higher
- Alternatively, you can use the MGBA emulator (Windows/Mac/Linux)
- [Download MGBA](https://mgba.io/downloads.html) (v0.10.0 or higher)
3. **Install and Setup**
Expand Down Expand Up @@ -79,11 +78,13 @@ There are a couple of VS Code extensions which we recommend, which should automa
- [vscode-lua](https://marketplace.visualstudio.com/items?itemName=trixnz.vscode-lua): Provides intellisense and linting for Lua.

Lua Versions:

- Bizhawk 2.8 uses Lua 5.1, this is the version currently set in our `.vscode/settings.json` file for linting.
- Bizhawk 2.9 and mGBA use Lua 5.4
- Since we intend to still support Bizhawk 2.8 the code must be compatible with both Lua 5.1 and 5.4
- Since we intend to still support Bizhawk 2.8 the code must be compatible with both Lua 5.1 and 5.4

Emu-specific Lua documentation:

- [Bizhawk Lua Functions](https://tasvideos.org/Bizhawk/LuaFunctions)
- [mGBA Scripting API](https://mgba.io/docs/scripting.html)

Expand Down
85 changes: 50 additions & 35 deletions ironmon_tracker/Battle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -495,61 +495,76 @@ function Battle.checkAbilitiesToTrack()
local battlerAbility = Battle.BattleParties[Battle.battler % 2][Battle.Combatants[Battle.IndexMap[Battle.battler]]].ability
local battleTargetAbility = Battle.BattleParties[Battle.battlerTarget % 2][Battle.Combatants[Battle.IndexMap[Battle.battlerTarget]]].ability

local abilityMsg
-- BATTLER: 'battler' had their ability triggered
local abilityMsg = GameSettings.ABILITIES.BATTLER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battlerAbility] then
-- Track a Traced pokemon's ability
if battlerAbility == 36 then
Battle.trackAbilityChanges(nil,36)
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
if GameSettings.ABILITIES.BATTLER then
abilityMsg = GameSettings.ABILITIES.BATTLER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battlerAbility] then
-- Track a Traced pokemon's ability; need to grab the target from the buffers for doubles
if battlerAbility == 36 then
Battle.trackAbilityChanges(nil,36)
local target = Memory.readbyte(GameSettings.gBattleTextBuff1 + 2)
combatantIndexesToTrack[target] = target
else
combatantIndexesToTrack[Battle.battler] = Battle.battler
end
end
combatantIndexesToTrack[Battle.battler] = Battle.battler
end

-- REVERSE_BATTLER: 'battlerTarget' had their ability triggered by the battler's ability
abilityMsg = GameSettings.ABILITIES.REVERSE_BATTLER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battleTargetAbility] then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
combatantIndexesToTrack[Battle.battler] = Battle.battler
if GameSettings.ABILITIES.REVERSE_BATTLER then
abilityMsg = GameSettings.ABILITIES.REVERSE_BATTLER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battleTargetAbility] then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
combatantIndexesToTrack[Battle.battler] = Battle.battler
end
end

-- ATTACKER: 'battleTarget' had their ability triggered
abilityMsg = GameSettings.ABILITIES.ATTACKER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battleTargetAbility] then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
if GameSettings.ABILITIES.ATTACKER then
abilityMsg = GameSettings.ABILITIES.ATTACKER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[battleTargetAbility] then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
end
end
--Synchronize
if abilityMsg ~= nil and abilityMsg[battlerAbility] and (Battle.Synchronize.attacker == Battle.attacker and Battle.Synchronize.battlerTarget == Battle.battlerTarget and Battle.Synchronize.battler ~= Battle.battler and Battle.Synchronize.battlerTarget ~= -1) then
combatantIndexesToTrack[Battle.battler] = Battle.battler
end

-- REVERSE ATTACKER: 'attacker' had their ability triggered
abilityMsg = GameSettings.ABILITIES.REVERSE_ATTACKER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[attackerAbility] then
combatantIndexesToTrack[Battle.attacker] = Battle.attacker
if GameSettings.ABILITIES.REVERSE_ATTACKER then
abilityMsg = GameSettings.ABILITIES.REVERSE_ATTACKER[Battle.battleMsg]
if abilityMsg ~= nil and abilityMsg[attackerAbility] then
combatantIndexesToTrack[Battle.attacker] = Battle.attacker
end
end

abilityMsg = GameSettings.ABILITIES.STATUS_INFLICT[Battle.battleMsg]
if abilityMsg ~= nil then
-- Log allied pokemon contact status ability trigger for Synchronize
if abilityMsg[battlerAbility] and ((Battle.battler == Battle.battlerTarget) or (Battle.Synchronize.attacker == Battle.attacker and Battle.Synchronize.battlerTarget == Battle.battlerTarget and Battle.Synchronize.battler ~= Battle.battler)) then
combatantIndexesToTrack[Battle.battler] = Battle.battler
end
if abilityMsg[battleTargetAbility] then
Battle.Synchronize.turnCount = Battle.turnCount
Battle.Synchronize.battler = Battle.battler
Battle.Synchronize.attacker = Battle.attacker
Battle.Synchronize.battlerTarget = Battle.battlerTarget
if GameSettings.ABILITIES.STATUS_INFLICT then
abilityMsg = GameSettings.ABILITIES.STATUS_INFLICT[Battle.battleMsg]
if abilityMsg ~= nil then
-- Log allied pokemon contact status ability trigger for Synchronize
if abilityMsg[battlerAbility] and ((Battle.battler == Battle.battlerTarget) or (Battle.Synchronize.attacker == Battle.attacker and Battle.Synchronize.battlerTarget == Battle.battlerTarget and Battle.Synchronize.battler ~= Battle.battler)) then
combatantIndexesToTrack[Battle.battler] = Battle.battler
end
if abilityMsg[battleTargetAbility] then
Battle.Synchronize.turnCount = Battle.turnCount
Battle.Synchronize.battler = Battle.battler
Battle.Synchronize.attacker = Battle.attacker
Battle.Synchronize.battlerTarget = Battle.battlerTarget
end
end
end

abilityMsg = GameSettings.ABILITIES.BATTLE_TARGET[Battle.battleMsg]
if abilityMsg ~= nil then
if abilityMsg[battleTargetAbility] and abilityMsg.scope == "self" then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
end
if abilityMsg.scope == "other" and abilityMsg[attackerAbility] then
combatantIndexesToTrack[Battle.attacker] = Battle.attacker
if GameSettings.ABILITIES.BATTLE_TARGET then
abilityMsg = GameSettings.ABILITIES.BATTLE_TARGET[Battle.battleMsg]
if abilityMsg ~= nil then
if abilityMsg[battleTargetAbility] and abilityMsg.scope == "self" then
combatantIndexesToTrack[Battle.battlerTarget] = Battle.battlerTarget
end
if abilityMsg.scope == "other" and abilityMsg[attackerAbility] then
combatantIndexesToTrack[Battle.attacker] = Battle.attacker
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion ironmon_tracker/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Constants.CharWidths = {
[" "] = 1,
["%"] = 7,
["0"] = 4,
["1"] = 3,
["1"] = 4,
["2"] = 4,
["3"] = 4,
["4"] = 4,
Expand Down
20 changes: 9 additions & 11 deletions ironmon_tracker/Drawing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ function Drawing.drawText(x, y, text, color, shadowcolor, size, family, style)
y = y - 1
end

-- Need a bit more space when drawing larger characters
if GameSettings.language == "Japanese" and Utils.startsWithJapaneseChineseChar(text) then
y = y + 1
end

-- For now, don't draw shadows for smaller-than-normal text (old behavior)
if Theme.DRAW_TEXT_SHADOWS and shadowcolor ~= nil and size == nil then
gui.drawText(x + 1, y + 1, text, shadowcolor, nil, size or Constants.Font.SIZE, family or Constants.Font.FAMILY, style)
Expand All @@ -76,18 +81,11 @@ function Drawing.drawText(x, y, text, color, shadowcolor, size, family, style)
end

function Drawing.drawHeader(x, y, text, color, shadowcolor, size, family, style)
-- For some reason on Linux the text is offset by 1 pixel (tested on Bizhawk 2.9)
if Main.OS == "Linux" then
x = x + 1
y = y - 1
-- Need even more space when drawing larger characters in the header
if GameSettings.language == "Japanese" and Utils.startsWithJapaneseChineseChar(text) then
y = y + 1
end

-- For now, don't draw shadows for smaller-than-normal text (old behavior)
if Theme.DRAW_TEXT_SHADOWS and shadowcolor ~= nil and size == nil then
gui.drawText(x + 1, y + 1, text, shadowcolor, nil, size or Constants.Font.HEADERSIZE, family or Constants.Font.FAMILY, style)
end
-- void gui.drawText(x, y, message, forecolor, backcolor, fontsize, fontfamily, fontstyle, horizalign, vertalign, surfacename)
gui.drawText(x, y, text, color, nil, size or Constants.Font.HEADERSIZE, family or Constants.Font.FAMILY, style)
Drawing.drawText(x, y, text, color, shadowcolor, size or Constants.Font.HEADERSIZE, family, style)
end

function Drawing.drawNumber(x, y, number, spacing, color, shadowcolor, size, family, style)
Expand Down
1 change: 1 addition & 0 deletions ironmon_tracker/FileManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FileManager.Files = {
ItalyData = "ItalyData.lua",
FranceData = "FranceData.lua",
GermanyData = "GermanyData.lua",
JapanData = "JapanData.lua",
},
Other = {
REPEL = "repelUsage.png",
Expand Down
Loading

0 comments on commit e9e83b2

Please sign in to comment.