Bob and Lynda
=============
I was thinking about writing another behind the scenes post, and thought that people might find how modes work interesting. We had some issues a while back with the Bob and Lynda mode, so why not dig into that can of worms again eh? The post below does get a bit detailed but hopefully there's some interesting bits in there.
---
First of all a bit of a recap of the Bob and Lynda shots:
- Initially the triple drop bank pops up, lit pink, and you have to knock them down
- Then the three standups on either side of the left and middle ramps are lit, hit either side of a ramp to light it
- Light and hit each ramp to finish the mode and start the hurry up at the hedges
- *IF* the middle ramp is lit, the crossing shot is lit as an optional shot. If the hurryup starts, this shot can collect it.
In the past, the crossing shot was not optional, and it was a pretty tough mode.
---
And that's how it was working, and everything was fine... when it was the only thing running. But going up that middle ramp also started other things, and it was starting these other modes at the same time and how they were stacking that caused lots of headaches for players (and programmers).
So first let's talk a bit more about pinball modes and how they work from a programming perspective.
In pinball most people normally use the term "mode" to talk about big chunks of a game, for Halloween that might be "Bob and Lynda", or a wizard mode like "Boogeyman" or a multiball like "House". But actually while a ball is on the playfield (and sometimes before or after that too), there are lots of modes running. Some of them are still quite similar to those big modes, for example "skillshot" which starts at the start of a ball and ends when the player either gets the skillshot or hits something else that counts as a miss. And other modes can be tiny, like "slings" which just plays a noise if the slings are hit and awards some points, that's it. A significant chunk of the game code is in modes - there's lots of them, and they run constantly - in Halloween there are more than 60 modes, and each one packages up a chunk of functionality. It's a good way to keep the logic organized.
If you ever think about programming your own game, a good place to start is the Mission Pinball Framework (MPF) which uses modes and events in the same way, they have some great documentation including this page on modes: https://missionpinball.org/game_design/mode_layering/
Running lots of modes isn't a problem in itself - at least not from the CPU's point of view - it can run hundreds at the same time without skipping a beat. But on a pinball machine you can (will?) run into issues with modes sharing or trying to control the same resources, like the screen, lights, or physical mechs such as diverters or drop targets. You have to make sure that things work on their own but also that they all work when all combinations of two or three or five other things are also running at the same time.
.
And this is where it can get complicated.
.
In Halloween, you can be running "House Attack" (the qualifying stage of House Multiball) at the same time as "Bob and Lynda" and there's a few bits of hardware they share:
- the screen: they both want to run videos when you achieve a certain thing, and some videos are more "important" *cough* than others.
- the diverter at the top of the middle ramp: most of the time this sends the ball left and back to the left flipper, but House mode tells it to divert to the right after three middle ramps, so the ball goes to the upper (House) playfield. It also starts left for Bob, but switches right once that ramp shot opens up. And then of course, it has to go back left when both of the modes end (assuming nothing else still wants it diverting right).
- the upper drop target in front of the crossing shot: if knocked down early in House this damages Laurie and pops back up. If enough spins have been hit and Michael's health is zero, it's purple and will stay down, opening up the crossing shot to start the multiball. In Bob it can be knocked down immediately and should NOT be lit red.
- the crossover shot + release: each mode monitors when a ball makes it over and controls when it is released (normally after a video has played).
There's another interesting thing about running lots of modes - you have to say what order they should run in. And running first isn't always best, things might get overridden later. Running last isn't always ideal either, and sometimes you kinda want a mode to run both first AND last - which is a real pain. You also want to keep the logic of each mode packaged up within that mode, but there are times when one mode needs to know what state another mode is in. In this example House needs to be aware that Bob will be playing the crossing shot video and not play the normal House one. There's lots of these little things.
---
So now we've got these two modes, Bob and House (actually Sanitarium's Easy setting uses all this stuff too, but lets keep this readable), and they can be running together or separately...
...and we've got problems.
Here's some highlights =)
- balls stuck on the crossover magnet until ball search releases them. Because House didn't know Bob had let it over but apparently it's not Bob's responsibility to release it.
- some drop target reset coils aren't quite as quick as others and you can sneak a quick ball over there - who releases it in this case?
- wrong videos playing at the crossover shot.
- wrong audio playing at the crossover shot if the wrong video played on top of the other one
- multiball starting but no MB jackpots showing on the playfield
- closing the diverter when Bob finished, so now you can't get back up to the upper playfield for House
Where to start?
First we re-analyzed each part of the process and redefined what should happen. This meant taking the basic rules we went through at the start and going into deep detail.
Here's some notes from House mode's crossover shot after we'd gone over it:
- if just this mode running, MB not started, DO: get points and show vid, start MB
- if just this mode running, MB started, DO: score super jackpot
- Bob running, house MB NOT qualified, DO: bob stuff, no house stuff except lights
- Bob running, house MB qualified, DO: bob stuff, DON'T show house vid, do start MB
- Bob running, house MB running too, DO: bob stuff, do get jackpot
We look at the logic and see if we can make it any clearer in the code. Sometimes you can take some code out of a few places and bring it in to one place, we did that with the diverter - now it has its own mode and is working great.
Sometimes the rules need tweaking too. We wanted to make Bob and Lynda slightly easier, but we wanted to keep that crossover shot. So making it optional seemed the best of all worlds. This didn't really make the code any simpler (!) as it really just added another combination, but it does make the gameplay better, and hitting it to collect the hurry-up is a real pinball moment - super satisfying.
---
And so there we have it, modes everywhere, all the time. Generally all working together nicely.
We keep adding new ones, some you won't notice, but some you definitely will =) and speaking of, I should get back to a couple of them now, thanks for reading!