You can change the z-value of any sprite with the following code:
# Change the z-value to 100
sprite_object.z = 100
Of course, the difficult part is to actually get the sprite-object.
Add the following code in a new script:
class Spriteset_Map
attr_reader :character_sprites, :picture_sprites
end
class Scene_Map
attr_reader :spriteset
end
This enables you to gain outside access to the character-sprites (event- and playersprites)
After that you should be able gain access to the sprite via:
$scene.spriteset.character_sprites[id].z = 100
# Picture
$scene.spriteset.picture_sprites[id].z = 100
Note that this only works during the map, should be done via the Script-command. The id should be the event-ID on the current map (so 1 will get you the sprite of the event with the ID 1). The player-sprite is the last object in that array and can be easily accesed using -1 as the id.
Higher Z-Values means "nearer" to the player. The map-tiles start at value 0, i'm not enterily sure how the priority and layer is handled, this is a bit more complex. Beware, that if you change the z-value the handling of priority with the tilemap can become obsolet or a problem.
Hope this helps.