Arngrim

O Brother

Sep 1st, 2021
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 139.30 KB | None | 0 0
  1. '****************************************************************
  2. '
  3. ' O Brother Where Art Thou (Zoss 2021)
  4. ' Game Design by Onevox
  5. ' Script by Scottacus
  6. ' Physics by Bord
  7. ' v1.0.2
  8. ' August 2021
  9. '
  10. ' Special thanks to Thalamus for beta testing and improving multiball, plus JFR1, mlager for testing,
  11. ' and post-release commenters to point out errors/improvements.
  12. '
  13. ' A tribute to the 2000 movie by the Coen Brothers and Touchstone Pictures, a brilliant allegorical comedy
  14. ' loosely based on Homer's Odyssey.
  15. '
  16. ' DOF config
  17. ' 101 Left Flipper, 102 Right Flipper
  18. ' 103 Left sling, 104 Right sling
  19. ' 105-107 Bumpers
  20. ' 108-109 Slingshot flashers
  21. ' 110-112 Bumper flashers
  22. ' 113 Drop Targets
  23. ' 406-407 Special Targets L/R
  24. ' 408-409 Center Targets L/R
  25. ' 410-413 Top Side Lane Rollovers L/R
  26. ' 414-415 Targets Mid L/R
  27. ' 417-420 Mid L/R
  28. ' 421-422 Out Lanes L/R
  29. ' 423-424 In Lanes L/R
  30. ' 425 Top Kicker
  31. ' 426 Drain, 425 Ball Release
  32. ' 427 Cedit Light
  33. ' 428 Knocker
  34. ' 429 Knocker and Kicker Strobe
  35. ' 430 Spinner1
  36. ' 431 Spinner2
  37. ' 450 Ball In Shooter Lane
  38. ' 441 Chime1-10s, 442 Chime2-100s, 443 Chime3-1000s
  39. '
  40. ' Code Flow
  41. ' EndGame
  42. ' ^
  43. ' Start Game -> New Game -> Check Continue -> Release Ball -> Drain -> Score Bouns -> Advance Player -> Next Ball
  44. ' ^ |
  45. ' EndGame = True <---------------------------------------------------------------
  46.  
  47. ' Ball Control Subroutine developed by: rothbauerw
  48. ' Press "c" during play to activate, the arrow keys control the ball
  49. '**********************************************************************************************************************
  50.  
  51. Option Explicit
  52. Randomize
  53.  
  54. On Error Resume Next
  55. ExecuteGlobal GetTextFile("controller.vbs")
  56. If Err Then MsgBox "Can't open controller.vbs"
  57. On Error Goto 0
  58.  
  59. Const cGameName = "OBWAT"
  60. Const cOptions = "OBWAT_2021.txt"
  61. Const HSFileName="O Brother Where Art Thou (Zoss 2021)"
  62.  
  63. '***************************************************************************************
  64. 'Set this variable to 1 to save a PinballY High Score file to your Tables Folder
  65. 'this will let the Pinball Y front end display the high scores when searching for tables
  66. '0 = No PinballY High Scores, 1 = Save PinballY High Scores
  67. Const cPinballY = 2
  68. '***************************************************************************************
  69.  
  70. Dim coloredBalls
  71. '***********************************Colored Balls**************************************************
  72. 'Comment the next line to make the game play with standard balls o/w BOT(0-2) = Green, Red, Blue
  73. coloredBalls = True
  74. '**************************************************************************************************
  75.  
  76. Dim balls
  77. Dim replays
  78. Dim maxPlayers
  79. Dim players
  80. Dim player
  81. Dim credit
  82. Dim score(6)
  83. Dim hScore(6)
  84. Dim sReel(4)
  85. Dim state
  86. Dim tilt
  87. Dim matchNumber
  88. Dim i,j, f, ii, Object, obj, Light, x, y, z
  89. Dim freePlay
  90. Dim ballsize,BallMass
  91. ballSize = 50
  92. ballMass = (Ballsize^3)/125000
  93. Dim BIP : BIP = 0
  94. Dim options
  95. Dim chime
  96. Dim onBumper
  97. Dim pfOption
  98. Dim musicOn
  99. Dim musicVolume
  100.  
  101.  
  102. 'Desktop reel pans, Valid values: "Lpan", "Mpan" and "Rpan"
  103. Const dtcrReel = "Rpan"
  104. Const dts1Reel = "Lpan"
  105. Const dts2Reel = "Rpan"
  106. Const dts3Reel = "Rpan"
  107. Const dts4Reel = "Rpan"
  108.  
  109. 'Backglass reel pans, Valid values: "Lpan", "Mpan" and "Rpan"
  110. Const bgcrReel = "Mpan"
  111. Const bgs1Reel = "Lpan"
  112. Const bgs2Reel = "Rpan"
  113. Const bgs3Reel = "Lpan"
  114. Const bgs4Reel = "Rpan"
  115.  
  116. Sub Table1_init
  117. LoadEM
  118. maxPlayers = 4
  119.  
  120. For x = 1 to maxPlayers
  121. Set sReel(x) = EVAL("scoreReel" & x)
  122. Next
  123.  
  124. Player=1
  125. LoadHighScore
  126.  
  127. ballsInPlay = 0
  128.  
  129. If highScore(0) = "" Then highScore(0) = 50000
  130. If highScore(1) = "" Then highScore(1) = 45000
  131. If highScore(2) = "" Then highScore(2) = 40000
  132. If highScore(3) = "" Then highScore(3) = 35000
  133. If HighScore(4) = "" Then highScore(4) = 30000
  134. If matchNumber = "" Then matchNumber = 4
  135. If ShowDT = True Then pfOption = 1
  136. If pfOption = "" Then pfOption = 1
  137. If initial(0,1) = "" Then
  138. initial(0,1) = 19: initial(0,2) = 5: initial(0,3) = 13
  139. initial(1,1) = 1: initial(1,2) = 1: initial(1,3) = 1
  140. initial(2,1) = 2: initial(2,2) = 2: initial(2,3) = 2
  141. initial(3,1) = 3: initial(3,2) = 3: initial(3,3) = 3
  142. initial(4,1) = 4: initial(4,2) = 4: initial(4,3) = 4
  143. End If
  144. If credit = "" Then credit = 0
  145. If freePlay = "" Then freePlay = 1
  146. If balls = "" Then balls = 5
  147. If chime = "" Then chime = 0
  148. If onBumper = "" Then onBumper = 1
  149. If musicOn = "" Then musicOn = 1
  150. If musicVolume = "" Then musicVolume = .5
  151.  
  152.  
  153. replaySettings
  154.  
  155. firstBallOut = 0
  156. updatePostIt
  157. dynamicUpdatePostIt.enabled = 1
  158. TiltReel.setValue(1)
  159. CreditReel.setvalue(credit)
  160.  
  161. If ShowDT = True Then
  162. For each object in backdropstuff
  163. Object.visible = 1
  164. Next
  165. End If
  166.  
  167. If ShowDt = False Then
  168. For each object in backdropstuff
  169. Object.visible = 0
  170. Next
  171. End If
  172.  
  173. ballShadowUpdate.enabled = True
  174.  
  175. MatchReel.setValue(MatchNumber) 'Need to set to change if 1 point table
  176.  
  177. tilt = False
  178. state = False
  179. gameState
  180.  
  181.  
  182.  
  183. ' InstructCard.image = "InstructReplay" & balls
  184. '***********Trough Ball Creation
  185. ' Drain.CreateSizedBallWithMass Ballsize/2, BallMass
  186. ' Kicker1.CreateSizedBallWithMass Ballsize/2, BallMass
  187. ' Kicker1.kick 0, 0
  188. ' Kicker2.CreateSizedBallWithMass Ballsize/2, BallMass
  189. ' Kicker2.kick 0, 0
  190.  
  191. End Sub
  192.  
  193. '***********KeyCodes
  194. Dim enableInitialEntry, firstBallOut
  195. Sub Table1_KeyDown(ByVal keycode)
  196.  
  197. If enableInitialEntry = True Then enterIntitals(keycode)
  198.  
  199. If keycode = addCreditKey Then
  200. playFieldSound "coinin",0,Drain,1
  201. addCredit = 1
  202. DOF 427, DOFOn
  203. scoreMotor5.enabled = 1
  204. End If
  205.  
  206. If keycode = startGameKey and capturedBalls < 1 Then
  207. If enableInitialEntry = False and operatormenu = 0 and backGlassOn = 1 Then
  208. If freePlay = 1 and players < 4 and firstBallOut = 0 Then startGame
  209. If freePlay = 0 and credit > 0 and players < 4 and firstBallOut = 0 Then
  210. credit = credit - 1
  211. If showDT = False Then PlayReelSound "Reel5", bgcrReel Else PlayReelSound "Reel5", dtcrReel
  212. creditReel.setvalue(credit)
  213. If credit < 1 Then
  214. DOF 427, DOFOff
  215. End If
  216. If B2SOn Then
  217. If freeplay = 0 Then controller.B2SSetCredits credit
  218. If freePlay = 0 and credit < 1 Then DOF 427, DOFOff
  219. End If
  220. startGame
  221. End If
  222. End If
  223. End If
  224.  
  225. If keycode = PlungerKey Then
  226. plunger.PullBack
  227. playFieldSound "plungerpull", 0, plunger, 1
  228. End If
  229.  
  230. If tilt = False and state = True Then
  231. If keycode = leftFlipperKey and contball = 0 Then
  232. LFPress = 1
  233. lf.fire
  234. playFieldSound SoundFX("FlipUpL",DOFFlippers), 0, leftFlipper, 1
  235. DOF 101,DOFOn
  236. playFieldSound "FlipBuzzL", -1, leftFlipper, 1
  237. rotateKeysLeft
  238. End If
  239.  
  240. If keycode = RightFlipperKey and contball = 0 Then
  241. RFPress = 1
  242. rf.fire
  243. playFieldSound SoundFX("FlipUpR",DOFFlippers), 0, RightFlipper,1
  244. DOF 102,DOFOn
  245. playFieldSound "FlipBuzzR", -1, RightFlipper,1
  246. rotateKeysRight
  247. End If
  248.  
  249. If keycode = leftTiltKey Then
  250. Nudge 90, 2
  251. checkTilt
  252. End If
  253.  
  254. If keycode = rightTiltKey Then
  255. Nudge 270, 2
  256. checkTilt
  257. End If
  258.  
  259. If keycode = centerTiltKey Then
  260. Nudge 0, 2
  261. checkTilt
  262. End If
  263. End If
  264.  
  265. If keycode = leftFlipperKey and state = False and operatorMenu = 0 and enableInitialEntry = 0 Then
  266. operatorMenuTimer.Enabled = true
  267. End If
  268.  
  269. If keycode = leftFlipperKey and state = False and operatorMenu = 1 Then
  270. options = options + 1
  271. If showDt = True Then If options = 4 Then options = 6 'skips non DT options
  272. If options = 7 Then options = 0
  273. optionMenu.visible = True
  274. playFieldSound "target", 0, SoundPointScoreMotor, 1.5
  275. Select Case (Options)
  276. Case 0:
  277. optionMenu.image = "FreeCoin" & freePlay
  278. Case 1:
  279. optionMenu.image = balls & "Balls"
  280. Case 2:
  281. optionMenu.image = "Music" & musicOn
  282. Case 3:
  283. endMusic
  284. 'playMusic "OBWAT/chime10.wav", musicVolume
  285. optionMenu.image = "musicVolume"
  286. optionMenu1.visible = 1
  287. If musicVolume < 1 Then
  288. optionMenu1.image = "vol" & (musicVolume * 10)
  289. Else
  290. optionMenu1.image = "vol10"
  291. End If
  292. Case 4:
  293. If musicOn = 1 Then playMusic "OBWAT/OBWAT1.mp3", MusicVolume
  294. optionMenu1.image = "DOF"
  295. optionMenu.image = "Chime" & chime
  296. Case 5:
  297. optionMenu.image = "UnderCab"
  298. optionMenu1.visible = 1
  299. optionMenu1.image = "Sound" & pfOption
  300. optionMenu2.visible = 1
  301. optionMenu2.image = "SoundChange"
  302. Select Case (pfOption)
  303. Case 1: speaker1.visible = 1: speaker2.visible = 1: speaker3.visible = 0: speaker4.visible = 0
  304. Case 2: speaker5.visible = 1: speaker6.visible = 1: speaker1.visible = 0: speaker2.visible = 0
  305. Case 3: speaker1.visible = 1: speaker2.visible = 1: speaker3.visible = 1: speaker4.visible = 1: speaker5.visible = 0: speaker6.visible = 0
  306. End Select
  307. Case 6:
  308. If musicOn = 1 Then playMusic "OBWAT/OBWAT1.mp3", MusicVolume
  309. For x = 1 to 6
  310. EVAL("Speaker" & x).visible = 0
  311. Next
  312. optionMenu1.visible = 0
  313. optionMenu.image = "SaveExit"
  314. optionMenu2.visible = 0
  315. End Select
  316. End If
  317.  
  318. If keycode = RightFlipperKey and state = False and operatorMenu = 1 Then
  319. playFieldSound "metalhit2", 0, SoundPointScoreMotor, 0.2
  320. Select Case (options)
  321. Case 0:
  322. If freePlay = 0 Then
  323. freePlay = 1
  324. DOF 427, DOFOn
  325. Else
  326. freePlay = 0
  327. If credit < 1 Then
  328. DOF 427, DOFOff
  329. End If
  330. If credit > 0 Then
  331. DOF 427, DOFOn
  332. End If
  333. End If
  334. optionMenu.image = "FreeCoin" & freePlay
  335. Case 1:
  336. If balls = 3 Then
  337. balls = 5
  338. Else
  339. balls = 3
  340. End If
  341. ' InstructCard.image = "InstructReplay" & balls
  342.  
  343. optionMenu.image = balls & "Balls"
  344. Case 2:
  345. If musicOn = 0 Then
  346. musicOn = 1
  347. PlayMusic"OBWAT/OBWAT1.mp3", MusicVolume
  348. Else
  349. musicOn = 0
  350. endMusic
  351. End If
  352. optionMenu.image = "music" & musicOn
  353. Case 3:
  354. musicVolume = musicVolume + .1
  355. If musicVolume > 1 Then musicVolume = .1
  356. If musicVolume < 1 Then
  357. optionMenu1.image = "vol" & (musicVolume *10)
  358. Else
  359. optionMenu1.image = "vol10"
  360. End If
  361. 'playMusic "OBWAT/chime10.wav", musicVolume
  362. Case 4:
  363. If chime = 0 Then
  364. chime= 1
  365. DOF 442,DOFPulse
  366. Else
  367. chime = 0
  368. playFieldsound SoundFX("Chime10",DOFChimes), 0, soundPoint13, 1
  369. End If
  370. optionMenu.image = "Chime" & chime
  371. Case 5:
  372. optionMenu1.visible = 1
  373. pfOption = pfOption + 1
  374. If pfOption = 4 Then pfOption = 1
  375. optionMenu1.image = "Sound" & pfOption
  376.  
  377. Select Case (pfOption)
  378. Case 1: speaker1.visible = 1: speaker2.visible = 1: speaker3.visible = 0: speaker4.visible = 0
  379. Case 2: speaker5.visible = 1: speaker6.visible = 1: speaker1.visible = 0: speaker2.visible = 0
  380. Case 3: speaker1.visible = 1: speaker2.visible = 1: speaker3.visible = 1: speaker4.visible = 1: speaker5.visible = 0: speaker6.visible = 0
  381. End Select
  382. Case 6:
  383. operatorMenu = 0
  384. saveHighScore
  385. dynamicUpdatePostIt.enabled = 1
  386. optionMenu.image = "FreeCoin" & freePlay
  387. optionMenu1.visible = 0
  388. optionMenu.visible = 0
  389. optionsMenu.visible = 0
  390. replaySettings
  391. End Select
  392. End If
  393.  
  394. If Keycode = mechanicalTilt Then
  395. tilt = True
  396. PlaySound "SFX_MusicOver"
  397. TiltReel.setValue(1)
  398. If B2SOn Then controller.B2SSetTilt 1
  399. turnOff
  400. End If
  401.  
  402. If keycode = 46 Then' C Key
  403. stopSound "FlipBuzzLA"
  404. stopSound "FlipBuzzLB"
  405. stopSound "FlipBuzzLC"
  406. stopSound "FlipBuzzLD"
  407. stopSound "FlipBuzzRA"
  408. stopSound "FlipBuzzRB"
  409. stopSound "FlipBuzzRC"
  410. stopSound "FlipBuzzRD"
  411. If contball = 1 Then
  412. contball = 0
  413. Else
  414. contball = 1
  415. End If
  416. End If
  417.  
  418. If keycode = 48 Then 'B Key
  419. If bcboost = 1 Then
  420. bcboost = bcboostmulti
  421. Else
  422. bcboost = 1
  423. End If
  424. End If
  425.  
  426. If keycode = 203 Then cLeft = 1' Left Arrow
  427.  
  428. If keycode = 200 Then cUp = 1' Up Arrow
  429.  
  430. If keycode = 208 Then cDown = 1' Down Arrow
  431.  
  432. If keycode = 205 Then cRight = 1' Right Arrow
  433.  
  434. If keycode = 52 Then Zup = 1' Period
  435.  
  436. '************************Start Of Test Keys****************************
  437. If keycode = 30 Then '"a"
  438. phaseCompleted
  439. stopSound("SFX_RadioShow")
  440. ' playsound "SFX_Paddling"
  441. End If
  442. '
  443. If Keycode = 31 Then '"s"
  444. score(1) = 100000
  445. endGame = 1
  446. checkContinue
  447.  
  448. ' For x = 1 to 4
  449. ' Score(x) = Int(rnd(1)*10000)
  450. ' Score(x) = Score(x) * 10
  451. ' SReels(x).setvalue(Score(x))
  452. ' If B2SOn Then Controller.B2SSetScorePlayer x, Score(x)
  453. ' Next
  454. End If
  455. '
  456. ' If keycode = 33 Then '"f"
  457. ' BallinPlay = 3
  458. ' End If
  459. '************************End Of Test Keys****************************
  460. End Sub
  461.  
  462. dim TestChr1, TestChr2, TestChr3, TestChr
  463.  
  464. Sub Table1_KeyUp(ByVal keycode)
  465.  
  466. If keycode = plungerKey Then
  467. plunger.Fire
  468. playFieldSound "PlungerFire", 0, plunger, 1
  469. End If
  470.  
  471. If keycode = leftFlipperKey Then
  472. operatorMenuTimer.Enabled = False
  473. End If
  474.  
  475. If tilt = False and state = True Then
  476. If keycode = leftFlipperKey and contball = 0 Then
  477. lfpress = 0
  478. LeftFlipper.eosTorqueAngle = EOSA
  479. LeftFlipper.eosTorque = EOST
  480. LeftFlipper.RotateToStart
  481. playFieldSound SoundFX("FlipDownL",DOFFlippers), 0, leftFlipper, 1
  482. DOF 101,DOFOff
  483. stopSound "FlipBuzzLA"
  484. stopSound "FlipBuzzLB"
  485. stopSound "FlipBuzzLC"
  486. stopSound "FlipBuzzLD"
  487. End If
  488.  
  489. If keycode = RightFlipperKey and contball = 0 Then
  490. rfpress = 0
  491. RightFlipper.eosTorqueAngle = EOSA
  492. RightFlipper.eosTorque = EOST
  493. RightFlipper.rotateToStart
  494. playFieldSound SoundFX("FlipDownR",DOFFlippers), 0, RightFlipper, 1
  495. DOF 102,DOFOff
  496. stopSound "FlipBuzzRA"
  497. stopSound "FlipBuzzRB"
  498. stopSound "FlipBuzzRC"
  499. stopSound "FlipBuzzRD"
  500. End If
  501. End If
  502.  
  503. If keycode = 203 then cLeft = 0' Left Arrow
  504.  
  505. If keycode = 200 then cUp = 0' Up Arrow
  506.  
  507. If keycode = 208 then cDown = 0' Down Arrow
  508.  
  509. If keycode = 205 then cRight = 0' Right Arrow
  510.  
  511. If keycode = 52 Then Zup = 0' Period
  512. End Sub
  513.  
  514. '************** Table Boot
  515. Dim backGlassOn
  516. Dim bootCount:bootCount = 0
  517. Sub bootTable_Timer
  518. bootCount = bootCount + 1
  519. If bootCount = 1 Then
  520. For each Light in GI:light.state = 1: Next
  521. If B2SOn Then
  522. Controller.B2SSetCredits Credit
  523. Controller.B2SSetMatch 34, MatchNumber
  524. Controller.B2SSetGameOver 35,1
  525. Controller.B2SSetTilt 33,1
  526. Controller.B2SSetBallInPlay 32,0
  527. Controller.B2SSetPlayerUp 30,0
  528. End If
  529.  
  530. If Credit > 0 Then DOF 427, DOFOn
  531. If FreePlay = 1 Then DOF 427, DOFOn
  532.  
  533. For x = 1 to maxPlayers
  534. If B2SOn Then controller.B2SSetScorePlayer x, score(x)
  535. sReel(x).setvalue(score(x))
  536. Next
  537. GameOverReel.setValue(1)
  538. If musicOn = 1 Then PlayMusic"OBWAT/OBWAT1.mp3", MusicVolume
  539. backGlassOn = 1
  540. me.enabled = False
  541. LightSeqAttract.Play SeqUpOn,25,100
  542. LightSeqAttract2.Play SeqClockRightOn,100,100
  543. LightSequenceObjs.Play SeqUpOn,25,100
  544. Alternator
  545. End If
  546. End Sub
  547.  
  548. '***********Replay Settings
  549. Sub replaySettings
  550. If balls = 5 Then
  551. replay(0) = 140000
  552. replay(1) = 156000
  553. replay(2) = 174000
  554. Else
  555. replay(0) = 86000
  556. replay(1) = 97000
  557. replay(2) = 10500
  558. End If
  559. End Sub
  560.  
  561. '***********Operator Menu
  562. Dim operatormenu
  563. Sub operatorMenuTimer_Timer
  564. If optionMenu.visible = 0 Then PlaySound "SFX_OB_SinceWeBeenFolo",0,1,0,0,0,1,0,0
  565. options = 0
  566. operatorMenu = 1
  567. dynamicUpdatePostIt.enabled = 0
  568. updatePostIt
  569. options = 0
  570. optionsMenu.visible = True
  571. optionMenu.visible = True
  572. optionMenu.image = "FreeCoin" & freePlay
  573. End Sub
  574.  
  575. '***********Start Game
  576. Dim ballInPlay, bonusScore
  577. Sub startGame
  578. DOF 124, DOFOn
  579. stopSound "SFX_Paddling"
  580. stopSound "SFX_RadioShow"
  581. If state = False Then
  582. PlaySound"SFX_WhoElected",0,1,0,0,0,1,0,0
  583. ballInPlay = 1
  584. If B2SOn Then
  585. controller.B2SSetCredits credit
  586. controller.B2SSetBallinPlay 32, ballInPlay
  587. controller.B2SSetCanPlay 31, 1
  588. controller.B2SSetPlayerup 30, 1
  589. controller.B2SSetGameOver 0
  590. End If
  591. UP1.setValue(1)
  592. BIPReel.setValue(ballInPlay)
  593. dynamicUpdatePostIt.enabled = 0
  594. updatePostIt
  595. tilt = False
  596. state = True
  597. gameState
  598. players = 1
  599. GameOverReel.setValue (0)
  600. CanPlayReel.setValue(1)
  601. for x = 1 to maxPlayers
  602. score(x) = (score(x) mod 100000)
  603. Next
  604. newGame
  605. If musicOn Then generateSongNumber
  606. Else If state = True and players < maxPlayers and ballinPlay = 1 Then
  607. players = players + 1
  608. creditReel.setvalue(credit)
  609. PlaySound "SFX_WhoElected" & players
  610. If B2SOn Then controller.B2SSetCredits credit
  611. If B2sOn Then controller.B2SSetCanPlay 31, players
  612. CanPlayReel.setValue(players)
  613. End If
  614. End If
  615. End Sub
  616.  
  617. '*********New Game
  618. Dim endGame
  619. Sub newGame
  620. player = 1
  621. endGame = 0
  622. radioDelay.enabled = 0
  623. radioEnd.enabled = 0
  624. If B2SOn Then
  625. controller.B2SSetShootAgain 36,0
  626. End If
  627. SamePlayerShootsAgain.state = 0
  628. For Each obj in bumpers: obj.hasHitEvent = 1: Next
  629. gameState
  630. mode(1)
  631. LightSeqAttract.StopPlay
  632. LightSeqAttract2.StopPlay
  633. LightSequenceObjs.StopPlay
  634. FOPLight.state = 1
  635. activePhase = 1
  636. playModeSound = 0
  637. capturedBalls = 0
  638. For Each obj in CharacterLights: obj.state = 2: Next
  639. resetTable
  640. LockBallsLight.state = 1
  641. GateWall.isdropped = 1
  642. For x = 1 to 4
  643. For y = 1 to 5
  644. Keys(x,y) = 0
  645. Next
  646. Next
  647. resetReel.enabled = True
  648. End Sub
  649.  
  650. '**********Check if Game Should Continue
  651. Dim relBall, rep(4)
  652. Sub checkContinue
  653. If endGame = 1 Then
  654. DOF 124, DOFOff
  655. radioDelay.enabled = 1
  656. turnOff
  657. match
  658. state = False
  659. BIPReel.setValue(0)
  660. For Each obj in Up: obj.setValue(0): Next
  661. gameState
  662. DynamicUpdatePostIt.enabled = 1
  663. firstBallOut = 0
  664. CanPlayReel.setValue(0)
  665. players = 0
  666. For x = 1 to 4
  667. rep(x) = 0
  668. repAwarded(x) = 0
  669. Next
  670. saveHighScore
  671. For Each obj in Bumperlights: obj.state = 0: Next
  672. For Each obj in bumpers: obj.hasHitEvent = 0: Next
  673. For Each obj in JourneyLights: obj.state = 0: Next
  674. For Each obj in ObjectLights: obj.state = 0: Next
  675. LockBallsLight.state = 0
  676. GateWall.isdropped = 1
  677. Kicker1.Kick 160, 12
  678. Kicker2.kick 230, 15
  679. Kicker3.Kick 10, 20
  680. ballsInPlay = ballsInPlay + capturedBalls
  681. kicker.enabled = 1
  682. songtimer.enabled = 0
  683. skedaddleKicker.enabled = 1
  684. LightSeqAttract.Play SeqUpOn,25,100
  685. LightSeqAttract2.Play SeqClockRightOn,100,100
  686. LightSequenceObjs.Play SeqUpOn,25,100
  687. If B2SOn Then
  688. controller.B2SSetGameOver 35,1
  689. controller.B2SSetballinplay 32, 0
  690. controller.B2SSetPlayerUp 30, 0
  691. controller.B2SSetcanplay 31, 0
  692. End If
  693. BIPReel.setValue(0)
  694. Else
  695. relBall = 1 'variable to tell score motor routine that this is a ball release run
  696. scoreMotor5.enabled = 1
  697. bonusScore = activePhase - 1
  698. BIPReel.setValue(ballinPlay)
  699. resetTable
  700. End If
  701. End Sub
  702.  
  703. '***************Drain and Release Ball
  704. Sub drain_Hit()
  705. playFieldSound "Drain", 0, drain, 0.001
  706. repAwarded(Player) = 0
  707. drain.DestroyBall 'this is used for multiball tables to avoid timing issues with balls moving in the trough
  708. ballsInPlay = ballsInPlay - 1
  709. If endGame = 1 Then capturedBalls = capturedBalls - 1
  710. If Multiball = 1 and ballsInplay = 1 Then
  711. phaseCompleted
  712. MultiballLight.state = 0
  713. for each obj in MultiBallGroup: obj.state = 1: Next
  714. End If
  715. If ballSaveOn = 1 Then
  716. releaseBall
  717. Elseif ballsInPlay = 0 and ballSaveOn = 0 and endGame = 0 Then
  718. scoreBonus
  719. End If
  720. End Sub
  721.  
  722. Dim BallsInPlay
  723. Sub ReleaseBall
  724. If ballREnabled = 0 Then
  725. BallRelease.CreateSizedBallWithMass Ballsize/2, BallMass
  726. BallRelease.kick 70,20
  727. ballsInPlay = ballsInPlay + 1
  728. playFieldSound SoundFX("FastKickIntoLaunchLane",DOFContactors), 0, Drain, 0.5
  729. DOF 425,DOFPulse
  730. If ballSaveOn = 0 Then ballSaveOn = 1: ballSave.enabled = 1: SamePlayerShootsAgain.state = 1
  731. End If
  732. BIPReel.setValue(ballInPlay)
  733. If B2SOn Then controller.B2SSetBallinPlay 32, BallinPlay
  734.  
  735. End Sub
  736.  
  737. '**********Check if Scoring Bonus is True
  738. Dim bonusFlag
  739. Sub scoreBonus
  740. endMusic()
  741. bonusFlag = 1
  742. If activePhase < 14 Then EVAL("bonus" & activePhase).state = 0
  743. scoreMotor.enabled = 1
  744. tb.text = "ap = " & activePhase
  745. If bonusScore = 0 And SamePlayerShootsAgain.state = 1 And scoreMotorLoop = 0 Then resetTable: releaseBall
  746. If bonusScore = 0 And SamePlayerShootsAgain.state = 0 And scoreMotorLoop = 0 Then
  747. If activePhase > 13 Then
  748. endGame = 1
  749. checkContinue
  750. Else
  751. advancePlayers
  752. End If
  753. End If
  754. End Sub
  755.  
  756.  
  757. '**********Advance Players
  758. Sub advancePlayers
  759. BonusFlag = 0
  760. If players = 1 or player = players Then
  761. player = 1
  762. EVAL("UP" & players).SetValue(0)
  763. Up1.SetValue(1)
  764. Else
  765. player = player + 1
  766. EVAL ("Up" & (player - 1)).setValue(0)
  767. EVAL ("Up" & player).setValue(1)
  768. End If
  769. If B2SOn Then controller.B2SSetPlayerup 30, player
  770. nextBall
  771. End Sub
  772.  
  773. '**********Next Ball
  774. Sub nextBall
  775. If Tilt = True Then
  776. For Each obj in bumpers: obj.hasHitEvent = 1: Next
  777. tilt = False
  778. tiltReel.setValue(0)
  779. If B2SOn Then
  780. controller.B2SSetTilt 33,0
  781. controller.B2SSetData 1, 1
  782. End If
  783. End If
  784. resetTable
  785. If Player = 1 then ballinPlay = ballinPlay + 1
  786. ' If player = 4 then BallinPlay = 5 'used for match testing
  787.  
  788. If ballinPlay > balls then
  789. endGame = 1
  790. checkContinue
  791. Else
  792. If musicOn Then generateSongNumber
  793. PlaySound "SFX_TightSpot",0,1,0,0,0,1,0,0
  794. If state = True Then checkContinue
  795. End If
  796. End Sub
  797.  
  798. '************Game State Check
  799. dim xx
  800.  
  801. Sub gameState
  802. If state = False Then
  803. GameOverReel.setValue(1)
  804. If B2SOn then controller.B2SSetGameOver 35,1
  805. Else
  806. GameOverReel.setValue(0)
  807. MatchReel.setValue(0)
  808. TiltReel.setValue(0)
  809. If B2SOn Then
  810. controller.B2SSetTilt 33,0
  811. controller.B2SSetMatch 34,0
  812. controller.B2SSetGameOver 35,0
  813. End If
  814. End If
  815. End Sub
  816.  
  817. '*************Ball in Launch Lane on Plunger Tip
  818. Dim ballREnabled, relGateHit
  819. Sub ballHome_hit
  820. ballREnabled = 1
  821. DOF 450, DOFOn
  822. relGateHit = 0
  823. Set controlBall = ActiveBall
  824. contBallInPlay = True
  825. End Sub
  826.  
  827. '*************Ball off of Plunger Tip
  828. Sub ballHome_unhit
  829. DOF 450, DOFOff
  830. End Sub
  831.  
  832. '******* for ball control script
  833. Sub EndControl_Hit()
  834. contBallinPlay = False
  835. End Sub
  836.  
  837. '************Check if Ball Out of Launch Lane
  838. Dim ballInLane
  839. Sub ballsInPlay_hit
  840. If ballREnabled = 1 Then
  841. If B2SOn Then controller.B2SSetShootAgain 36,0
  842. ballREnabled = 0
  843. ballInLane = False
  844. End If
  845. firstBallOut = 1
  846. End Sub
  847.  
  848. '**********Reset Table
  849. Sub resetTable
  850. BIPReel.setValue(BallinPlay)
  851. keySum = 0
  852. bonafide = 0
  853. bonafideTotal = 0
  854. bonafidePhase = 0
  855. WatchLight.state = 0
  856. For Each obj in BonaFideLights: obj.state = 0: Next
  857. DTRaise 1: DTRaise 2: DTRaise 3: DTRaise 4
  858. bonusMult = 1
  859. For each obj in MultiplierLights: obj.state = 0: Next
  860. For each obj in BumperLights: obj.state = 0: Next
  861. DapperDanLight.state = 0
  862. FOPLight.state = 1
  863. For each obj in OutlaneLights: obj.state = 0: Next
  864.  
  865. If activePhase > 1 Then
  866. For x = 1 to (activePhase - 1)
  867. EVAL("bonus" & x).state = 1
  868. Next
  869. End If
  870. EVAL("bonus" & activePhase).state = 2
  871. For x = 1 to 5
  872. Keys(player,x) = 0
  873. Next
  874. For Each obj in KeyLights: obj.state = 0: Next
  875. For Each obj in lockLights: obj.state = 0: Next
  876. End Sub
  877.  
  878. '************** Treasure Phases
  879. Dim activePhase
  880. Sub mode(phase)
  881. Select Case phase
  882. Case 1: multiballReady
  883. bonus1.state = 2
  884. Case 2: HandcarLight.state = 2: bonus2.state = 2
  885. Case 3: bonus3.state = 2: CarLight.state = 2
  886. Case 4: bonus4.state = 2: WaterLight.state = 2
  887. Case 5: bonus5.state = 2: CarLight.state = 2: GuitarLight.state = 2
  888. Case 6: bonus6.state = 2: GuitarLight.state = 2: MicLight.state = 2
  889. Case 7: bonus7.state = 2: MachineGunLight.state = 2: CarLight.state = 2: GeorgeLight.state = 2
  890. Case 8: bonus8.state = 2: MoonshineLight.state = 2: FrogLight.state = 2: For Each obj in SirenLights: obj.state = 2: Next
  891. Case 9: bonus9.state = 2: FistsLight.state = 2: VernonLight.state = 2
  892. Case 10: bonus10.state = 2: AnvilLight.state = 2: FrogLight.state = 2
  893. Case 11: bonus11.state = 2: BroomLight.state = 2: StokesLight.state = 2: BeardLight.state = 2
  894. Case 12: bonus12.state = 2: BeardLight.state = 2: FlourLight.state = 2: NooseLight.state = 2
  895. Case 13: bonus13.state = 2: CowLight.state = 2: WaterLight.state = 2: RingLight.state = 2
  896. End Select
  897. End Sub
  898.  
  899. Dim playModeSound
  900. Sub modeCheck
  901. For Each obj in ObjectLights
  902. If obj.state = 2 Then playModeSound = playModeSound + 1
  903. Next
  904. Select Case activePhase
  905. Case 2: If HandcarLight.state = 1 Then multiballReady
  906. Case 3: If CarLight.state = 1 Then multiballReady
  907. Case 4: If WaterLight.state = 1 Then multiballReady
  908. Case 5: If CarLight.state = 1 and GuitarLight.state = 1 Then multiballReady
  909. Case 6: If GuitarLight.state = 1 and MicLight.state = 1 Then multiballReady
  910. Case 7: If MachineGunLight.state = 1 and CarLight.state = 1 and GeorgeLight.state = 1 Then multiballReady
  911. Case 8: If MoonshineLight.state = 1 and FrogLight.state = 1 and Siren1Light.state = 1 and Siren2Light.state = 1 and Siren3Light.state = 1 Then multiballReady
  912. Case 9: If FistsLight.state = 1 and VernonLight.state = 1 Then multiballReady
  913. Case 10: If AnvilLight.state = 1 and FrogLight.state = 1 Then multiballReady
  914. Case 11: If BroomLight.state = 1 and StokesLight.state = 1 and BeardLight.state = 1 Then multiballReady
  915. Case 12: If BeardLight.state = 1 and FlourLight.state = 1 and NooseLight.state = 1 Then multiballReady
  916. Case 13: If CowLight.state = 1 and WaterLight.state = 1 and RingLight.state = 1 Then multiballReady
  917. End Select
  918. End Sub
  919.  
  920. Sub phaseCompleted
  921. playModeSound = 0
  922. Select Case activePhase
  923. Case 1: bonus1.state = 1
  924. Case 2: bonus2.state = 1
  925. Case 3: bonus3.state = 1
  926. Case 4: bonus4.state = 1
  927. Case 5: bonus5.state = 1
  928. Case 6: bonus6.state = 1
  929. Case 7: bonus7.state = 1
  930. Case 8: bonus8.state = 1
  931. Case 9: bonus9.state = 1
  932. Case 10: bonus10.state = 1
  933. Case 11: bonus11.state = 1
  934. Case 12: bonus12.state = 1
  935. Case 13: bonus13.state = 1
  936. End Select
  937. multiball = 0
  938. bonusScore = activePhase
  939. activePhase = activePhase + 1
  940. tb.text = "AP = " & activePhase
  941. For Each obj in standupLights: obj.state = 0: Next
  942. For Each obj in ObjectLights: obj.state = 0: Next
  943. For Each obj in CharacterLights: obj.state = 0: Next
  944. mode(activePhase)
  945. End Sub
  946.  
  947. Sub multiballReady
  948. For Each obj in CharacterLights: obj.state = 2: Next
  949. LockBallsLight.state = 1
  950. End Sub
  951.  
  952. '************** Bumpers Hit
  953. Sub bumpers_Hit(Index)
  954. If tilt = False Then
  955. If EVAL("BumperLight" & (Index + 1)).state = 1 Then
  956. addscore 100
  957. Else
  958. addScore 10
  959. End If
  960. DOF (105 + Index), DOFPulse
  961. DOF (110 + Index), DOFPulse
  962. End If
  963. End Sub
  964.  
  965. Dim Alt
  966. Sub Alternator
  967. Alt = Alt + 1
  968. If Alt > 1 Then Alt = 0
  969. If Alt = 1 Then
  970. VictrolaLightR.state = 1
  971. VictrolaLightL.state = 0
  972. Else
  973. VictrolaLightR.state = 0
  974. VictrolaLightL.state = 1
  975. End If
  976. End Sub
  977.  
  978. '************** StandUps Hit
  979. Dim standupHit
  980. Sub standUps_Hit(Index)
  981. DOF 114 + Index, DOFPulse
  982. If tilt = False Then
  983. Select Case (Index)
  984. Case 0: addScore 500
  985. If StokesLight.state = 2 Then
  986. StokesLight.state = 1: modeCheck: If playModeSound = 0 Then playObjectiveSound
  987. ElseIf StokesLight.state = 0 Then
  988. flashLight Index,1
  989. End If
  990. Case 1: addScore 500
  991. If VernonLight.state = 2 Then
  992. VernonLight.state = 1: modeCheck: If playModeSound = 0 Then playObjectiveSound
  993. Elseif VernonLight.state = 0 Then
  994. flashLight Index,1
  995. End If
  996. Case 2: addScore 10
  997. For each obj in bumperLights: obj.state = 0: Next
  998. If FOPLight.state = 0 Then PlaySound "SFX_DontCarry",0,1,0,0,0,1,0,0
  999. DapperDanLight.state = 0
  1000. FOPLight.state = 1
  1001. Case 3: addScore 1000
  1002. For each obj in bumperLights: obj.state = 1: Next
  1003. If DapperDanLight.state = 0 Then PlaySound "SFX_DapperDan",0,1,0,0,0,1,0,0
  1004. DapperDanLight.state = 1
  1005. FOPLight.state = 0
  1006. Case 4: addScore 300: Siren1Light.state = 1: modeCheck: If playModeSound = 0 Then playObjectiveSound
  1007. Case 5: addScore 300: Siren2Light.state = 1: modeCheck: If playModeSound = 0 Then playObjectiveSound
  1008. Case 6: addScore 300: Siren3Light.state = 1: modeCheck: If playModeSound = 0 Then playObjectiveSound
  1009. Case 7: addScore 500
  1010. If GuitarLight.state = 2 Then
  1011. GuitarLight.state = 1
  1012. modeCheck
  1013. If playModeSound = 0 Then
  1014. Select Case activePhase
  1015. Case 5: playObjectiveSound
  1016. Case 6: playObjectiveSound
  1017. End Select
  1018. End If
  1019. ElseIf GuitarLight.state = 0 Then
  1020. flashLight Index,1
  1021. End If
  1022. Case 8: If WatchLight.state = 2 Then
  1023. WatchLight.state = 1: addScore 5000
  1024. PlaySound "SFX_DOLightFingers",0,1,0,0,0,1,0,0
  1025. ElseIf WatchLight.state = 0 Then
  1026. flashLight Index,1
  1027. PlaySound "SFX_CountOnYou",0,1,0,0,0,1,0,0
  1028. End If
  1029. Case 9: addScore 500
  1030. If GeorgeLight.state = 2 Then
  1031. GeorgeLight.state = 1:
  1032. modeCheck
  1033. If playModeSound = 0 Then playObjectiveSound
  1034. ElseIf GeorgeLight.state = 2 Then
  1035. flashLight Index,1
  1036. End If
  1037. End Select
  1038. playModeSound = 0
  1039. If Siren1Light.state = 1 and Siren2Light.state = 1 and Siren3Light.state = 1 and activePhase <> 8 Then
  1040. For Each obj in OutlaneLights: obj.state = 1: Next
  1041. For Each obj in SirenLights: obj.state = 0: Next
  1042. End If
  1043. End If
  1044. End Sub
  1045.  
  1046. Dim currentIndex
  1047. Sub flashLight(Index, onOff)
  1048. If Index < 10 Then currentIndex = Index
  1049. If onOff = 1 Then
  1050. standupLights(currentIndex).state = 1
  1051. Else
  1052. standupLights(currentIndex).state = 0
  1053. End If
  1054. flashTimer.enabled = 1
  1055. End Sub
  1056.  
  1057. Sub flashTimer_timer
  1058. flashLight 11,0
  1059. flashTimer.enabled = 0
  1060. End Sub
  1061.  
  1062. '***********Rotate Spinner
  1063. 'Dim angle
  1064. 'Sub spinnerTimer_Timer
  1065. ' angle = (sin (spinner.CurrentAngle))
  1066. ' spinner_Mesh.RotX = spinner.CurrentAngle
  1067. ' spinnerRod.TransZ = -sin( (spinner.CurrentAngle+180) * (2*3.14/360)) * 5
  1068. ' spinnerRod.TransX = (sin( (spinner.CurrentAngle- 90) * (2*3.14/360)) * -5)
  1069. 'End Sub
  1070.  
  1071. '************** 10's Rubbers
  1072. Sub TensRubbers_Hit
  1073. addScore 10
  1074. End Sub
  1075.  
  1076. '*************** Triggers
  1077. Sub triggers_hit(index)
  1078. If tilt = False Then
  1079. Select Case (index)
  1080. Case 0:
  1081. End Select
  1082. End If
  1083. End Sub
  1084.  
  1085. '************** Button Animation
  1086. 'Dim button
  1087. 'Sub rollOverAnimation_Timer
  1088. ' button = button + 1
  1089. ' Select Case Button
  1090. ' Case 1: WiggleGateOpenButton.transz = -2
  1091. ' Case 2: WiggleGateOpenButton.transz = 0
  1092. ' Case 3: WiggleGateOpenButton.transz = 1
  1093. ' Case 4: WiggleGateOpenButton.transz = 1
  1094. ' button = 0
  1095. ' rollOverAnimation.enabled = 0
  1096. ' End Select
  1097. 'End Sub
  1098.  
  1099. '*************** Targets
  1100. Dim bonafide, bonafideTotal, bonafidePhase, bonafideMultiplier
  1101. Sub dropTargets_hit(index)
  1102. If resetDropsTimer.enabled = 1 Then exit Sub
  1103. If tilt = False Then
  1104. Select Case (index)
  1105. Case 0: If bonafidePhase = 0 Then BLight.state = 1: else: FLight.state = 1
  1106. Case 1: If bonafidePhase = 0 Then OLight.state = 1: else: ILight.state = 1
  1107. Case 2: If bonafidePhase = 0 Then NLight.state = 1: else: DLight.state = 1
  1108. Case 3: If bonafidePhase = 0 Then ALight.state = 1: else: ELight.state = 1
  1109. End Select
  1110. For each obj in bona
  1111. If obj.state = 1 and bonafidePhase = 0 Then bonafideTotal = bonafideTotal + 1
  1112. Next
  1113. For Each obj in fide
  1114. If obj.state = 1 and bonafidePhase = 1 Then bonafideTotal = bonafideTotal + 1
  1115. Next
  1116. If bonafideTotal = 4 Then
  1117. resetDropsTimer.enabled = 1
  1118. End If
  1119. If BLight.state = 1 and OLight.state = 1 and bonafidePhase= 0 Then WatchLight.state = 2
  1120. If FLight.state = 1 and ILight.state = 1 Then WatchLight.state = 2
  1121. bonafideTotal = 0
  1122. addScore 100
  1123. End If
  1124. End Sub
  1125.  
  1126. Sub resetDropsTimer_Timer
  1127. DTRaise 1: DTRaise 2: DTRaise 3: DTRaise 4
  1128. WatchLight.state = 0
  1129. If tilt = False Then
  1130. If bonafidePhase = 0 and bonafide < 1 Then
  1131. addScore 1000
  1132. PlaySound "SFX_BonaFide",0,1,0,0,0,1,0,0
  1133. ElseIf bonafidePhase = 0 and bonafide > 0 Then
  1134. addScore 1000
  1135. PlaySound "SFX_Paterfamilias",0,1,0,0,0,1,0,0
  1136. Else
  1137. addScore 1000
  1138. For Each obj in bona: obj.state = 0: Next
  1139. for Each obj in fide: obj.state = 0: Next
  1140. bonafide = bonafide + 1
  1141. If bonafide > 2 Then bonafide = 2
  1142. Select Case bonafide
  1143. Case 1: PlaySound "SFX_BonaFide2",0,1,0,0,0,1,0,0
  1144. Case 2: PlaySound "SFX_Paterfamilias",0,1,0,0,0,1,0,0: bonafide = 2
  1145. End Select
  1146. If keySum > 0 Then
  1147. bonafideMultiplier = 2
  1148. Else
  1149. bonafideMultiplier = 0
  1150. End If
  1151. EVAL("MultiLight" & (bonafide + bonafideMultiplier)).state = 1
  1152. If bonafide > 1 Then EVAL("MultiLight" & (bonafide + bonafideMultiplier - 1)).state = 0
  1153. End If
  1154. bonafidePhase = bonafidePhase + 1
  1155. If bonafidePhase > 1 Then bonafidePhase = 0
  1156. bonusMultiplier
  1157. End If
  1158. resetDropsTimer.enabled = 0
  1159. End Sub
  1160.  
  1161. Dim bonusMult
  1162. Sub bonusMultiplier
  1163. If bonafide > 0 Then
  1164. bonusMult = (bonafide + 1)
  1165. If keySum > 0 Then bonusMult = bonusMult * 2
  1166. End If
  1167. End Sub
  1168.  
  1169. Sub dtDropTrigger_hit
  1170. DTDrop 1: DTDrop 2
  1171. End Sub
  1172.  
  1173. Sub dtDropTrigger_unhit
  1174. If skedaddleKicker.enabled = 0 Then dtRaiser.enabled = 1
  1175. End Sub
  1176.  
  1177. Sub dtRaiser_timer
  1178. If BLight.state = 0 and bonafidePhase = 0 or FLight.state = 0 and bonafidePhase = 1 Then DTRaise 1
  1179. If OLight.state = 0 and bonafidePhase = 0 or ILight.state = 0 and bonafidePhase = 1 Then DTRaise 2
  1180. dtRaiser.enabled = 0
  1181. End Sub
  1182.  
  1183. '************************ Ramps
  1184. Sub wireRampTrigger_Hit
  1185. If HandcarLight.state = 2 Then
  1186. HandcarLight.state = 1
  1187. modeCheck
  1188. If playModeSound = 0 Then playObjectiveSound
  1189. ElseIf MachineGunLight.state = 2 Then
  1190. MachineGunLight.state = 1
  1191. modeCheck
  1192. If playModeSound = 0 Then playObjectiveSound
  1193. ElseIf FlourLight.state = 2 Then
  1194. FlourLight.state = 1
  1195. modeCheck
  1196. If playModeSound = 0 Then playObjectiveSound
  1197. Else:
  1198. PlaySound "SFX_Train3",0,1,0,0,0,1,0,0
  1199. End If
  1200. playModeSound = 0
  1201. End Sub
  1202.  
  1203. Sub frogRampTrigger_Hit
  1204. If MicLight.state = 2 Then
  1205. MicLight.state = 1
  1206. modeCheck
  1207. If playModeSound = 0 Then playObjectiveSound
  1208. ElseIf MoonshineLight.state = 2 and FrogLight.state = 1 Then
  1209. MoonshineLight.state = 1
  1210. modeCheck
  1211. If playModeSound = 0 Then playObjectiveSound
  1212. ElseIf FrogLight.state = 2 Then
  1213. FrogLight.state = 1
  1214. modeCheck
  1215. Select Case activePhase
  1216. Case 8: If playModeSound = 0 Then playObjectiveSound
  1217. Case 10: If playModeSound = 0 Then playObjectiveSound
  1218. End Select
  1219. Else:
  1220. PlaySound "SFXFrog",0,1,0,0,0,1,0,0
  1221. End If
  1222. playModeSound = 0
  1223. End Sub
  1224.  
  1225. Sub readyForMB
  1226. For Each obj in CharacterLights: obj.state = 2: Next
  1227. LockBallsLight.state = 1
  1228. End Sub
  1229.  
  1230. Sub rollOvers_Hit(Index)
  1231. DOF 125 + Index, DOFPulse
  1232. If tilt = False Then
  1233. Select Case Index
  1234. Case 0: If LeftOutlaneLight.state = 1 Then
  1235. addscore 1000
  1236. Else:
  1237. addScore 100
  1238. End If
  1239. Playsound "SFX_NoSense",0,1,0,0,0,1,0,0
  1240. Case 1: addScore 300: Keys(player, 5) = 1: KeyLight5.state = 1: keyCheck:
  1241. Case 2: If AnvilLight.state = 2 Then
  1242. AnvilLight.state = 1
  1243. modeCheck
  1244. If playModeSound = 0 Then playObjectiveSound
  1245. ElseIf CarLight.state = 2 Then
  1246. CarLight.state = 1
  1247. modeCheck
  1248. If playModeSound = 0 Then
  1249. Select Case activePhase
  1250. Case 3: playObjectiveSound
  1251. Case 5: playObjectiveSound
  1252. Case 7: playObjectiveSound
  1253. End Select
  1254. End If
  1255. ElseIf BeardLight.state = 2 Then
  1256. BeardLight.state = 1
  1257. modeCheck
  1258. If playModeSound = 0 Then
  1259. Select Case activePhase
  1260. Case 11: playObjectiveSound
  1261. Case 12: playObjectiveSound
  1262. End Select
  1263. End If
  1264. Else:
  1265. PlaySound "SFX_Car",0,1,0,0,0,1,0,0
  1266. End If
  1267. playModeSound = 0
  1268. Case 3: addscore 300: Keys(player, 1) = 1: KeyLight1.state = 1: keyCheck
  1269. Case 4: addscore 300: Keys(player, 2) = 1: KeyLight2.state = 1: keyCheck
  1270. Case 5: addscore 300: Keys(player, 3) = 1: KeyLight3.state = 1: keyCheck
  1271. Case 6: addscore 300: Keys(player, 4) = 1: KeyLight4.state = 1: keyCheck
  1272. Case 7: If RightOutlaneLight.state = 1 Then
  1273. addscore 1000
  1274. Else:
  1275. addScore 100
  1276. End If
  1277. PlaySound "SFX_OB_SamHill",0,1,0,0,0,1,0,0
  1278. End Select
  1279. End If
  1280. wireNumber = index
  1281. wireAnimation.enabled = 1
  1282. End Sub
  1283.  
  1284. Sub starRollOvers_Hit(Index)
  1285. Select Case Index
  1286. Case 0: If LeftStarLight.state = 1 Then
  1287. addScore 500
  1288. Else
  1289. addScore 50
  1290. End If
  1291. Case 1: If CowLight.state = 2 Then
  1292. CowLight.state = 1
  1293. modeCheck
  1294. If playModeSound = 0 Then playObjectiveSound
  1295. Else
  1296. PlaySound "SFX_CowMoo",0,1,0,0,0,1,0,0
  1297. End If
  1298. Case 2: If BroomLight.state = 2 Then
  1299. BroomLight.state = 1
  1300. modeCheck
  1301. If playModeSound = 0 Then playObjectiveSound
  1302. ElseIf FistsLight.state = 2 Then
  1303. FistsLight.state = 1
  1304. modeCheck
  1305. If playModeSound = 0 Then playObjectiveSound
  1306. ElseIf NooseLight.state = 2 Then
  1307. NooseLight.state = 1
  1308. modeCheck
  1309. If playModeSound = 0 Then playObjectiveSound
  1310. Else
  1311. PlaySound "SFX_Dogs3",0,1,0,0,0,1,0,0
  1312. End If
  1313. End Select
  1314. playModeSound = 0
  1315. End Sub
  1316.  
  1317. '************** Wire RollOver Animation
  1318. Dim wire, wireNumber
  1319. Sub wireAnimation_Timer
  1320. wire = wire + 1
  1321. Select Case wire
  1322. Case 1: EVAL ("wire" & wireNumber + 1).transz = -10
  1323. Case 2: EVAL ("wire" & wireNumber + 1).transz = -4
  1324. Case 3: EVAL ("wire" & wireNumber + 1).transz = -1
  1325. Case 4: EVAL ("wire" & wireNumber + 1).transz = 0
  1326. wire = 0
  1327. wireAnimation.enabled = 0
  1328. End Select
  1329. End Sub
  1330.  
  1331. Dim Keys(4,6), keyTotal, keySum
  1332. Sub keyCheck
  1333. For Each obj in KeyLights
  1334. If obj.state = 1 Then keyTotal = (keyTotal + 1)
  1335. Next
  1336. If keyTotal = 5 Then
  1337. PlaySound "SFX_Chain",0,1,0,0,0,1,0,0
  1338. keySum = keySum + 1
  1339. If keySum > 3 Then keySum = 3
  1340. For Each obj in KeyLights: obj.state = 0: Next
  1341. For x = 1 to 5
  1342. Keys(player,x) = 0
  1343. Next
  1344. EVAL("LockLight" & keySum).state = 1
  1345. addScore (1000 * keySum)
  1346. bonafideMultiplier = 2
  1347. If bonafide > 0 Then
  1348. EVAL("MultiLight" & (bonafide + bonafideMultiplier)).state = 1
  1349. EVAL("MultiLight" & bonafide).state = 0
  1350. End If
  1351. bonusMultiplier
  1352. If keySum = 3 Then SamePlayerShootsAgain.state = 1
  1353. End If
  1354. keyTotal = 0
  1355. End Sub
  1356.  
  1357. Dim tempKeys(4,5)
  1358. Sub rotateKeysLeft
  1359. For x = 1 To 5
  1360. tempKeys(player, x) = Keys(player, x)
  1361. Next
  1362. For x = 1 to 5
  1363. If tempKeys(player, x) = 1 Then Keys(player, x - 1) = 1
  1364. If tempKeys(player, x) = 0 Then Keys(player, x - 1) = 0
  1365. Next
  1366. Keys(player, 5) = Keys(player, 0)
  1367. updateKeys
  1368. End Sub
  1369.  
  1370. Sub rotateKeysRight
  1371. For x = 1 To 5
  1372. tempKeys(player, x) = Keys(player, x)
  1373. Next
  1374. For x = 1 to 5
  1375. If tempKeys(player, x) = 1 Then Keys(player, x + 1) = 1
  1376. If tempKeys(player, x) = 0 Then Keys(player, x + 1) = 0
  1377. Next
  1378. Keys(player, 1) = Keys(player, 6)
  1379. updateKeys
  1380. End Sub
  1381.  
  1382. Sub updateKeys
  1383. For x = 1 to 5
  1384. If Keys(player,x) = 1 Then
  1385. EVAL("KeyLight" & x).state = 1
  1386. Else
  1387. EVAL("KeyLight" & x).state = 0
  1388. End If
  1389. Next
  1390. End Sub
  1391.  
  1392. '************ Kickers
  1393. Dim kickStep, multiball, capturedBalls
  1394. Sub Kickers_Hit(Index)
  1395. playFieldSound "SaucerIn", 0, EVAL("kicker" & Index + 1), 1
  1396. scoreMotorLoop = 0
  1397. kickStep = 0
  1398. If tilt = False Then
  1399. If Index < 3 Then
  1400. addScore 3000
  1401. End If
  1402. End If
  1403. If Index = 2 Then GateWall.isdropped = 0
  1404. If Index = 3 Then
  1405. If multiballLight.state = 2 Then
  1406. addScore 5000
  1407. PlaySound "SFX_CashRegister2"
  1408. Else
  1409. addScore 1000
  1410. End If
  1411. skedaddleKicker.enabled = 1
  1412. Exit Sub
  1413. End If
  1414. If LockBallsLight.state = 0 Then
  1415. kicker.enabled = 1
  1416. Else
  1417. BallsInPlay = BallsInPlay - 1
  1418. capturedBalls = capturedBalls + 1
  1419. If BallsInPlay = 0 and capturedBalls < 3 Then
  1420. ReleaseBall
  1421. EVAL("character" & Index).state = 1
  1422. Else
  1423. For Each obj in CharacterLights: obj.state = 0: Next
  1424. LockBallsLight.state = 0
  1425. For Each obj in ObjectLights: obj.state = 0: Next
  1426. ' For Each obj in standupLights: obj.state = 1: Next
  1427. capturedBalls = 0
  1428. BallsInPlay = 3
  1429. multiball = 1
  1430. MultiballLight.state = 2
  1431. for each obj in MultiballGroup: obj.state = 2: Next
  1432. playExitSound
  1433. kicker.enabled = 1
  1434. End If
  1435. End If
  1436. End Sub
  1437.  
  1438. Sub kicker_timer
  1439. Select Case kickStep
  1440. Case 7: Kicker1.Kick 160, 12
  1441. Kicker2.kick 230, 15
  1442. Kicker3.Kick 10, 20
  1443. DOF 432, DOFPulse
  1444. playModeSound = 0
  1445. GateWall.isdropped = 1
  1446. PlayFieldSound SoundFX("SaucerKick",DOFContactors),0, kicker1, 1
  1447. For Each obj in KickArm: obj.ObjRotX=12: Next
  1448. Case 8: For Each obj in KickArm: obj.ObjRotX = -45: Next
  1449. Case 9: For Each obj in KickArm: obj.ObjRotX = -45: Next
  1450. Case 10: For Each obj in KickArm: obj.ObjRotX = 24: Next
  1451. Case 11: For Each obj in KickArm: obj.ObjRotX = 12: Next
  1452. Case 12: For Each obj in KickArm: obj.ObjRotX = 0:: Next
  1453. kicker.Enabled = 0
  1454. kickStep = 0
  1455. End Select
  1456. kickStep = kickStep + 1
  1457. End Sub
  1458.  
  1459. Sub skedaddleKicker_Timer
  1460. Select Case kickStep
  1461. Case 1: DTDrop 1: DTDrop 2: DTDrop 3: DTDrop 4
  1462. If RingLight.state = 2 Then
  1463. RingLight.state = 1
  1464. modeCheck
  1465. If playModeSound = 0 Then playObjectiveSound
  1466. Else:
  1467. If endGame = 0 and ballsInPlay = 1 Then PlaySound "SFX_Skedaddle",0,1,0,0,0,1,0,0
  1468. End If
  1469. playModeSound = 0
  1470. Case 7: Kicker4.kick 240, 20
  1471. PlayFieldSound SoundFXDOF("SaucerKick",432,DOFPulse,DOFContactors),0, kicker4, 1
  1472. DOF 429, DOFPulse
  1473. Pkickarm4.ObjRotX=12
  1474. Case 8: Pkickarm4.ObjRotX = -45
  1475. Case 9: Pkickarm4.ObjRotX = -45
  1476. Case 10: Pkickarm4.ObjRotX = 24
  1477. Case 11: Pkickarm4.ObjRotX = 12
  1478. Case 12: Pkickarm4.ObjRotX = 0
  1479. skedaddleKicker.Enabled = 0
  1480. kickStep = 0
  1481. If BLight.state = 0 and bonafidePhase = 0 or FLight.state = 0 and bonafidePhase = 1 Then DTRaise 1
  1482. If OLight.state = 0 and bonafidePhase = 0 or ILight.state = 0 and bonafidePhase = 1 Then DTRaise 2
  1483. If NLight.state = 0 and bonafidePhase = 0 or DLight.state = 0 and bonafidePhase = 1 Then DTRaise 3
  1484. If ALight.state = 0 and bonafidePhase = 0 or ELight.state = 0 and bonafidePhase = 1 Then DTRaise 4
  1485. End Select
  1486. kickStep = kickStep + 1
  1487. End Sub
  1488.  
  1489. Sub playExitSound 'Start Multiball
  1490. DOF 433, DOFPulse
  1491. soundPlayed = 0
  1492. Select Case activePhase
  1493. Case 1: PlaySound "SFX_Escape"
  1494. Case 2: PlaySound "SFX_HitchRide2"
  1495. Case 3: PlaySound "SFX_FleeBarn"
  1496. Case 4: PlaySound "SFX_GetBaptized"
  1497. Case 5: PlaySound "SFX_SingIntoCan"
  1498. Case 6: PlaySound "SFX_YonderCan"
  1499. Case 7: PlaySound "SFX_JackingUp"
  1500. Case 8: PlaySound "SFX_SeducedA"
  1501. Case 9: PlaySound "SFX_Fight"
  1502. Case 10: PlaySound "SFX_ToadB"
  1503. Case 11: PlaySound "SFX_CrashRally"
  1504. Case 12: PlaySound "SFX_Pardoned"
  1505. Case 13: PlaySound "SFX_Repose"
  1506. End Select
  1507. End Sub
  1508.  
  1509. Dim soundPlayed
  1510. soundPlayed = 0
  1511. Sub playObjectiveSound 'Have All Objects
  1512. If soundPlayed = 0 Then
  1513. Select Case activePhase
  1514. Case 2: PlaySound "SFX_HitchRide1"
  1515. Case 3: PlaySound "SFX_Coppers"
  1516. Case 4: PlaySound "SFX_Gopher"
  1517. Case 5: PlaySound "SFX_PickUpTommy"
  1518. Case 6: PlaySound "SFX_RecordSong"
  1519. Case 7: PlaySound "SFX_George"
  1520. Case 8: PlaySound "SFX_SeducedB"
  1521. Case 9: PlaySound "SFX_Vernon"
  1522. Case 10: PlaySound "SFX_FreePete"
  1523. Case 11: PlaySound "SFX_Homer"
  1524. Case 12: PlaySound "SFX_ThankSoggy"
  1525. 'Case 13: PlaySoung "SFXNoTreasure"
  1526. End Select
  1527. End If
  1528. soundPlayed = 1
  1529. End Sub
  1530.  
  1531. ''**********Sling Shot Animations
  1532. '' Rstep and Lstep are the variables that increment the animation
  1533. ''****************
  1534. Dim lStep, rStep, slingTotal
  1535. Sub rightSlingShot_Slingshot
  1536. playfieldSound SoundFXDOF("SlingShot",109,DOFPulse,DOFContactors), 0, SoundPoint13, 1
  1537. DOF 104, DOFPulse
  1538. If VictrolaLightR.state = 1 Then
  1539. addscore 100
  1540. Else
  1541. addscore 10
  1542. End If
  1543. rSling0.Visible = 0
  1544. rSling1.Visible = 1
  1545. sling1.Rotx = 10
  1546. rStep = 0
  1547. slingTotal = slingTotal + 1
  1548. If slingTotal mod 20 = 0 Then
  1549. ' PlaySound "SFX_CashRegister"
  1550. PlaySound "SFX_FatContract",0,1,0,0,0,1,0,0
  1551. addScore 1000
  1552. End If
  1553. rightSlingShot.TimerEnabled = 1
  1554. End Sub
  1555.  
  1556. Sub rightSlingShot_Timer
  1557. Select Case rStep
  1558. Case 3:rSLing1.Visible = 0:rSLing2.Visible = 1:sling1.Rotx = 0
  1559. Case 4:rSLing2.Visible = 0:rSLing0.Visible = 1:rightSlingShot.TimerEnabled = 0
  1560. End Select
  1561. rStep = rStep + 1
  1562. End Sub
  1563. '
  1564. Sub leftSlingShot_Slingshot
  1565. playfieldSound SoundFXDOF("SlingShot",103,DOFPulse,DOFContactors), 0, SoundPoint12, 1
  1566. DOF 108, DOFPulse
  1567. If VictrolaLightL.state = 1 Then
  1568. addscore 100
  1569. Else
  1570. addscore 10
  1571. End If
  1572. lSling0.Visible = 0
  1573. lSling1.Visible = 1
  1574. sling2.Rotx = 10
  1575. lStep = 0
  1576. slingTotal = slingTotal + 1
  1577. If slingTotal mod 20 = 0 Then
  1578. ' PlaySound "SFX_CashRegister"
  1579. PlaySound "SFX_FatContract",0,1,0,0,0,1,0,0
  1580. addScore 1000
  1581. End If
  1582. leftSlingShot.TimerEnabled = 1
  1583. End Sub
  1584.  
  1585. Sub leftSlingShot_Timer
  1586. Select Case lStep
  1587. Case 3:lSLing1.Visible = 0:lSLing2.Visible = 1:sling2.Rotx = 0
  1588. Case 4:lSLing2.Visible = 0:lSLing0.Visible = 1:leftSlingShot.TimerEnabled = 0
  1589. End Select
  1590. lStep = lStep + 1
  1591. End Sub
  1592.  
  1593. Sub waterSling_Slingshot
  1594. addScore 100
  1595. If WaterLight.state = 2 Then
  1596. WaterLight.state = 1
  1597. modeCheck
  1598. If playModeSound = 0 Then
  1599. Select Case activePhase
  1600. Case 4: playObjectiveSound
  1601. Case 13: playObjectiveSound
  1602. End Select
  1603. End If
  1604. playModeSound = 0
  1605. End If
  1606. End Sub
  1607.  
  1608. '*************** Spinners
  1609. Sub spinners_Spin(Index)
  1610. playFieldSound "spinner", 0, Spinner1, 1
  1611. If tilt = False Then
  1612. addscore 100
  1613. DOF (430 + Index), DOFPulse
  1614. End If
  1615. End Sub
  1616.  
  1617. Dim ballSaveOn, ballSaveCount
  1618. '**************Ball Save
  1619. Sub ballSave_Timer
  1620. ballSaveCount = ballSaveCount + 1
  1621. If ballSaveCount = 8 Then SamePlayerShootsAgain.state = 2
  1622. If ballSaveCount = 10 Then: SamePlayerShootsAgain.state = 0: ballSaveOn = 0: ballSaveCount = 0: ballSave.enabled = 0
  1623. End Sub
  1624.  
  1625. '**************Special
  1626. Sub special
  1627. AddCredit = 1
  1628. ScoreMotor5.enabled = 1
  1629. playsound SoundFXDOF("Knocker",428,DOFPulse,DOFKnocker)
  1630. DOF 429, DOFPulse
  1631. End Sub
  1632.  
  1633. '***************Delay to start radio sfx
  1634. Sub radioDelay_Timer
  1635. If activePhase = 14 Then
  1636. PlaySound "EMGameEnd",0,1,0,0,0,1,0,0
  1637. Else
  1638. PlaySound "SFX_RadioShow",0,1,0,0,0,1,0,0
  1639. End If
  1640. sortScores
  1641. checkHighScores
  1642. radioDelay.enabled = 0
  1643. radioEnd.enabled = 1
  1644. End Sub
  1645.  
  1646. Sub radioEnd_Timer
  1647. If musicOn = 1 Then PlayMusic"OBWAT/OBWAT1.mp3", MusicVolume
  1648. radioEnd.Enabled = 0
  1649. End Sub
  1650.  
  1651. '***************Score Motor Run one full rotation
  1652. Dim scoreMotorCount, addCredit
  1653. Sub scoremotor5_Timer
  1654. scoreMotorCount = scoreMotorCount + 1
  1655. playFieldSound "ScoreMotorSingleFire", 0, SoundPointScoreMotor, 0. 'need to set location of score motor under the PF
  1656. If scoremotorCount = 5 Then
  1657. If relBall = 1 Then
  1658. relBall = 0
  1659. releaseBall
  1660. End If
  1661. If addCredit = 1 Then
  1662. credit = credit + 1
  1663. If showDT = False Then PlayReelSound "Reel5", bgcrReel Else PlayReelSound "Reel5", dtcrReel
  1664. DOF 427, DOFOn
  1665. If credit > 15 then credit = 15
  1666. CreditReel.setValue (credit)
  1667. If B2SOn Then
  1668. controller.B2SSetCredits credit
  1669. End If
  1670. If credit > 0 Then DOF 427, DOFOn
  1671. addCredit = 0
  1672. End If
  1673. scoreMotorCount = 0
  1674. scoreMotor5.enabled = 0
  1675. End If
  1676. End Sub
  1677.  
  1678. '**************Score Motor Routine
  1679. Dim bellRing, scoreMotorLoop, kickerUp, KickBonus, motorOn
  1680. Sub ScoreMotor_timer
  1681. scoreMotorLoop = scoreMotorLoop + 1
  1682. If scoreMotorLoop < 6 Then playFieldSound "ScoreMotorSingleFire", 0, SoundPointScoreMotor, 0.2
  1683. motorOn = 1
  1684.  
  1685. ' BonusFlag lets the sub know that the bonus score is being paid out
  1686. ' The bonus is paid out on the 2nd and 4th positions of the score motor, the 6th position is the index reel notch
  1687. If bonusFlag = 1 Then
  1688. Select Case scoreMotorLoop
  1689. Case 1:
  1690. Case 2: If bonusScore > 0 Then
  1691. If tilt = False Then totalUp 1000 * bonusMult
  1692. If bonusScore < 14 Then EVAL("bonus" & BonusScore).State = 0
  1693. bonusScore = bonusScore - 1
  1694. End If
  1695. Case 3:
  1696. Case 4: If bonusScore > 0 Then
  1697. If tilt = False Then totalUp 1000 * bonusMult
  1698. EVAL("bonus" & BonusScore).State = 0
  1699. bonusScore = bonusScore - 1
  1700. End If
  1701. Case 5:
  1702. Case 6: scoreMotorLoop = 0
  1703. If bonusScore < 1 Then
  1704. scoreBonus
  1705. motorOn = 0
  1706. scoreMotor.enabled = 0
  1707. End If
  1708. End Select
  1709. Else
  1710. scoreMotorLoop = 0
  1711. scoremotor.enabled = 0
  1712. Exit Sub
  1713. End If
  1714. End Sub
  1715.  
  1716. '***************Scoring Routine
  1717. Dim point, point100
  1718. Sub addScore(points)
  1719. reelDone(player) = 0
  1720. If tilt = False Then
  1721. If points > 9 and points <100 Then
  1722. totalUp(points)
  1723. If chime = 0 Then
  1724. playFieldSound SoundFX("Chime10",DOFChimes), 0, soundPoint13, 1
  1725. Else
  1726. DOF 442,DOFPulse
  1727. End If
  1728. Exit Sub
  1729. End If
  1730.  
  1731. If points > 99 and points < 1000 Then
  1732. ' Number Matching, decrement the match unit for each 100 point score
  1733. point100 = (points / 100)
  1734. If matchNumber >= point100 Then
  1735. matchNumber = matchNumber - point100
  1736. Else
  1737. point100 = point100 - matchNumber
  1738. matchNumber = 10 - point100
  1739. End If
  1740. Alternator
  1741. totalUp(points)
  1742. If chime = 0 Then
  1743. playFieldSound SoundFX("Chime100",DOFChimes), 0, soundPoint13, 1
  1744. Else
  1745. DOF 443,DOFPulse
  1746. End If
  1747. Exit Sub
  1748. End If
  1749.  
  1750. If Points > 999 Then
  1751. totalUp(points)
  1752. If chime = 0 Then
  1753. playFieldSound SoundFX("Chime100",DOFChimes), 0, soundPoint13, 1
  1754. Else
  1755. DOF 443,DOFPulse
  1756. End If
  1757. End If
  1758.  
  1759. End If
  1760. End Sub
  1761.  
  1762. Dim replayX, replay(7), repAwarded(5)
  1763. Sub totalUp(points)
  1764. If B2SOn and showDT = False Then
  1765. If Player = 1 Then PlayReelSound "Reel1", bgs1Reel
  1766. If Player = 2 Then PlayReelSound "Reel2", bgs2Reel
  1767. If Player = 3 Then PlayReelSound "Reel3", bgs3Reel
  1768. If Player = 4 Then PlayReelSound "Reel4", bgs4Reel
  1769. End If
  1770.  
  1771. If showDT = True Then
  1772. If Player = 1 Then PlayReelSound "Reel1", dts1Reel
  1773. If Player = 2 Then PlayReelSound "Reel2", dts2Reel
  1774. If Player = 3 Then PlayReelSound "Reel3", dts3Reel
  1775. If Player = 4 Then PlayReelSound "Reel4", dts4Reel
  1776. End If
  1777.  
  1778. If bonusFlag = 1 Then
  1779. If chime = 0 Then
  1780. playFieldSound SoundFX("chime1000",DOFChimes), 0, SoundPoint13, 1
  1781. Else
  1782. DOF 443,DOFPulse
  1783. End If
  1784. End If
  1785.  
  1786. score(Player) = score(player) + points
  1787. sReel(Player).addvalue(points)
  1788.  
  1789.  
  1790. If B2SOn Then controller.B2SSetScorePlayer player, score(player)
  1791.  
  1792. If score(player) > replay(rep(player)) or score(player) = replay(rep(player)) Then
  1793. If rep(player) > 3 Then Exit Sub
  1794. AddCredit = 1
  1795. ScoreMotor5.enabled = 1
  1796. rep(player) = rep(player) + 1
  1797. playsound SoundFXDOF("knocker",428,DOFPulse,DOFKnocker)
  1798. DOF 429, DOFPulse
  1799. End If
  1800. End Sub
  1801.  
  1802.  
  1803. '***************Tilt
  1804. Dim tiltSens, tiltPenalty
  1805. '**** Set tiltPenalty; 0 = loose current ball / 1 = end game
  1806. tiltPenalty = 0
  1807.  
  1808. Sub checkTilt
  1809. If tilttimer.enabled = True Then
  1810. tiltSens = tiltSens + 1
  1811. If tiltSens = 3 Then
  1812. tilt = True
  1813. PlaySound "SFX_MusicOver",0,1,0,0,0,1,0,0
  1814. TiltReel.setValue(1)
  1815. If B2SOn Then controller.B2SSetTilt 33,1
  1816. If B2SOn Then controller.B2SSetdata 1, 0
  1817. turnOff
  1818. End If
  1819. Else
  1820. tiltSens = 0
  1821. tilttimer.enabled = True
  1822. End If
  1823. End Sub
  1824.  
  1825. Sub tilttimer_Timer()
  1826. tilttimer.enabled = False
  1827. End Sub
  1828.  
  1829. '***************Match
  1830. Sub match
  1831. ' matchNumber = ((int(rnd(1)*10)) * 10) + 10
  1832. If matchNumber = 0 Then matchNumber = 10
  1833. MatchReel.setValue(matchNumber) 'need to change if 1 point table
  1834.  
  1835. If B2SOn Then controller.B2SSetMatch 34, matchNumber
  1836.  
  1837. For i = 1 to players
  1838. If (matchNumber * 1) = (score(i) mod 10) Then 'need to set this to match 10's or 100's
  1839. addCredit = 1
  1840. scoreMotor5.enabled = 1
  1841. playsound SoundFXDOF("Knocker",428,DOFPulse,DOFKnocker)
  1842. DOF 429, DOFPulse
  1843. End If
  1844. Next
  1845. End Sub
  1846.  
  1847. '************Music Playing Routines
  1848. Dim songTrack(10), songPlace, songNumber
  1849. Sub generateSongNumber
  1850. songNumber = INT(10 * RND(1) )
  1851. checkSongNumber
  1852. End Sub
  1853.  
  1854. Sub checkSongNumber
  1855. For x = 0 to 9
  1856. If songTrack(x) = songNumber Then
  1857. generateSongNumber
  1858. Exit Sub
  1859. End If
  1860. Next
  1861. songPlace = songPlace + 1
  1862. songTrack(songPlace) = songNumber
  1863. ' tb.text = "sn1 = " & songTrack(1) & " sn2 = " & songTrack(2) & " sn3 = " & songTrack(3) & " sn4 = " & songTrack(4) & " sn5 = " & songTrack(5) & " sn6 = " & songTrack(6) & " sn7 = " & songTrack(7) & " sn8 = " & songTrack(8) & " sn9 = " & songTrack(9)
  1864. songPlayer(songNumber)
  1865. If songPlace = 9 Then
  1866. songPlace = 0
  1867. For x = 0 to 9
  1868. songTrack(x) = ""
  1869. Next
  1870. End If
  1871. End Sub
  1872.  
  1873.  
  1874. Sub songPlayer(track)
  1875. Select Case track
  1876. Case 0: PlayMusic "OBWAT/OBWAT2.mp3", MusicVolume: songLength = 25144: songTimer.enabled = 1
  1877. Case 1: PlayMusic "OBWAT/OBWAT3.mp3", MusicVolume: songLength = 21233: songTimer.enabled = 1
  1878. Case 2: PlayMusic "OBWAT/OBWAT4.mp3", MusicVolume: songLength = 20625: songTimer.enabled = 1
  1879. Case 3: PlayMusic "OBWAT/OBWAT5.mp3", MusicVolume: songLength = 23315: songTimer.enabled = 1
  1880. Case 4: PlayMusic "OBWAT/OBWAT6.mp3", MusicVolume: songLength = 13562: songTimer.enabled = 1
  1881. Case 5: PlayMusic "OBWAT/OBWAT7.mp3", MusicVolume: songLength = 15272: songTimer.enabled = 1
  1882. Case 6: PlayMusic "OBWAT/OBWAT8.mp3", MusicVolume: songLength = 13603: songTimer.enabled = 1
  1883. Case 7: PlayMusic "OBWAT/OBWAT9.mp3", MusicVolume: songLength = 25781: songTimer.enabled = 1
  1884. Case 8: PlayMusic "OBWAT/OBWAT11.mp3", MusicVolume: songLength = 9281: songTimer.enabled = 1
  1885. Case 9: PlayMusic "OBWAT/OBWAT13.mp3", MusicVolume: songLength = 18389: songTimer.enabled = 1
  1886. End Select
  1887. End Sub
  1888.  
  1889. Dim songLength, songLoop
  1890. Sub songTimer_Timer()
  1891. songLength = songLength - 1
  1892. TB1.text = songLength
  1893. If songLength = 0 Then
  1894. songTimer.enabled = 0
  1895. generateSongNumber
  1896. End If
  1897. End Sub
  1898.  
  1899.  
  1900. '************Reset Reels
  1901.  
  1902. 'This Sub looks at each individual digit in each players score and sets them in an array RScore. If the value is >0 and <9
  1903. 'then the players score is increased by one times the position value of that digit (ie 1 * 1000 for the 1000's digit)
  1904. 'If the value of the digit is 9 then it subtracts 9 times the postion value of that digit (ie 9*100 for the 100's digit)
  1905. 'so that the score is not rolled over and the next digit in line gets incremented as well (ie 9 in the 10's positon gets
  1906. 'incremented so the 100's position rolls up by one as well since 90 -> 100). Lastly the RScore array values get incremented
  1907. 'by one to get ready for the next pass.
  1908.  
  1909. Dim rScore(4,5), resetLoop, test, playerTest, resetFlag, reelFlag, reelStop, reelDone(4), SJWreelDone(4)
  1910. Sub countUp
  1911. For playerTest = 1 to 4
  1912. For test = 0 to 4
  1913. rScore(playerTest,test) = Int(score(playerTest)/10^test) mod 10
  1914. Next
  1915. Next
  1916.  
  1917. For playerTest = 1 to 4
  1918. For x = 0 to 4
  1919. If rscore(playerTest, x) > 0 And rscore(playerTest, x) < 9 Then score(playerTest) = score(playerTest) + 10^x
  1920. If rScore(playerTest, x) = 9 Then score(playerTest) = score(playerTest) - (9 * 10^x)
  1921. If rScore(playerTest, x) > 0 Then rScore(playerTest, x) = rScore(playerTest, x) + 1
  1922. If rScore(playerTest, x) = 10 Then rScore(playerTest, x) = 0
  1923. Next
  1924. Next
  1925.  
  1926. If score(1) = 0 and score(2) = 0 and score(3) = 0 and score(4) = 0 Then
  1927. reelFlag = 1
  1928. For i = 1 to maxPlayers
  1929. score(i) = 0
  1930. rep(i) = 0
  1931. repAwarded(i) = 0
  1932. Next
  1933. End If
  1934. End Sub
  1935.  
  1936. 'This Sub sets each B2S reel or Desdktop reels to their new values and then plays the score motor sound each time and the
  1937. 'reel sounds only if the reels are being stepped
  1938.  
  1939. Sub updateReels
  1940. For playerTest = 1 to 4
  1941. If B2SOn and showDT = False and reelDone(playerTest) = 0 and reelStop = 0 Then
  1942. controller.B2SSetScorePlayer playerTest, score(playerTest)
  1943. If reelDone(1) = 0 and playerTest = 1 Then PlayReelSound "Reel1", bgs1Reel
  1944. If reelDone(2) = 0 and playerTest = 2 Then PlayReelSound "Reel2", bgs2Reel
  1945. If reelDone(3) = 0 and playerTest = 3 Then PlayReelSound "Reel3", bgs3Reel
  1946. If reelDone(4) = 0 and playerTest = 4 Then PlayReelSound "Reel4", bgs4Reel
  1947. If score(playerTest) = 0 Then reelDone(playerTest) = 1
  1948. End If
  1949.  
  1950. If showDT = True and reelDone(playerTest) = 0 and reelStop = 0 Then
  1951. sReel(playerTest).setvalue (score(playerTest))
  1952. If reelDone(1) = 0 and playerTest = 1 Then playReelSound "Reel1", dts1Reel
  1953. If reelDone(2) = 0 and playerTest = 2 Then playReelSound "Reel2", dts2Reel
  1954. If reelDone(3) = 0 and playerTest = 3 Then playReelsound "Reel3", dts3Reel
  1955. If reelDone(4) = 0 and playerTest = 4 Then playReelSound "Reel4", dts4Reel
  1956. If score(playerTest) = 0 Then reelDone(playerTest) = 1
  1957. End If
  1958.  
  1959. Next
  1960. playfieldSound "scoreMotorSingleFire", 0, soundPointScoreMotor, 0.2
  1961. If reelStop = 0 Then playsound "reel"
  1962. If reelFlag = 1 Then reelStop = 1
  1963.  
  1964. End Sub
  1965.  
  1966. 'This Timer runs a loop that calls the CountUp and UpdateReels routines to step the reels up five times and Then
  1967. 'check to see if they are all at zero during a two loop pause and then step them the rest of the way to zero
  1968.  
  1969. Dim testFlag
  1970. Sub resetReel_Timer
  1971. For x = 1 to 4
  1972. score(x) = (score(x) Mod 100000)
  1973. Next
  1974. resetLoop = resetLoop + 1
  1975. If resetLoop = 1 and score(1) = 0 and score(2) = 0 and score(3) = 0 and score(4) = 0 Then
  1976. resetLoop = 0
  1977. If testFlag = 0 Then releaseBall
  1978. testFlag = 0
  1979. resetReel.enabled = 0
  1980. Exit Sub
  1981. End If
  1982. Select Case resetLoop
  1983. Case 1: countUp: updateReels
  1984. Case 2: countUp: updateReels
  1985. Case 3: countUp: updateReels
  1986. Case 4: countUp: updateReels
  1987. Case 5: countUp: updateReels
  1988. Case 6: If reelStop = 1 Then
  1989. resetLoop = 0
  1990. reelFlag = 0
  1991. reelStop = 0
  1992. If testFlag = 0 Then releaseBall
  1993. testFlag = 0
  1994. resetReel.enabled = 0
  1995. Exit Sub
  1996. End If
  1997.  
  1998. Case 7:
  1999. Case 8: countUp: updateReels
  2000. Case 9: countUp: updateReels
  2001. Case 10: countUp: updateReels
  2002. Case 11: countUp: updateReels
  2003. Case 12: countUp: updateReels:
  2004. resetLoop = 0
  2005. reelFlag = 0
  2006. reelStop = 0
  2007. If testFlag = 0 Then releaseBall
  2008. testFlag = 0
  2009. resetReel.enabled = 0
  2010. Exit Sub
  2011. End Select
  2012. End Sub
  2013.  
  2014. '************************************************Post It Note Section**************************************************************************
  2015. '***************Static Post It Note Update
  2016. Dim hsY, shift, scoreMil, score100K, score10K, scoreK, score100, score10, scoreUnit
  2017. Dim hsInitial0, hsInitial1, hsInitial2
  2018. Dim hsArray: hsArray = Array("HS_0","HS_1","HS_2","HS_3","HS_4","HS_5","HS_6","HS_7","HS_8","HS_9","HS_Space","HS_Comma")
  2019. Dim hsiArray: hsIArray = Array("HSi_0","HSi_1","HSi_2","HSi_3","HSi_4","HSi_5","HSi_6","HSi_7","HSi_8","HSi_9","HSi_10","HSi_11","HSi_12","HSi_13","HSi_14","HSi_15","HSi_16","HSi_17","HSi_18","HSi_19","HSi_20","HSi_21","HSi_22","HSi_23","HSi_24","HSi_25","HSi_26")
  2020.  
  2021. Sub updatePostIt
  2022. scoreMil = Int(highScore(0)/1000000)
  2023. score100K = Int( (highScore(0) - (scoreMil*1000000) ) / 100000)
  2024. score10K = Int( (highScore(0) - (scoreMil*1000000) - (score100K*100000) ) / 10000)
  2025. scoreK = Int( (highScore(0) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) ) / 1000)
  2026. score100 = Int( (highScore(0) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) ) / 100)
  2027. score10 = Int( (highScore(0) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) ) / 10)
  2028. scoreUnit = (highScore(0) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) - (score10*10) )
  2029.  
  2030. pScore6.image = hsArray(scoreMil):If highScore(0) < 1000000 Then pScore6.image = hsArray(10)
  2031. pScore5.image = hsArray(score100K):If highScore(0) < 100000 Then pScore5.image = hsArray(10)
  2032. pScore4.image = hsArray(score10K):If highScore(0) < 10000 Then pScore4.image = hsArray(10)
  2033. pScore3.image = hsArray(scoreK):If highScore(0) < 1000 Then pScore3.image = hsArray(10)
  2034. pScore2.image = hsArray(score100):If highScore(0) < 100 Then pScore2.image = hsArray(10)
  2035. pScore1.image = hsArray(score10):If highScore(0) < 10 Then pScore1.image = hsArray(10)
  2036. pScore0.image = hsArray(scoreUnit):If highScore(0) < 1 Then pScore0.image = hsArray(10)
  2037. If highScore(0) < 1000 Then
  2038. PComma.image = hsArray(10)
  2039. Else
  2040. pComma.image = hsArray(11)
  2041. End If
  2042. If highScore(0) < 1000000 Then
  2043. pComma1.image = hsArray(10)
  2044. Else
  2045. pComma1.image = hsArray(11)
  2046. End If
  2047. If highScore(0) > 999999 Then shift = 0 :pComma.transx = 0
  2048. If highScore(0) < 1000000 Then shift = 1:pComma.transx = -10
  2049. If highScore(0) < 100000 Then shift = 2:pComma.transx = -20
  2050. If highScore(0) < 10000 Then shift = 3:pComma.transx = -30
  2051. For hsY = 0 to 6
  2052. EVAL("Pscore" & hsY).transx = (-10 * shift)
  2053. Next
  2054. initial1.image = hsIArray(initial(0,1))
  2055. initial2.image = hsIArray(initial(0,2))
  2056. initial3.image = hsIArray(initial(0,3))
  2057. End Sub
  2058.  
  2059. '***************Show Current Score
  2060. Sub showScore
  2061. scoreMil = Int(highScore(activeScore(flag))/1000000)
  2062. score100K = Int( (highScore(activeScore(flag)) - (scoreMil*1000000) ) / 100000)
  2063. score10K = Int( (highScore(activeScore(flag)) - (scoreMil*1000000) - (score100K*100000) ) / 10000)
  2064. scoreK = Int( (highScore(activeScore(flag)) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) ) / 1000)
  2065. score100 = Int( (highScore(activeScore(flag)) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) ) / 100)
  2066. score10 = Int( (highScore(activeScore(flag)) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) ) / 10)
  2067. scoreUnit = (highScore(activeScore(flag)) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) - (score10*10) )
  2068.  
  2069. pScore6.image = hsArray(scoreMil):If highScore(activeScore(flag)) < 1000000 Then pScore6.image = hsArray(10)
  2070. pScore5.image = hsArray(score100K):If highScore(activeScore(flag)) < 100000 Then pScore5.image = hsArray(10)
  2071. pScore4.image = hsArray(score10K):If highScore(activeScore(flag)) < 10000 Then pScore4.image = hsArray(10)
  2072. pScore3.image = hsArray(scoreK):If highScore(activeScore(flag)) < 1000 Then pScore3.image = hsArray(10)
  2073. pScore2.image = hsArray(score100):If highScore(activeScore(flag)) < 100 Then pScore2.image = hsArray(10)
  2074. pScore1.image = hsArray(score10):If highScore(activeScore(flag)) < 10 Then pScore1.image = hsArray(10)
  2075. pScore0.image = hsArray(scoreUnit):If highScore(activeScore(flag)) < 1 Then pScore0.image = hsArray(10)
  2076. If highScore(activeScore(flag)) < 1000 Then
  2077. pComma.image = hsArray(10)
  2078. Else
  2079. pComma.image = hsArray(11)
  2080. End If
  2081. If highScore(activeScore(flag)) < 1000000 Then
  2082. pComma1.image = hsArray(10)
  2083. Else
  2084. pComma1.image = hsArray(11)
  2085. End If
  2086. If highScore(flag) > 999999 Then shift = 0 :pComma.transx = 0
  2087. If highScore(activeScore(flag)) < 1000000 Then shift = 1:pComma.transx = -10
  2088. If highScore(activeScore(flag)) < 100000 Then shift = 2:pComma.transx = -20
  2089. If highScore(activeScore(flag)) < 10000 Then shift = 3:pComma.transx = -30
  2090. For HSy = 0 to 6
  2091. EVAL("Pscore" & hsY).transx = (-10 * shift)
  2092. Next
  2093. initial1.image = hsIArray(initial(activeScore(flag),1))
  2094. initial2.image = hsIArray(initial(activeScore(flag),2))
  2095. initial3.image = hsIArray(initial(activeScore(flag),3))
  2096. End Sub
  2097.  
  2098. '***************Dynamic Post It Note Update
  2099. Dim scoreUpdate, dHSx
  2100. Sub dynamicUpdatePostIt_Timer
  2101. scoreMil = Int(highScore(scoreUpdate)/1000000)
  2102. score100K = Int( (highScore(ScoreUpdate) - (scoreMil*1000000) ) / 100000)
  2103. score10K = Int( (highScore(scoreUpdate) - (ScoreMil*1000000) - (Score100K*100000) ) / 10000)
  2104. scoreK = Int( (highScore(scoreUpdate) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) ) / 1000)
  2105. score100 = Int( (highScore(ScoreUpdate) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) ) / 100)
  2106. score10 = Int( (highScore(ScoreUpdate) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) ) / 10)
  2107. scoreUnit = (highScore(ScoreUpdate) - (scoreMil*1000000) - (score100K*100000) - (score10K*10000) - (scoreK*1000) - (score100*100) - (score10*10) )
  2108.  
  2109. pScore6.image = hsArray(ScoreMil):If highScore(scoreUpdate) < 1000000 Then pScore6.image = hsArray(10)
  2110. pScore5.image = hsArray(Score100K):If highScore(scoreUpdate) < 100000 Then pScore5.image = hsArray(10)
  2111. pScore4.image = hsArray(Score10K):If highScore(scoreUpdate) < 10000 Then pScore4.image = hsArray(10)
  2112. pScore3.image = hsArray(ScoreK):If highScore(scoreUpdate) < 1000 Then pScore3.image = hsArray(10)
  2113. pScore2.image = hsArray(Score100):If highScore(scoreUpdate) < 100 Then pScore2.image = hsArray(10)
  2114. pScore1.image = hsArray(Score10):If highScore(scoreUpdate) < 10 Then pScore1.image = hsArray(10)
  2115. pScore0.image = hsArray(ScoreUnit):If highScore(scoreUpdate) < 1 Then pScore0.image = hsArray(10)
  2116. If highScore(scoreUpdate) < 1000 Then
  2117. pComma.image = hsArray(10)
  2118. Else
  2119. pComma.image = hsArray(11)
  2120. End If
  2121. If highScore(scoreUpdate) < 1000000 Then
  2122. pComma1.image = hsArray(10)
  2123. Else
  2124. pComma1.image = hsArray(11)
  2125. End If
  2126. If highScore(scoreUpdate) > 999999 Then shift = 0 :pComma.transx = 0
  2127. If highScore(scoreUpdate) < 1000000 Then shift = 1:pComma.transx = -10
  2128. If highScore(scoreUpdate) < 100000 Then shift = 2:pComma.transx = -20
  2129. If highScore(scoreUpdate) < 10000 Then shift = 3:pComma.transx = -30
  2130. For dHSx = 0 to 6
  2131. EVAL("Pscore" & dHSx).transx = (-10 * shift)
  2132. Next
  2133. initial1.image = hsIArray(initial(scoreUpdate,1))
  2134. initial2.image = hsIArray(initial(scoreUpdate,2))
  2135. initial3.image = hsIArray(initial(scoreUpdate,3))
  2136. scoreUpdate = scoreUpdate + 1
  2137. If scoreUpdate = 5 then scoreUpdate = 0
  2138. End Sub
  2139.  
  2140. '***************Bubble Sort
  2141. Dim tempScore(2), tempPos(3), position(5)
  2142. Dim bSx, bSy
  2143. 'Scores are sorted high to low with Position being the player's number
  2144. Sub sortScores
  2145. For bSx = 1 to 4
  2146. position(bSx) = bSx
  2147. Next
  2148. For bSx = 1 to 4
  2149. For bSy = 1 to 3
  2150. If score(bSy) < score(bSy+1) Then
  2151. tempScore(1) = score(bSy+1)
  2152. tempPos(1) = position(bSy+1)
  2153. score(bSy+1) = score(bSy)
  2154. score(bSy) = tempScore(1)
  2155. position(bSy+1) = position(BSy)
  2156. position(bSy) = tempPos(1)
  2157. End If
  2158. Next
  2159. Next
  2160. End Sub
  2161.  
  2162. '*************Check for High Scores
  2163.  
  2164. Dim highScore(5), activeScore(5), hs, chX, chY, chZ, chIX, tempI(4), tempI2(4), flag, hsI, hsX
  2165. 'goes through the 5 high scores one at a time and compares them to the player's scores high to
  2166. 'if a player's score is higher it marks that postion with ActiveScore(x) and moves all of the other
  2167. ' high scores down by one along with the high score's player initials
  2168. ' also clears the new high score's initials for entry later
  2169. Sub checkHighScores
  2170. flag = 0
  2171. For hs = 1 to maxPlayers 'look at all 5 saved high scores
  2172. For chY = 0 to 4 'look at 4 player scores
  2173. If score(hs) > highScore(chY) Then
  2174. flag = flag + 1 'flag to show how many high scores needs replacing
  2175. tempScore(1) = highScore(chY)
  2176. highScore(chY) = score(hs)
  2177. activeScore(hs) = chY 'ActiveScore(x) is the high score being modified with x=1 the largest and x=4 the smallest
  2178. For chIX = 1 to 3 'set initals to blank and make temporary initials = to intials being modifed so they can move down one high score
  2179. tempI(chIX) = initial(chY,chIX)
  2180. initial(chY,chIX) = 0
  2181. Next
  2182.  
  2183. If chY < 4 Then 'check if not on lowest high score for overflow error prevention
  2184. For chZ = chY+1 to 4 'set as high score one more than score being modifed (CHy+1)
  2185. tempScore(2) = highScore(chZ) 'set a temporaray high score for the high score one higher than the one being modified
  2186. highScore(chZ) = tempScore(1) 'set this score to the one being moved
  2187. tempScore(1) = tempScore(2) 'reassign TempScore(1) to the next higher high score for the next go around
  2188. For chIX = 1 to 3
  2189. tempI2(chIX) = initial(chZ,chIX) 'make a new set of temporary initials
  2190. Next
  2191. For chIX = 1 to 3
  2192. initial(chZ,chIX) = tempI(chIX) 'set the initials to the set being moved
  2193. tempI(chIX) = tempI2(chIX) 'reassign the initials for the next go around
  2194. Next
  2195. Next
  2196. End If
  2197. chY = 4 'if this loop was accessed set CHy to 4 to get out of the loop
  2198. End If
  2199. Next
  2200. Next
  2201. ' Goto Initial Entry
  2202. hsI = 1 'go to the first initial for entry
  2203. hsX = 1 'make the displayed inital be "A"
  2204. If flag > 0 Then 'Flag 0 when all scores are updated so leave subroutine and reset variables
  2205. showScore
  2206. PlayerEntry.visible = 1
  2207. PlayerEntry.image = "Player" & position(Flag)
  2208. initial(activeScore(flag),1) = 1 'make first inital "A"
  2209. For chY = 2 to 3
  2210. initial(activeScore(flag),chY) = 0 'set other two to " "
  2211. Next
  2212. For chY = 1 to 3
  2213. EVAL("Initial" & chY).image = hsIArray(initial(activeScore(flag),chY)) 'display the initals on the tape
  2214. Next
  2215. initialTimer1.enabled = 1 'flash the first initial
  2216. dynamicUpdatePostIt.enabled = 0 'stop the scrolling intials timer
  2217. stopSound("SFX_RadioShow")
  2218. if activePhase < 14 Then playsound "SFX_Paddling"
  2219. 'DOF 428, DOFPulse
  2220. enableInitialEntry = True
  2221. End If
  2222. End Sub
  2223.  
  2224. '************Enter Initials Keycode Subroutine
  2225. Dim initial(6,5), initialsDone
  2226. Sub enterIntitals(keycode)
  2227. If keyCode = leftFlipperKey Then
  2228. hsX = hsX - 1 'HSx is the inital to be displayed A-Z plus " "
  2229. If hsX < 0 Then hsX = 26
  2230. If hsI < 4 Then EVAL("Initial" & hsI).image = hsIArray(hsX) 'HSi is which of the three intials is being modified
  2231. playSound "metalhit_thin"
  2232. End If
  2233. If keycode = RightFlipperKey Then
  2234. hsX = hsX + 1
  2235. If hsX > 26 Then hsX = 0
  2236. If hsI < 4 Then EVAL("Initial"& hsI).image = hsIArray(hsX)
  2237. playSound "metalhit_thin"
  2238. End If
  2239. If keycode = startGameKey and initialsDone = 0 Then
  2240. If hsI < 3 Then 'if not on the last initial move on to the next intial
  2241. EVAL("Initial" & hsI).image = hsIArray(hsX) 'display the initial
  2242. initial(activeScore(flag), hsI) = hsX 'save the inital
  2243. playSound "metalhit_medium"
  2244. EVAL("InitialTimer" & hsI).enabled = 0 'turn that inital's timer off
  2245. EVAL("Initial" & hsI).visible = 1 'make the initial not flash but be turn on
  2246. initial(activeScore(flag),hsI + 1) = hsX 'move to the next initial and make it the same as the last initial
  2247. EVAL("Initial" & hsI +1).image = hsIArray(hsX) 'display this intial
  2248. ' y = 1
  2249. EVAL("InitialTimer" & hsI + 1).enabled = 1 'make the new intial flash
  2250. hsI = hsI + 1 'increment HSi
  2251. Else 'if on the last initial then get ready yo exit the subroutine
  2252. initial3.visible = 1 'make the intial visible
  2253. playSound "metalhit_medium"
  2254. initialTimer3.enabled = 0 'shut off the flashing
  2255. initial(activeScore(flag),3) = hsX 'set last initial
  2256. initialEntry 'exit subroutine
  2257. End If
  2258. End If
  2259. End Sub
  2260.  
  2261. '************Update Initials and see if more scores need to be updated
  2262. Dim eIX
  2263. Sub initialEntry
  2264. playsound SoundFXDOF("Chime10",441,DOFPulse,DOFChimes)
  2265. flag = flag - 1
  2266. ' TextBox2.text = Flag
  2267. hsI = 1
  2268. If flag < 0 Then flag = 0: Exit Sub
  2269. If flag = 0 Then 'exit high score entry mode and reset variables
  2270. initialsDone = 1 'prevents changes in intials while the highScoreDelay timer waits to finish
  2271. players = 0
  2272. For eIX = 1 to 4
  2273. activeScore(eIX) = 0
  2274. position(eIX) = 0
  2275. Next
  2276. For eIX = 1 to 3
  2277. EVAL("InitialTimer" & eIX).enabled = 0
  2278. Next
  2279. playerEntry.visible = 0
  2280. scoreUpdate = 0 'go to the highest score
  2281. updatePostIt 'display that score
  2282. highScoreDelay.enabled = 1
  2283. Else
  2284. showScore
  2285. playerEntry.image = "Player" & position(flag)
  2286. ' TextBox3.text = ActiveScore(Flag) 'tells which high score is being entered
  2287. ' TextBox2.text = Flag
  2288. ' TextBox1.text = Position(Flag) 'tells which player is entering values
  2289. initial(activeScore(flag),1) = 1 'set the first initial to "A"
  2290. For chY = 2 to 3
  2291. initial(activeScore(flag),chY) = 0 'set the other two to " "
  2292. Next
  2293. For chY = 1 to 3
  2294. EVAL("Initial" & chY).image = hsIArray(initial(activeScore(flag),chY)) 'display the intials
  2295. Next
  2296. hsX = 1 'go to the letter "A"
  2297. initialTimer1.enabled = 1 'flash the first intial
  2298. End If
  2299. End Sub
  2300.  
  2301. '************Delay to prevent start button push for last initial from starting game Update
  2302. Sub highScoreDelay_timer
  2303. highScoreDelay.enabled = 0
  2304. enableInitialEntry = False
  2305. initialsDone = 0
  2306. saveHighScore
  2307. For eIX = 1 to 3
  2308. EVAL("InitialTimer" & eIX).enabled = 0
  2309. Next
  2310. dynamicUpdatePostIt.enabled = 1 'turn scrolling high score back on
  2311. End Sub
  2312.  
  2313. '************Flash Initials Timers
  2314. Sub initialTimer1_Timer
  2315. y = y + 1
  2316. If y > 1 Then y = 0
  2317. If y = 0 Then
  2318. initial1.visible = 1
  2319. Else
  2320. initial1.visible = 0
  2321. End If
  2322. End Sub
  2323.  
  2324. Sub initialTimer2_Timer
  2325. y = y + 1
  2326. If y > 1 Then y = 0
  2327. If y = 0 Then
  2328. initial2.visible = 1
  2329. Else
  2330. initial2.visible = 0
  2331. End If
  2332. End Sub
  2333.  
  2334. Sub initialTimer3_Timer
  2335. y = y + 1
  2336. If y > 1 Then y = 0
  2337. If y = 0 Then
  2338. initial3.visible = 1
  2339. Else
  2340. initial3.visible = 0
  2341. End If
  2342. End Sub
  2343.  
  2344. '*************Load Scores
  2345. Sub loadHighScore
  2346. Dim fileObj
  2347. Dim scoreFile
  2348. Dim temp(40)
  2349. Dim textStr
  2350.  
  2351. dim hiInitTemp(3)
  2352. dim hiInit(5)
  2353.  
  2354. Set fileObj = CreateObject("Scripting.FileSystemObject")
  2355. If Not fileObj.FolderExists(UserDirectory) Then
  2356. Exit Sub
  2357. End If
  2358. If Not fileObj.FileExists(UserDirectory & cOptions) Then
  2359. Exit Sub
  2360. End If
  2361. Set scoreFile = fileObj.GetFile(UserDirectory & cOptions)
  2362. Set textStr = scoreFile.OpenAsTextStream(1,0)
  2363. If (textStr.AtEndOfStream = True) Then
  2364. Exit Sub
  2365. End If
  2366.  
  2367. For x = 1 to 33
  2368. temp(x) = textStr.readLine
  2369. Next
  2370. TextStr.Close
  2371. For x = 0 to 4
  2372. highScore(x) = cdbl (temp(x+1))
  2373. Next
  2374. For x = 0 to 4
  2375. hiInit(x) = (temp(x + 6))
  2376. Next
  2377. i = 10
  2378. For x = 0 to 4
  2379. For y = 1 to 3
  2380. i = i + 1
  2381. initial(x,y) = cdbl (temp(i))
  2382. Next
  2383. Next
  2384. credit = cdbl (temp(26))
  2385. freePlay = cdbl (temp(27))
  2386. balls = cdbl (temp(28))
  2387. matchNumber = cdbl (temp(29))
  2388. chime = cdbl (temp(30))
  2389. pfOption = cdbl (temp(31))
  2390. musicOn = cdbl (temp(32))
  2391. musicVolume = cdbl (temp(33))
  2392. Set scoreFile = Nothing
  2393. Set fileObj = Nothing
  2394. End Sub
  2395.  
  2396. '************Save Scores
  2397. Sub saveHighScore
  2398. Dim hiInit(5)
  2399. Dim hiInitTemp(5)
  2400. Dim FolderPath
  2401. For x = 0 to 4
  2402. For y = 1 to 3
  2403. hiInitTemp(y) = chr(initial(x,y) + 64)
  2404. Next
  2405. hiInit(x) = hiInitTemp(1) + hiInitTemp(2) + hiInitTemp(3)
  2406. Next
  2407. Dim fileObj
  2408. Dim scoreFile
  2409. Set fileObj = createObject("Scripting.FileSystemObject")
  2410. If Not fileObj.folderExists(userDirectory) Then
  2411. Exit Sub
  2412. End If
  2413. Set scoreFile = fileObj.createTextFile(userDirectory & cOptions,True)
  2414.  
  2415. For x = 0 to 4
  2416. scoreFile.writeLine highScore(x)
  2417. Next
  2418. For x = 0 to 4
  2419. scoreFile.writeLine hiInit(x)
  2420. Next
  2421. For x = 0 to 4
  2422. For y = 1 to 3
  2423. scoreFile.writeLine initial(x,y)
  2424. Next
  2425. Next
  2426. scoreFile.WriteLine credit
  2427. scorefile.writeline freePlay
  2428. scoreFile.WriteLine balls
  2429. scoreFile.WriteLine matchNumber
  2430. scoreFile.WriteLine chime
  2431. scoreFile.WriteLine pfOption
  2432. scoreFile.WriteLine musicOn
  2433. scoreFile.WriteLine musicVolume
  2434. scoreFile.Close
  2435. Set scoreFile = Nothing
  2436. Set fileObj = Nothing
  2437.  
  2438. 'This section of code writes a file in the User Folder of VisualPinball that contains the High Score data for PinballY.
  2439. 'PinballY can read this data and display the high scores on the DMD during game selection mode in PinballY.
  2440.  
  2441. Set FileObj = CreateObject("Scripting.FileSystemObject")
  2442.  
  2443. If cPinballY = 0 Then Exit Sub
  2444.  
  2445. If Not FileObj.FolderExists(UserDirectory) Then
  2446. Exit Sub
  2447. End If
  2448.  
  2449. FolderPath = FileObj.GetParentFolderName(UserDirectory)
  2450.  
  2451. If cPinballY = 1 Then
  2452. Set ScoreFile = FileObj.CreateTextFile(FolderPath & "/Tables/" & hsFileName & ".PinballYHighScores",True)
  2453. Else
  2454. Set ScoreFile = FileObj.CreateTextFile(UserDirectory & hsFileName & ".PinballYHighScores",True)
  2455. End If
  2456.  
  2457. For x = 0 to 4
  2458. ScoreFile.WriteLine HighScore(x)
  2459. ScoreFile.WriteLine HiInit(x)
  2460. Next
  2461. ScoreFile.Close
  2462. Set ScoreFile = Nothing
  2463. Set FileObj = Nothing
  2464.  
  2465. End Sub
  2466.  
  2467. '************Shut Down and De-Energize on Tilt
  2468. Sub turnOff
  2469.  
  2470. leftFlipper.RotateToStart
  2471. rightFlipper.RotateToStart
  2472. stopSound "flipBuzzLA"
  2473. stopSound "flipBuzzLB"
  2474. stopSound "flipBuzzLC"
  2475. stopSound "flipBuzzLD"
  2476. stopSound "flipBuzzRA"
  2477. stopSound "flipBuzzRB"
  2478. stopSound "flipBuzzRC"
  2479. stopSound "flipBuzzRD"
  2480. DOF 101, DOFOff
  2481. DOF 102, DOFOff
  2482. End Sub
  2483.  
  2484. '*****************************************************Supporting Code Written By Others*************************************
  2485.  
  2486.  
  2487.  
  2488. ' Roth's drop target routine
  2489. '************************************************************************************************
  2490. 'These are the hit subs for the DT walls that start things off and send the number of the wall hit to the DTHit sub
  2491. Sub DW001_Hit : DTHit 01 : DOF 113, DOFPulse : End Sub
  2492. Sub DW002_Hit : DTHit 02 : DOF 113, DOFPulse : End Sub
  2493. Sub DW003_Hit : DTHit 03 : DOF 113, DOFPulse : End Sub
  2494. Sub DW004_Hit : DTHit 04 : DOF 113, DOFPulse : End Sub
  2495.  
  2496. ' sub to raise all DTs at once
  2497.  
  2498. Sub ResetDrops
  2499. DTRaise 1: DTRaise 2: DTRaise 3: DTRaise 4
  2500. For x = 1 to 4
  2501. targetsDown(x) = 0
  2502. Next
  2503. End Sub
  2504.  
  2505. 'Configure the behavior of Drop Targets.
  2506. Const DTDropSpeed = 110 'in milliseconds
  2507. Const DTDropUpSpeed = 40 'in milliseconds
  2508. Const DTDropUnits = 44 'VP units primitive drops
  2509. Const DTDropUpUnits = 10 'VP units primitive raises above the up position on drops up
  2510. Const DTMaxBend = 8 'max degrees primitive rotates when hit
  2511. Const DTDropDelay = 20 'time in milliseconds before target drops (due to friction/impact of the ball)
  2512. Const DTRaiseDelay = 40 'time in milliseconds before target drops back to normal up position after the solendoid fires to raise the target
  2513. Const DTBrickVel = 30 'velocity at which the target will brick, set to '0' to disable brick
  2514. Const DTEnableBrick = 1 'Set to 0 to disable bricking, 1 to enable bricking
  2515. Const DTDropSound = "DTDrop" 'Drop Target Drop sound
  2516. Const DTResetSound = "DTReset" 'Drop Target reset sound
  2517. Const DTHitSound = "Target_Hit_1" 'Drop Target Hit sound
  2518. Const DTMass = 0.2 'Mass of the Drop Target (between 0 and 1), higher values provide more resistance
  2519.  
  2520. '******************************************************
  2521. ' DROP TARGETS FUNCTIONS
  2522. '******************************************************
  2523. 'An array of objects for each DT of (primary wall, secondary wall, primitive, switch, animate variable)
  2524. Dim DT001, DT002, DT003, DT004
  2525. DT001 = Array(DW001, DOW001, drop001, 01, 0)
  2526. DT002 = Array(DW002, DOW002, drop002, 02, 0)
  2527. DT003 = Array(DW003, DOW003, drop003, 03, 0)
  2528. DT004 = Array(DW004, DOW004, drop004, 04, 0)
  2529.  
  2530.  
  2531. 'An array of DT arrays
  2532. Dim DTArray
  2533. DTArray = Array(DT001, DT002, DT003, DT004)
  2534.  
  2535. ' This function looks over the DTArray and polls the ID the target hit (ie 06) and returns its position in the array (ie 0)
  2536. Function DTArrayID(switch)
  2537. Dim i
  2538. For i = 0 to uBound(DTArray)
  2539. If DTArray(i)(3) = switch Then DTArrayID = i: Exit Function
  2540. Next
  2541. End Function' This function looks over the DTArray and pulls the ID the target hit (ie 06))
  2542.  
  2543. Sub DTRaise(switch)
  2544. Dim i
  2545. i = DTArrayID(switch)
  2546. DTArray(i)(4) = -1 'this sets the last variable in the DT array to -1 from 0 to raise DT
  2547. DoDTAnim
  2548. End Sub
  2549.  
  2550. Sub DTDrop(switch)
  2551. Dim i
  2552. i = DTArrayID(switch)
  2553. DTArray(i)(4) = 1 'this sets the last variable in the DT array to 1 from 0
  2554. DoDTAnim
  2555. End Sub
  2556.  
  2557. Sub DTHit(switch)
  2558. Dim i
  2559. i = DTArrayID(switch) ' this sets i to be the position of the DT in the array DTArray
  2560.  
  2561. DTArray(i)(4) = DTCheckBrick(Activeball, DTArray(i)(2)) ' this sets the animate value (-1 raise, 1&4 drop, 0 do nothing, 3 bend backwards, 2 BRICK
  2562.  
  2563. If DTArray(i)(4) = 1 or DTArray(i)(4) = 3 or DTArray(i)(4) = 4 Then ' if the value from brick checking is not 2 then apply ball physics
  2564. DTBallPhysics Activeball, DTArray(i)(2).rotz, DTMass
  2565. End If
  2566. DoDTAnim
  2567. End Sub
  2568.  
  2569. sub DTBallPhysics(aBall, angle, mass)
  2570. dim rangle,bangle,calc1, calc2, calc3
  2571. rangle = (angle - 90) * 3.1416 / 180
  2572. bangle = atn2(cor.ballvely(aball.id),cor.ballvelx(aball.id))
  2573.  
  2574. calc1 = cor.BallVel(aball.id) * cos(bangle - rangle) * (aball.mass - mass) / (aball.mass + mass)
  2575. calc2 = cor.BallVel(aball.id) * sin(bangle - rangle) * cos(rangle + 4*Atn(1)/2)
  2576. calc3 = cor.BallVel(aball.id) * sin(bangle - rangle) * sin(rangle + 4*Atn(1)/2)
  2577.  
  2578. aBall.velx = calc1 * cos(rangle) + calc2
  2579. aBall.vely = calc1 * sin(rangle) + calc3
  2580. End Sub
  2581.  
  2582. Sub DTAnim_Timer() ' 10 ms timer
  2583. DoDTAnim
  2584. End Sub
  2585.  
  2586. 'Check if target is hit on it's face or sides and whether a 'brick' occurred
  2587. Function DTCheckBrick(aBall, dtprim)
  2588. dim bangle, bangleafter, rangle, rangle2, Xintersect, Yintersect, cdist, perpvel, perpvelafter, paravel, paravelafter
  2589. rangle = (dtprim.rotz - 90) * 3.1416 / 180
  2590. rangle2 = dtprim.rotz * 3.1416 / 180
  2591. bangle = atn2(cor.ballvely(aball.id),cor.ballvelx(aball.id))
  2592. bangleafter = Atn2(aBall.vely,aball.velx)
  2593.  
  2594. Xintersect = (aBall.y - dtprim.y - tan(bangle) * aball.x + tan(rangle2) * dtprim.x) / (tan(rangle2) - tan(bangle))
  2595. Yintersect = tan(rangle2) * Xintersect + (dtprim.y - tan(rangle2) * dtprim.x)
  2596.  
  2597. cdist = Distance(dtprim.x, dtprim.y, Xintersect, Yintersect)
  2598.  
  2599. perpvel = cor.BallVel(aball.id) * cos(bangle-rangle)
  2600. paravel = cor.BallVel(aball.id) * sin(bangle-rangle)
  2601.  
  2602. perpvelafter = BallSpeed(aBall) * cos(bangleafter - rangle)
  2603. paravelafter = BallSpeed(aBall) * sin(bangleafter - rangle)
  2604. 'debug.print "brick " & perpvel & " : " & paravel & " : " & perpvelafter & " : " & paravelafter
  2605.  
  2606. If perpvel > 0 and perpvelafter <= 0 Then
  2607. If DTEnableBrick = 1 and perpvel > DTBrickVel and DTBrickVel <> 0 and cdist < 8 Then
  2608. DTCheckBrick = 3
  2609. Else
  2610. DTCheckBrick = 1
  2611. End If
  2612. ElseIf perpvel > 0 and ((paravel > 0 and paravelafter > 0) or (paravel < 0 and paravelafter < 0)) Then
  2613. DTCheckBrick = 4
  2614. Else
  2615. DTCheckBrick = 0
  2616. End If
  2617.  
  2618. DTCheckBrick = 1
  2619. End Function
  2620.  
  2621. '**************************************How this all works********************************************
  2622. 'This uses walls to register the hits and primitives that get dropped as well as an offsetwall which is a wall that is set behind the main wall.
  2623. '1) The wallTarget, offsetWallTarget, primitive, target number and animation value of 0 are put into arrays called DT006 - DT010
  2624. '2) A master array called DTArray contains all of the DT0xx arrays
  2625. '3) If a wall is hit then the position in the array of the wall hit is determined
  2626. '4) The animation value is calculated by DTCheckBrick
  2627. '5) If the animation value is 1,3 or 4 then DTBallPhysics applies velocity corrections to the active ball
  2628. '6) the animation sub is called and it passes each element of the DT array to the DTAnimate function
  2629. ' - if the animate value is 0 do nothing
  2630. ' - if the animate value is 1 or 4 then bend the dt back make the front wall not collidable and turn on the offset wall's collide and
  2631. ' when the elapsed drop target delay time has passed change the animate value to 2
  2632. ' - if the animate value is two then drop the target and once it is dropped turn off the collide for the offset wall
  2633. ' - if the animate value is 3 then BRICK bend the prim back and the forth but no drop
  2634. ' - if the anumate value is -1 then raise the drop target past its resting point and drop back down and if a ball is over it kick the ball up in the air
  2635. '****************************************************************************************************
  2636.  
  2637. Sub DoDTAnim()
  2638. Dim i
  2639. For i = 0 to Ubound(DTArray)
  2640. DTArray(i)(4) = DTAnimate(DTArray(i)(0), DTArray(i)(1), DTArray(i)(2), DTArray(i)(3), DTArray(i)(4))
  2641. Next
  2642. End Sub
  2643.  
  2644. ' This is the function that animates the DT drop and raise
  2645. Function DTAnimate(primary, secondary, prim, switch, animate)
  2646. dim transz
  2647. Dim animtime, rangle
  2648. rangle = prim.rotz * 3.1416 / 180 ' number of radians
  2649.  
  2650. DTAnimate = animate
  2651.  
  2652. if animate = 0 Then ' no action to be taken
  2653. primary.uservalue = 0 ' primary.uservalue is used to keep track of gameTime
  2654. DTAnimate = 0
  2655. Exit Function
  2656. Elseif primary.uservalue = 0 then
  2657. primary.uservalue = gametime ' sets primary.uservalue to game time for calculating how much time has elapsed
  2658. end if
  2659.  
  2660. animtime = gametime - primary.uservalue 'variable for elapsed time
  2661.  
  2662. If (animate = 1 or animate = 4) and animtime < DTDropDelay Then 'if the time elapse is less than time for the dt to start to drop after impact
  2663. primary.collidable = 0 'primary wall is not collidable
  2664. If animate = 1 then secondary.collidable = 1 else secondary.collidable = 0 'animate 1 turns on offset wall collide and 4 turns offest collide off
  2665. prim.rotx = DTMaxBend * cos(rangle) ' bend the primitive back the max value
  2666. prim.roty = DTMaxBend * sin(rangle)
  2667. DTAnimate = animate
  2668. Exit Function
  2669. elseif (animate = 1 or animate = 4) and animtime > DTDropDelay Then ' if the drop time has passed then
  2670. primary.collidable = 0 ' primary wall is not collidable
  2671. If animate = 1 then secondary.collidable = 1 else secondary.collidable = 0 'animate 1 turns on offset wall collide and 4 turns offest collide off
  2672. prim.rotx = DTMaxBend * cos(rangle) ' bend the primitive back the max value
  2673. prim.roty = DTMaxBend * sin(rangle)
  2674. animate = 2 '**** sets animate to 2 for dropping the DT
  2675. playFieldSound "DTDrop", 0, prim, 1
  2676. End If
  2677.  
  2678. if animate = 2 Then ' DT drop time
  2679. transz = (animtime - DTDropDelay)/DTDropSpeed * DTDropUnits * -1
  2680. if prim.transz > -DTDropUnits Then ' if not fully dropped then transz
  2681. prim.transz = transz
  2682. end if
  2683.  
  2684. prim.rotx = DTMaxBend * cos(rangle)/2
  2685. prim.roty = DTMaxBend * sin(rangle)/2
  2686.  
  2687. if prim.transz <= -DTDropUnits Then ' if fully dropped then
  2688. prim.transz = -DTDropUnits
  2689. secondary.collidable = 0 ' turn off collide for secondary wall now the rubber behind can be hit
  2690. 'controller.Switch(Switch) = 1
  2691. primary.uservalue = 0 ' reset the time keeping value
  2692. DTAnimate = 0 ' turn off animation
  2693. Exit Function
  2694. Else
  2695. DTAnimate = 2
  2696. Exit Function
  2697. end If
  2698. End If
  2699.  
  2700. '*** animate 3 is a brick!
  2701. If animate = 3 and animtime < DTDropDelay Then ' if elapsed time is less than the drop time
  2702. primary.collidable = 0 'turn off primary collide
  2703. secondary.collidable = 1 'turn on secondary collide
  2704. prim.rotx = DTMaxBend * cos(rangle) 'rotate back
  2705. prim.roty = DTMaxBend * sin(rangle)
  2706. elseif animate = 3 and animtime > DTDropDelay Then
  2707. primary.collidable = 1 'turn on the primary collide
  2708. secondary.collidable = 0 'turn off secondary collide
  2709. prim.rotx = 0 'rotate back to start
  2710. prim.roty = 0
  2711. primary.uservalue = 0
  2712. DTAnimate = 0
  2713. Exit Function
  2714. End If
  2715.  
  2716. if animate = -1 Then ' If the value is -1 raise the DT past its resting point
  2717. transz = (1 - (animtime)/DTDropUpSpeed) * DTDropUnits * -1
  2718. If prim.transz = -DTDropUnits Then
  2719. Dim BOT, b
  2720. BOT = GetBalls
  2721.  
  2722. For b = 0 to UBound(BOT) ' if a ball is over a DT that is rising, pop it up in the air with a vel of 20
  2723. If InRect(BOT(b).x,BOT(b).y,prim.x-25,prim.y-10,prim.x+25, prim.y-10,prim.x+25,prim.y+25,prim.x -25,prim.y+25) Then
  2724. BOT(b).velz = 20
  2725. End If
  2726. Next
  2727. End If
  2728.  
  2729. if prim.transz < 0 Then
  2730. prim.transz = transz
  2731. elseif transz > 0 then
  2732. prim.transz = transz
  2733. end if
  2734.  
  2735. if prim.transz > DTDropUpUnits then 'If the dt is at the top of its rise
  2736. DTAnimate = -2 ' set the dt animate to -2
  2737. prim.rotx = 0 'remove the rotation
  2738. prim.roty = 0
  2739. primary.uservalue = gametime
  2740. end if
  2741. primary.collidable = 0
  2742. secondary.collidable = 1
  2743. 'controller.Switch(Switch) = 0
  2744.  
  2745. End If
  2746.  
  2747. if animate = -2 and animtime > DTRaiseDelay Then ' if the value is -2 then drop back down to resting height
  2748. prim.transz = (animtime - DTRaiseDelay)/DTDropSpeed * DTDropUnits * -1 + DTDropUpUnits
  2749. if prim.transz < 0 then
  2750. prim.transz = 0
  2751. primary.uservalue = 0
  2752. DTAnimate = 0
  2753.  
  2754. primary.collidable = 1
  2755. secondary.collidable = 0
  2756. end If
  2757. End If
  2758. End Function
  2759.  
  2760. '******************************************************
  2761. ' DROP TARGET
  2762. ' SUPPORTING FUNCTIONS
  2763. '******************************************************
  2764.  
  2765. ' Used for flipper correction, rubber dampeners, and drop targets
  2766. Function BallSpeed(ball) 'Calculates the ball speed
  2767. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  2768. End Function
  2769.  
  2770. ' Used for drop targets
  2771. Function Atn2(dy, dx)
  2772. dim pi
  2773. pi = 4*Atn(1)
  2774.  
  2775. If dx > 0 Then
  2776. Atn2 = Atn(dy / dx)
  2777. ElseIf dx < 0 Then
  2778. If dy = 0 Then
  2779. Atn2 = pi
  2780. Else
  2781. Atn2 = Sgn(dy) * (pi - Atn(Abs(dy / dx)))
  2782. end if
  2783. ElseIf dx = 0 Then
  2784. if dy = 0 Then
  2785. Atn2 = 0
  2786. else
  2787. Atn2 = Sgn(dy) * pi / 2
  2788. end if
  2789. End If
  2790. End Function
  2791.  
  2792. ' Used for drop targets
  2793. '*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
  2794. Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
  2795. Dim AB, BC, CD, DA
  2796. AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
  2797. BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
  2798. CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
  2799. DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
  2800.  
  2801. If (AB <= 0 AND BC <=0 AND CD <= 0 AND DA <= 0) Or (AB >= 0 AND BC >=0 AND CD >= 0 AND DA >= 0) Then
  2802. InRect = True
  2803. Else
  2804. InRect = False
  2805. End If
  2806. End Function
  2807.  
  2808. ' Used for drop targets
  2809. Function Distance(ax,ay,bx,by)
  2810. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  2811. End Function
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821. '*****************************************
  2822. ' BALL SHADOW
  2823. '*****************************************
  2824. Dim BallShadow
  2825. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  2826.  
  2827. Sub BallShadowUpdate_timer()
  2828. Dim BOT, b
  2829. BOT = GetBalls
  2830. ' hide shadow of deleted balls
  2831. If UBound(BOT)<(tnob-1) Then
  2832. For b = (UBound(BOT) + 1) to (tnob-1)
  2833. BallShadow(b).visible = 0
  2834. Next
  2835. End If
  2836. ' exit the Sub if no balls on the table
  2837. If UBound(BOT) = -1 Then Exit Sub
  2838. ' render the shadow for each ball
  2839. For b = 0 to UBound(BOT)
  2840. If BOT(b).X < Table1.Width/2 Then
  2841. BallShadow(b).X = ((BOT(b).X) + ((BOT(b).X - (Table1.Width/2))/7))
  2842. Else
  2843. BallShadow(b).X = ((BOT(b).X) + ((BOT(b).X - (Table1.Width/2))/7))
  2844. End If
  2845. ballShadow(b).Y = BOT(b).Y + 10
  2846. If BOT(b).Z > 20 Then
  2847. BallShadow(b).visible = 1
  2848. Else
  2849. BallShadow(b).visible = 0
  2850. End If
  2851. Next
  2852. End Sub
  2853.  
  2854. 'This table has a ball shadow that projects through the shooter lane wall and needs to be turned off
  2855. Sub ballshadowOff_hit
  2856. BallShadow(0).visible = 0
  2857. BallShadowUpdate.enabled = 0
  2858. End Sub
  2859.  
  2860. Sub ballShadowOff_unhit
  2861. BallShadowUpdate.enabled = 1
  2862. End Sub
  2863.  
  2864. '************************************************************************
  2865. ' Ball Control - 3 Axis
  2866. '************************************************************************
  2867.  
  2868. Dim Cup, Cdown, Cleft, Cright, Zup, contball, contballinplay, ControlBall, bcboost
  2869. Dim bcvel, bcyveloffset, bcboostmulti
  2870.  
  2871. bcboost = 1 'Do Not Change - default setting
  2872. bcvel = 4 'Controls the speed of the ball movement
  2873. bcyveloffset = -.014 'Offsets the force of gravity to keep the ball from drifting vertically on the table, should be negative
  2874. bcboostmulti = 3 'Boost multiplier to ball veloctiy (toggled with the B key)
  2875.  
  2876. Sub BallControl_Timer()
  2877. If Contball and ContBallInPlay then
  2878. If Cright = 1 Then
  2879. ControlBall.velx = bcvel * bcboost
  2880. ElseIf Cleft = 1 Then
  2881. ControlBall.velx = -bcvel * bcboost
  2882. Else
  2883. ControlBall.velx = 0
  2884. End If
  2885. If Cup = 1 Then
  2886. ControlBall.vely = -bcvel * bcboost
  2887. ElseIf Cdown = 1 Then
  2888. ControlBall.vely = bcvel * bcboost
  2889. Else
  2890. ControlBall.vely = bcyveloffset
  2891. End If
  2892. If Zup = 1 Then
  2893. ControlBall.velz = bcvel * bcboost
  2894. Else
  2895. ControlBall.velz = -bcvel * bcboost
  2896. End If
  2897. End If
  2898. End Sub
  2899.  
  2900. ' *********************************************************************
  2901. ' Supporting Ball & Sound Functions
  2902. ' *********************************************************************
  2903.  
  2904. Function AudioPan(TableObj) 'Calculates the pan for a TableObj based on the X position on the table. "table1" is the name of the table. New AudioPan algorithm for accurate stereo pan positioning.
  2905. Dim tmp
  2906. If PFOption=1 Then tmp = TableObj.x * 2 / table1.width-1
  2907. If PFOption=2 Then tmp = TableObj.y * 2 / table1.height-1
  2908. If tmp < 0 Then
  2909. AudioPan = -((0.8745898957*(ABS(tmp)^12.78313661)) + (0.1264569796*(ABS(tmp)^1.000771219)))
  2910. Else
  2911. AudioPan = (0.8745898957*(ABS(tmp)^12.78313661)) + (0.1264569796*(ABS(tmp)^1.000771219))
  2912. End If
  2913. End Function
  2914.  
  2915. Function xGain(TableObj)
  2916. 'xGain algorithm calculates a PlaySound Volume parameter multiplier to provide a Constant Power "pan".
  2917. 'PFOption=1: xGain = 1 at PF Left, xGain = 0.32931 (-3dB for PlaySound's volume parameter) at PF Center and xGain = 1 at PF Right. Used for Left & Right stereo PF Speakers.
  2918. 'PFOption=2: xGain = 1 at PF Top, xGain = 0.32931 (-3dB for PlaySound's volume parameter) at PF Center and xGain = 1 at PF Bottom. Used for Top & Bottom stereo PF Speakers.
  2919. Dim tmp, PI
  2920. If PFOption=1 Then tmp = TableObj.x * 2 / table1.width-1
  2921. If PFOption=2 Then tmp = TableObj.y * 2 / table1.height-1
  2922. PI = 4 * ATN(1)
  2923. If tmp < 0 Then
  2924. xGain = 0.3293074856*EXP(-0.9652695455*tmp^3 - 2.452909811*tmp^2 - 2.597701999*tmp)
  2925. Else
  2926. xGain = 0.3293074856*EXP(-0.9652695455*-tmp^3 - 2.452909811*-tmp^2 - 2.597701999*-tmp)
  2927. End If
  2928. ' TB1.text = "xGain=" & Round(xGain,4)
  2929. End Function
  2930.  
  2931. Function XVol(tableobj)
  2932. 'XVol algorithm calculates a PlaySound Volume parameter multiplier for a tableobj based on its X table position to provide a Constant Power "pan".
  2933. 'XVol = 1 at PF Left, XVol = 0.32931 (-3dB for PlaySound's volume parameter) at PF Center and XVol = 0 at PF Right
  2934. Dim tmpx
  2935. If PFOption = 3 Then
  2936. tmpx = tableobj.x * 2 / table1.width-1
  2937. XVol = 0.3293074856*EXP(-0.9652695455*tmpx^3 - 2.452909811*tmpx^2 - 2.597701999*tmpx)
  2938. End If
  2939. ' TB1.text = "xVol=" & Round(xVol,4)
  2940. End Function
  2941.  
  2942. Function YVol(tableobj)
  2943. 'YVol algorithm calculates a PlaySound Volume parameter multiplier for a tableobj based on its Y table position to provide a Constant Power "fade".
  2944. 'YVol = 1 at PF Top, YVol = 0.32931 (-3dB for PlaySound's volume parameter) at PF Center and YVol = 0 at PF Bottom
  2945. Dim tmpy
  2946. If PFOption = 3 Then
  2947. tmpy = tableobj.y * 2 / table1.height-1
  2948. YVol = 0.3293074856*EXP(-0.9652695455*tmpy^3 - 2.452909811*tmpy^2 - 2.597701999*tmpy)
  2949. End If
  2950. ' TB2.text = "yVol=" & Round(yVol,4)
  2951. End Function
  2952.  
  2953. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  2954. Vol = Csng(BallVel(ball) ^2 / 2000)
  2955. End Function
  2956.  
  2957. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  2958. Pitch = BallVel(ball) * 20
  2959. End Function
  2960.  
  2961. Function BallVel(ball) 'Calculates the ball speed
  2962. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  2963. End Function
  2964.  
  2965. '******************************************************
  2966. ' JP's VP10 Rolling Sounds - Modified by Whirlwind
  2967. '******************************************************
  2968.  
  2969. '******************************************
  2970. ' Explanation of the rolling sound routine
  2971. '******************************************
  2972.  
  2973. ' ball rolling sounds are played based on the ball speed and position
  2974. ' the routine checks first for deleted balls and stops the rolling sound.
  2975. ' The For loop goes through all the balls on the table and checks for the ball speed and
  2976. ' if the ball is on the table (height lower than 30) then then it plays the sound
  2977. ' otherwise the sound is stopped.
  2978.  
  2979. 'New algorithms added to make sounds for TopArch Hits, Arch Rolls, ball bounces and glass hits.
  2980. 'For stereo, xGain is a Playsound volume multiplier that provides a Constant Power pan.
  2981. 'For quad, multiple PlaySound commands are launched together that are panned and faded to their maximum extents where PlaySound's PAN and FADE have the least error.
  2982. 'XVol and YVol are Playsound volume multipliers that provide a Constant Power "pan" and "fade".
  2983. 'Subtracting XVol or YVol from 1 yields an inverse response.
  2984.  
  2985. Const tnob = 5 ' total number of balls
  2986.  
  2987. 'Change GHT, GHB and PFL values based upon the real pinball table dimensions. Values are used by the GlassHit code.
  2988. Const GHT = 6 'Glass height in inches at top of real playfield
  2989. Const GHB = 6 'Glass height in inches at bottom of real playfield
  2990. Const PFL = 40 'Real playfield length in inches
  2991.  
  2992. ReDim rolling(tnob)
  2993. InitRolling
  2994.  
  2995. ReDim ArchRolling(tnob)
  2996. InitArchRolling
  2997.  
  2998. Dim ArchHit
  2999. 'Sub TopArch_Hit
  3000. ' ArchHit = 1
  3001. ' ArchTimer.Enabled = True
  3002. 'End Sub
  3003.  
  3004. Sub LowerArch_Hit
  3005. ArchHit = 1
  3006. ArchTimer.Enabled = True
  3007. End Sub
  3008.  
  3009. Dim archCount
  3010. 'The ArchHit sound is played and.the ArchTimer is enabled upon the first hit of the arch by the ball
  3011. 'ArchTimer is enabled for 15ms after which ArchTimer2 is enabled for 2 seconds
  3012. 'While ArchTimer2 is enabled it "locks-out" the ArchHit sound from being played again until after 2 seconds have elapsed
  3013. Sub ArchTimer_Timer
  3014. archCount = archCount + 1
  3015. If archCount = 1 Then
  3016. archCount = 0
  3017. ArchTimer.enabled = False
  3018. If ArchTimer2.enabled = False Then ArchTimer2.enabled = True
  3019. End If
  3020. End Sub
  3021.  
  3022. Dim archCount2
  3023. Sub ArchTimer2_Timer
  3024. archCount2 = archCount2 + 1
  3025. If archCount2 = 1 Then
  3026. archCount2 = 0
  3027. ArchTimer2.enabled = False
  3028. End If
  3029. End Sub
  3030.  
  3031. Sub NotOnArch_Hit
  3032. ArchHit = 0
  3033. End Sub
  3034.  
  3035. Sub NotOnArch2_Hit
  3036. ArchHit = 0
  3037. End Sub
  3038.  
  3039. Sub InitRolling
  3040. Dim i
  3041. For i = 0 to tnob
  3042. rolling(i) = False
  3043. Next
  3044. End Sub
  3045.  
  3046. Sub InitArchRolling
  3047. Dim i
  3048. For i = 0 to tnob
  3049. ArchRolling(i) = False
  3050. Next
  3051. End Sub
  3052.  
  3053. Sub RollingTimer_Timer()
  3054. Dim BOT, b, paSub
  3055. BOT = GetBalls
  3056. paSub=35000 'Playsound pitch adder for subway/ramp rolling ball sound
  3057.  
  3058. 'TB.text="BOT(b).Z " & formatnumber(BOT(b).Z,1)
  3059. 'TB.text="BOT(b).VelZ " & formatnumber(BOT(b).VelZ,1)
  3060. 'TB.text="GLASS " & formatnumber((BOT(b).Y * ((GHT-GHB)/PFL)) + (GHB*50/1.0625) - (BallSize/2),1)
  3061. 'TB.text = "ArchTimer.enabled=" & ArchTimer.enabled & " ArchTimer2.enabled=" & ArchTimer2.enabled & " ArchHit=" & ArchHit
  3062.  
  3063. ' stop the sound of deleted balls
  3064. For b = UBound(BOT) + 1 to tnob
  3065. rolling(b) = False
  3066. StopSound("BallrollingA" & b)
  3067. StopSound("BallrollingB" & b)
  3068. StopSound("BallrollingC" & b)
  3069. StopSound("BallrollingD" & b)
  3070. Next
  3071.  
  3072. ' exit the sub if no balls on the table
  3073. If UBound(BOT) = -1 Then Exit Sub
  3074.  
  3075. ' play the rolling sound for each ball
  3076. For b = 0 to UBound(BOT)
  3077. ' TB.text = "Ball0.z=" & (BOT(0).z) 'Use to verify ball.z (currently -3) when in Adrian's new saucer primitives.
  3078.  
  3079.  
  3080. ' Ball Rolling sounds
  3081. '**********************
  3082. ' Ball=50 units=1.0625". One unit = 0.02125" Ball.z is ball center.
  3083. ' A ball in Adrian's saucer has a Z of -3. Use <-5 for subway sounds.
  3084. If PFOption = 1 or PFOption = 2 Then
  3085. If BallVel(BOT(b)) > 1 AND BOT(b).z > 10 and BOT(b).z <26 Then 'Ball on playfield
  3086. rolling(b) = True
  3087. PlaySound("BallrollingA" & b), -1, Vol(BOT(b)) * 0.2 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3088. ElseIf BallVel(BOT(b)) > 1 AND BOT(b).z < -5 Then 'Ball on subway
  3089. PlaySound("BallrollingA" & b), -1, Vol(BOT(b)) * 0.2 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b))+paSub, 1, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3090. ElseIf rolling(b) = True Then
  3091. StopSound("BallrollingA" & b)
  3092. rolling(b) = False
  3093. End If
  3094. End If
  3095.  
  3096. If PFOption = 3 Then
  3097. If BallVel(BOT(b)) > 1 AND BOT(b).z > 10 and BOT(b).z < 26 Then 'Ball on playfield
  3098. rolling(b) = True
  3099. PlaySound("BallrollingA" & b), -1, Vol(BOT(b)) * 0.2 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Left PF Speaker
  3100. PlaySound("BallrollingB" & b), -1, Vol(BOT(b)) * 0.2 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Right PF Speaker
  3101. PlaySound("BallrollingC" & b), -1, Vol(BOT(b)) * 0.2 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Left PF Speaker
  3102. PlaySound("BallrollingD" & b), -1, Vol(BOT(b)) * 0.2 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Right PF Speaker
  3103. ElseIf BallVel(BOT(b)) > 1 AND BOT(b).z < -5 Then 'Ball on subway
  3104. PlaySound("BallrollingA" & b), -1, Vol(BOT(b)) * 0.2 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b))+paSub, 1, 0, -1 'Top Left PF Speaker
  3105. PlaySound("BallrollingB" & b), -1, Vol(BOT(b)) * 0.2 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b))+paSub, 1, 0, -1 'Top Right PF Speaker
  3106. PlaySound("BallrollingC" & b), -1, Vol(BOT(b)) * 0.2 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b))+paSub, 1, 0, 1 'Bottom Left PF Speaker
  3107. PlaySound("BallrollingD" & b), -1, Vol(BOT(b)) * 0.2 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b))+paSub, 1, 0, 1 'Bottom Right PF Speaker
  3108. ElseIf rolling(b) = True Then
  3109. StopSound("BallrollingA" & b) 'Top Left PF Speaker
  3110. StopSound("BallrollingB" & b) 'Top Right PF Speaker
  3111. StopSound("BallrollingC" & b) 'Bottom Left PF Speaker
  3112. StopSound("BallrollingD" & b) 'Bottom Right PF Speaker
  3113. rolling(b) = False
  3114. End If
  3115. End If
  3116.  
  3117. ' Arch Hit and Arch Rolling sounds
  3118. '***********************************
  3119. If PFOption = 1 or PFOption = 2 Then
  3120. If BallVel(BOT(b)) > 1 And ArchHit =1 Then
  3121. If ArchTimer2.enabled = 0 Then
  3122. PlaySound("ArchHit" & b), 0, (BallVel(BOT(b))/32)^5 * xGain(BOT(b)), AudioPan(BOT(b)), 0, (BallVel(BOT(b))/40)^7, 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3123. End If
  3124. ArchRolling(b) = True
  3125. PlaySound("ArchRollA" & b), -1, (BallVel(BOT(b))/40)^5 * xGain(BOT(b)), AudioPan(BOT(b)), 0, (BallVel(BOT(b))/40)^7, 1, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3126. Else
  3127. If ArchRolling(b) = True Then
  3128. StopSound("ArchRollA" & b)
  3129. ArchRolling(b) = False
  3130. End If
  3131. End If
  3132. ' If ArchTimer2.enabled = 0 And ArchHit = 1 Then TB.text = "ArchHit vol=" & round((BallVel(BOT(b))/32)^5 * 1 * xGain(BOT(b)),4) 'Keep below 1.
  3133. End If
  3134.  
  3135. If PFOption = 3 Then
  3136. If BallVel(BOT(b)) > 1 And ArchHit =1 Then
  3137. If ArchTimer2.enabled = 0 Then
  3138. PlaySound("ArchHit" & b), 0, (BallVel(BOT(b))/32)^5 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, (BallVel(BOT(b))/40)^5, 0, 0, -1 'Top Left PF Speaker
  3139. PlaySound("ArchHit" & b), 0, (BallVel(BOT(b))/32)^5 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, (BallVel(BOT(b))/40)^5, 0, 0, -1 'Top Right PF Speaker
  3140. PlaySound("ArchHit" & b), 0, (BallVel(BOT(b))/32)^5 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, (BallVel(BOT(b))/40)^5, 0, 0, 1 'Bottom Left PF Speaker
  3141. PlaySound("ArchHit" & b), 0, (BallVel(BOT(b))/32)^5 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, (BallVel(BOT(b))/40)^5, 0, 0, 1 'Bottom Right PF Speaker
  3142. End If
  3143. ArchRolling(b) = True
  3144. PlaySound("ArchRollA" & b), -1, (BallVel(BOT(b))/40)^5 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, (BallVel(BOT(b))/40)^5, 1, 0, -1 'Top Left PF Speaker
  3145. PlaySound("ArchRollB" & b), -1, (BallVel(BOT(b))/40)^5 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, (BallVel(BOT(b))/40)^5, 1, 0, -1 'Top Right PF Speaker
  3146. PlaySound("ArchRollC" & b), -1, (BallVel(BOT(b))/40)^5 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, (BallVel(BOT(b))/40)^5, 1, 0, 1 'Bottom Left PF Speaker
  3147. PlaySound("ArchRollD" & b), -1, (BallVel(BOT(b))/40)^5 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, (BallVel(BOT(b))/40)^5, 1, 0, 1 'Bottom Right PF Speaker
  3148. Else
  3149. If ArchRolling(b) = True Then
  3150. StopSound("ArchRollA" & b) 'Top Left PF Speaker
  3151. StopSound("ArchRollB" & b) 'Top Right PF Speaker
  3152. StopSound("ArchRollC" & b) 'Bottom Left PF Speaker
  3153. StopSound("ArchRollD" & b) 'Bottom Right PF Speaker
  3154. ArchRolling(b) = False
  3155. End If
  3156. End If
  3157. End If
  3158.  
  3159. ' Ball drop sounds
  3160. '*******************
  3161. 'Four intensities of ball bounce sound files ranging from 1 to 4 bounces. The number of bounces increases as the ball's downward Z velocity increases.
  3162. 'A BOT(b).VelZ < -2 eliminates nuisance ball bounce sounds.
  3163.  
  3164. If PFOption = 1 or PFOption = 2 Then
  3165. If BOT(b).VelZ > -4 And BOT(b).VelZ < -2 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3166. PlaySound "BallDrop1" & b, 0, ABS(BOT(b).VelZ)/600 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3167. ElseIf BOT(b).VelZ > -8 And BOT(b).VelZ < -4 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3168. PlaySound "BallDrop2" & b, 0, ABS(BOT(b).VelZ)/600 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3169. ElseIf BOT(b).VelZ > -12 And BOT(b).VelZ < -8 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3170. PlaySound "BallDrop3" & b, 0, ABS(BOT(b).VelZ)/600 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3171. ElseIf BOT(b).VelZ < -12 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3172. PlaySound "BallDrop4" & b, 0, ABS(BOT(b).VelZ)/600 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3173. End If
  3174. End If
  3175.  
  3176. If PFOption = 3 Then
  3177. If BOT(b).VelZ > -4 And BOT(b).VelZ < -2 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3178. PlaySound "BallDrop1" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Left PF Speaker
  3179. PlaySound "BallDrop1" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Right PF Speaker
  3180. PlaySound "BallDrop1" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Left PF Speaker
  3181. PlaySound "BallDrop1" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Right PF Speaker
  3182. ElseIf BOT(b).VelZ > -8 And BOT(b).VelZ < -4 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3183. PlaySound "BallDrop2" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Left PF Speaker
  3184. PlaySound "BallDrop2" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Right PF Speaker
  3185. PlaySound "BallDrop2" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Left PF Speaker
  3186. PlaySound "BallDrop2" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Right PF Speaker
  3187. ElseIf BOT(b).VelZ > -12 And BOT(b).VelZ < -8 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3188. PlaySound "BallDrop3" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Left PF Speaker
  3189. PlaySound "BallDrop3" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Right PF Speaker
  3190. PlaySound "BallDrop3" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Left PF Speaker
  3191. PlaySound "BallDrop3" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Right PF Speaker
  3192. ElseIf BOT(b).VelZ < -12 And BOT(b).Z > 24 And BallinPlay => 1 Then
  3193. PlaySound "BallDrop4" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Left PF Speaker
  3194. PlaySound "BallDrop4" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 1, 0, -1 'Top Right PF Speaker
  3195. PlaySound "BallDrop4" & b, 0, ABS(BOT(b).VelZ)/600 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Left PF Speaker
  3196. PlaySound "BallDrop4" & b, 0, ABS(BOT(b).VelZ)/600 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 1, 0, 1 'Bottom Right PF Speaker
  3197. End If
  3198. End If
  3199. 'TB.text="BOT(b).VelZ " & round(BOT(b).VelZ,1)
  3200.  
  3201. ' Glass hit sounds
  3202. '*******************
  3203. ' Ball=50 units=1.0625". Ball.z is ball center. Balls are physically limited by Top Glass Height. Max ball.z is 25 units below Top Glass Height.
  3204. ' To ensure ball can go high enough to trigger glass hit, make Table Options/Dimensions & Slope/Top Glass Height equal to (GHT*50/1.0625) + 5
  3205.  
  3206. If PFOption = 1 or PFOption = 2 Then
  3207. If BOT(b).Z > (BOT(b).Y * ((GHT-GHB)/PFL)) + (GHB*50/1.0625) - BallSize/2 And BallinPlay => 1 Then
  3208. PlaySound "GlassHit" & b, 0, ABS(BOT(b).VelZ)/30 * xGain(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3209. End If
  3210. End If
  3211.  
  3212. If PFOption = 3 Then
  3213. If BOT(b).Z > (BOT(b).Y * ((GHT-GHB)/PFL)) + (GHB*50/1.0625) - Ballsize/2 And BallinPlay => 1 Then
  3214. PlaySound "GlassHit" & b, 0, ABS(BOT(b).VelZ)/30 * XVol(BOT(b)) * YVol(BOT(b)), -1, 0, Pitch(BOT(b)), 0, 0, -1 'Top Left PF Speaker
  3215. PlaySound "GlassHit" & b, 0, ABS(BOT(b).VelZ)/30 * (1-XVol(BOT(b))) * YVol(BOT(b)), 1, 0, Pitch(BOT(b)), 0, 0, -1 'Top Right PF Speaker
  3216. PlaySound "GlassHit" & b, 0, ABS(BOT(b).VelZ)/30 * XVol(BOT(b)) * (1-YVol(BOT(b))), -1, 0, Pitch(BOT(b)), 0, 0, 1 'Bottom Left PF Speaker
  3217. PlaySound "GlassHit" & b, 0, ABS(BOT(b).VelZ)/30 * (1-XVol(BOT(b))) * (1-YVol(BOT(b))), 1, 0, Pitch(BOT(b)), 0, 0, 1 'Bottom Right PF Speaker
  3218. End If
  3219. End If
  3220. Next
  3221. End Sub
  3222.  
  3223. '*************Hit Sound Routines
  3224. 'Eliminated the Hit Subs extra velocity criteria since the PlayFieldSoundAB command already incorporates the ball’s velocity.
  3225.  
  3226. Sub aRubberPins_Hit(idx)
  3227. PlayFieldSoundAB "pinhit_low", 0, 1
  3228. End Sub
  3229.  
  3230. Sub aTargets_Hit(idx)
  3231. PlayFieldSoundAB "target", 0, 1
  3232. End Sub
  3233.  
  3234. Sub aMetalsThin_Hit(idx)
  3235. PlayFieldSoundAB "metalhit_thin", 0, 1
  3236. End Sub
  3237.  
  3238. Sub aMetalsMedium_Hit(idx)
  3239. PlayFieldSoundAB "metalhit_medium", 0, 1
  3240. End Sub
  3241.  
  3242. Sub aMetals2_Hit(idx)
  3243. PlayFieldSoundAB "metalhit2", 0, 1
  3244. End Sub
  3245.  
  3246. Sub aGates_Hit(idx)
  3247. PlayFieldSoundAB "gate4", 0, 1
  3248. End Sub
  3249.  
  3250. Sub aRubberBands_Hit(idx)
  3251. If BallinPlay > 0 Then 'Eliminates the thump of Trough Ball Creation balls hitting walls 9 and 14 during table initiation
  3252. PlayFieldSoundAB "rubber2", 0, 1
  3253. End If
  3254. End Sub
  3255.  
  3256. Sub RubberWheel_hit
  3257. PlayFieldSoundAB "rubber_hit_2", 0, 1
  3258. End Sub
  3259.  
  3260. Sub aPosts_Hit(idx)
  3261. PlayFieldSoundAB "rubber2", 0, 1
  3262. End Sub
  3263.  
  3264. Sub aWoods_Hit(idx)
  3265. PlayFieldSoundAB "wood", 0, 1
  3266. End Sub
  3267.  
  3268. Sub LeftFlipper_Collide(parm)
  3269. RandomSoundFlipper()
  3270. End Sub
  3271.  
  3272. Sub RightFlipper_Collide(parm)
  3273. RandomSoundFlipper()
  3274. End Sub
  3275.  
  3276. Sub RandomSoundFlipper()
  3277. Select Case Int(Rnd*3)+1
  3278. Case 1 : PlayFieldSoundAB "flip_hit_1", 0, 1
  3279. Case 2 : PlayFieldSoundAB "flip_hit_2", 0, 1
  3280. Case 3 : PlayFieldSoundAB "flip_hit_3", 0, 1
  3281. End Select
  3282. End Sub
  3283.  
  3284. Sub ApronWall_Hit
  3285. Dim Volume
  3286. If ActiveBall.vely < 0 Then Volume = abs(ActiveBall.vely) / 1 Else Volume = ActiveBall.vely / 30 'The first bounce is -vely subsequent bounces are +vely
  3287. ' TextBox1.text = "Volume = " & Volume
  3288. If ActiveBall.z > 24 Then
  3289. If PFOption = 1 Or PFOption = 2 Then
  3290. PlaySound "ApronHit", 0, Volume * xGain(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3291. End If
  3292. If PFOption = 3 Then
  3293. PlaySound "ApronHit", 0, Volume * XVol(ActiveBall) * YVol(ActiveBall), -1, 0, Pitch(ActiveBall), 0, 0, -1 'Top Left PF Speaker
  3294. PlaySound "ApronHit", 0, Volume * (1-XVol(ActiveBall)) * YVol(ActiveBall), 1, 0, Pitch(ActiveBall), 0, 0, -1 'Top Right PF Speaker
  3295. PlaySound "ApronHit", 0, Volume * XVol(ActiveBall) * (1-YVol(ActiveBall)), -1, 0, Pitch(ActiveBall), 0, 0, 1 'Bottom Left PF Speaker
  3296. PlaySound "ApronHit", 0, Volume * (1-XVol(ActiveBall)) * (1-YVol(ActiveBall)), 1, 0, Pitch(ActiveBall), 0, 0, 1 'Bottom Right PF Speaker
  3297. End If
  3298. End If
  3299. End Sub
  3300.  
  3301. '**********************
  3302. ' Ball Collision Sound
  3303. '**********************
  3304.  
  3305. '**************************************
  3306. ' Explanation of the collision routine
  3307. '**************************************
  3308.  
  3309. ' The collision is built in VP.
  3310. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  3311. ' will call this routine.
  3312.  
  3313. 'New algorithm for BallBallCollision
  3314. 'For stereo, xGain is a Playsound volume multiplier that provides a Constant Power pan.
  3315. 'For quad, multiple PlaySound commands are launched together that are panned and faded to their maximum extents where PlaySound's PAN and FADE have the least error.
  3316. 'XVol and YVol are Playsound volume multipliers that provide a Constant Power "pan" and "fade".
  3317. 'Subtracting XVol or YVol from 1 yields an inverse response.
  3318.  
  3319. Sub OnBallBallCollision(ball1, ball2, velocity)
  3320. If PFOption = 1 or PFOption = 2 Then
  3321. PlaySound "BBcollide", 0, (Csng(velocity) ^2 / 2000) * xGain(ball1), AudioPan(ball1), 0, Pitch(ball1), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3322. End If
  3323. If PFOption = 3 Then
  3324. PlaySound "BBcollide", 0, (Csng(velocity) ^2 / 2000) * XVol(ball1) * YVol(ball1), -1, 0, Pitch(ball1), 0, 0, -1 'Top Left Playfield Speaker
  3325. PlaySound "BBcollide", 0, (Csng(velocity) ^2 / 2000) * (1-XVol(ball1)) * YVol(ball1), 1, 0, Pitch(ball1), 0, 0, -1 'Top Right Playfield Speaker
  3326. PlaySound "BBcollide", 0, (Csng(velocity) ^2 / 2000) * XVol(ball1) * (1-YVol(ball1)), -1, 0, Pitch(ball1), 0, 0, 1 'Bottom Left Playfield Speaker
  3327. PlaySound "BBcollide", 0, (Csng(velocity) ^2 / 2000) * (1-XVol(ball1)) * (1-YVol(ball1)), 1, 0, Pitch(ball1), 0, 0, 1 'Bottom Right Playfield Speaker
  3328. End If
  3329. End Sub
  3330.  
  3331. Sub PlayFieldSound (SoundName, Looper, TableObject, VolMult)
  3332. 'Plays the sound of a table object at the table object's coordinates.
  3333. 'For stereo, xGain is a Playsound volume multiplier that provides a Constant Power pan.
  3334. 'For quad, multiple PlaySound commands are launched together that are panned and faded to their maximum extents where PlaySound's PAN and FADE have the least error.
  3335. 'XVol and YVol are Playsound volume multipliers that provide a Constant Power "pan" and "fade".
  3336. 'Subtracting XVol or YVol from 1 yields an inverse response.
  3337.  
  3338. If PFOption = 1 Or PFOption = 2 Then
  3339. If Looper = -1 Then
  3340. PlaySound SoundName&"A", Looper, VolMult * xGain(TableObject), AudioPan(TableObject), 0, 0, 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3341. End If
  3342. If Looper = 0 Then
  3343. PlaySound SoundName, Looper, VolMult * xGain(TableObject), AudioPan(TableObject), 0, 0, 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3344. End If
  3345. End If
  3346. If PFOption = 3 Then
  3347. If Looper = -1 Then
  3348. PlaySound SoundName&"A", Looper, VolMult * XVol(TableObject) * YVol(TableObject), -1, 0, 0, 0, 0, -1 'Top Left PF Speaker
  3349. PlaySound SoundName&"B", Looper, VolMult * (1-XVol(TableObject)) * YVol(TableObject), 1, 0, 0, 0, 0, -1 'Top Right PF Speaker
  3350. PlaySound SoundName&"C", Looper, VolMult * XVol(TableObject) * (1-YVol(TableObject)), -1, 0, 0, 0, 0, 1 'Bottom Left PF Speaker
  3351. PlaySound SoundName&"D", Looper, VolMult * (1-XVol(TableObject)) * (1-YVol(TableObject)), 1, 0, 0, 0, 0, 1 'Bottom Right PF Speaker
  3352. End If
  3353. If Looper = 0 Then
  3354. PlaySound SoundName, Looper, VolMult * XVol(TableObject) * YVol(TableObject), -1, 0, 0, 0, 0, -1 'Top Left PF Speaker
  3355. PlaySound SoundName, Looper, VolMult * (1-XVol(TableObject)) * YVol(TableObject), 1, 0, 0, 0, 0, -1 'Top Right PF Speaker
  3356. PlaySound SoundName, Looper, VolMult * XVol(TableObject) * (1-YVol(TableObject)), -1, 0, 0, 0, 0, 1 'Bottom Left PF Speaker
  3357. PlaySound SoundName, Looper, VolMult * (1-XVol(TableObject)) * (1-YVol(TableObject)), 1, 0, 0, 0, 0, 1 'Bottom Right PF Speaker
  3358. End If
  3359. End If
  3360. End Sub
  3361.  
  3362. Sub PlayFieldSoundAB (SoundName, Looper, VolMult)
  3363. 'Plays the sound of a table object at the Active Ball's location.
  3364. 'For stereo, xGain is a Playsound volume multiplier that provides a Constant Power pan.
  3365. 'For quad, multiple PlaySound commands are launched together that are panned and faded to their maximum extents where PlaySound's PAN and FADE have the least error.
  3366. 'XVol and YVol are Playsound volume multipliers that provide a Constant Power "pan" and "fade".
  3367. 'Subtracting XVol or YVol from 1 yields an inverse response.
  3368.  
  3369. If PFOption = 1 Or PFOption = 2 Then
  3370. PlaySound SoundName, Looper, VolMult * Vol(ActiveBall) * xGain(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  3371. End If
  3372. If PFOption = 3 Then
  3373. PlaySound SoundName, Looper, VolMult * Vol(ActiveBall) * XVol(ActiveBall) * YVol(ActiveBall), -1, 0, Pitch(ActiveBall), 0, 0, -1 'Top Left PF Speaker
  3374. PlaySound SoundName, Looper, VolMult * Vol(ActiveBall) * (1-XVol(ActiveBall)) * YVol(ActiveBall), 1, 0, Pitch(ActiveBall), 0, 0, -1 'Top Right PF Speaker
  3375. PlaySound SoundName, Looper, VolMult * Vol(ActiveBall) * XVol(ActiveBall) * (1-YVol(ActiveBall)), -1, 0, Pitch(ActiveBall), 0, 0, 1 'Bottom Left PF Speaker
  3376. PlaySound SoundName, Looper, VolMult * Vol(ActiveBall) * (1-XVol(ActiveBall)) * (1-YVol(ActiveBall)), 1, 0, Pitch(ActiveBall), 0, 0, 1 'Bottom Right PF Speaker
  3377. End If
  3378. End Sub
  3379.  
  3380. Sub PlayReelSound (SoundName, Pan)
  3381. Dim ReelVolAdj
  3382. ReelVolAdj = 0.2
  3383. 'Provides a Constant Power Pan for the backglass reel sound volume to match the playfield's Constant Power Pan response
  3384. If showDT = False Then '-3dB for desktop mode
  3385. If Pan = "Lpan" Then PlaySound SoundName, 0, ReelVolAdj * 1.00, -0.12, 0, 0, 0, 1, 0 'Panned 3/4 Left at 0dB * ReelVolAdj
  3386. If Pan = "Mpan" Then PlaySound SoundName, 0, ReelVolAdj * 0.33, 0.00, 0, 0, 0, 1, 0 'Panned Middle at -3dB * ReelVolAdj
  3387. If Pan = "Rpan" Then PlaySound SoundName, 0, ReelVolAdj * 1.00, 0.12, 0, 0, 0, 1, 0 'Panned 3/4 Right at 0dB * ReelVolAdj
  3388. Else
  3389. If Pan = "Lpan" Then PlaySound SoundName, 0, ReelVolAdj * 0.33, -0.12, 0, 0, 0, 1, 0 'Panned 3/4 Left at -3dB * ReelVolAdj
  3390. If Pan = "Mpan" Then PlaySound SoundName, 0, ReelVolAdj * 0.11, 0.00, 0, 0, 0, 1, 0 'Panned Middle at -6dB * ReelVolAdj
  3391. If Pan = "Rpan" Then PlaySound SoundName, 0, ReelVolAdj * 0.33, 0.12, 0, 0, 0, 1, 0 'Panned 3/4 Right at -3dB * ReelVolAdj
  3392. End If
  3393. End Sub
  3394.  
  3395. '******************************************************
  3396. ' FLIPPER AND RUBBER CORRECTION
  3397. '******************************************************
  3398. dim LFPress, RFPress, EOST, EOSA, EOSTnew, EOSaNew
  3399. dim FStrength, FRampUp, fElasticity, EOSRampUp, SOSRampUp
  3400. dim RFEndAngle, LFEndAngle, LFCount, RFCount, LiveCatch
  3401.  
  3402. LFEndAngle = Leftflipper.EndAngle
  3403. RFEndAngle = RightFlipper.EndAngle
  3404.  
  3405. EOST = leftflipper.eosTorque 'End of Swing Torque
  3406. EOSA = leftflipper.eosTorqueAngle 'End of Swing Torque Angle
  3407. fStrength = LeftFlipper.strength 'Flipper Strength
  3408. fRampUp = LeftFlipper.RampUp 'Flipper Ramp Up
  3409. fElasticity = LeftFlipper.elasticity 'Flipper Elasticity
  3410. EOStNew = 1.0 'new Flipper Torque
  3411. EOSaNew = 0.2 'new FLipper Tprque Angle
  3412. EOSRampUp = 1.5 'new EOS Ramp Up weaker at EOS because of the weaker holding coil
  3413. SOSRampUp = 8.5 'new SOS Ramp Up strong at start because of the stronger starting coil
  3414. LiveCatch = 8 'variable to check elapsed time from
  3415.  
  3416. '********Need to have a flipper timer to check for these values
  3417.  
  3418. Sub flipperTimer_Timer
  3419. Dim BOT, b
  3420. BOT = GetBalls
  3421. Lflip.ObjRotZ = LeftFlipper.currentangle
  3422. Rflip.ObjRotZ = RightFlipper.currentangle
  3423. ' For b = 0 to UBound(BOT)
  3424. ' BOT(0).color = vbgreen
  3425. ' If b > 0 then BOT(1).color = vbred
  3426. ' If b > 1 Then BOT(2).color = vbblue
  3427. ' tb.text = "x = " & BOT(0).x
  3428. ' tb1.text = "y = " & BOT(0).y
  3429. ' tb.text = formatnumber(BOT(b).AngMomY,1)
  3430. ' tb.text = "AngMomX = " & formatnumber(BOT(b).AngMomX,1)
  3431. ' tb1.text = "AngMomY = " & formatnumber(BOT(b).AngMomY,1)
  3432. ' tb2.text = "AngMMomZ = " & formatnumber(BOT(b).AngMomZ,1)
  3433.  
  3434. ' Next
  3435.  
  3436. ' lFlip.rotz = leftflipper.CurrentAngle -121 'silver metal flipper obj
  3437. ' lFlipR.rotz = leftflipper.CurrentAngle -121
  3438. ' rFlip.rotz = RightFlipper.CurrentAngle +121
  3439. ' rFlipR.rotz = RightFlipper.CurrentAngle +121
  3440.  
  3441.  
  3442. FlipperLSh.RotZ = LeftFlipper.CurrentAngle
  3443. FlipperRSh.RotZ = RightFlipper.CurrentAngle
  3444.  
  3445.  
  3446.  
  3447. '--------------Flipper Tricks Section
  3448. 'What this code does is swing the flipper fast and make the flipper soft near its EOS to enable live catches. It resets back to the base Table
  3449. 'settings once the flipper reaches the end of swing. The code also makes the flipper starting ramp up high to simulate the stronger starting
  3450. 'coil strength and weaker at its EOS to simulate the weaker hold coil.
  3451.  
  3452. If LeftFlipper.CurrentAngle = LeftFlipper.EndAngle and LFPress = 1 Then 'If the flipper is fully swung and the flipper button is pressed then...
  3453. LeftFlipper.eosTorqueAngle = EOSaNew 'sets flipper EOS Torque Angle to .2
  3454. LeftFlipper.eosTorque = EOStNew 'sets flipper EOS Torque to 1
  3455. LeftFlipper.RampUp = EOSRampUp 'sets flipper ramp up to 1.5
  3456. If LFCount = 0 Then LFCount = GameTime 'sets the variable LFCount = to the elapsed game time
  3457. If GameTime - LFCount < LiveCatch Then 'if less than 8ms have elasped then we are in a "Live Catch" scenario
  3458. LeftFlipper.Elasticity = 0.1 'sets flipper elasticity WAY DOWN to allow Live Catches
  3459. If LeftFlipper.EndAngle <> LFEndAngle Then LeftFlipper.EndAngle = LFEndAngle 'Keep the flipper at its EOS and don't let it deflect
  3460. Else
  3461. LeftFlipper.Elasticity = fElasticity 'reset flipper elasticity to the base table setting
  3462. End If
  3463. Elseif LeftFlipper.CurrentAngle > LeftFlipper.startangle - 0.05 Then 'If the flipper has started its swing, make it swing fast to nearly the end...
  3464. LeftFlipper.RampUp = SOSRampUp 'set flipper Ramp Up high
  3465. LeftFlipper.EndAngle = LFEndAngle - 3 'swing to within 3 degrees of EOS
  3466. LeftFlipper.Elasticity = fElasticity 'Set the elasticity to the base table elasticity
  3467. LFCount = 0
  3468. Elseif LeftFlipper.CurrentAngle > LeftFlipper.EndAngle + 0.01 Then 'If the flipper has swung past it's end of swing then...
  3469. LeftFlipper.eosTorque = EOST 'set the flipper EOS Torque back to the base table setting
  3470. LeftFlipper.eosTorqueAngle = EOSA 'set the flipper EOS Torque Angle back to the base table setting
  3471. LeftFlipper.RampUp = fRampUp 'set the flipper Ramp Up back to the base table setting
  3472. LeftFlipper.Elasticity = fElasticity 'set the flipper Elasticity back to the base table setting
  3473. End If
  3474.  
  3475. If RightFlipper.CurrentAngle = RightFlipper.EndAngle and RFPress = 1 Then
  3476. RightFlipper.eosTorqueAngle = EOSaNew
  3477. RightFlipper.eosTorque = EOStNew
  3478. RightFlipper.RampUp = EOSRampUp
  3479. If RFCount = 0 Then RFCount = GameTime
  3480. If GameTime - RFCount < LiveCatch Then
  3481. RightFlipper.Elasticity = 0.1
  3482. If RightFlipper.EndAngle <> RFEndAngle Then RightFlipper.EndAngle = RFEndAngle
  3483. Else
  3484. RightFlipper.Elasticity = fElasticity
  3485. End If
  3486. Elseif RightFlipper.CurrentAngle < RightFlipper.StartAngle + 0.05 Then
  3487. RightFlipper.RampUp = SOSRampUp
  3488. RightFlipper.EndAngle = RFEndAngle + 3
  3489. RightFlipper.Elasticity = fElasticity
  3490. RFCount = 0
  3491. Elseif RightFlipper.CurrentAngle < RightFlipper.EndAngle - 0.01 Then
  3492. RightFlipper.eosTorque = EOST
  3493. RightFlipper.eosTorqueAngle = EOSA
  3494. RightFlipper.RampUp = fRampUp
  3495. RightFlipper.Elasticity = fElasticity
  3496. End If
  3497.  
  3498. End Sub
  3499.  
  3500. dim LF : Set LF = New FlipperPolarity
  3501. dim RF : Set RF = New FlipperPolarity
  3502.  
  3503.  
  3504. InitPolarity
  3505.  
  3506. Sub InitPolarity()
  3507. dim x, a : a = Array(LF, RF)
  3508. for each x in a
  3509. 'safety coefficient (diminishes polarity correction only)
  3510. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  3511. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  3512.  
  3513. x.enabled = True
  3514. x.TimeDelay = 69 '*****Important, this variable is an offset for the speed that the ball travels down the table to determine if the flippers have been fired
  3515. 'This is needed because the corrections to ball trajectory should only applied if the flippers have been fired and the ball is in the trigger zones.
  3516. 'FlipAT is set to GameTime when the ball enters the flipper trigger zones and if GameTime is less than FlipAT + this time delay then changes to velocity
  3517. 'and trajectory are applied. If the flipper is fired before the ball enters the trigger zone then with this delay added to FlipAT the changes
  3518. 'to tragectory and velocity will not be applied. Also if the flipper is in the final 20 degrees changes to ball values will also not be applied.
  3519. '"Faster" tables will need a smaller value while "slower" tables will need a larger value to give the ball more time to get to the flipper.
  3520. 'If this value is not set high enough the Flipper Velocity and Polarity corrections will NEVER be applied.
  3521. Next
  3522.  
  3523. 'rf.report "Polarity"
  3524. AddPt "Polarity", 0, 0, -2.7
  3525. AddPt "Polarity", 1, 0.16, -2.7
  3526. AddPt "Polarity", 2, 0.33, -2.7
  3527. AddPt "Polarity", 3, 0.37, -2.7 '4.2
  3528. AddPt "Polarity", 4, 0.41, -2.7
  3529. AddPt "Polarity", 5, 0.45, -2.7 '4.2
  3530. AddPt "Polarity", 6, 0.576,-2.7
  3531. AddPt "Polarity", 7, 0.66, -1.8'-2.1896
  3532. AddPt "Polarity", 8, 0.743, -0.5
  3533. AddPt "Polarity", 9, 0.81, -0.5
  3534. AddPt "Polarity", 10, 0.88, 0
  3535.  
  3536. '"Velocity" Profile
  3537. addpt "Velocity", 0, 0, 1
  3538. addpt "Velocity", 1, 0.16, 1.06
  3539. addpt "Velocity", 2, 0.41, 1.05
  3540. addpt "Velocity", 3, 0.53, 1'0.982
  3541. addpt "Velocity", 4, 0.702, 0.968
  3542. addpt "Velocity", 5, 0.95, 0.968
  3543. addpt "Velocity", 6, 1.03, 0.945
  3544.  
  3545. LF.Object = LeftFlipper
  3546. LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
  3547. RF.Object = RightFlipper
  3548. RF.EndPoint = EndPointRp
  3549. End Sub
  3550.  
  3551. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  3552. dim a : a = Array(LF, RF)
  3553. dim x : for each x in a
  3554. x.addpoint aStr, idx, aX, aY
  3555. Next
  3556. End Sub
  3557.  
  3558.  
  3559. Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
  3560. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : End Sub
  3561. Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
  3562. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub
  3563.  
  3564. 'Methods:
  3565. '.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
  3566. '.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
  3567. '.Object - set to flipper reference. Optional.
  3568. '.StartPoint - set start point coord. Unnecessary, if .object is used.
  3569.  
  3570. 'Called with flipper -
  3571. 'ProcessBalls - catches ball data.
  3572. ' - OR -
  3573. '.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
  3574.  
  3575. '***************This is flipperPolarity's addPoint Sub
  3576. Class FlipperPolarity
  3577. Public Enabled
  3578. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  3579. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  3580. private Flipper, FlipperStart, FlipperEnd, LR, PartialFlipCoef
  3581. Private Balls(20), balldata(20)
  3582.  
  3583. dim PolarityIn, PolarityOut
  3584. dim VelocityIn, VelocityOut
  3585. dim YcoefIn, YcoefOut
  3586.  
  3587. Public Sub Class_Initialize
  3588. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  3589. Enabled = True: TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new spoofBall: next
  3590. End Sub
  3591.  
  3592. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  3593. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  3594. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  3595. Public Property Let EndPoint(aInput) : if IsObject(aInput) then FlipperEnd = aInput.x else FlipperEnd = aInput : end if : End Property
  3596. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  3597.  
  3598. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  3599. Select Case aChooseArray
  3600. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  3601. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  3602. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  3603. End Select
  3604.  
  3605. End Sub
  3606.  
  3607. '********Triggered by a ball hitting the flipper trigger area
  3608. Public Sub AddBall(aBall) : dim x :
  3609. for x = 0 to uBound(balls)
  3610. if IsEmpty(balls(x)) then set balls(x) = aBall : exit sub :end if
  3611. Next
  3612. End Sub
  3613.  
  3614. Private Sub RemoveBall(aBall)
  3615. dim x : for x = 0 to uBound(balls)
  3616. if TypeName(balls(x) ) = "IBall" then
  3617. if aBall.ID = Balls(x).ID Then
  3618. balls(x) = Empty
  3619. Balldata(x).Reset
  3620. End If
  3621. End If
  3622. Next
  3623. End Sub
  3624.  
  3625. '*********Used to rotate flipper since this is removed from the key down for the flippers
  3626. Public Sub Fire()
  3627. Flipper.RotateToEnd
  3628. processballs
  3629. End Sub
  3630.  
  3631. Public Sub ProcessBalls() 'save data of balls in flipper range
  3632. FlipAt = GameTime
  3633. dim x : for x = 0 to uBound(balls)
  3634. if not IsEmpty(balls(x) ) then balldata(x).Data = balls(x)
  3635. Next
  3636. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle)) '% of flipper swing
  3637. PartialFlipCoef = abs(PartialFlipCoef-1)
  3638. if abs(Flipper.CurrentAngle - Flipper.EndAngle) < 20 Then 'last 20 degrees of swing is not dealt with
  3639. PartialFlipCoef = 0
  3640. End If
  3641. ' tb.text = FlipAT
  3642. End Sub
  3643.  
  3644. '***********gameTime is a global variable of how long the game has progressed in ms
  3645. '***********This function lets the table know if the flipper has been fired
  3646. Private Function FlipperOn()
  3647. ' TB.text = gameTime & ":" & (FlipAT + TimeDelay) ' ******MOVE TB into view WHEN THIS FLIPPER FUNCTIONALITY IS ADDED TO A NEW TABLE TO CHECK IF THE TIME DELAY IS LONG ENOUGH*****
  3648. if gameTime < FlipAt + TimeDelay then FlipperOn = True
  3649. End Function 'Timer shutoff for polaritycorrect
  3650.  
  3651. '***********This is turned on when a ball leaves the flipper trigger area
  3652. Public Sub PolarityCorrect(aBall)
  3653. if FlipperOn() then 'don't run this if the flippers are at rest
  3654. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  3655. dim teststr : teststr = "Cutoff"
  3656. tmp = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  3657. if tmp < 0.1 then 'if real ball position is behind flipper, exit Sub to prevent stucks 'Disabled 1.03, I think it's the Mesh that's causing stucks, not this
  3658. end if
  3659.  
  3660. 'y safety Exit
  3661. if aBall.VelY > -8 then 'if ball going down then remove the ball
  3662. RemoveBall aBall
  3663. exit Sub
  3664. end if
  3665. 'Find balldata. BallPos = % on Flipper
  3666. for x = 0 to uBound(Balls)
  3667. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  3668. idx = x
  3669. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  3670. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  3671. end if
  3672. Next
  3673.  
  3674. 'Velocity correction
  3675. if not IsEmpty(VelocityIn(0) ) then
  3676. ' tb.text = "Vel corr"
  3677. Dim VelCoef
  3678. if IsEmpty(BallData(idx).id) and aBall.VelY < -12 then 'if tip hit with no collected data, do vel correction anyway
  3679. if PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1) > 1.1 then 'adjust plz
  3680. VelCoef = LinearEnvelope(5, VelocityIn, VelocityOut)
  3681. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  3682. if Enabled then aBall.Velx = aBall.Velx*VelCoef'VelCoef
  3683. if Enabled then aBall.Vely = aBall.Vely*VelCoef'VelCoef
  3684. end if
  3685. Else
  3686. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  3687. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  3688. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  3689. end if
  3690. End If
  3691.  
  3692. 'Polarity Correction (optional now)
  3693. if not IsEmpty(PolarityIn(0) ) then
  3694. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  3695. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  3696. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  3697. End If
  3698. End If
  3699. RemoveBall aBall
  3700. End Sub
  3701. End Class
  3702.  
  3703. '================================
  3704. 'Helper Functions
  3705.  
  3706.  
  3707. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  3708. dim x, aCount : aCount = 0
  3709. redim a(uBound(aArray) )
  3710. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  3711. if not IsEmpty(aArray(x) ) Then
  3712. if IsObject(aArray(x)) then
  3713. Set a(aCount) = aArray(x) 'Set creates an object in VB
  3714. Else
  3715. a(aCount) = aArray(x)
  3716. End If
  3717. aCount = aCount + 1
  3718. End If
  3719. Next
  3720. if offset < 0 then offset = 0
  3721. redim aArray(aCount-1+offset) 'Resize original array
  3722. for x = 0 to aCount-1 'set objects back into original array
  3723. if IsObject(a(x)) then
  3724. Set aArray(x) = a(x)
  3725. Else
  3726. aArray(x) = a(x)
  3727. End If
  3728. Next
  3729. End Sub
  3730.  
  3731. '**********Takes in more than one array and passes them to ShuffleArray
  3732. Sub ShuffleArrays(aArray1, aArray2, offset)
  3733. ShuffleArray aArray1, offset
  3734. ShuffleArray aArray2, offset
  3735. End Sub
  3736.  
  3737. '**********Calculate ball speed as hypotenuse of velX/velY triangle
  3738. Function BallSpeed(ball) 'Calculates the ball speed
  3739. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  3740. End Function
  3741.  
  3742. '**********Calculates the value of Y for an input x using the slope intercept equation
  3743. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  3744. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  3745. Y = M*x+b
  3746. PSlope = Y
  3747. End Function
  3748.  
  3749. Class spoofball
  3750. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  3751. Public Property Let Data(aBall)
  3752. With aBall
  3753. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  3754. id = .ID : mass = .mass : radius = .radius
  3755. end with
  3756. End Property
  3757. Public Sub Reset()
  3758. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  3759. id = Empty : mass = Empty : radius = Empty
  3760. End Sub
  3761. End Class
  3762.  
  3763. '****************************************************************************
  3764. 'PHYSICS DAMPENERS
  3765.  
  3766. 'These are data mined bounce curves,
  3767. 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
  3768. 'Requires tracking ballspeed to calculate COR
  3769.  
  3770.  
  3771. Sub dPosts_Hit(idx)
  3772. RubbersD.dampen Activeball
  3773. End Sub
  3774.  
  3775. Sub dSleeves_Hit(idx)
  3776. SleevesD.Dampen Activeball
  3777. End Sub
  3778.  
  3779. '*********This sets up the rubbers:
  3780. dim RubbersD
  3781. Set RubbersD = new Dampener 'Makes a Dampener Class Object
  3782. RubbersD.name = "Rubbers"
  3783.  
  3784. 'cor bounce curve (linear)
  3785. 'for best results, try to match in-game velocity as closely as possible to the desired curve
  3786. RubbersD.addpoint 0, 0, 0.935 '0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
  3787. RubbersD.addpoint 1, 3.77, 0.935 '0.96
  3788. RubbersD.addpoint 2, 5.76, 0.942 '0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
  3789. RubbersD.addpoint 3, 15.84, 0.874
  3790. RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
  3791.  
  3792. dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
  3793. SleevesD.name = "Sleeves"
  3794. SleevesD.CopyCoef RubbersD, 0.85
  3795.  
  3796. '**********Class for dampener section of nfozzy's code
  3797. Class Dampener
  3798. Public Print, debugOn 'tbpOut.text
  3799. public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
  3800. Public ModIn, ModOut
  3801. Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
  3802.  
  3803. Public Sub AddPoint(aIdx, aX, aY)
  3804. ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
  3805. End Sub
  3806.  
  3807. public sub Dampen(aBall)
  3808. if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
  3809. dim RealCOR, DesiredCOR, str, coef
  3810. ' Uses the LinearEnvelope function to calculate the correction based upon where it's value sits in relation
  3811.  
  3812. ' to the addpoint parameters set above. Basically interpolates values between set points in a linear fashion
  3813. DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
  3814.  
  3815. ' Uses the function BallSpeed's value at the point of impact/the active ball's velocity which is constantly being updated
  3816. ' RealCor is always less than 1
  3817. RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
  3818.  
  3819. ' Divides the desired CoR by the real COR to make a multiplier to correct velocity in x and y
  3820. coef = desiredcor / realcor
  3821.  
  3822. ' TB.text = coef
  3823.  
  3824. ' Applies the coef to x and y velocities
  3825. aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
  3826. End Sub
  3827.  
  3828. '***********This Sub sets the values for Sleeves (or any other future objects) to 85% (or whatever is passed in) of Posts
  3829. Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
  3830. dim x : for x = 0 to uBound(aObj.ModIn)
  3831. addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
  3832. Next
  3833. End Sub
  3834. End Class
  3835.  
  3836. '*****************************Generates cor.ballVel for dampener
  3837. Sub RDampen_Timer() ' 1 ms timer always on
  3838. CoR.Update
  3839. End Sub
  3840.  
  3841. '*********CoR is Coefficient of Restitution defined as "how much of the kinetic energy remains for the objects
  3842. 'to rebound from one another vs. how much is lost as heat, or work done deforming the objects
  3843. dim cor : set cor = New CoRTracker
  3844.  
  3845. Class CoRTracker
  3846. public ballvel, ballvelx, ballvely
  3847.  
  3848. Private Sub Class_Initialize : redim ballvel(0) : redim ballvelx(0): redim ballvely(0) : End Sub
  3849.  
  3850. Public Sub Update() 'tracks in-ball-velocity
  3851. dim str, b, AllBalls, highestID : allBalls = getballs
  3852.  
  3853. for each b in allballs
  3854. if b.id >= HighestID then highestID = b.id
  3855. Next
  3856.  
  3857. if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
  3858. if uBound(ballvelx) < highestID then redim ballvelx(highestID) 'set bounds
  3859. if uBound(ballvely) < highestID then redim ballvely(highestID) 'set bounds
  3860.  
  3861. for each b in allballs
  3862. ballvel(b.id) = BallSpeed(b)
  3863. ballvelx(b.id) = b.velx
  3864. ballvely(b.id) = b.vely
  3865. Next
  3866. End Sub
  3867. End Class
  3868.  
  3869. '********Interpolates the value for areas between the low and upper bounds sent to it
  3870. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  3871. dim y 'Y output
  3872. dim L 'Line
  3873. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  3874. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  3875. Next
  3876. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  3877. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  3878.  
  3879. 'clamp 2.0
  3880. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  3881. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  3882.  
  3883. LinearEnvelope = Y
  3884. End Function
  3885.  
  3886. Sub Table1_Exit
  3887. If B2sOn Then controller.stop
  3888. saveHighScore
  3889. End Sub
  3890.  
  3891.  
Advertisement
Add Comment
Please, Sign In to add comment