Changing Map Layers

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Changing Map Layers

Post by Willy Elektrix »

Hey folks! I haven't been around much, but I've been diligently working on my game. I've got a cool idea for a feature, but I'm not sure how to implement it. Maybe you can help?

I want to create an elevated bridge on one of my maps. The player can walk under the bridge (and it is an overhead layer), but also walk across the bridge (and it stops being an overhead layer).

I initially though that I would use an on step command that moved the tile layer. However, after examining the plotscripting dictionary, I don't see a command to do that. What am I missing?

As always, thanks for your help!
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

There's actually 2 commands for this

write pass block (x,y,value)

with the value of 128 for overhead and 0 for not overhead

or

write map block (x,y,value,layer)
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

There's actually a constant, "overheadtile", for the overhead tile wallmap bit instead of using 128.

Writing to the wallmap was originally the only way to create a bridge you could walk under and over. (When map layers were added, writing to the tilemap became a second option.) Now you can swap the order of map layers too, but you can't change which map layer a hero/npc walkabout appears on (although it's much requested).

I think there's still no good option for creating bridges like that, and although it's something I wish the engine did support straightfowardly, I can't even think of how to implement that.
Last edited by TMC on Fri Dec 28, 2018 4:04 pm, edited 2 times in total.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

A simple solution (maybe) might be to use a slice to represent the bridge, and another slice to represent the checking range of the bridge.
When the player is in the appropriate range, it moves the slice above and
below the player and writes the bridge tile(s) as passable or impassable on the respective sides.

You might use zones rather than a slice to check if player is in range.

I frankly hate every implementation of bridges to the point that I avoid using bridges altogether in my games. Much like some other people around here.
It's really complicated if you want to factor in
- being able to reach NPCs from "top" of the bridge and vice-versa
- multiple pathing NPCs that have to use or consider the bridge
- multiple bridges overlapping

You could probably accomplish this with just 1 NPC (I think) by checking which direction the hero is facing it from. Or you could have 4 NPCs on one spot facing different directions and check if they're facing the hero :P
I hate (the idea of) running out of NPC definitions though.
You don't really need to use NPCs at all, instead looking at the current tile, direction, and maybe zones.

In all honesty though, Foxley's or Bird's script will probably do adequately for anyone's purposes.
And really, trying to figure out how to make your game without using any bridges is probably feasible and won't drive you TOO insane!


rambling thoughts and ideas
- special layer(s) for bridge? probably not
- sorting NPC slice and bridge slice to appear on top of each other?
- multiple NPC layers? haaaaaaa
- special tiles akin to one-way tiles? that perhaps move an NPC above or below the bridge?
- maybe we could consider special multi-tile nodes? such as the route through a bridge
- maybe define special nodes or areas with e.g., zones or slices?

relative node values could vary by NPC, current node, adjacent nodes. etc.,
- for example, pathing cost values such as A, B, C, D which are used for relative cost rather than absolute cost

e.g generic pairs which are mutually impassable to each other.
- example. making it so that a node with value A considers any adjacent node B impassable from there.

could be used to create unique pathing maps for each NPC
you could use modifiers for NPCs to use, which interpret the pathing values, maybe combined with an actual pathing value.

could be used to separate out or combine complicated bridges, like 2 bridges directly adjacent but distinct. you might need to define their relationships on an individual basis
Last edited by SwordPlay on Fri Dec 28, 2018 10:03 pm, edited 18 times in total.
"Imagination. Life is your creation."
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

Maybe a different solution without map layers. This uses an NPC and a script to get a bridge.

Select "Walkabout Layering: NPCs over Heroes" at the General Map Data of your map.
Also select "Save Anywhere: NO", because if you would save it on the bridge and load it afterwards, the height level of the hero might change.

The bridge is drawn on the tilemap as a maptile, but also placed at the same place as a step-on-NPC (in this example NPC #0 at position X=12 and Y=2). In the picture you can see four NPC #1 in the four directions of the bridge. These NPC #1 are activated by stepping on them and cast the following script:

Code: Select all

plotscript,bridge,begin
if (hero X == 12) 
  then (write pass block (12,2,10)
        delete NPC (0)
	    create NPC (0,12,2,left))
if (hero Y == 2) 
  then (write pass block (12,2,5)
        if (NPC X (0) == 12) then (delete NPC (0)))
end
At first, this script checks the position of the hero. Depending on that, the walls of the bridge maptile will be checked.

If we are in a vertical line (X=12) to the bridge (meaning that we are on the lower part of the cliff), the bridge-NPC will be created at our bridge spot. If we walk towards it, we will be below the bridge, as NPCs are drawn above heroes.

If we are in a horizontal line (Y=2) to the bridge (meaning that we are on the upper part of the cliff), the script checks, if there is an existing bridge-NPC there at its position (in this example X=12). It that is true, the bridge-NPC must be deleted. As no NPC is there anymore, there is just the maptile of the bridge left. If we walk now towards it, the hero will be above the bridge, as heros would walk above maptiles.

This plotscript works with both ways, with or without the bridge-NPC being placed on the map in the map editor.[/code]
Attachments
Bridge Example
Bridge Example
Bridge.gif (4.87 KiB) Viewed 2595 times
Last edited by Bird on Fri Dec 28, 2018 7:31 pm, edited 1 time in total.
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

Thanks for these replies. I'm going to experiment with some of these ideas today. I'll let you know if I can make them work.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

I'd go for the "write map block" command. There are no NPCs travelling on or under the bridge and I know that method to be pretty easy.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

Spoonweaver wrote:There's actually 2 commands for this

write pass block (x,y,value)

with the value of 128 for overhead and 0 for not overhead

or

write map block (x,y,value,layer)
This worked for me. It's a very simple solution, especially since there are no random battles in this game. Thanks!
User avatar
Spoonweaver
Liquid Metal King Slime
Posts: 6461
Joined: Mon Dec 08, 2008 7:07 am
Contact:

Post by Spoonweaver »

Glad to help
Post Reply