Big NPCs
A Plotscript by Camdog

Sometimes you wish to create an image that can be placed dynamically, like an NPC, but does not correspond with the standard image sizes. You can do this by altering map tiles, but then you are stuck with task of reverting them back if the image changes or moves. Another way to solve this problem is by creating a block of NPCs placed together in such a way that a larger image is shown. This script allows you to do that simply.

plotscript, drawBigPicture, startX = 0, startY = 0, 
width = 1, height = 1, npcId = 0, begin
variable(x, y) #loop vars
variable(curFrame, curNpc, curNpcId) #for looping
through the npc graphics

curFrame := 1
curNpcId := npcId

for (y, startY, startY + (height -- 1), 1) do(
for (x, startX, startX + (width -- 1), 1) do(
curNpc := create npc(curNpcId, x, y)

switch(curFrame) do(
case(1) do(
set npc direction(curNpc, up)
set npc frame(curNpc, 0)
)
case(2) do(
set npc direction(curNpc, up)
set npc frame(curNpc, 1)
)
case(3) do(
set npc direction(curNpc, right)
set npc frame(curNpc, 0)
)
case(4) do(
set npc direction(curNpc, right)
set npc frame(curNpc, 1)
)
case(5) do(
set npc direction(curNpc, down)
set npc frame(curNpc, 0)
)
case(6) do(
set npc direction(curNpc, down)
set npc frame(curNpc, 1)
)
case(7) do(
set npc direction(curNpc, left)
set npc frame(curNpc, 0)
)
case(8) do(
set npc direction(curNpc, left)
set npc frame(curNpc, 1)
)
)

curFrame := curFrame + 1

if (curFrame >> 8) then(
curFrame := 1
curNpcId := curNpcId + 1
)
)
)
end

To use this script, you must first break your larger picture down into a series of NPCs (which are 20 x 20 slices of your graphic). Then, place the slices in order going from left to right. For example, if you have a large image that is 60 X 40 pixels, that is equivalent to two rows of 3 NPCs. So, slice your image up into 6 20 x 20 images, import them as NPC images, and line them up from left to right on any walkabout graphic. If you have more slices than places to put them on a single walkabout graphic line, just go to the next one, still moving from left to right. The drawBigPicture script will compensate for this.

When you have your image imported, you can call drawBigScript to display it. The arguments are, in order, the X starting position (in tiles), the Y starting position (in tiles), the width (in tiles), the height (in tiles), and finally the NPC id that contains the actual image. So, if I point NPC id 3 to the walkabout set containing my large image, which is 3 tiles by 2 tiles large, I can draw it at tile 14,9 on the map by calling drawBigPicture like so: drawBigPicture(14, 9, 3, 2, 3). If your graphic takes up more than 1 NPC, just set the next NPC id to the next walkabout picture set.

If you want to remove this picture, you'll need to destroy each NPC on the screen with the appropriate id. This can be done easily like so:

while(NPC copy count(pictureId) >> 0) do(destroy npc(pictureId))
while(NPC copy count(pictureId+1) >> 0) do(destroy npc(pictureId+1))
#repeat for every row of walkabout pictures you use for your large image

Remember to set the NPCs to the appropriate walkabout set in the map that calls this function! Just importing the graphic won't be enough.