It was determined that a certain modding project in the Keen community would benefit greatly from the ability to have each switch do multiple things, specifically enabling a blinking arrow (toward the next part of a confusing level) in addition to performing its normal job. Fortunately, this is a source-modding project, so such changes are certainly possible. Seeing a chance to improve my C-writing skills, I volunteered to implement the feature.
I decided that the simplest way to do it was to move the existing switch-flipping "effect" logic into its own method and call that in a for loop from the entry switch-flipping function. The for loop decreases the Y coordinate, moving up in the level, until a non-switch tile is encountered. Practically speaking, the change causes all switches above a flipped switch to also flip. It has the added bonus of not breaking any existing switches. Players are unable to flip a switch at the top of a stack because there is no ground from which to flip them on.
That method was all good when there was room for extra switch tiles in the foreground above the switch that needs to do multiple things. I realized that many switches are in narrow/short corridors where there is an important foreground tile already above the switch. So, I made a special infoplane value that identifies a switch as a multiple-effect switch. When such a switch is flipped, infoplane values are checked in a similar upward fashion, but the foreground tile below them doesn't matter. In this mode, the type of every action (foreground/bridge or infoplane/platform) is determined by the type of the original switch rather than the type of the switch at each position.
The code change request was accepted, and the feature was implemented with my code, which will appear in the mod's source alongside the final compiled release.
No comments:
Post a Comment