mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-22 21:46:51 +02:00
Fix Gen 1/2 battle, menu, PC and audio parity gaps; wire luacheck into CI
CLOSES #1484, CLOSES #1486, CLOSES #1513, CLOSES #1517, CLOSES #1556, CLOSES #1564, CLOSES #1567
This commit is contained in:
+34
-4
@@ -808,6 +808,31 @@ local function buildOverworld()
|
||||
local Movement = rawRequire("src.script.gen2.Movement")
|
||||
local HiddenItems = rawRequire("src.world.gen2.HiddenItems")
|
||||
local Bike = rawRequire("src.world.gen2.Bike")
|
||||
local FieldMoves = rawRequire("src.world.gen2.FieldMoves")
|
||||
|
||||
-- home/map.asm:1869
|
||||
local function stepAllowed(world, entity, dir)
|
||||
local d = Map2.DELTA[dir]
|
||||
if not (world.map and d and entity and entity.cellX) then return true end
|
||||
if not Permissions.stepPermitted(
|
||||
function(cx, cy) return world:cellCollisionAcross(world.map, cx, cy) end,
|
||||
entity.cellX, entity.cellY, dir) then
|
||||
return false
|
||||
end
|
||||
local map = world.map
|
||||
if entity == world.player and FieldMoves.isSurfing(world.playerState) then
|
||||
map = world:surfMap(world.map)
|
||||
end
|
||||
local tx, ty = entity.cellX + d[1], entity.cellY + d[2]
|
||||
if not map:inBounds(tx, ty) or not map:isWalkable(tx, ty) then return false end
|
||||
for _, e in ipairs(world.entities or {}) do
|
||||
if e ~= entity and not e.passable then
|
||||
if e.cellX == tx and e.cellY == ty then return false end
|
||||
if e.moving and e.targetX == tx and e.targetY == ty then return false end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local api = nil
|
||||
-- one WorldAPI instance, so queueScript reuses the five-verb allow list
|
||||
@@ -1011,20 +1036,25 @@ local function buildOverworld()
|
||||
|
||||
-- Gold has ONE movement slot; a second concurrent call is refused with a
|
||||
-- reason rather than dropped (src/world/gen2/WorldAPI.lua:171's recipe).
|
||||
function ow.scriptMove(entity, dir, tiles, onDone)
|
||||
function ow.scriptMove(entity, dir, tiles, onDone, opts)
|
||||
local world = w("scriptMove")
|
||||
if not world then return nil, "no overworld" end
|
||||
if world.moveState then return nil, "a movement is already running" end
|
||||
local step = Movement.stepByte(dir)
|
||||
if not step then return nil, "unknown direction: " .. tostring(dir) end
|
||||
local bytes = {}
|
||||
for _ = 1, math.max(0, tiles or 1) do bytes[#bytes + 1] = step end
|
||||
bytes[#bytes + 1] = Movement.STEP_END
|
||||
local objectId = objectIdOf(world, entity)
|
||||
if not objectId then
|
||||
return nil, "no Gen 2 objectId for that entity: only the player and a "
|
||||
.. "mapped object (def.index) can be moved"
|
||||
end
|
||||
local n = math.max(0, tiles or 1)
|
||||
if opts and opts.collide and n > 0 and not stepAllowed(world, entity, dir) then
|
||||
entity.facing = dir
|
||||
n = 0
|
||||
end
|
||||
local bytes = {}
|
||||
for _ = 1, n do bytes[#bytes + 1] = step end
|
||||
bytes[#bytes + 1] = Movement.STEP_END
|
||||
world:beginMovement(objectId, bytes, onDone)
|
||||
return true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user