Spoiler:Real Elevators is no longer available on the ZDoom Forums. Thank you.
One of the quality of life things I've always wanted: elevators that would move like the real thing; in other words, they accelerate when they start to move and decelerate when they near their destination.
Ok...that's not that tall an order is it? ... ... ... ... Yes and no.
Anyway, introducing Real Elevators(v0.3.2), a tiny code library that does just what I've always wanted in a nice neat package!So, how it works: there's more under the hood than this, but the only functions - yes functions - users need to know about are MoveElevator and MoveElevatorObject. This functions are called from a script that should be activated by the player, as shown below.
- * Real Elevators is a modder's resource. This code does nothing on its own.
A script using MoveElevator might look like this: the script is called from another which is flagged as an ENTER script, thus the player is the activator of this elevator script, which also handles level transition effects.Code: Select all
/* This function is called from implementation scripts to move an elevator. It is assumed that it is a player that is the script activator. Args: ElevatorId, int, this is the sector id of the elevator control sector(s). SkipAccel, bool, if true the elevator will begin moving at full speed but can still decelerate. SkipDecel, bool, if true the elevator will move to its final position at full speed. TotalDist, int, how far the elevator will move; positive values move up, negative move down. MaxSpeed, int, the maximum speed the elevator will move at. AccelDist, int, how much of the Total Distance will be used for accelerating AND decelerating; this value is effectively doubled. MoveStartBias, int, this value increases or decreases the rate of acceleration for the first half of acceleration; positive increase, negative decrease. MoveEndBias, int, this value increases or decreases the rate of deceleration for the last half of deceleration; positive increase, negative decrease. JustFloor, bool, if true only the floor of the given sector will be moved; this is for regular lifts and not 3D floor elevators! */ function void MoveElevator (int ElevatorId, bool SkipAccel, bool SkipDecel, int TotalDist, int MaxSpeed, int AccelDist, int MoveStartBias, int MoveEndBias, bool JustFloor) { // . . . stuff that none of us ever have to do again to make an elevator accelerate or decelerate :P }
Using MoveElevatorObject is Even Simpler!Code: Select all
//Starting Location/Level Selection Elevator script "LEVELELEVATORSTART" (void) { SetPlayerProperty(0, 1, PROP_TOTALLYFROZEN); FadeTo(24, 24, 24, 1.0, 0.0); Thing_Move(0, 1043, 1); MoveElevator(3000, true, false, -212, 15, 96, 0, 1, false); delay(15); SetPlayerProperty(0, 0, PROP_TOTALLYFROZEN); FadeTo(24, 24, 24, 0.0, 0.5); }
- The function only has 2 arguments: The TID of the object(s) to move, and the ID of a reference floor.
- The reference floor is thought of as "below" the objects, and should be part of the elevator.
- MoveElevatorObject should be called in tandem with MoveElevator.
Features:Code: Select all
function void MoveElevatorObject (int ObjectID, int SectorID) { ACS_NamedExecuteAlways("ElevatorObjectMove", 0, ObjectID, SectorID); }
Download:
- This library should be multiplayer friendly, allowing up to 8 players to be activating and riding elevators at any given time.
- I originally designed this around elevators made from 3D floors, but I've also tweaked the code to include regular lifts as well.
- Objects, such as light sources, can be moved through a second function that can be called in tandem. (v0.3.2)
Most Recent Version:Old Versions:
- RealElevators_0-3-2.pk3
Usage:
- RealElevators_0-3-1.pk3
- RealElevators_0-3.pk3
- RealElevators_0-2.pk3
Updates:
- Load the package you downloaded with ZDL or equivalent.
- Mod authors are free to do with this as they please, especially integrate into their own stuff, I just ask for credit, thanks!
- Pretty sure this is done and I won't be updating it any time soon. I'm already using this code in my own stuff and I added multiplayer and regular lifts for the public release, so it seems pretty feature complete to me. Please let me know if you have any problems or suggestions!
- v0.3! - well I thought I was done but then I had another thought: what if someone wants the elevator to not decelerate? Like what if you want to "break" an elevator mid-transit? It doesn't make sense that it should necessarily come to a nice gradual halt. So deceleration skipping is now a feature. This does mean that the MoveElevator function has received an additional argument.
- v0.3.1! - found a small bug that broke multiplayer, I should be using ACS_NamedExecuteAlways to call the ElevatorMove script.
- v0.3.2! - Moving objects that should be attached to the elevator is now possible!
All of my mods can be found on my GitHub.