This commit is contained in:
ghoulslash 2026-03-21 16:55:24 +01:00 committed by GitHub
commit 64ff6565bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 0 deletions

View File

@ -1447,6 +1447,18 @@
.2byte \metatileId
.2byte \impassable
.endm
@ Set a metatile at all tiles within the bounds [xmin,ymin] to [xmax,ymax] inclusive with desired elevation
.macro setmetatileinrange xmin:req, ymin:req, xmax:req, ymax:req, tileid:req, collision=FALSE, elevation=0xFF
callnative ScriptSetMetatileInRange
.byte \xmin
.byte \ymin
.byte \xmax
.byte \ymax
.2byte \tileid
.byte \collision
.byte \elevation
.endm
@ Queues a weather change to the default weather for the map.
.macro resetweather

View File

@ -2758,6 +2758,43 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
return FALSE;
}
void NativeFunc_SetMetatileInRange(struct ScriptContext *ctx)
{
u8 xmin = ScriptReadByte(ctx);
u8 ymin = ScriptReadByte(ctx);
u8 xmax = ScriptReadByte(ctx);
u8 ymax = ScriptReadByte(ctx);
u16 tileId = VarGet(ScriptReadHalfword(ctx));
bool8 hasCollision = ScriptReadByte(ctx);
u8 elevation = ScriptReadByte(ctx);
u32 i, j;
if (xmin > xmax)
SWAP(xmin, xmax, i);
if (ymin > ymax)
SWAP(ymin, ymax, i);
xmin += MAP_OFFSET;
ymin += MAP_OFFSET;
xmax += MAP_OFFSET;
ymax += MAP_OFFSET;
// try set impassable
if (hasCollision)
tileId |= MAPGRID_COLLISION_MASK;
// set elevation
if (elevation < 15)
tileId |= (elevation << MAPGRID_ELEVATION_SHIFT);
for (i = xmin; i <= xmax; i++)
{
for (j = ymin; j <= ymax; j++)
MapGridSetMetatileEntryAt(i, j, tileId);
}
}
bool8 ScrCmd_opendoor(struct ScriptContext *ctx)
{
u16 x = VarGet(ScriptReadHalfword(ctx));