Freeform Shutters
Description
This script allows you to place shutters manually on the screen wherever you want. No longer are you constricted to the door combo sets that place your doors at the center edge of your screen. These shutters will act like Z1 shutters - they'll push you into the screen and close behind you. They require no FFCs to set up - in fact, once the (extremely simple) combos are set up, all you need to do is put the shutter down and place a combo flag that determines the type of shutter. This script includes the following shutter types:
- One-way shutters
- Shutters that open after killing all enemies in the room
- Shutters that open when temporary secrets (or tiered secrets) are triggered
- Shutters that open after the permanent secret screen flag is set
- Shutters that require another script to open
Screenshots and Demo
Download the Demo
The demo will give you an idea of how it all works. Note that I've included an additional simple script in the demo to demonstrate shutters that are controlled by script. In the game, pressing both A and B at the same time will open "script shutters." Probably not the best use of the script shutters, but hopefully it conveys the possibilities. Be sure to look at the combo setup - I placed the shutter in favorite combos, so you can quickly scroll to it. It's simple - shutters always work in pairs: closed shutter, then open shutter.
Code
It's big, so download the code here.
Setup
I'll divide this section into four parts: setting up the script, setting up combos, placing the combos on the screen, and advanced shutters.
Script Setup
First, save the code above into a new text file called shutterControl.z.
Next, if you don't have any scripts at all this is simple. Just save the following as a new file and compile it in ZQuest:
Then assign the script to "Active" under Global. You're done, and can move on to part 2!
If you already have some scripts, then in your main script, just below any other imported files, add the line
import "shutterControl.z"
Next, in your global script, you should have an infinite loop. At the end of the infinite loop, just before waitFrame(), add the following lines:
shutterControl(); updatePrev();
Your global script should now look something like this. If you don't have a global script, you can go ahead and just take this one:
Combo Setup
Set up your combos so that each closed-shutter combo is followed by an open-shutter combo. This is the case even for multiple-combo shutters - each closed combo in the shutter needs to be directly followed by an open shutter combo. See the screenshot above to see exactly what I mean.
The only other requirement is to select combo type "Script 1" for the closed shutter combos. Open shutter combos can be anything else or nothing at all - just not "Script 1."
Screen Placement
If you just place the shutters anywhere on the edges of the screen now, they'll work perfectly as enemy shutters. You can also place them away from the edge of the screen, but you need to place shutter "Script 1" combos from the edge where Link will enter the screen up through the shutters. See the demo for an example.
If you want different functionality, place combo flags on every shutter combo you want to change as follows:
- Temporary Secrets open shutters: Combo Flag 98 (General Purpose 1)
- Permanent Secret Screen State opens shutters: Combo Flag 99 (General Purpose 2)
- One-Way Shutters: Combo Flag 100 (General Purpose 3)
- Separate Script opens shutters: Combo Flag 101 (General Purpose 3)
Advanced Shutters
Not really too advanced, but you can create shutters that open via other scripts. Each time you enter a room, the global bool "shutterFlag" is set to false. if any other script changes this variable to true, the "script shutters" - i.e., the shutters with combo flag 101 placed on them - will open. Note that this isn't permanent - each time you enter the room, the shutter will close.
Resources
Nothing that doesn't come bundled with ZC.
Acknowledgements
I want to thank LinktheMaster and Nick for their help on this project. LinktheMaster was patient with my billions of questions about ZScript throughout the entire writing process of the script. That's billions, with a 'b'. I was about two-thirds of the way through the script before I realized Nick had already done something very similar - his advice throughout was also extremely helpful. Thanks!