Disabling and enabling map layers with plotscripting?

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

sheamkennedy wrote:Thanks for sharing!

This also just lead me to another idea I had awhile back regarding faking transparencies. I was just thinking, what would happen if I used this code to make a foreground map layer flicker on, and off at a specified rate (example. every tick). I presume it would make it appear that the tiles on that layer would be 50% transparent. Now what if I made the map tiles on that layer look like clouds. This should make it appear as if my character is semi-visible while passing below these clouds. It could make for a nice effect, but I fear it may also slow down the game immensely depending on the size of the map.

I have seen people do rain-like effects in their games without noticeable slow downs though, so I could be wrong. I'll have to give it a try, but unfortunately don't have time at the moment.
It'd work, but as James mentioned it'd be really jarring visually and coupled with OHRRPGCE's relatively low framerate it'd look pretty bad.

An alternative would be to overlay some crosshatch/checkerboard pixels over the walkabout/NPC layer. I did an experiment with this by having animated maptiles with crosshatched pixels that toggle in an alternating pattern every 1 tick. Honestly, it didn't look very good. I think it might be feasible if OHRRPGCE's framerate gets increased down the line though, because the flickeriness would be greatly reduced.
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 »

Bob the Hamster wrote:Actually, I think toggling the visibility of a map layer every tick would have no noticeable slowdown.

it might be seizure inducing, but it won't slow you down :)
Excellent! I'm not seizure prone but in the case that I do use implement this technique in my game, I'll be sure to warn players beforehand.
⊕ 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
BMR
Metal King Slime
Posts: 3310
Joined: Mon Feb 27, 2012 2:46 pm
Location: The Philippines
Contact:

Post by BMR »

sheamkennedy wrote: I'll be sure to warn players beforehand.
And perhaps with an option to turn it off for people who do find it seizure-inducing.
Being from the third world, I reserve the right to speak in the third person.

Using Editor version wip 20170527 gfx_sdl+fb music_sdl
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 »

BMR wrote:
sheamkennedy wrote: I'll be sure to warn players beforehand.
And perhaps with an option to turn it off for people who do find it seizure-inducing.
Haha, well I guess that wouldn't be a difficult option to add.
⊕ 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
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

I gave my idea a try... No slow down in the game, but definitely sore on the eyes. 1 tick is just too long of a gap between turning on and off the map layer. If it were possible, I'd say about 1/16 to 1/4 of a tick would be a better delay.

Though I must say it did look like a pretty trippy effect so maybe I'll think of a better use for it.
⊕ 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
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

I did some updates on this, and here's a more complex test of the cutaway system I'll be using:

https://www.dropbox.com/s/gk0au59a6x6j5 ... 2.zip?dl=0

I added an extra dithering/fog-of-war layer to obscure exterior areas while indoors. Also, I'm slowly and clumsily drawing real maptiles; feast your eyes.

Here's the updated .hss script, feel free to use it, include it, make edits however you see fit:

Code: Select all

#***********************
#* Cutaway view toggle *
#***********************

# Use the following layers in this order:
#	- Map layer 0: base background
#	- Map layer 1: exterior view background
#	- Walkabout/NPC layer
#	- Map layer 2: interior view foreground
#	- Map layer 3: exterior view foreground
#	- Map Layer 4: interior view dithering/fog-of-war

#	Then, place a step-on NPC with 'hide exterior' at the first step going into a building,
#	and 'show exterior' at the first step going outside a building (e.g. the doorstep)

#	Also, disable Map Layers 2 & 4 in the map editor if the map starts in an exterior view area.
#	This prevents the interior foreground layer from being shown on top of the exterior background layer
#	before the hide/show scripts get a chance to display the proper layers.

include, plotscr.hsd


plotscript, hide exterior, begin
	set slice visible(lookup slice(sl:map layer1), off) #-Turns off the exterior background layer
	set slice visible(lookup slice(sl:map layer3), off) #-Turns off the exterior foreground layer
	set slice visible(lookup slice(sl:map layer2), on)	#-Turns on the interior foreground layer
	set slice visible(lookup slice(sl:map layer4), on)	#-Turns on the dithering/FOW layer
end

plotscript, show exterior, begin
	set slice visible(lookup slice(sl:map layer1), on)	#-Turns on the exterior background layer
	set slice visible(lookup slice(sl:map layer3), on)	#-Turns on the exterior foreground layer
	set slice visible(lookup slice(sl:map layer2), off)	#-Turns off the interior foreground layer
	set slice visible(lookup slice(sl:map layer4), off)	#-Turns off the dithering/FOW layer

end
User avatar
Bob the Hamster
Liquid Metal King Slime
Posts: 7460
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

That looks good! The exterior fog is a nice touch.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Thanks James!

Also, if anyone wants to add the script to the example scripts on the main site, feel free.
Post Reply