FYI, I have a working script for Flip Flop, but the backglass itself has an issue - the score reels for player 3 and 4 are both set in the B2S Editor for player 3.
Once that is addressed, this script should work for the table:
' Flip Flop -- Bally, 1974
' Release 1.0, 22 December 2001
' Design: Jim Patla
' Art: Dick White
' Script: Ash ([email protected])
' Table: Ash
'
' Special thanks to Randy Davis, author of VP...
'
' Also thanks to all the table authors (credited and not) from whom I
' lifted and modified code from!
'
option explicit
Const GameTitle = "FlipFlop"
Const MaxPlayers = 4
Const ShinyBall = "ballimage8"
'Variables common to most tables
dim playerScore(4)
dim highScore
dim gameInProgress
dim credits
dim bonus
dim bonusTotal
dim ballInPlay
dim numberOfBalls
dim currentPlayer
dim numberOfPlayers
dim highScoreToDate
dim highScoreDisplayed
dim samePlayerShootsAgain
dim score 'Object that handles scoring duties
dim freeGame(3,4) 'Score required for a free game (0 = no award)
dim tilt 'Object that handles tilt-related stuff
dim ballOut 'Whether the ball is on the play field
dim newGame 'Whether this is a new game
dim extraBallActive 'Whether extra ball targets are active
dim specialActive 'Whether special lights are active
dim tiltDisabled 'Deactivate Tilt keys until Tilt cleared
dim gameStart 'Control for scoring reel reset
dim resetCount 'Control for scoring reel reset
dim demoCount
dim scoreLanesActive
dim specialScored
dim extraBallScored
dim Trumpet
dim Special, made1, made2, made3
Dim x, i, j, k
Dim NudgeZone
Dim HiScore
' Extra game - specials
Const goal1 = 70999
Const goal2 = 113999
Const goal3 = 146999
'Arrays for controls that are array-esque
dim gameInfo(6)
'Variable specific to this table
Const DoNewBall = "NewBall"
Const DoAddCredits = "AddCredits"
dim LightBonus(10)
set LightBonus(1) = LightBonus1
set LightBonus(2) = LightBonus2
set LightBonus(3) = LightBonus3
set LightBonus(4) = LightBonus4
set LightBonus(5) = LightBonus5
set LightBonus(6) = LightBonus6
set LightBonus(7) = LightBonus7
set LightBonus(8) = LightBonus8
set LightBonus(9) = LightBonus9
set LightBonus(10) = LightBonus10
dim LightMisc(10)
set LightMisc(1) = LightLeftSpecial
set LightMisc(2) = LightRightSpecial
set LightMisc(3) = LightLeftInlane
set LightMisc(4) = LightRightInlane
set LightMisc(5) = LightExtraBallRight
set LightMisc(6) = LightExtraBallLeft
set LightMisc(7) = LightShootAgain
set LightMisc(8) = LightBonusX2
set LightMisc(9) = LightLeftOutlane
set LightMisc(10) = LightRightOutlane
dim LightPlayer(4)
set LightPlayer(1) = LightPlayer1
set LightPlayer(2) = LightPlayer2
set LightPlayer(3) = LightPlayer3
set LightPlayer(4) = LightPlayer4
dim ScoreDigit(4,4)
set ScoreDigit(1,1) = ScoreD1P1
set ScoreDigit(2,1) = ScoreD2P1
set ScoreDigit(3,1) = ScoreD3P1
set ScoreDigit(4,1) = ScoreD4P1
set ScoreDigit(1,2) = ScoreD1P2
set ScoreDigit(2,2) = ScoreD2P2
set ScoreDigit(3,2) = ScoreD3P2
set ScoreDigit(4,2) = ScoreD4P2
set ScoreDigit(1,3) = ScoreD1P3
set ScoreDigit(2,3) = ScoreD2P3
set ScoreDigit(3,3) = ScoreD3P3
set ScoreDigit(4,3) = ScoreD4P3
set ScoreDigit(1,4) = ScoreD1P4
set ScoreDigit(2,4) = ScoreD2P4
set ScoreDigit(3,4) = ScoreD3P4
set ScoreDigit(4,4) = ScoreD4P4
Dim Scores(4)
Dim FiveKFlag
ExecuteGlobal GetTextFile("core.vbs")
ExecuteGlobal GetTextFile("b2s.vbs")
Dim Controller
Sub LoadController()
Set Controller = CreateObject("B2S.Server")
Controller.B2SName = "FlipFlop" ' *****!!!!This must match the name of your directb2s file!!!!
Controller.Run()
End Sub
'****** General table stuff
Sub TableFlipFlop_Init()
LoadController
made1 = True : made2 = True : made3 = True
dim i,n
Randomize
credits = 0
numberOfPlayers = 0
resetCount = 0
for i = 1 to MaxPlayers
playerScore(i) = 0
next
gameInProgress = false
TextBoxMatch.Text = ""
controller.b2ssetData 34,0
gameStart = true
numberOfBalls = 5
set score = new ScoringThing
set tilt = new TiltOMatic
'Set defaults for stored info
for i = 1 to 6
gameInfo(i) = 0
next
controller.b2ssetData 35,1
TextBoxGame.Text = "GAME"
TextBoxOver.Text = "OVER"
controller.b2ssetData 35,1
TextBoxBall.Text = ""
TextBoxMatch.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
LoadHighScore
TextBoxHigh.text = highScore
DisplayHS
TextBoxCredits.text = credits
controller.b2ssetCredits credits
for n = 1 to 4
currentPlayer = n
DisplayScore
next
currentPlayer = 1
DemoTimer.enabled = true
BonusTimer.enabled = false
Flip1.IsDropped = true
Flop1.IsDropped = false
Flip2.IsDropped = true
Flop2.IsDropped = false
Flip3.IsDropped = true
Flop3.IsDropped = false
Flip4.IsDropped = true
Flop4.IsDropped = false
Trumpet = 0
made1 = False : made2 = False : made3 = False
End Sub
Sub TableFlipFlop_KeyUp(ByVal keycode)
If keycode = PlungerKey Then
Plunger.Fire
if ballOut then
PlaySound "PlungeRel"
else
PlaySound "PlungeRel"
end if
End If
if gameInProgress and not tilt.IsTilted then
If keycode = LeftFlipperKey Then
LeftFlipper.RotateToStart
LeftTopFlipper.RotateToStart
PlaySound "FlipperUp"
End If
If keycode = RightFlipperKey Then
if tilt.IsTilted then Exit Sub
RightFlipper.RotateToStart
RightTopFlipper.RotateToStart
PlaySound "FlipperUp"
End If
end if
If Keycode=9 Then Advancebonus
End Sub
Sub TableFlipFlop_KeyDown(ByVal keycode)
If keycode = PlungerKey Then
Plunger.PullBack
PlaySound "PlungePull"
End If
If gameInProgress and not tilt.IsTilted Then
If keycode = LeftFlipperKey Then
LeftFlipper.RotateToEnd
LeftTopFlipper.RotateToEnd
PlaySound "FlipperDown"
End If
If keycode = RightFlipperKey Then
RightFlipper.RotateToEnd
RightTopFlipper.RotateToEnd
PlaySound "FlipperDown"
End If
If keycode = LeftTiltKey Then
if tiltDisabled = 0 then
If NudgeZone=True Then
Nudge 90, 1.15
Else
Nudge 90, 0.6
End If
tilt.Tilt LeftTiltKey
end if
End If
If keycode = RightTiltKey Then
if tiltDisabled = 0 then
If NudgeZone=True Then
Nudge 270, 1.15
Else
Nudge 270, 0.6
End If
tilt.Tilt RightTiltKey
end if
End If
If keycode = CenterTiltKey Then
if tiltDisabled = 0 then
If NudgeZone=True Then
Nudge 180, 1.25
Else
Nudge 180, 0.8
End If
tilt.Tilt CenterTiltKey
end if
End If
End If
if keycode = 2 then '1
AddPlayer
End If
if keycode = 19 then 'R
DisplayRuleSheet
End If
if keycode = 6 then '5
InsertCoin keycode - 5
end if
End Sub
Sub Plunger_Init()
BumperRight.State = LightStateOn
BumperLeft.State = LightStateOn
End Sub
'****** Scoring of playfield elements
Sub Trigger1_Hit()
NudgeZone=False
End Sub
Sub Trigger1_UnHit()
NudgeZone=True
End Sub
Sub LeftSlingshotBounce_Slingshot()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 10, 10, 10, "Slingshot", "LeftSlingshot"
End Sub
Sub RightSlingshotBounce_Slingshot()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 10, 10, 10, "Slingshot", "RightSlingshot"
End Sub
Sub LeftBumperSlingshot_Slingshot()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 10, 10, 10, "Slingshot", "LeftBumperSlingshot"
End Sub
Sub RightBumperSlingshot_Slingshot()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 10, 10, 10, "Slingshot", "RightBumperSlingshot"
End Sub
Sub BumperLeft_Hit()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 100, 100, 10, "Bumper", "BumperLeft"
End Sub
Sub BumperRight_Hit()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 100, 100, 10, "Bumper", "BumperTop"
End Sub
Sub TriggerBallRoll_Hit()
PlaySound "BallRoll"
End Sub
Sub TriggerBallRoll1_Hit()
PlaySound "ballrolling"
End Sub
Sub TriggerRightInlane_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if LightRightInlane.State = LightStateOn then
score.AddScore currentPlayer, 5000, 5000, 10, "Bonus", "TriggerRightInlane"
else
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerRightInlane"
End if
End Sub
Sub R31_Hit()
Playsound "rubberQ"
End Sub
Sub R32_Hit()
Playsound "rubberQ"
End Sub
Sub Wall500_Hit()
Playsound "rubberQ"
End Sub
Sub Wall504_Hit()
Playsound "rubberQ"
End Sub
Sub Wall501_Hit()
Playsound "rubberQ"
End Sub
Sub Wall502_Hit()
Playsound "rubberQ"
End Sub
Sub Wall503_Hit()
Playsound "rubberQ"
End Sub
Sub Wall61_Hit()
Playsound "rubberQ"
End Sub
Sub Wall73_Hit()
Playsound "rubberQ"
End Sub
Sub Wall96_Hit()
Playsound "rubberQ"
End Sub
Sub Wall97_Hit()
Playsound "rubberQ"
End Sub
Sub Wall98_Hit()
Playsound "rubberQ"
End Sub
Sub Wall99_Hit()
Playsound "rubberQ"
End Sub
Sub Ramp1210_Hit()
Playsound "rubberQ"
End Sub
Sub Ramp2126_Hit()
Playsound "rubberQ"
End Sub
Sub Wall12_Hit()
Playsound "rubberQ"
End Sub
Sub Wall56_Hit()
Playsound "rubberQ"
End Sub
Sub Wall458_Hit()
Playsound "rubberQ"
End Sub
Sub Wall202_Hit()
Playsound "rubberQ"
End Sub
Sub Wall163_Hit()
Playsound "rubberQ"
End Sub
Sub Wall2_Hit()
Playsound "metalping"
End Sub
Sub Wall3_Hit()
Playsound "metalping"
End Sub
Sub Wall4_Hit()
Playsound "metalping"
End Sub
Sub Wall30_Hit()
Playsound "metalping"
End Sub
Sub Wall998_Hit()
Playsound "Side"
End Sub
Sub Wall997_Hit()
Playsound "Side"
End Sub
Sub TriggerLeftInlane_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if LightLeftInlane.State = LightStateOn then
score.AddScore currentPlayer, 5000, 5000, 10, "Bonus", "TriggerLeftInlane"
else
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerLeftInlane"
end if
End Sub
Sub TriggerRightOutlane_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if LightRightOutlane.State = LightStateOn then
score.AddScore currentPlayer, 5000, 5000, 10, "Bonus", "TriggerRightInlane"
else
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerRightInlane"
end if
End Sub
Sub TriggerLeftOutlane_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if LightLeftOutlane.State = LightStateOn then
score.AddScore currentPlayer, 5000, 5000, 10, "Bonus", "TriggerLeftInlane"
else
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerLeftInlane"
end if
End Sub
Sub SaucerLeft_Hit()
if tilt.IsTilted then
SaucerRight.kick 225,5
SaucerLeft.kick 135,5
Playsound "Saucer"
Exit Sub
End If
if LightExtraBallLeft.State = LightStateOn then
LightShootAgain.State = LightStateOn
controller.b2ssetData 36,1
LightExtraBallLeft.State = LightStateOff
samePlayerShootsAgain = true
extraBallActive = false
extraBallScored = true
end if
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "SaucerLeft"
SaucerTimer.enabled = true
End Sub
Sub SaucerRight_Hit()
if tilt.IsTilted then
SaucerRight.kick 225,5
SaucerLeft.kick 135,5
Playsound "Saucer"
Exit Sub
End If
if LightExtraBallRight.State = LightStateOn then
LightShootAgain.State = LightStateOn
controller.b2ssetData 36,1
LightExtraBallRight.State = LightStateOff
samePlayerShootsAgain = true
extraBallActive = false
extraBallScored = true
end if
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "SaucerRight"
SaucerTimer.enabled = true
End Sub
Sub TargetFlip1_Hit()
if tilt.IsTilted then Exit Sub
if Flip1.IsDropped = true then
Flip1.IsDropped = false
Flop1.IsDropped = true
PlaySound "Flip"
AdvanceBonus
CheckTargets
end if
End Sub
Sub TargetFlip2_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip2.IsDropped = true then
Flip2.IsDropped = false
Flop2.IsDropped = true
PlaySound "Flip"
AdvanceBonus
CheckTargets
end if
End Sub
Sub TargetFlip3_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip3.IsDropped = true then
Flip3.IsDropped = false
Flop3.IsDropped = true
PlaySound "Flip"
AdvanceBonus
CheckTargets
end if
End Sub
Sub TargetFlip4_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip4.IsDropped = true then
Flip4.IsDropped = false
Flop4.IsDropped = true
PlaySound "Flip"
AdvanceBonus
CheckTargets
end if
End Sub
Sub TriggerFlip1_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip1.IsDropped = true then
Flip1.IsDropped = false
Flop1.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlip2_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip2.IsDropped = true then
Flip2.IsDropped = false
Flop2.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlip3_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip3.IsDropped = true then
Flip3.IsDropped = false
Flop3.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlip4_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip4.IsDropped = true then
Flip4.IsDropped = false
Flop4.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlop1_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip1.IsDropped = true then
Flop1.IsDropped = false
Flip1.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlop2_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip2.IsDropped = true then
Flop2.IsDropped = false
Flip2.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlop3_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip3.IsDropped = true then
Flop3.IsDropped = false
Flip3.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerFlop4_Hit()
PlaySound "TargetSound"
if tilt.IsTilted then Exit Sub
if Flip4.IsDropped = true then
Flop4.IsDropped = false
Flip4.IsDropped = true
PlaySound "Flip"
CheckTargets
end if
End Sub
Sub TriggerRightSpecial_Hit()
if tilt.IsTilted then Exit Sub
if LightRightSpecial.State = LightStateOn then
AddSpecial
LightRightSpecial.State =LightStateOff
end if
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerRightSpecial"
End Sub
Sub TriggerLeftSpecial_Hit()
if tilt.IsTilted then Exit Sub
if LightLeftSpecial.State = LightStateOn then
AddSpecial
LightLeftSpecial.State = LightStateOff
end if
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerLeftSpecial"
End Sub
Sub TriggerBottomRight_Hit()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerBottomRight"
End Sub
Sub TriggerBottomLeft_Hit()
if tilt.IsTilted then Exit Sub
score.AddScore currentPlayer, 500, 500, 10, "Trigger", "TriggerBottomLeft"
End Sub
Sub BumperResetLeft_Hit()
PlaySound "rubberQ"
if LightResetLeft.State = LightStateOn then
ResetTargets
AdvanceBonus
AdvanceBonus
AdvanceBonus
AdvanceBonus
CheckTargets
end if
End Sub
Sub BumperResetRight_Hit()
PlaySound "rubberQ"
if LightResetRight.State = LightStateOn then
ResetTargets
AdvanceBonus
AdvanceBonus
AdvanceBonus
AdvanceBonus
CheckTargets
end if
End Sub
Sub SaucerTimer_Timer()
SaucerRight.kick 225,5
SaucerLeft.kick 135,5
Playsound "Saucer"
SaucerTimer.enabled = false
End Sub
Sub SwitchLights
if scoreLanesActive then
if LightLeftOutlane.State = LightStateOn then
LightLeftOutlane.State = LightStateOff
LightLeftInlane.State = LightStateOff
LightExtraBallLeft.State = LightStateOff
LightRightOutlane.State = LightStateOn
LightRightInlane.State = LightStateOn
if not extraBallScored then
LightExtraBallRight.State = LightStateOn
end if
else
LightLeftOutlane.State = LightStateOn
LightLeftInlane.State = LightStateOn
LightExtraBallLeft.State = LightStateOn
LightRightOutlane.State = LightStateOff
LightRightInlane.State = LightStateOff
if not extraBallScored then
LightExtraBallRight.State = LightStateOff
end if
end if
end if
End Sub
Sub ResetTargets
Flip1.IsDropped = true
Flop1.IsDropped = false
Flip2.IsDropped = true
Flop2.IsDropped = false
Flip3.IsDropped = true
Flop3.IsDropped = false
Flip4.IsDropped = true
Flop4.IsDropped = false
PlaySound "Reset"
LightResetLeft.State = LightStateOff
LightResetRight.State = LightStateOff
End Sub
Sub CheckTargets
dim i
i = 0
if Flip1.IsDropped = false then
i = i + 1
end if
if Flip2.IsDropped = false then
i = i + 1
end if
if Flip3.IsDropped = false then
i = i + 1
end if
if Flip4.IsDropped = false then
i = i + 1
end if
if i = 4 then
LightResetRight.State = LightStateOn
LightResetLeft.State = LightStateOn
end if
End Sub
'****** Here we deal with the bonus counter and its ramifications
sub AdvanceBonus
'Add 1000 to the bonus
if bonus < 19000 then
DoBonusLight bonus, LightStateOff
bonus = bonus + 1000
DoBonusLight bonus,LightStateOn
end if
if bonus > 11000 then
SwitchLights
end if
if bonus = 11000 then
scoreLanesActive = true
extraBallActive = true
LightLeftOutlane.State = LightStateOn
LightLeftInlane.State = LightStateOn
LightExtraBallLeft.State = LightStateOn
end if
if bonus = 19000 and not specialActive then
specialActive = true
LightRightSpecial.State = LightStateOn
end if
if specialActive and not specialScored then
if LightLeftSpecial.State = LightStateOn then
LightLeftSpecial.State = LightStateOff
LightRightSpecial.State = LightStateOn
else
LightRightSpecial.State = LightStateOff
LightLeftSpecial.State = LightStateOn
end if
end if
end sub
sub DoBonusLight(score, newState)
'Change the state of the indicated bonus light
dim ones
ones = (score mod 10000) / 1000
if ones <> 0 then LightBonus(ones).State = newState
if score >= 10000 then
LightBonus10.State = newState
end if
end sub
sub CollectBonus
'Starts bonus collection
bonusTotal = bonus
BonusTimer.enabled = true
end sub
sub BonusTimer_Timer()
'Adds a bonus amount for every timer tick, and stop when we hit 0
'Wait for other scoring events to finish
if not score.IsScoring() then
if bonus = 0 then
BonusTimer.enabled = false
NextPlayer
else
if LightBonusX2.State = LightStateOn then
score.AddScore currentPlayer, 2000, 1000, 200, "DoubleBonus", "Bonus"
else
score.AddScore currentPlayer, 1000, 1000, 10, "Bonus", "Bonus"
end if
DoBonusLight bonus, LightStateOff
bonus = bonus - 1000
DoBonusLight bonus, LightStateOn
end if
end if
end sub
'****** Credits and coin things
Sub InsertCoin(coinslot)
'Handles credits added/coin and bookkeeping
dim creditsGiven, coinsRequired, skipCoinReset
PlaySound "CoinInsert"
creditsGiven = 1
skipCoinReset = false
coinsRequired = 1
'Return coin if we're at the maximum
if credits + creditsGiven > 9 then
PlaySound "CoinReject"
Exit Sub
end if
'Give 'em the credits
score.DoThisWhenDone DoAddCredits, 1200, "", creditsGiven
PlaySound "CoinCredit"
gameInfo(coinslot + 3) = gameInfo(coinslot + 3) + 1
if tilt.IsTilted then
AddCredit(1)
end if
End Sub
Sub AddCredit(addCredits)
'Add a credit
credits = credits + addCredits
if credits > 9 then credits = 9
TextBoxCredits.Text = credits
controller.b2ssetCredits credits
End Sub
sub AddSpecial()
'Award of a free game
PlaySound "Special"
AddCredit 1
specialScored = true
end sub
'****** Subs to start the game and keep it moving along
Sub AddPlayer
'Adds a player to the game if there are credits, space enough, and
'this is still the first ball. Otherwise, starts a new game.
if not gameInProgress then numberOfPlayers = 0
if credits > 0 and numberOfPlayers < 1 and gameStart then
resetCount = 0
TextBoxBall.text = 1
controller.b2ssetData 32,1
TextBox1.Text = 1
controller.b2ssetData 31,1
PlaySound "StartGame"
GameStartTimer.enabled = true
end if
DemoTimer.enabled = false
TextBoxDemo.text="Table by Humid & Ash"
if credits > 0 and numberOfPlayers < MaxPlayers then
AddCredit -1
gameInfo(1) = gameInfo(1) + 1
If gameInProgress and ballInPlay = 1 then
numberOfPlayers = numberOfPlayers + 1
if numberOfPlayers > 1 then
TextBox2.Text = 2
controller.b2ssetData 31,2
end if
if numberOfPlayers > 2 then
TextBox3.Text = 3
controller.b2ssetData 31,3
end if
if numberOfPlayers > 3 then
TextBox4.Text = 4
controller.b2ssetData 31,4
end if
else
newGame = true
StartGame
numberOfPlayers = 1
ballInPlay = 1
TextBoxBall.text = 1
controller.b2ssetData 32,1
NextPlayer
end if
end if
End Sub
Sub StartGame
'Resets the game for play
dim i, j, k
made1 = False : made2 = False : made3 = False
for i = 1 to MaxPlayers
playerScore(i) = 0
next
gameInProgress = true
tiltDisabled = 1
currentPlayer = 0
TextBoxGame.Text = ""
TextBoxOver.Text = ""
controller.b2ssetData 35,0
TextBoxMatch.Text = ""
controller.b2ssetData 34,0
specialActive = false
extraBallActive = false
scoreLanesActive = false
ResetTargets
End Sub
sub NewBall
'Starts a new ball
dim i
score.ClearHasScored
score.StartScoring
tilt.ClearTilt
for i = 1 to 10
LightBonus(i).State = LightStateOff
next
for i = 1 to 10
LightMisc(i).State = LightStateOff
next
controller.b2ssetData 36,0
ResetTargets
'StartGame sound includes new ball sound
if not newGame then
PlaySound "NewBall"
score.DoThisWhenDone DoNewBall, 600, "", 0
end if
if ballinPlay = 3 or ballInPlay = numberOfBalls then
LightBonusX2.State = LightStateOn
else
LightBonusX2.State = LightStateOff
end if
newGame = false
specialActive = false
extraBallActive = false
samePlayerShootsAgain = false
specialScored = false
extraBallScored = false
bonus = 1000
DoBonusLight bonus,LightStateOn
end sub
sub NextPlayer
'Moves on to the next player, and handles same player shoots again.
'Also checks for end of game.
if currentPlayer > 0 then
LightPlayer(currentPlayer).State = LightStateOff
controller.b2ssetData 30,0
End If
if not samePlayerShootsAgain then
currentPlayer = currentPlayer + 1
else
LightShootAgain.State = LightStateOff
controller.b2ssetData 36,0
end if
if currentPlayer > numberOfPlayers then
ballInPlay = ballInPlay + 1
currentPlayer = 1
end if
if ballInPlay > numberOfBalls then
GameOver
else
TextBoxBall.Text = ballInPlay
controller.b2ssetData 32,ballinPlay
LightPlayer(currentPlayer).State = LightStateOn
controller.b2ssetData 30,currentPlayer
NewBall
end if
end sub
Sub EnableTable(enable)
'Enables or disables the bumpers, usually when tilted
End Sub
sub GameStartTimer_Timer
' ResetB2SData 24,27,0 'Rollover lights off
'StepB2SData 0, 23, 0, 2, 200, ""
' if resetCount = 9 then
gameStart = false
score.DoThisWhenDone DoNewBall, 1600, "", 0
for i = 1 to 4
freeGame(1,i) = 0
freeGame(2,i) = 0
freeGame(3,i) = 0
Scores(i)=0
Controller.B2SSetScorePlayer i,0
next
currentPlayer = 1
GameStartTimer.enabled = false
'end if
end sub
Sub Drain_Hit()
'Begins the end of play cycle
PlaySound "Drain"
Drain.DestroyBall
tiltDisabled = 1
'Bug (v1.0) -- if gameInProgress == false, then the player
'has restarted the game
if not gameInProgress then
GameOver
AddPlayer
elseif tilt.IsTilted then
NextPlayer
elseif score.HasScored() then
CollectBonus
else
samePlayerShootsAgain = true
NextPlayer
end if
End Sub
sub GameOver()
'Game over, man! Does all the end of game stuff.
dim i
for i = 1 to 10
LightBonus(i).State = LightStateOff
next
for i = 1 to 10
LightMisc(i).State = LightStateOff
next
controller.b2ssetData 36,0
LeftFlipper.RotateToStart
LeftTopFlipper.RotateToStart
RightFlipper.RotateToStart
RightTopFlipper.RotateToStart
gameInProgress = false
gameStart = true
Match
TextBoxGame.Text = "GAME"
TextBoxOver.Text = "OVER"
controller.b2ssetData 35,1
TextBoxBall.Text = ""
controller.b2ssetData 32,0
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
controller.b2ssetData 31,0
PlaySound "EndGame"
for i = 1 to numberOfPlayers
if playerScore(i) > highScore then
highScore = playerScore(i)
TextBoxHigh.text = highScore
DisplayHS
end if
next
SaveHighScore
DemoTimer.enabled = true
end sub
Sub Match()
'Matches last two digits of score for free game.
dim matchNumber, i
matchNumber = int(rnd(1)*10)*10
TextBoxMatch.Text = ""
' If matchNumber = 0 then
' TextBoxMatch.Text = "00"
' Else
TextBoxMatch.Text = matchNumber
If matchNumber =0 then
controller.b2ssetData 34,10
else
controller.b2ssetData 34,matchNumber
end if
' End If
For i = 1 to numberOfPlayers
If matchNumber = (playerScore(i) Mod 100) then AddSpecial
Next
End Sub
Sub DisplayScore
dim tempScore,digit,i,j
tempScore = playerScore(currentPlayer) '- (int(playerScore(currentPlayer) / 100000) * 100000)
Controller.B2SSetScorePlayer currentPlayer,tempScore
for j = 1 to 3
if playerScore(currentPlayer) > freeGame(j,currentPlayer) and freeGame(j,currentPlayer) <> 0 then
AddSpecial
freeGame(j,currentPlayer) = 0
end if
next
End Sub
'***** ScoringThing
Const MaxQueueSize = 100
Const ScorePause = -100001
Const ScoreDoSomething = -100002
Class ScoringThing
'ST encapsulates a lot of scoring issues. It is not a very pure object
'because it references things on the table directly (like certain lights
'and the score text). To try and keep things as object oriented as possible,
'I've isolated outside influences at the end of the class.
dim players() 'Player number of this scoring item
dim points() 'Point value of this scoring item, say 500
dim steps() '# of steps, so we can score 500 in 100 point chunks
dim intervals() 'Time between each step
dim obj() 'Object that made the request, for later reference
dim soundName() 'Noise scoring event will make
dim playSoundOnce() 'Whether the sound is played once or each time
dim name() 'Name of playfield element that scored this
dim queueStart 'Scores are held in a standard fifo queue
dim queueEnd
dim scored 'A flag, so we can track 0 point balls
dim acceptNewScores 'Usually true, set to false when tilted
Private Sub Class_Initialize
redim players(MaxQueueSize), points(MaxQueueSize), steps(MaxQueueSize)
redim intervals(MaxQueueSize), obj(MaxQueueSize), soundName(MaxQueueSize)
redim playSoundOnce(MaxQueueSize), name(MaxQueueSize)
queueStart = 0
queueEnd = 0
scored = false
acceptNewScores = true
StopTimer
End Sub
Public Sub AddScore(player, value, step, time, sound, elementName)
'Adds a scoring element to the queue.
'Repeating sounds must come in with "+" as the first character.
If not acceptNewScores then Exit Sub
If (queueEnd + 1) Mod MaxQueueSize = queueStart Then
MsgBox "Score queue filled!"
Else
name(queueEnd) = elementName
players(queueEnd) = player
points(queueEnd) = value
steps(queueEnd) = step
intervals(queueEnd) = time
playSoundOnce(queueEnd) = (Left(sound, 1) <> "+")
if playSoundOnce(queueEnd) then
soundName(queueEnd) = sound
else
soundName(queueEnd) = Mid(sound, 2)
end if
If Not IsScoring() Then StartTimer time
queueEnd = (queueEnd + 1) Mod MaxQueueSize
scored = true
End If
End Sub
Public Sub AddPause(time)
'Pause for dramatic effect
AddScore 0, ScorePause, 0, time, "Pause"
End Sub
Public Sub DoThisWhenDone(whatToDo, time, sound, value)
'For kickers that want scoring to finish before they kick out
obj(queueEnd) = whatToDo
AddScore 0, ScoreDoSomething, value, time, sound, "Action"
End Sub
Public Sub TimeToScore()
'It's time to score! Called by the score timer and does score
'interval, then moves to next score in the queue if this interval
'is finished.
if not acceptNewScores then exit sub
If points(queueStart) > 0 Then
AddToScore
checkspecials
points(queueStart) = points(queueStart) - steps(queueStart)
End If
if points(queueStart) = ScoreDoSomething then
DoIt
End If
If points(queueStart) <= 0 Then
queueStart = (queueStart + 1) Mod MaxQueueSize
If queueStart <> queueEnd Then
StartTimer intervals(queueStart)
Else
StopTimer
End If
End If
End Sub
Public Sub ClearHasScored()
'Usually at the start of a ball
scored = false
End Sub
Public Function HasScored()
HasScored = scored
End Function
Public Sub StartScoring
'Reset after every ball
acceptNewScores = true
End Sub
Public Sub StopScoring
'Usually done after a tilt
acceptNewScores = false
End Sub
Public Sub ClearScoreQueue
'Also a tilt thing, makes sure the tilter loses all their points,
'the rapscallion.
StopTimer
queueStart = 0
queueEnd = 0
End Sub
Public Function NameInQueue(elementName)
'Looks to see if the element is already in the queue, usually to
'avoid scoring things twice
dim i, done
NameInQueue = false
done = false
i = queueStart
while not done
if queueStart = queueEnd then
done = true
else
if name(i) = elementName then
NameInQueue = true
done = true
end if
end if
i = (i + 1) mod MaxQueueSize
wend
End Function
'****** Here we have the code that is defiled by references to things
' outside the class.
Private Sub StartTimer(time)
'Starts the scoring timer
ScoreTimer.Interval = time
ScoreTimer.Enabled = True
End Sub
Private Sub StopTimer()
'Stops the timer, usually after all the queued up scoring is done
ScoreTimer.Enabled = False
End Sub
Public Function IsScoring()
IsScoring = ScoreTimer.Enabled
End Function
Private Sub AddToScore()
'Adds the point value to the players score, plays any sounds,
'updates the score text field, and checks for point specials
playerScore(players(queueStart)) = playerScore(players(queueStart)) + steps(queueStart)
if soundName(queueStart) <> "" then
PlaySound soundName(queueStart)
if playSoundOnce(queueStart) then soundName(queueStart) = ""
end if
DisplayScore
End Sub
Private Sub DoIt()
'Handles things that need to be done after a scoring event is
'complete.
if soundName(queueStart) <> "" then PlaySound soundName(queueStart)
select case obj(queueStart)
case DoNewBall
KickerNewBall.CreateBall'.Image = ShinyBall
KickerNewBall.kick 60,5
tiltDisabled = 0
PlaySound "PlungeBall"
ballOut = false
case DoAddCredits
AddCredit steps(queueStart)
end select
End Sub
End Class
Sub ScoreTimer_Timer()
score.TimeToScore
End Sub
'****** Tilt handler
Class TiltOMatic
'Embodies everything there is to know about tilting. It sort of tries
'to emulate the action of the tilt pendulum. We're ignoring the ball
'on the track tilt because it's hard to simulate differently than the
'way tilting is done now, and the slam switch because there's no way
'to hit the coin box in VP (yet).
'Like ScoringThing, this isn't a pure class because it references
'stuff outside the class. Sorry, OOP fans.
dim tilted 'Boolean whether we have tilted or not
dim tiltValue 'Int value... when it exceeds threshold, machine tilts
dim tiltThreshold 'Read from the options file
dim lastTiltSource 'Where the last tilt came from
dim bumperForce(4) 'Saves the forces of the 4 bumpers
Private Sub Class_Initialize
tilted = false
tiltValue = 0
tiltThreshold = 5
lastTiltSource = 0
End Sub
Public Sub Tilt(source)
'Handles tilt problems, gives extra emphasis to multiple tilts
'from the same source.
if source = lastTiltSource then
tiltValue = tiltValue + 2
else
tiltValue = tiltValue + 1
end if
lastTiltSource = source
if tiltValue > tiltThreshold then
'Do all the tilting stuff
PlaySound "Tilt"
TextBoxTilt.Text = "TILT"
controller.b2ssetData 33,1
tilted = true
LeftFlipper.RotateToStart
LeftTopFlipper.RotateToStart
RightFlipper.RotateToStart
RightTopFlipper.RotateToStart
score.ClearScoreQueue
score.StopScoring
EnableTable false
else
if not TiltTimer.Enabled then
TiltTimer.Enabled = true
TiltTimer.Interval = 2000
end if
end if
End Sub
Public Sub DampenSwing()
'The swing of the pendulum gets a little smaller
tiltValue = tiltValue - 1
lastTiltSource = 0
if tiltValue <= 0 then TiltTimer.Enabled = false
End Sub
Public Sub ClearTilt()
tiltValue = 0
tilted = false
lastTiltSource = 0
TextBoxTilt.Text = ""
controller.b2ssetData 33,0
EnableTable true
end sub
Public Function IsTilted()
IsTilted = tilted
end function
Public Function GetThreshold()
GetThreshold = tiltThreshold
end Function
Public Sub SetThreshold(number)
tiltThreshold = number
end sub
End Class
Sub TiltTimer_Timer()
tilt.DampenSwing
End Sub
Sub CheckSpecials
If playerScore(currentPlayer) > goal1 Then
If made1 = False Then
made1 = True
GetSpecial
End If
End If
If playerScore(currentPlayer) > goal2 Then
If made2 = False Then
made2 = True
GetSpecial
End If
End If
If playerScore(currentPlayer) > goal3 Then
If made3 = False Then
made3 = True
GetSpecial
End If
End If
End Sub
Sub GetSpecial
' add credits
PlaySound "Special"
AddCredit(1)
End Sub
Sub SaveHighScore
' Based on Black's Highscore routines
Dim FileObj
Dim ScoreFile
Set FileObj=CreateObject("Scripting.FileSystemObject")
If Not FileObj.FolderExists(UserDirectory) then
Exit Sub
End if
Set ScoreFile=FileObj.CreateTextFile(UserDirectory & "FlipFlop.txt",True)
ScoreFile.WriteLine credits
ScoreFile.WriteLine playerScore(1)
ScoreFile.WriteLine playerScore(2)
ScoreFile.WriteLine playerScore(3)
ScoreFile.WriteLine playerScore(4)
ScoreFile.WriteLine highScore
ScoreFile.Close
Set ScoreFile=Nothing
Set FileObj=Nothing
end sub
Sub LoadHighScore
' Based on Black's Highscore routines
dim n
Dim FileObj
Dim ScoreFile
Dim TextStr
dim temp1
dim temp2
dim temp3
dim temp4
dim temp5
dim temp6
Set FileObj=CreateObject("Scripting.FileSystemObject")
If Not FileObj.FolderExists(UserDirectory) then
Exit Sub
End if
If Not FileObj.FileExists(UserDirectory & "FlipFlop.txt") then
Exit Sub
End if
Set ScoreFile=FileObj.GetFile(UserDirectory & "FlipFlop.txt")
Set TextStr=ScoreFile.OpenAsTextStream(1,0)
If (TextStr.AtEndOfStream=True) then
Exit Sub
End if
temp1=TextStr.ReadLine
temp2=Textstr.ReadLine
temp3=Textstr.ReadLine
temp4=Textstr.ReadLine
temp5=Textstr.ReadLine
temp6=Textstr.ReadLine
TextStr.Close
credits = CDbl(temp1)
playerScore(1) = CDbl(temp2)
playerScore(2) = CDbl(temp3)
playerScore(3) = CDbl(temp4)
playerScore(4) = CDbl(temp5)
highScore = CDbl(temp6)
Set ScoreFile = Nothing
Set FileObj = Nothing
for n = 1 to 4
currentPlayer = n
DisplayScore
next
End Sub
Sub DemoTimer_timer 'from original code by Leon Spalding
demoCount = demoCount + 1
if demoCount = 1 then TextBoxDemo.text="Table by Humid & Ash"
if demoCount = 2 then TextBoxDemo.text="'R' Rule Sheet"
if demoCount = 3 then TextBoxDemo.text="Flip Flop (Bally 1974)"
if demoCount = 4 then TextBoxDemo.text="'5' Add Coin"
if demoCount = 5 then TextBoxDemo.text="'1' Adds Player"
if demoCount = 6 then TextBoxDemo.text="Thanx RipleYYY:scoring"
if demoCount = 7 then TextBoxDemo.text="Design: Jim Patla"
if demoCount = 8 then TextBoxDemo.text="Art: Dick White"
if demoCount = 8 then demoCount = 0
End Sub
sub DisplayRuleSheet()
' This displays a brief summary of the game rules.
dim t
t = "Upper 8 buttons activate (upper 4) and reset (lower 4) flips."
t = t+chr(13)&chr(13)
t = t&"Lower pop bumpers score 100 pts."
t = t+chr(13)&chr(13)
t = t&"Slingshots score 10 pts."
t = t+chr(13)&chr(13)
t = t&"Upper Skill Lanes score 500 pts and award Special when lit."
t = t+chr(13)&chr(13)
t = t&"Saucers score 500 pts and award Extra Ball when lit."
t = t+chr(13)&chr(13)
t = t&"Center target bank activates corresponding flip and advances"
t = t+chr(13)&"bonus by 1000."
t = t+chr(13)&chr(13)
t = t&"Inlanes & Outlanes lanes score 500 pts, 5000 when lit."
t = t+chr(13)&chr(13)
t = t&"Lower playfield rollover triggers score 500 pts."
t = t+chr(13)&chr(13)
t = t&"Yellow target bumpers reset flips & awards 4000 bonus when lit."
t = t+chr(13)&chr(13)
t = t&"Bonus value of 11000 activates Extra Ball lights and lower lane lights."
t = t+chr(13)&" Extra Ball (and lane) lights switch sides upon bonus advance."
t = t+chr(13)&" Extra Ball awards one ball. Limit one Extra Ball per ball in play."
t = t+chr(13)&chr(13)
t = t&"Bonus value of 19000 activates Special lights. Special awards one extra play."
t = t+chr(13)&"Limit of one special scored per ball."
t = t+chr(13)&chr(13)
t = t&"Tilt disqualfies ball in play."
t = t+chr(13)&chr(13)
t = t&"Match awards 1 credit."
msgBox t, vbOKonly, "Rules and Scoring"
End Sub
Sub DisplayHS()
Controller.B2SSetScorePlayer 5,highScore
End Sub
Sub b2sSplitScoreHS (Byval b2splayer, Byval b2sscorevalue)
Dim B2Ssplit
b2splayer=36
b2sscorevalue=b2sscorevalue-Int(b2sscorevalue/1000000)
B2Ssplit= Int(b2sscorevalue/100000):B2SData(b2splayer)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*100000)
B2Ssplit= Int(b2sscorevalue/10000):B2SData(b2splayer+1)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*10000)
B2Ssplit= Int(b2sscorevalue/1000):B2SData(b2splayer+2)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*1000)
B2Ssplit= Int(b2sscorevalue/100):B2SData(b2splayer+3)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*100)
B2Ssplit= Int(b2sscorevalue/10):B2SData(b2splayer+4)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*10)
controller.b2ssetData b2splayer+5,b2sscorevalue
End Sub
Sub b2sSplitScore (Byval b2splayer1, Byval b2sscorevalue)
Dim B2Ssplit
Dim b2splayer
b2splayer=(b2splayer1-1)*6
b2sscorevalue=b2sscorevalue-Int(b2sscorevalue/1000000)
B2Ssplit= Int(b2sscorevalue/100000):B2SData(b2splayer1+23)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*100000)
B2Ssplit= Int(b2sscorevalue/10000):B2SData(b2splayer+1)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*10000)
B2Ssplit= Int(b2sscorevalue/1000):B2SData(b2splayer+2)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*1000)
B2Ssplit= Int(b2sscorevalue/100):B2SData(b2splayer+3)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*100)
B2Ssplit= Int(b2sscorevalue/10):B2SData(b2splayer+4)=Chr(B2Ssplit+1):b2sscorevalue=b2sscorevalue-Int(B2Ssplit*10)
controller.b2ssetData b2splayer+5,b2sscorevalue
End Sub