Post new topic    
Metal Slime
Send private message
Changing Map Layers 
 PostFri Dec 28, 2018 3:21 am
Send private message Reply with quote
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!
Metal Slime
Send private message
 
 PostFri Dec 28, 2018 3:47 am
Send private message Reply with quote
I did this a while back:

https://www.slimesalad.com/forum/viewgame.php?p=130492
Liquid Metal King Slime
Send private message
 
 PostFri Dec 28, 2018 3:00 pm
Send private message Reply with quote
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)
Metal King Slime
Send private message
 
 PostFri Dec 28, 2018 4:03 pm
Send private message Reply with quote
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.
Chemical Slime
Send private message
 
 PostFri Dec 28, 2018 6:43 pm
Send private message Reply with quote
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
Slime Knight
Send private message
 
 PostFri Dec 28, 2018 7:29 pm
Send private message Reply with quote
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:
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]
Metal Slime
Send private message
 
 PostSun Dec 30, 2018 3:57 pm
Send private message Reply with quote
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.
Liquid Metal Slime
Send private message
 
 PostSun Dec 30, 2018 7:18 pm
Send private message Reply with quote
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
Metal Slime
Send private message
 
 PostSun Dec 30, 2018 9:32 pm
Send private message Reply with quote
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!
Liquid Metal King Slime
Send private message
 
 PostFri Jan 04, 2019 3:55 pm
Send private message Reply with quote
Glad to help
Display posts from previous: