Page 1 of 1

[SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 12:55 am
by Lark
What is that annoying throbbing? What are those pulsing blue lights along the edges of that room? Why are all of those monsters frozen solid in cages? Well, welcome to Lark's Cryogenic Chamber script! It's something I wondered if I could do and I'm actually pretty satisfied with the results.

How to Use the Cryogenic Chamber:
SpoilerShow
Place the script in a single square. Put walls and one or more doors around it to contain the monster. At least one door is required. Optionally place a monster in the chamber, let the script spawn a random monster, or specify the monster the script is to spawn. Pick options like items that might be added to the monster, can the chamber be restarted, and etcetera. Select the holding cell (described later), add your own buttons or whatever to activate, deactivate, or toggle chamber operation, and you're done!
What you will see:
SpoilerShow
The monster will be mobile, flapping wings, rotating, or staring at you. A whine, intense blue light will shine, frost will spew from the ceiling, and ***BAM***, your monster is frozen in place... maybe forever! The chamber pulses with blue light, and fog descends from the ceiling due to the cold. The constant throbbing of refrigeration is ever present and usually not in sync with other independent chambers that may be close by.
Image
Image

Revival is also fun. The blue light fades, a red one come on brightly, sizzling is heard quickly followed by a column of flames descending from the ceiling and then ice explodes off of the previously trapped monster as the door opens! Now it's time for a fight!
Image
Image
Image
Features:
SpoilerShow
  • Place your own occupant, or let the script do it.
  • Specify the level of your monster in the script if it is defining the occupant.
  • Allow the chamber to randomly be empty.
  • Add items to your monster, which are preserved, or let the script randomly add objects you define.
  • Specify a holding cell for your monster (explained still further below).
  • Fracture the creature when revived with ice flying everywhere, or select a more demure thawing.
  • Optionally prohibit the chamber from being reactivated.
  • If it can be restarted, specify an optional delay which much pass before restarting can occur.
  • If delayed starting is selected, decide if failed restart attempts reset the restart timer or not.
  • Optional delay startup a few seconds for a more graphically pleasing startup, or go for faster!
  • Optional have the script place an activating pressure plate in the chamber itself. [DO NOT place one manually in the chamber - it won't work right!]
  • The script discovers all doors which are opened when the chamber is deactivated.
  • As indicated above, I think the graphics and sounds for activating and deactivating are quite nice.
  • Automatic chamber refreshing prevents those pesky, unwanted, accidental thaws.
  • Connect external triggers to the activate(), deactivate(), or toggle() methods to affect the chamber’s operation any way you like.

How it Works:
SpoilerShow
I discovered, on my elevator script, that you can't place some things in the game from scripts and have them look right. Therefore, you must define your own doors, pressure plates (other than a hidden one in the chamber itself), and etcetera. I recommend a drainage tile in the bottom of the chamber, but it’s optional. The script executed, finds all of the doors, installs an option pressure plate in the chamber itself for reactivation (don't do this yourself - use the script!!!) delays a short period of time so that multiple chambers in the same area won't cycle at exactly the same time, and then it triggers the startup sequence.

Startup makes sure the doors are closed, checks to see if the chamber is resetting or if it can actually start, and looks for a monster already inside. If none is found, the script will spawn the one you specified in the options, a random one, or none at all. If appropriate, items will be randomly added to the monster you already put in the chamber or the one the script created. The monster is further inspected to ensure that no groups are present. It simply won't do (for technical and story reasons) to try to freeze a group. You should see why later....

The single occupant is trapped, and now the magic begins. The graphics and sounds start playing and the original monster is whisked away to a holding cell. This can be a hidden one by one cell or a large room or hallway as long as enough X blockers are around to keep the monster from moving. A doppelganger or substitute monster, just like the original, is created in its place and it's hit with a modified spell that does little damage, but 100% freezes the occupant.

Graphics cycle every few seconds, the chamber throbs, and the system is stable, but refreshed every 10 minutes because I've had a few monsters thaw on their own before the freeze duration should have expired. The refresh process destroys the doppelganger in the chamber, creates another just like it, and freezes the monster again. This repeats as long as the chamber is active.

When the chamber is deactivated, the graphics start, the doppelganger is hit with 9999 points of physical and cold damage thus shattering it into those really nice ice fragments that fly everywhere then quickly melt. Any objects the doppelganger drops are destroyed and, in this instant, the original monster is transported back in the empty void - so fast that you can't see it happen. This is done for two main reasons. 1) If you free, then refreeze a monster, its hit points will be the same (unless healing occurs while it's outside of the chamber? It could happen I guess.) 2) Perhaps more importantly, the monster will be carrying exactly what it was before - no more and no less. Short of destroying a monster and seeing what it drops, there is no way to tell what a monster is carrying. I did this in earlier versions, but duplicate shields, spears, and etcetera kept happening for various reasons. This is cleaner and developed when I still thought I'd support groups.

The original monster is back in place, the graphics wind down, and the doors open. There are some nice puzzles I think can be developed in waiting or luring a monster into a chamber and having it automatically activated by that hidden pressure plate the script spawns or by actions on your party's part. You know, a monster so far above the party that killing it simply isn't an option. I've done a few...

