mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
15029d811f
# Closed issues CLOSES #17: Incorrect Character Visuals (Only with GBC filter) CLOSES #23: Could you allow the player to change the order of the moves CLOSES #24: Evolution music not playing during evolution CLOSES #26: Standing on door glitch CLOSES #27: Battle Intro text automatically continues CLOSES #29: Visual bug when zoomed out CLOSES #32: Team Rocket recruiter doesn't battle with you unless you speak with him first CLOSES #33: Developer/Debug Console CLOSES #35: Professor Oak's introduction Inaccuracies CLOSES #36: Missing Pokemon Dex entries when picking starter + Rival Pathing issues CLOSES #39: Guy who stops player from skipping brock doesn't bring you to brock's gym + doesn't leave once you've beaten brock CLOSES #40: Bill cutscene is broken CLOSES #41: Ticket guy failing to be a Ticket guy CLOSES #42: S.S. anne odd behavior + Missing sailing away animation CLOSES #43: Dig Attack animation appears to be glitched CLOSES #44: Pokeball flashing doesn't appear to be accurate CLOSES #45: Inaccurate Cut Animation CLOSES #46: Dugtrio i caught in diglett cave has two of the same move CLOSES #47: Rival ignores player in Lavender Tower CLOSES #48: Healing pad in lavender tower does not function CLOSES #49: Incorrect dialogue with parched security guard CLOSES #50: (Game Breaking!) Rocket grunt guarding poster refuses to move CLOSES #51: Badges showing up as items I can deposit in PC CLOSES #52: Visual bug on Celadon Department Store roof (Red Filter) CLOSES #54: Visual issue on route 15 + Fuchsia City CLOSES #56: Running animation missing CLOSES #57: Safari Zone does not display steps while you are inside of it CLOSES #58: (Game Breaking!) Softlock at cycling road gate CLOSES #59: Bike visual issues CLOSES #60: Cycling road not forcing you to get on your bike CLOSES #61: No keycard doors in Silph Co. CLOSES #63: Missing teleporter animation CLOSES #64: Inaccurate spinning CLOSES #65: Reimplement unused Silph Co. Chief and Professor Oak trainer battles
90 lines
2.4 KiB
Lua
90 lines
2.4 KiB
Lua
-- The 20-slot bag (BAG_ITEM_CAPACITY, constants/menu_constants.asm):
|
|
-- a distinct item id occupies one slot regardless of quantity; badges
|
|
-- live in the inventory table but are not bag items. save.bagOrder
|
|
-- keeps acquisition order like wBagItems (SELECT can reorder it).
|
|
|
|
local Bag = {}
|
|
|
|
Bag.CAPACITY = 20
|
|
|
|
local function isBadge(id)
|
|
return id:find("BADGE", 1, true) ~= nil
|
|
end
|
|
|
|
-- exported so item lists that share save.inventory (e.g. the PC deposit
|
|
-- menu) can exclude badges the same way the bag does
|
|
Bag.isBadge = isBadge
|
|
|
|
function Bag.slots(save)
|
|
local n = 0
|
|
for id in pairs(save.inventory) do
|
|
if not isBadge(id) then n = n + 1 end
|
|
end
|
|
return n
|
|
end
|
|
|
|
-- Acquisition-ordered id list (wBagItems). Rebuilt sorted once for
|
|
-- saves from before the order existed, then maintained incrementally.
|
|
function Bag.order(save)
|
|
local order = save.bagOrder
|
|
if not order then
|
|
order = {}
|
|
for id in pairs(save.inventory) do
|
|
if not isBadge(id) then table.insert(order, id) end
|
|
end
|
|
table.sort(order)
|
|
save.bagOrder = order
|
|
end
|
|
-- drop stale ids, append unknown ones (defensive against direct
|
|
-- inventory writes)
|
|
local seen = {}
|
|
for i = #order, 1, -1 do
|
|
local id = order[i]
|
|
if not save.inventory[id] or seen[id] then
|
|
table.remove(order, i)
|
|
else
|
|
seen[id] = true
|
|
end
|
|
end
|
|
for id in pairs(save.inventory) do
|
|
if not isBadge(id) and not seen[id] then table.insert(order, id) end
|
|
end
|
|
return order
|
|
end
|
|
|
|
-- Add qty of an item; returns false (and adds nothing) when a new slot
|
|
-- is needed and the bag is full, or when the stack would pass 99
|
|
-- (AddItemToInventory's per-slot quantity cap).
|
|
function Bag.add(save, id, qty)
|
|
local inv = save.inventory
|
|
if not inv[id] and not isBadge(id) and Bag.slots(save) >= Bag.CAPACITY then
|
|
return false
|
|
end
|
|
if not isBadge(id) and (inv[id] or 0) + (qty or 1) > 99 then
|
|
return false
|
|
end
|
|
local isNew = not inv[id]
|
|
inv[id] = (inv[id] or 0) + (qty or 1)
|
|
if isNew and not isBadge(id) then
|
|
table.insert(Bag.order(save), id)
|
|
end
|
|
return true
|
|
end
|
|
|
|
-- Remove qty (default 1); clears the slot and its order entry at zero.
|
|
function Bag.remove(save, id, qty)
|
|
local inv = save.inventory
|
|
inv[id] = (inv[id] or 0) - (qty or 1)
|
|
if inv[id] <= 0 then
|
|
inv[id] = nil
|
|
local order = save.bagOrder
|
|
if order then
|
|
for i, oid in ipairs(order) do
|
|
if oid == id then table.remove(order, i) break end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return Bag
|