The only way you could do it is if it was on layer x above the objects, and once in the area of the player, set it to layer y under him.
But it would still draw under the tree.
The only way I can see this happening is doing the method I just stated, but checking if the player is in the area of an object with a layer above his own.
PHP Code:
temp.new_layer = 3;
if (plane_x in |player.x, player.x+3| && plane_y in |player.y, player.y+4|)
{
temp.draw_over = false;
for(np:npcs)
{
if (np.layer > player.layer)
{
if (player.x+1.5 in |np.x, np.x+(getimgwidth(np.image)/16)| && player.y+2 in |np.y, np.y+(getimgheight(np.image)/16)|)
temp.draw_over = true;
}
}
if (!draw_over)
temp.new_layer = 0;
}
showimg(200, "plane.png", plane_x, plane_y).layer = new_layer;
I just wrote that up quickly in notepad. lol
But...you get my point.