I don't support groups for several reasons. 1) Story line wise, you always get one person in a cryogenic chamber, not two or more. Heck, what's going to happen on Stargate Universe!? They were one chamber short in the end, you know. 2) You can't spawn a party of three skeletons limiting revival graphics. 3) You can't add items to groups. 4) Groups are sometimes a single monster to start with, but entity wise, they eventually turn into discrete monsters that occupy a single square - i.e. no longer a group, but 4 separate monsters.

Well, I have a couple of movies to post, but the resolution is too high, so I'll post them later. This post is already too long, sorry!
What you Need and Download:
SpoilerShow
  • Download the Cryogenics Chamber.zip file at https://ntg.missouristate.edu/images/la ... hamber.zip
  • It contains the CryogenicChamber.lua script, definitions needed for sounds, objects, spells, etcetera, and the sounds of course.
  • Put the definitions somewhere so that Grimrock will pick them up. Adjust sound volumes here to suit you.
  • Put the .wav files in your sound directory
  • Drop the script into an appropriately created chamber.
  • Set the options as documented above and more completely in the script.
  • Enjoy!
Please let me know what you think and if you use it anywhere. :)

Thanks, -Lark

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 1:07 am
by Neikun
*jaw on floor*
*floor on a million miles away*
That is a brilliant idea!
Looks fantastic.

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 1:32 am
by Grimwold
Completely awesome work

(and I see now why you needed to check what a monster was carrying).


EDIT - the script doesn't seem to know that gratings can be used as doors.. it complains that I have no door.

[RE-EDIT @ 23:52] - I really like how it starts to activate and then stops if the party enters the cryo chamber... (oh there's a default cooldown timer of 15 seconds on chamber activation!)

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 3:34 am
by Lark
Neikun wrote:*jaw on floor*
*floor on a million miles away*
That is a brilliant idea!
Looks fantastic.
Thank you! That's the best reaction I could have ever hoped for! I hope you find it useful.
Grimwold wrote:Completely awesome work

(and I see now why you needed to check what a monster was carrying).

EDIT - the script doesn't seem to know that gratings can be used as doors.. it complains that I have no door.

[RE-EDIT @ 23:52] - I really like how it starts to activate and then stops if the party enters the cryo chamber... (oh there's a default cooldown timer of 15 seconds on chamber activation!)
Thank you! I really like writing scripts that people find useful. And yes, this is why I wondered if you’d solved the problem of what monsters were carrying. You can see that I used the holding cell method ultimately instead of destroying monsters to see what they were carrying. Also, the chamber will false start if the party enters, a group enters, or a single monster enters before the cooldown timer has expired. Party, groups, and premature freezing aren't supported! :)

Regarding missing doors, the line of code doors = findAll(self.level, self.x, self.y, {"door"}, "any", true, false, true) on line 422 of version 1.0 (the only one so far) finds doors. Note that {"door"} is a table with one element, if you want it to find gratings as doors too (an oversight on my part) change the table to {"door", "grating"} and that will allow doors and gratings. The full line is: doors = findAll(self.level, self.x, self.y, {"door", "grating"}, "any", true, false, true). I’ve not tried it with ice lizards, but they don’t freeze so they’ll probably just remain animated. I'll update the zip file with the door fix tomorrow.

Thank you! -Lark

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 11:26 am
by Grimwold
Cool. thanks for the tip regarding the door/grating.

One other thing that came to mind.. would it be possible to add a variable that says whether to fully activate when the party enters.. be handy for a puzzle where the party needs to go through the cryo chamber to trap a monster that's following.

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 3:38 pm
by Lark
I've updated the zip file with the changes above so that gratings will also be found as doors.
Grimwold wrote:Cool. thanks for the tip regarding the door/grating.

One other thing that came to mind.. would it be possible to add a variable that says whether to fully activate when the party enters.. be handy for a puzzle where the party needs to go through the cryo chamber to trap a monster that's following.
I thought about supporting freezing the party for up to a given amount of time (before millions of years pass and they die) so you could set there and hope that snail would eventually wander onto that pressure plate linked to the deactivate() function. I actually started the code when I realized that, much to my dismay, my cryogenic spell won't freeze the party! Figure out how to freeze the party and I'll add this. I agree: it would make for a nice puzzle.

If you just want to "fully activate" by doing everything else except freezing the party, that's easy. It would work the same way as if you trapped an ice lizard - trapped, running, but not frozen. It would be inconsistent with not activating for groups, however.

As it is, if you have a cryogenic chamber in a hallway (i.e. two doors), you can walk in, get delayed slightly due to the "false startup", walk on, and the monster following will get trapped - provided the cool-down timer has expired. That's where having an activate() attempt reset the cool-down timer is "fun" (a.k.a. "annoying") because the monster will just keep following you. How do you trick them into the chamber without resetting the timer?

Thanks, -Lark

Re: [SCRIPT] Cryogenic Chamber

Posted: Fri Nov 02, 2012 3:59 pm
by cromcrom
All this looks amazing and cool, very nice :-)

Re: [SCRIPT] Cryogenic Chamber

Posted: Mon Nov 05, 2012 10:38 am
by ZeroAlligator
Thanks for sharing this code Lark, I was going crazy trying to figure out how to script a timer without having to place and call a timer within the editor; your solution is perfect, and your code is nice and clean. Well done.

-Mark