mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 20:50:21 +02:00
feat(mods): allow caught markers in wild battle HUDs
This commit is contained in:
@@ -145,6 +145,17 @@ function BattleState:statusHUDVisible()
|
|||||||
self) ~= false
|
self) ~= false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleState:caughtMarkerVisible()
|
||||||
|
local dex = self.game and self.game.save and self.game.save.pokedex
|
||||||
|
if not self.enemy or (self.kind ~= "wild" and self.kind ~= "safari")
|
||||||
|
or not (dex and dex.owned and dex.owned[self.enemy.mon.species]) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if not Runtime.wantsHook("battle.caught_marker_visible") then return false end
|
||||||
|
return Runtime.call("battle.caught_marker_visible",
|
||||||
|
function() return false end, self) == true
|
||||||
|
end
|
||||||
|
|
||||||
function BattleState:moveGridNavigation()
|
function BattleState:moveGridNavigation()
|
||||||
if self:wideLayout() then return true end
|
if self:wideLayout() then return true end
|
||||||
if not Runtime.wantsHook("battle.move_grid_navigation") then return false end
|
if not Runtime.wantsHook("battle.move_grid_navigation") then return false end
|
||||||
@@ -4779,7 +4790,7 @@ end
|
|||||||
-- Party pokeball row (SetupPokeballs tiles: ball / status ball /
|
-- Party pokeball row (SetupPokeballs tiles: ball / status ball /
|
||||||
-- fainted ball / empty), 6 slots stepping dx from (x,y).
|
-- fainted ball / empty), 6 slots stepping dx from (x,y).
|
||||||
local ballQuads
|
local ballQuads
|
||||||
function BattleState:drawBallRow(party, x, y, dx)
|
local function balls()
|
||||||
if ballQuads == nil then
|
if ballQuads == nil then
|
||||||
local ok, img = pcall(love.graphics.newImage, "assets/generated/battle/balls.png")
|
local ok, img = pcall(love.graphics.newImage, "assets/generated/battle/balls.png")
|
||||||
if ok then
|
if ok then
|
||||||
@@ -4791,11 +4802,23 @@ function BattleState:drawBallRow(party, x, y, dx)
|
|||||||
ballQuads = false
|
ballQuads = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not ballQuads then return end
|
return ballQuads or nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleState:drawCaughtBall(x, y)
|
||||||
|
local quads = balls()
|
||||||
|
if not quads then return end
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.draw(quads.img, quads[0], x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleState:drawBallRow(party, x, y, dx)
|
||||||
|
local quads = balls()
|
||||||
|
if not quads then return end
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
local mon = party[i]
|
local mon = party[i]
|
||||||
local tile = not mon and 3 or mon.hp <= 0 and 2 or mon.status and 1 or 0
|
local tile = not mon and 3 or mon.hp <= 0 and 2 or mon.status and 1 or 0
|
||||||
love.graphics.draw(ballQuads.img, ballQuads[tile], x + (i - 1) * dx, y)
|
love.graphics.draw(quads.img, quads[tile], x + (i - 1) * dx, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5511,7 +5534,12 @@ function BattleState:drawHUDs(slide)
|
|||||||
love.graphics.translate(hudShake, 0)
|
love.graphics.translate(hudShake, 0)
|
||||||
end
|
end
|
||||||
love.graphics.setColor(0, 0, 0, 1)
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
Font.draw(self.enemy.name, nameX(1, self.enemy.name), 0)
|
local enemyNameX = nameX(1, self.enemy.name)
|
||||||
|
local enemyNameWidth = Font.draw(self.enemy.name, enemyNameX, 0)
|
||||||
|
if self:caughtMarkerVisible() then
|
||||||
|
self:drawCaughtBall(enemyNameX + enemyNameWidth, 0)
|
||||||
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
|
end
|
||||||
if self.enemy.shownStatus then
|
if self.enemy.shownStatus then
|
||||||
Font.draw(self:statusLabel({ status = self.enemy.shownStatus }), 40, 8)
|
Font.draw(self:statusLabel({ status = self.enemy.shownStatus }), 40, 8)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -193,6 +193,26 @@ do
|
|||||||
"battle status HUD returns when the hook is removed")
|
"battle status HUD returns when the hook is removed")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ------- battle.caught_marker_visible (caught wild marker)
|
||||||
|
|
||||||
|
do
|
||||||
|
local BattleState = require("src.battle.BattleState")
|
||||||
|
local state = { kind = "wild", enemy = { mon = { species = "RATTATA" } },
|
||||||
|
game = { save = { pokedex = { owned = { RATTATA = true } } } } }
|
||||||
|
check(not BattleState.caughtMarkerVisible(state),
|
||||||
|
"caught marker is opt-in")
|
||||||
|
local unsub = wrap("battle.caught_marker_visible", function() return true end)
|
||||||
|
check(BattleState.caughtMarkerVisible(state),
|
||||||
|
"a mod can show a caught wild marker")
|
||||||
|
state.kind = "trainer"
|
||||||
|
check(not BattleState.caughtMarkerVisible(state),
|
||||||
|
"trainer battles never show a caught marker")
|
||||||
|
state.kind, state.game.save.pokedex.owned.RATTATA = "wild", false
|
||||||
|
check(not BattleState.caughtMarkerVisible(state),
|
||||||
|
"uncaught wild Pokemon have no marker")
|
||||||
|
unsub()
|
||||||
|
end
|
||||||
|
|
||||||
-- ------- grid navigation ownership (alternate menu renderers)
|
-- ------- grid navigation ownership (alternate menu renderers)
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
Reference in New Issue
Block a user