Outhere

Luck Smile (jpsalas_Inder 1976) 1p_1.0

Dec 5th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.50 KB | None | 0 0
  1. ' ***********************************************************************
  2. ' VISUAL PINBALL X EM Script by JPSalas
  3. ' Basic EM script up to 4 players
  4. ' uses core.vbs for extra functions
  5. ' Luck Smile / IPD No. 3886 / INDER 1976 / 1 Players
  6. ' ***********************************************************************
  7.  
  8. 'DOF Config by Outhere
  9. '101 Left Flipper
  10. '102 Right Flipper
  11. '103 Left Slingshot
  12. '104
  13. '105 Right Slingshot
  14. '106
  15. '107 Bumper Left
  16. '108
  17. '109 Bumper Right
  18. '110 Ball Release
  19. '111 kicker Left Hole
  20. '112 kicker Center Hole
  21. '113 kicker Right Hole
  22. '114 Kicker Bonus
  23. '115 Chimes
  24. '116 Chimes
  25. '117 Chimes
  26. '118 Chimes
  27. '119 Bell
  28.  
  29. Option Explicit
  30. Randomize
  31.  
  32. ' core.vbs constants
  33. Const BallSize = 50 ' 50 is the normal size
  34. Const BallMass = 1.7 ' 1 is the normal ball mass.
  35.  
  36. ' load extra vbs files
  37. LoadCoreFiles
  38.  
  39. Sub LoadCoreFiles
  40. On Error Resume Next
  41. ExecuteGlobal GetTextFile("core.vbs")
  42. If Err Then MsgBox "Can't open core.vbs"
  43. On Error Resume Next
  44. ExecuteGlobal GetTextFile("controller.vbs")
  45. If Err Then MsgBox "Can't open controller.vbs"
  46. End Sub
  47.  
  48. ' Valores Constants
  49. Const cGameName = "lucksmile1" ' B2S name
  50. Const MaxPlayers = 1 ' 1 to 4 can play
  51. Const MaxMultiplier = 3 ' limit bonus multiplier
  52. Const BallsPerGame = 3 ' 3 or 5
  53. Const FreePlay = False ' Free play or coins
  54. Const Special1 = 690000 ' extra ball or credit
  55. Const Special2 = 920000
  56. 'Const Special3 = 920000
  57.  
  58. ' Global variables
  59. Dim PlayersPlayingGame
  60. Dim CurrentPlayer
  61. Dim Credits
  62. Dim Bonus
  63. Dim BallsRemaining(4)
  64. Dim BonusMultiplier
  65. Dim ExtraBallsAwards(4)
  66. Dim Special1Awarded(4)
  67. Dim Special2Awarded(4)
  68. 'Dim Special3Awarded(4)
  69. Dim Score(4)
  70. Dim HighScore
  71. Dim Match
  72. Dim Tilt
  73. Dim TiltSensitivity
  74. Dim Tilted
  75. Dim Add10
  76. Dim Add100
  77. Dim Add1000
  78. Dim Add10000
  79. Dim x
  80.  
  81. ' Control variables
  82. Dim BallsOnPlayfield
  83.  
  84. ' Boolean variables
  85. Dim bAttractMode
  86. Dim bFreePlay
  87. Dim bGameInPlay
  88. Dim bOnTheFirstBall
  89. Dim bExtraBallWonThisBall
  90. Dim bJustStarted
  91. Dim bBallInPlungerLane
  92. Dim bBallSaverActive
  93.  
  94. ' core.vbs variables
  95.  
  96. ' *********************************************************************
  97. ' Common rutines to all the tables
  98. ' *********************************************************************
  99.  
  100. Sub Table1_Init()
  101. Dim x
  102.  
  103. ' Init som objects, like walls, targets
  104. VPObjects_Init
  105. LoadEM
  106.  
  107. ' load highscore
  108. Loadhs
  109. ScoreReel1.SetValue HSScore(1)
  110. If B2SOn then
  111. Controller.B2SSetScorePlayer 1, HSScore(1)
  112. End If
  113. UpdateCredits
  114.  
  115. ' init all the global variables
  116. bFreePlay = FreePlay
  117. bAttractMode = False
  118. bOnTheFirstBall = False
  119. bGameInPlay = False
  120. bBallInPlungerLane = False
  121. BallsOnPlayfield = 0
  122. Tilt = 0
  123. TiltSensitivity = 6
  124. Tilted = False
  125. Match = 0
  126. bJustStarted = True
  127. Add10 = 0
  128. Add100 = 0
  129. Add1000 = 0
  130.  
  131. ' setup table in game over mode
  132. EndOfGame
  133.  
  134. 'turn on GI lights
  135. vpmtimer.addtimer 1000, "GiOn '"
  136.  
  137. ' Remove desktop items in FS mode
  138. If Table1.ShowDT then
  139. For each x in aReels
  140. x.Visible = 1
  141. Next
  142. Else
  143. For each x in aReels
  144. x.Visible = 0
  145. Next
  146. End If
  147.  
  148. ' Start the RealTime timer
  149. RealTime.Enabled = 1
  150.  
  151. ' Load table color
  152. LoadLut
  153. End Sub
  154.  
  155. '******
  156. ' Keys
  157. '******
  158.  
  159. Sub Table1_KeyDown(ByVal Keycode)
  160.  
  161. If keycode = LeftMagnaSave Then bLutActive = True
  162. If keycode = RightMagnaSave Then
  163. If bLutActive Then NextLUT:End If
  164. End If
  165.  
  166. If EnteringInitials then
  167. CollectInitials(keycode)
  168. Exit Sub
  169. End If
  170.  
  171. ' add coins
  172. If Keycode = AddCreditKey Then
  173. If(Tilted = False)Then
  174. AddCredits 1
  175. PlaySound "fx_coin"
  176. End If
  177. End If
  178.  
  179. ' plunger
  180. If keycode = PlungerKey Then
  181. Plunger.Pullback
  182. PlaySoundAt "fx_plungerpull", plunger
  183. End If
  184.  
  185. ' tilt keys
  186. If keycode = LeftTiltKey Then Nudge 90, 8:PlaySound "fx_nudge", 0, 1, -0.1, 0.25:CheckTilt
  187. If keycode = RightTiltKey Then Nudge 270, 8:PlaySound "fx_nudge", 0, 1, 0.1, 0.25:CheckTilt
  188. If keycode = CenterTiltKey Then Nudge 0, 9:PlaySound "fx_nudge", 0, 1, 1, 0.25:CheckTilt
  189.  
  190. ' keys during game
  191.  
  192. If bGameInPlay AND NOT Tilted Then
  193. If keycode = LeftFlipperKey Then SolLFlipper 1
  194. If keycode = RightFlipperKey Then SolRFlipper 1
  195.  
  196. If keycode = StartGameKey Then
  197. If((PlayersPlayingGame <MaxPlayers)AND(bOnTheFirstBall = True))Then
  198.  
  199. If(bFreePlay = True)Then
  200. PlayersPlayingGame = PlayersPlayingGame + 1
  201. UpdatePlayersPlaying
  202. 'PlaySound "so_fanfare1"
  203. Else
  204. If(Credits> 0)then
  205. PlayersPlayingGame = PlayersPlayingGame + 1
  206. Credits = Credits - 1
  207. UpdateCredits
  208. UpdateBallInPlay
  209. UpdatePlayersPlaying
  210. Else
  211. ' Not Enough Credits to start a game.
  212. 'PlaySound "so_nocredits"
  213. End If
  214. End If
  215. End If
  216. End If
  217. Else
  218.  
  219. If keycode = StartGameKey Then
  220. If(bFreePlay = True)Then
  221. If(BallsOnPlayfield = 0)Then
  222. ResetScores
  223. ResetForNewGame()
  224. End If
  225. Else
  226. If(Credits> 0)Then
  227. If(BallsOnPlayfield = 0)Then
  228. Credits = Credits - 1
  229. UpdateCredits
  230. ResetScores
  231. ResetForNewGame()
  232. End If
  233. Else
  234. ' Not Enough Credits to start a game.
  235. 'PlaySound "so_nocredits"
  236. End If
  237. End If
  238. End If
  239. End If ' If (GameInPlay)
  240. End Sub
  241.  
  242. Sub Table1_KeyUp(ByVal keycode)
  243.  
  244. If keycode = LeftMagnaSave Then bLutActive = False
  245.  
  246. If EnteringInitials then
  247. Exit Sub
  248. End If
  249.  
  250. If bGameInPlay AND NOT Tilted Then
  251. ' teclas de los flipers
  252. If keycode = LeftFlipperKey Then SolLFlipper 0
  253. If keycode = RightFlipperKey Then SolRFlipper 0
  254. End If
  255.  
  256. If keycode = PlungerKey Then
  257. Plunger.Fire
  258. If bBallInPlungerLane Then
  259. PlaySoundAt "fx_plunger", plunger
  260. Else
  261. PlaySoundAt "fx_plunger_empty", plunger
  262. End If
  263. End If
  264. End Sub
  265.  
  266. '******************
  267. ' Table stop/pause
  268. '******************
  269.  
  270. Sub table1_Paused
  271. End Sub
  272.  
  273. Sub table1_unPaused
  274. End Sub
  275.  
  276. Sub table1_Exit
  277. Savehs
  278. 'Controller.Stop
  279. End Sub
  280.  
  281. '********************
  282. ' Flippers
  283. '********************
  284.  
  285. Sub SolLFlipper(Enabled)
  286. If Enabled Then
  287. PlaySoundAt SoundFXDOF("fx_flipperup", 101, DOFOn, DOFFlippers), LeftFlipper
  288. LeftFlipper.EOSTorque = 0.75:LeftFlipper.RotateToEnd
  289. Else
  290. PlaySoundAt SoundFXDOF("fx_flipperdown", 101, DOFOff, DOFFlippers), LeftFlipper
  291. LeftFlipper.EOSTorque = 0.1:LeftFlipper.RotateToStart
  292. End If
  293. End Sub
  294.  
  295. Sub SolRFlipper(Enabled)
  296. If Enabled Then
  297. PlaySoundAt SoundFXDOF("fx_flipperup", 102, DOFOn, DOFFlippers), RightFlipper
  298. RightFlipper.EOSTorque = 0.75:RightFlipper.RotateToEnd
  299. Else
  300. PlaySoundAt SoundFXDOF("fx_flipperdown", 102, DOFOff, DOFFlippers), RightFlipper
  301. RightFlipper.EOSTorque = 0.1:RightFlipper.RotateToStart
  302. End If
  303. End Sub
  304.  
  305. ' flippers hit Sound
  306.  
  307. Sub LeftFlipper_Collide(parm)
  308. PlaySound "fx_rubber_flipper", 0, parm / 60, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  309. End Sub
  310.  
  311. Sub RightFlipper_Collide(parm)
  312. PlaySound "fx_rubber_flipper", 0, parm / 60, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  313. End Sub
  314.  
  315. '***********
  316. ' GI lights
  317. '***********
  318.  
  319. Sub GiOn 'enciende las luces GI
  320. Dim bulb
  321. For each bulb in aGiLights
  322. bulb.State = 1
  323. Next
  324. End Sub
  325.  
  326. Sub GiOff 'apaga las luces GI
  327. Dim bulb
  328. For each bulb in aGiLights
  329. bulb.State = 0
  330. Next
  331. End Sub
  332.  
  333. '**************
  334. ' TILT
  335. '**************
  336.  
  337. Sub CheckTilt
  338. Tilt = Tilt + TiltSensitivity
  339. TiltDecreaseTimer.Enabled = True
  340. If Tilt> 15 Then
  341. Tilted = True
  342. TiltReel.SetValue 1
  343. If B2SOn then
  344. Controller.B2SSetTilt 1
  345. end if
  346. DisableTable True
  347. ' BallsRemaining(CurrentPlayer) = 0 'player looses the game
  348. TiltRecoveryTimer.Enabled = True 'wait for all the balls to drain
  349. End If
  350. End Sub
  351.  
  352. Sub TiltDecreaseTimer_Timer
  353. If Tilt> 0 Then
  354. Tilt = Tilt - 0.1
  355. Else
  356. TiltDecreaseTimer.Enabled = False
  357. End If
  358. End Sub
  359.  
  360. Sub DisableTable(Enabled)
  361. If Enabled Then
  362. GiOff
  363. LeftFlipper.RotateToStart
  364. RightFlipper.RotateToStart
  365. Bumper001.Force = 0
  366. Bumper002.Force = 0
  367. LeftSlingshot.Disabled = 1
  368. RightSlingshot.Disabled = 1
  369. Else
  370. GiOn
  371. Bumper001.Force = 10
  372. Bumper002.Force = 10
  373. LeftSlingshot.Disabled = 0
  374. RightSlingshot.Disabled = 0
  375. End If
  376. End Sub
  377.  
  378. Sub TiltRecoveryTimer_Timer()
  379. ' all the balls have drained
  380. If(BallsOnPlayfield = 0)Then
  381. EndOfBall()
  382. TiltRecoveryTimer.Enabled = False
  383. End If
  384. ' otherwise repeat
  385. End Sub
  386.  
  387. '***************************************************************
  388. ' Supporting Ball & Sound Functions v3.0
  389. ' includes random pitch in PlaySoundAt and PlaySoundAtBall
  390. '***************************************************************
  391.  
  392. Dim TableWidth, TableHeight
  393.  
  394. TableWidth = Table1.width
  395. TableHeight = Table1.height
  396.  
  397. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  398. Vol = Csng(BallVel(ball) ^2 / 2000)
  399. End Function
  400.  
  401. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  402. Dim tmp
  403. tmp = ball.x * 2 / TableWidth-1
  404. If tmp> 0 Then
  405. Pan = Csng(tmp ^10)
  406. Else
  407. Pan = Csng(-((- tmp) ^10))
  408. End If
  409. End Function
  410.  
  411. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  412. Pitch = BallVel(ball) * 20
  413. End Function
  414.  
  415. Function BallVel(ball) 'Calculates the ball speed
  416. BallVel = (SQR((ball.VelX ^2) + (ball.VelY ^2)))
  417. End Function
  418.  
  419. Function AudioFade(ball) 'only on VPX 10.4 and newer
  420. Dim tmp
  421. tmp = ball.y * 2 / TableHeight-1
  422. If tmp> 0 Then
  423. AudioFade = Csng(tmp ^10)
  424. Else
  425. AudioFade = Csng(-((- tmp) ^10))
  426. End If
  427. End Function
  428.  
  429. Sub PlaySoundAt(soundname, tableobj) 'play sound at X and Y position of an object, mostly bumpers, flippers and other fast objects
  430. PlaySound soundname, 0, 1, Pan(tableobj), 0.1, 0, 0, 0, AudioFade(tableobj)
  431. End Sub
  432.  
  433. Sub PlaySoundAtBall(soundname) ' play a sound at the ball position, like rubbers, targets, metals, plastics
  434. PlaySound soundname, 0, Vol(ActiveBall), pan(ActiveBall), 0.4, 0, 0, 0, AudioFade(ActiveBall)
  435. End Sub
  436.  
  437. '***********************************************
  438. ' JP's VP10 Rolling Sounds + Ballshadow v3.0
  439. ' uses a collection of shadows, aBallShadow
  440. '***********************************************
  441.  
  442. Const tnob = 19 'total number of balls, 20 balls, from 0 to 19
  443. Const lob = 0 'number of locked balls
  444. Const maxvel = 34 'max ball velocity
  445. ReDim rolling(tnob)
  446. InitRolling
  447.  
  448. Sub InitRolling
  449. Dim i
  450. For i = 0 to tnob
  451. rolling(i) = False
  452. Next
  453. End Sub
  454.  
  455. Sub RollingUpdate()
  456. Dim BOT, b, ballpitch, ballvol, speedfactorx, speedfactory
  457. BOT = GetBalls
  458.  
  459. ' stop the sound of deleted balls and hide the shadow
  460. For b = UBound(BOT) + 1 to tnob
  461. rolling(b) = False
  462. StopSound("fx_ballrolling" & b)
  463. aBallShadow(b).Y = 3000
  464. Next
  465.  
  466. ' exit the sub if no balls on the table
  467. If UBound(BOT) = lob - 1 Then Exit Sub 'there no extra balls on this table
  468.  
  469. ' play the rolling sound for each ball and draw the shadow
  470. For b = lob to UBound(BOT)
  471. aBallShadow(b).X = BOT(b).X
  472. aBallShadow(b).Y = BOT(b).Y
  473.  
  474. If BallVel(BOT(b))> 1 Then
  475. If BOT(b).z <30 Then
  476. ballpitch = Pitch(BOT(b))
  477. ballvol = Vol(BOT(b))
  478. Else
  479. ballpitch = Pitch(BOT(b)) + 25000 'increase the pitch on a ramp
  480. ballvol = Vol(BOT(b)) * 10
  481. End If
  482. rolling(b) = True
  483. PlaySound("fx_ballrolling" & b), -1, ballvol, Pan(BOT(b)), 0, ballpitch, 1, 0, AudioFade(BOT(b))
  484. Else
  485. If rolling(b) = True Then
  486. StopSound("fx_ballrolling" & b)
  487. rolling(b) = False
  488. End If
  489. End If
  490.  
  491. ' rothbauerw's Dropping Sounds
  492. If BOT(b).VelZ <-1 and BOT(b).z <55 and BOT(b).z> 27 Then 'height adjust for ball drop sounds
  493. PlaySound "fx_balldrop", 0, ABS(BOT(b).velz) / 17, Pan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  494. End If
  495.  
  496. ' jps ball speed control
  497. If BOT(b).VelX AND BOT(b).VelY <> 0 Then
  498. speedfactorx = ABS(maxvel / BOT(b).VelX)
  499. speedfactory = ABS(maxvel / BOT(b).VelY)
  500. If speedfactorx <1 Then
  501. BOT(b).VelX = BOT(b).VelX * speedfactorx
  502. BOT(b).VelY = BOT(b).VelY * speedfactorx
  503. End If
  504. If speedfactory <1 Then
  505. BOT(b).VelX = BOT(b).VelX * speedfactory
  506. BOT(b).VelY = BOT(b).VelY * speedfactory
  507. End If
  508. End If
  509. Next
  510. End Sub
  511.  
  512. '**********************
  513. ' Ball Collision Sound
  514. '**********************
  515.  
  516. Sub OnBallBallCollision(ball1, ball2, velocity)
  517. PlaySound "fx_collide", 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  518. End Sub
  519.  
  520. '************************************
  521. ' Diverse Collection Hit Sounds v3.0
  522. '************************************
  523.  
  524. Sub aMetals_Hit(idx):PlaySoundAtBall "fx_MetalHit":End Sub
  525. Sub aMetalWires_Hit(idx):PlaySoundAtBall "fx_MetalWire":End Sub
  526. Sub aRubber_Bands_Hit(idx):PlaySoundAtBall "fx_rubber_band":End Sub
  527. Sub aRubber_LongBands_Hit(idx):PlaySoundAtBall "fx_rubber_longband":End Sub
  528. Sub aRubber_Posts_Hit(idx):PlaySoundAtBall "fx_rubber_post":End Sub
  529. Sub aRubber_Pins_Hit(idx):PlaySoundAtBall "fx_rubber_pin":End Sub
  530. Sub aRubber_Pegs_Hit(idx):PlaySoundAtBall "fx_rubber_peg":End Sub
  531. Sub aPlastics_Hit(idx):PlaySoundAtBall "fx_PlasticHit":End Sub
  532. Sub aGates_Hit(idx):PlaySoundAtBall "fx_Gate":End Sub
  533. Sub aWoods_Hit(idx):PlaySoundAtBall "fx_Woodhit":End Sub
  534. Sub aTargets_Hit(idx):ActiveBall.VelZ = BallVel(Activeball) * (RND / 2):End Sub
  535.  
  536. '************************************************************************************************************************
  537. ' Only for VPX 10.2 and higher.
  538. ' FlashForMs will blink light or a flasher for TotalPeriod(ms) at rate of BlinkPeriod(ms)
  539. ' When TotalPeriod done, light or flasher will be set to FinalState value where
  540. ' Final State values are: 0=Off, 1=On, 2=Return to previous State
  541. '************************************************************************************************************************
  542.  
  543. Sub FlashForMs(MyLight, TotalPeriod, BlinkPeriod, FinalState)
  544.  
  545. If TypeName(MyLight) = "Light" Then
  546. If FinalState = 2 Then
  547. FinalState = MyLight.State
  548. End If
  549. MyLight.BlinkInterval = BlinkPeriod
  550. MyLight.Duration 2, TotalPeriod, FinalState
  551. ElseIf TypeName(MyLight) = "Flasher" Then
  552. Dim steps
  553. steps = Int(TotalPeriod / BlinkPeriod + .5)
  554. If FinalState = 2 Then
  555. FinalState = ABS(MyLight.Visible)
  556. End If
  557. MyLight.UserValue = steps * 10 + FinalState
  558. MyLight.TimerInterval = BlinkPeriod
  559. MyLight.TimerEnabled = 0
  560. MyLight.TimerEnabled = 1
  561. ExecuteGlobal "Sub " & MyLight.Name & "_Timer:" & "Dim tmp, steps, fstate:tmp=me.UserValue:fstate = tmp MOD 10:steps= tmp\10 -1:Me.Visible = steps MOD 2:me.UserValue = steps *10 + fstate:If Steps = 0 then Me.Visible = fstate:Me.TimerEnabled=0:End if:End Sub"
  562. End If
  563. End Sub
  564.  
  565. '****************************************
  566. ' Init table for a new game
  567. '****************************************
  568.  
  569. Sub ResetForNewGame()
  570. 'debug.print "ResetForNewGame"
  571. Dim i
  572.  
  573. bGameInPLay = True
  574. bBallSaverActive = False
  575.  
  576. StopAttractMode
  577. If B2SOn then
  578. Controller.B2SSetGameOver 0
  579. end if
  580.  
  581. GiOn
  582.  
  583. CurrentPlayer = 1
  584. PlayersPlayingGame = 1
  585. UpdatePlayersPlaying
  586. bOnTheFirstBall = True
  587. For i = 1 To MaxPlayers
  588. Score(i) = 0
  589. ExtraBallsAwards(i) = 0
  590. Special1Awarded(i) = False
  591. Special2Awarded(i) = False
  592. 'Special3Awarded(i) = False
  593. BallsRemaining(i) = BallsPerGame
  594. Next
  595. BonusMultiplier = 1
  596. Bonus = 0
  597. UpdateBallInPlay
  598.  
  599. Clear_Match
  600.  
  601. ' init other variables
  602. Tilt = 0
  603.  
  604. ' init game variables
  605. Game_Init()
  606.  
  607. ' start a music?
  608. ' first ball
  609. vpmtimer.addtimer 2000, "FirstBall '"
  610. End Sub
  611.  
  612. Sub FirstBall
  613. 'debug.print "FirstBall"
  614. ' reset table for a new ball, rise droptargets ++
  615. ResetForNewPlayerBall()
  616. CreateNewBall()
  617. End Sub
  618.  
  619. ' (Re-)init table for a new ball or player
  620.  
  621. Sub ResetForNewPlayerBall()
  622. 'debug.print "ResetForNewPlayerBall"
  623. AddScore 0
  624.  
  625. ' reset multiplier to 1x
  626.  
  627. ' turn on lights, and variables
  628. bExtraBallWonThisBall = False
  629. ResetNewBallLights
  630. ResetNewBallVariables
  631. End Sub
  632.  
  633. ' Crete new ball
  634.  
  635. Sub CreateNewBall()
  636. BallRelease.CreateSizedBallWithMass BallSize / 2, BallMass
  637. BallsOnPlayfield = BallsOnPlayfield + 1
  638. UpdateBallInPlay
  639. UpdateCurrentPlayer
  640. PlaySoundAt SoundFXDOF("fx_Ballrel", 110, DOFPulse, DOFContactors), BallRelease
  641. BallRelease.Kick 90, 4
  642. End Sub
  643.  
  644. ' player lost the ball
  645.  
  646. Sub EndOfBall()
  647. 'debug.print "EndOfBall"
  648. ' Lost the first ball, now it cannot accept more players
  649. bOnTheFirstBall = False
  650.  
  651. 'No bonus count in this table
  652. ' StartBonusCount
  653.  
  654. vpmtimer.addtimer 400, "EndOfBall2 '"
  655. End Sub
  656.  
  657. ' After bonus count go to the next step
  658. '
  659. Sub EndOfBall2()
  660. 'debug.print "EndOfBall2"
  661.  
  662. Tilted = False
  663. Tilt = 0
  664. TiltReel.SetValue 0
  665. If B2SOn then
  666. Controller.B2SSetTilt 0
  667. end if
  668. DisableTable False
  669.  
  670. ' win extra ball?
  671. If(ExtraBallsAwards(CurrentPlayer)> 0)Then
  672. 'debug.print "Extra Ball"
  673.  
  674. ' if so then give it
  675. ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer)- 1
  676.  
  677. ' turn off light if no more extra balls
  678. If(ExtraBallsAwards(CurrentPlayer) = 0)Then
  679. XtraBall.SetValue 0
  680. If B2SOn then
  681. Controller.B2SSetShootAgain 0
  682. End If
  683. End If
  684.  
  685. ' extra ball sound?
  686.  
  687. ' reset as in a new ball
  688. ResetForNewPlayerBall()
  689. CreateNewBall()
  690. Else ' no extra ball
  691.  
  692. BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer)- 1
  693.  
  694. ' last ball?
  695. If(BallsRemaining(CurrentPlayer) <= 0)Then
  696. CheckHighScore()
  697. End If
  698.  
  699. ' this is not the last ball, chack for new player
  700. EndOfBallComplete()
  701. End If
  702. End Sub
  703.  
  704. Sub EndOfBallComplete()
  705. 'debug.print "EndOfBallComplete"
  706. Dim NextPlayer
  707.  
  708. ' other players?
  709. If(PlayersPlayingGame> 1)Then
  710. NextPlayer = CurrentPlayer + 1
  711. ' if it is the last player then go to the first one
  712. If(NextPlayer> PlayersPlayingGame)Then
  713. NextPlayer = 1
  714. End If
  715. Else
  716. NextPlayer = CurrentPlayer
  717. End If
  718.  
  719. 'debug.print "Next Player = " & NextPlayer
  720.  
  721. ' end of game?
  722. If((BallsRemaining(CurrentPlayer) <= 0)AND(BallsRemaining(NextPlayer) <= 0))Then
  723.  
  724. ' match if playing with coins
  725. If bFreePlay = False Then
  726. Verification_Match
  727. End If
  728.  
  729. ' end of game
  730. EndOfGame()
  731. Else
  732. ' next player
  733. CurrentPlayer = NextPlayer
  734.  
  735. ' update score
  736. AddScore 0
  737.  
  738. ' reset table for new player
  739. ResetForNewPlayerBall()
  740. CreateNewBall()
  741. End If
  742. End Sub
  743.  
  744. ' Called at the end of the game
  745.  
  746. Sub EndOfGame()
  747. 'debug.print "EndOfGame"
  748. bGameInPLay = False
  749. bJustStarted = False
  750. GameOverR.SetValue 1
  751. If B2SOn then
  752. Controller.B2SSetGameOver 1
  753. Controller.B2SSetBallInPlay 0
  754. Controller.B2SSetPlayerUp 0
  755. Controller.B2SSetCanPlay 0
  756. end if
  757. ' turn off flippers
  758. SolLFlipper 0
  759. SolRFlipper 0
  760.  
  761. ' start the attract mode
  762. StartAttractMode
  763. End Sub
  764.  
  765. ' Fuction to calculate the balls left
  766. Function Balls
  767. Dim tmp
  768. tmp = BallsPerGame - BallsRemaining(CurrentPlayer) + 1
  769. If tmp> BallsPerGame Then
  770. Balls = BallsPerGame
  771. Else
  772. Balls = tmp
  773. End If
  774. End Function
  775.  
  776. '******************
  777. ' Match
  778. '******************
  779.  
  780. Sub Verification_Match()
  781. PlaySound "fx_match"
  782. Match = INT(RND(1) * 10) * 10 ' random between 10 and 90
  783. Display_Match
  784. If(Score(CurrentPlayer)MOD 100) = Match Then
  785. PlaySound "fx_knocker"
  786. AddCredits 1
  787. End If
  788. End Sub
  789.  
  790. Sub Clear_Match()
  791. MatchReel.SetValue 10 'this is ¿?
  792. 'MatchReel2.SetValue 10
  793. If B2SOn then
  794. Controller.B2SSetMatch 10
  795. end if
  796. End Sub
  797.  
  798. Sub Display_Match()
  799. MatchReel.SetValue(Match \ 11) + 1
  800. 'MatchReel2.SetValue(Match \ 11) + 1
  801. If B2SOn then
  802. If Match = 0 then
  803. Controller.B2SSetMatch 100
  804. else
  805. Controller.B2SSetMatch Match
  806. end if
  807. end if
  808. End Sub
  809.  
  810. ' *********************************************************************
  811. ' Drain / Plunger Functions
  812. ' *********************************************************************
  813.  
  814. Sub Drain_Hit()
  815. Drain.DestroyBall
  816. BallsOnPlayfield = BallsOnPlayfield - 1
  817. PlaySoundAt "fx_drain", Drain
  818.  
  819. 'tilted?
  820. If Tilted Then
  821. StopEndOfBallMode
  822. End If
  823.  
  824. ' if still playing and not tilted
  825. If(bGameInPLay = True)AND(Tilted = False)Then
  826.  
  827. ' ballsaver?
  828. If(bBallSaverActive = True)Then
  829. CreateNewBall()
  830. Else
  831. ' last ball?
  832. If(BallsOnPlayfield = 0)Then
  833. StopEndOfBallMode
  834. vpmtimer.addtimer 500, "EndOfBall '"
  835. Exit Sub
  836. End If
  837. End If
  838. End If
  839. End Sub
  840.  
  841. Sub swPlungerRest_Hit()
  842. bBallInPlungerLane = True
  843. End Sub
  844.  
  845. Sub swPlungerRest_UnHit()
  846. bBallInPlungerLane = False
  847. End Sub
  848.  
  849. ' ****************************************
  850. ' Score functions
  851. ' ****************************************
  852.  
  853. Sub AddScore(Points)
  854. If Tilted Then Exit Sub
  855. Select Case Points
  856. Case 10, 100, 1000, 10000
  857. Score(CurrentPlayer) = Score(CurrentPlayer) + points
  858. UpdateScore points
  859. ' sounds
  860. If Points = 1000 AND(Score(CurrentPlayer)MOD 10000) \ 1000 = 0 Then 'new reel 10000
  861. PlaySound SoundFXDOF("bell10000", 115, DOFPulse, DOFChimes)
  862. ElseIf Points = 100 AND(Score(CurrentPlayer)MOD 1000) \ 100 = 0 Then 'new reel 1000
  863. PlaySound SoundFXDOF("bell1000", 116, DOFPulse, DOFChimes)
  864. ElseIf Points = 10 AND(Score(CurrentPlayer)MOD 100) \ 10 = 0 Then 'new reel 100
  865. PlaySound SoundFXDOF("bell100", 117, DOFPulse, DOFChimes)
  866. Else
  867. PlaySound SoundFXDOF("bell", 118, DOFPulse, DOFChimes) &Points
  868. End If
  869. Case 20, 30, 40, 50, 60, 70, 80, 90
  870. Add10 = Add10 + Points \ 10
  871. AddScore10Timer.Enabled = TRUE
  872. Case 200, 300, 400, 500, 600, 700, 800, 900
  873. Add100 = Add100 + Points \ 100
  874. AddScore100Timer.Enabled = TRUE
  875. Case 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000
  876. Add1000 = Add1000 + Points \ 1000
  877. AddScore1000Timer.Enabled = TRUE
  878. Case 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000
  879. Add10000 = Add10000 + Points \ 10000
  880. AddScore10000Timer.Enabled = TRUE
  881. End Select
  882.  
  883. ' check for higher score and specials
  884. If Score(CurrentPlayer) >= Special1 AND Special1Awarded(CurrentPlayer) = False Then
  885. AwardSpecial
  886. Special1Awarded(CurrentPlayer) = True
  887. End If
  888. If Score(CurrentPlayer) >= Special2 AND Special2Awarded(CurrentPlayer) = False Then
  889. AwardSpecial
  890. Special2Awarded(CurrentPlayer) = True
  891. End If
  892. ' If Score(CurrentPlayer) >= Special3 AND Special3Awarded(CurrentPlayer) = False Then
  893. ' AwardSpecial
  894. ' Special3Awarded(CurrentPlayer) = True
  895. ' End If
  896. End Sub
  897.  
  898. '************************************
  899. ' Score sound Timers
  900. '************************************
  901.  
  902. Sub AddScore10Timer_Timer()
  903. if Add10> 0 then
  904. AddScore 10
  905. Add10 = Add10 - 1
  906. Else
  907. Me.Enabled = FALSE
  908. End If
  909. End Sub
  910.  
  911. Sub AddScore100Timer_Timer()
  912. if Add100> 0 then
  913. AddScore 100
  914. Add100 = Add100 - 1
  915. Else
  916. Me.Enabled = FALSE
  917. End If
  918. End Sub
  919.  
  920. Sub AddScore1000Timer_Timer()
  921. if Add1000> 0 then
  922. AddScore 1000
  923. Add1000 = Add1000 - 1
  924. Else
  925. Me.Enabled = FALSE
  926. End If
  927. End Sub
  928.  
  929. Sub AddScore10000Timer_Timer()
  930. if Add10000> 0 then
  931. AddScore 10000
  932. Add10000 = Add10000 - 1
  933. Else
  934. Me.Enabled = FALSE
  935. End If
  936. End Sub
  937.  
  938. '*******************
  939. ' BONUS
  940. '*******************
  941.  
  942. Sub AddBonus(bonuspoints)
  943. If(Tilted = False)Then
  944. Bonus = Bonus + bonuspoints
  945. PlaySound "Bell2"
  946. If Bonus> 10 Then
  947. Bonus = 10
  948. End If
  949. UpdateBonusLights
  950. End if
  951. End Sub
  952.  
  953. Sub AddBonusMultiplier(multi)
  954. If(Tilted = False)Then
  955. BonusMultiplier = BonusMultiplier + multi
  956. If BonusMultiplier> MaxMultiplier Then
  957. BonusMultiplier = MaxMultiplier
  958. End If
  959. UpdateMultiplierLights
  960. End if
  961. End Sub
  962.  
  963. Sub UpdateMultiplierLights
  964. Select Case BonusMultiplier
  965. 'Case 1:li2.State = 1:li3.State = 0:li4.State = 0
  966. 'Case 2:li2.State = 0:li3.State = 1:li4.State = 0
  967. 'Case 3:li2.State = 0:li3.State = 0:li4.State = 1
  968. End Select
  969. End Sub
  970.  
  971. Sub StartBonusCount
  972. ' prevent the ball from draining
  973. Post2.IsDropped = 0
  974. Select Case BonusMultiplier
  975. Case 1:BonusCountTimer.Interval = 250
  976. Case 2:BonusCountTimer.Interval = 400
  977. Case 3:BonusCountTimer.Interval = 650
  978. End Select
  979. BonusCountTimer.Enabled = 1
  980. End Sub
  981.  
  982. Sub BonusCountTimer_Timer
  983. 'debug.print "BonusCount_Timer"
  984. If Bonus> 0 Then
  985. Bonus = Bonus -1
  986. AddScore 10000 * BonusMultiplier
  987. UpdateBonusLights
  988. Else
  989. BonusCountTimer.Enabled = 0
  990. 'Enable the drain again
  991. Post2.IsDropped = 1
  992. 'set bonus to 1
  993. Addbonus 1
  994. If BallinBonusKicker Then
  995. vpmtimer.addtimer 1000, "BonusKickOut '"
  996. End If
  997. 'vpmtimer.addtimer 1000, "EndOfBall2 '"
  998. End If
  999. End Sub
  1000.  
  1001. Sub UpdateBonusLights
  1002. Select Case Bonus
  1003. Case 0:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1004. Case 1:bl1.State = 1:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1005. Case 2:bl1.State = 0:bl2.State = 1:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1006. Case 3:bl1.State = 0:bl2.State = 0:bl3.State = 1:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1007. Case 4:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 1:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1008. Case 5:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 1:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1009. Case 6:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 1:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1010. Case 7:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 1:bl8.State = 0:bl9.State = 0:bl10.State = 0
  1011. Case 8:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 1:bl9.State = 0:bl10.State = 0
  1012. Case 9:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 1:bl10.State = 0
  1013. Case 10:bl1.State = 0:bl2.State = 0:bl3.State = 0:bl4.State = 0:bl5.State = 0:bl6.State = 0:bl7.State = 0:bl8.State = 0:bl9.State = 0:bl10.State = 1
  1014. End Select
  1015. End Sub
  1016.  
  1017. '**********************************
  1018. ' Score EM reels
  1019. '**********************************
  1020.  
  1021. Sub UpdateScore(playerpoints)
  1022. Select Case CurrentPlayer
  1023. Case 1:ScoreReel1.Addvalue playerpoints
  1024. 'Case 2:ScoreReel2.Addvalue playerpoints
  1025. 'Case 3:ScoreReel3.Addvalue playerpoints
  1026. 'Case 4:ScoreReel4.Addvalue playerpoints
  1027.  
  1028. End Select
  1029. If B2SOn then
  1030. Controller.B2SSetScorePlayer CurrentPlayer, Score(CurrentPlayer)
  1031. end if
  1032. End Sub
  1033.  
  1034. Sub ResetScores
  1035. ScoreReel1.ResetToZero
  1036. 'ScoreReel2.ResetToZero
  1037. 'ScoreReel3.ResetToZero
  1038. 'ScoreReel4.ResetToZero
  1039. If B2SOn then
  1040. Controller.B2SSetScorePlayer1 0
  1041. Controller.B2SSetScoreRolloverPlayer1 0
  1042. 'Controller.B2SSetScorePlayer2 0
  1043. 'Controller.B2SSetScoreRolloverPlayer2 0
  1044. 'Controller.B2SSetScorePlayer3 0
  1045. 'Controller.B2SSetScoreRolloverPlayer3 0
  1046. 'Controller.B2SSetScorePlayer4 0
  1047. 'Controller.B2SSetScoreRolloverPlayer4 0
  1048. end if
  1049. End Sub
  1050.  
  1051. Sub AddCredits(value) 'limit to 15 credits
  1052. If Credits <15 Then
  1053. Credits = Credits + value
  1054. UpdateCredits
  1055. end if
  1056. End Sub
  1057.  
  1058. Sub UpdateCredits
  1059. PlaySound "fx_relay"
  1060. CreditsReel.SetValue credits
  1061. 'CreditsReel2.SetValue credits
  1062. If B2SOn then
  1063. Controller.B2SSetCredits Credits
  1064. end if
  1065. End Sub
  1066.  
  1067. Sub UpdateBallInPlay
  1068. Select Case Balls
  1069. Case 0:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1070. Case 1:bip1.State = 1:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1071. Case 2:bip1.State = 0:bip2.State = 1:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1072. Case 3:bip1.State = 0:bip2.State = 0:bip3.State = 1:bip4.State = 0:bip5.State = 0
  1073. Case 4:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 1:bip5.State = 0
  1074. Case 5:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 1
  1075. End Select
  1076. If B2SOn then
  1077. Controller.B2SSetBallInPlay Balls
  1078. end if
  1079. End Sub
  1080.  
  1081. Sub UpdatePlayersPlaying
  1082. Select Case PlayersPlayingGame
  1083. 'Case 0:cp1.State = 0:cp2.State = 0:cp3.State = 0:cp4.State = 0
  1084. 'Case 1:cp1.State = 1:cp2.State = 0:cp3.State = 0:cp4.State = 0
  1085. 'Case 2:cp1.State = 1:cp2.State = 1:cp3.State = 0:cp4.State = 0
  1086. 'Case 3:cp1.State = 1:cp2.State = 1:cp3.State = 1:cp4.State = 0
  1087. 'Case 4:cp1.State = 1:cp2.State = 1:cp3.State = 1:cp4.State = 1
  1088. End Select
  1089. If B2SOn then
  1090. 'Controller.B2SSetPlayersPlaying PlayersPlayingGame
  1091. end if
  1092. End Sub
  1093.  
  1094. Sub UpdateCurrentPlayer
  1095. Select Case CurrentPlayer
  1096. 'Case 0:pl1.State = 0:pl2.State = 0:pl3.State = 0:pl4.State = 0
  1097. 'Case 1:pl1.State = 1:pl2.State = 0:pl3.State = 0:pl4.State = 0
  1098. 'Case 2:pl1.State = 0:pl2.State = 1:pl3.State = 0:pl4.State = 0
  1099. 'Case 3:pl1.State = 0:pl2.State = 0:pl3.State = 1:pl4.State = 0
  1100. 'Case 4:pl1.State = 0:pl2.State = 0:pl3.State = 0:pl4.State = 1
  1101. End Select
  1102. If B2SOn then
  1103. 'Controller.B2SSetCurrentPlayer CurrentPlayer
  1104. end if
  1105. End Sub
  1106.  
  1107. '*************************
  1108. ' Specials
  1109. '*************************
  1110.  
  1111. Sub AwardExtraBall()
  1112. If NOT bExtraBallWonThisBall Then
  1113. PlaySound "fx_knocker"
  1114. ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) + 1
  1115. bExtraBallWonThisBall = True
  1116. XtraBall.SetValue 1
  1117. Else
  1118. Addscore 5000
  1119. END If
  1120. End Sub
  1121.  
  1122. Sub AwardSpecial()
  1123. PlaySound "fx_knocker"
  1124. AddCredits 1
  1125. End Sub
  1126.  
  1127. Sub AwardAddaBall()
  1128. If BallsRemaining(CurrentPlayer) <11 Then
  1129. PlaySound "fx_knocker"
  1130. BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer) + 1
  1131. UpdateBallInPlay
  1132. End If
  1133. End Sub
  1134.  
  1135. ' ********************************
  1136. ' Attract Mode
  1137. ' ********************************
  1138. ' use the"Blink Pattern" of each light
  1139.  
  1140. Sub StartAttractMode()
  1141. Dim x
  1142. bAttractMode = True
  1143. For each x in aLights
  1144. x.State = 2
  1145. Next
  1146. GameOverR.SetValue 1
  1147. 'update current player and balls
  1148. End Sub
  1149.  
  1150. Sub StopAttractMode()
  1151. Dim x
  1152. bAttractMode = False
  1153. TurnOffPlayfieldLights
  1154. ResetScores
  1155. GameOverR.SetValue 0
  1156. End Sub
  1157.  
  1158. '*************************************
  1159. ' Highscore Routines
  1160. ' Based og Black's and GNMOD's code
  1161. '*************************************
  1162.  
  1163. Dim EnteringInitials
  1164. EnteringInitials = False
  1165.  
  1166. Dim SelectedChar ' character under the "cursor" when entering initials
  1167. Dim HSTimerCount: HSTimerCount = 0
  1168. Dim InitialString ' the string holding the player's initials as they're entered
  1169. Dim AlphaString: AlphaString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_<"
  1170. Dim AlphaStringPos ' pointer to AlphaString, move Forward and backward with flipper keys
  1171. Dim HSNewHigh ' The new score to be recorded
  1172. Dim HSScore(5) ' High Scores read in from config file
  1173. Dim HSName(5) ' High Score Initials read in from config file
  1174.  
  1175. ' default high scores
  1176. HSScore(1) = 250000
  1177. HSScore(2) = 240000
  1178. HSScore(3) = 230000
  1179. HSScore(4) = 220000
  1180. HSScore(5) = 210000
  1181.  
  1182. HSName(1) = "AAA"
  1183. HSName(2) = "ZZZ"
  1184. HSName(3) = "XXX"
  1185. HSName(4) = "ABC"
  1186. HSName(5) = "BBB"
  1187.  
  1188. ' Load Highscores
  1189.  
  1190. Sub Loadhs
  1191. Dim FileObj
  1192. Dim ScoreFile, TextStr
  1193. Dim check0, x
  1194.  
  1195. Set FileObj = CreateObject("Scripting.FileSystemObject")
  1196. If Not FileObj.FolderExists(UserDirectory)then
  1197. Credits = 0
  1198. Exit Sub
  1199. End If
  1200. If Not FileObj.FileExists(UserDirectory & cGameName& ".txt")then
  1201. Credits = 0
  1202. Exit Sub
  1203. End If
  1204. Set ScoreFile = FileObj.GetFile(UserDirectory & cGameName& ".txt")
  1205. Set TextStr = ScoreFile.OpenAsTextStream(1, 0)
  1206. If(TextStr.AtEndOfStream = True)then
  1207. Exit Sub
  1208. End If
  1209. check0 = Int(textStr.readLine)
  1210. If check0 = 0 then
  1211. Credits = Int(textstr.readline)
  1212. For x = 1 to 5
  1213. HSScore(x) = Int(textstr.readline)
  1214. Next
  1215. For x = 1 to 5
  1216. HSName(x) = textstr.readline
  1217. Next
  1218. End If
  1219. TextStr.Close
  1220. Set ScoreFile = Nothing
  1221. Set FileObj = Nothing
  1222. SortHighscore 'added to fix a previous error
  1223. End Sub
  1224.  
  1225. ' Save Highscores
  1226.  
  1227. Sub Savehs
  1228. Dim FileObj
  1229. Dim ScoreFile
  1230. Dim x
  1231. Set FileObj = CreateObject("Scripting.FileSystemObject")
  1232. If Not FileObj.FolderExists(UserDirectory)then
  1233. Exit Sub
  1234. End If
  1235. Set ScoreFile = FileObj.CreateTextFile(UserDirectory & cGameName& ".txt", True)
  1236. ScoreFile.WriteLine 0
  1237. ScoreFile.WriteLine Credits
  1238. For x = 1 to 5
  1239. scorefile.writeline HSScore(x)
  1240. Next
  1241. For x = 1 to 5
  1242. scorefile.writeline HSName(x)
  1243. Next
  1244. ScoreFile.Close
  1245. Set ScoreFile = Nothing
  1246. Set FileObj = Nothing
  1247. End Sub
  1248.  
  1249. ' Sort Highscores
  1250.  
  1251. Sub SortHighscore
  1252. Dim tmp, tmp2, i, j
  1253. For i = 1 to 5
  1254. For j = 1 to 4
  1255. If HSScore(j) <HSScore(j + 1)Then
  1256. tmp = HSScore(j + 1)
  1257. tmp2 = HSName(j + 1)
  1258. HSScore(j + 1) = HSScore(j)
  1259. HSName(j + 1) = HSName(j)
  1260. HSScore(j) = tmp
  1261. HSName(j) = tmp2
  1262. End If
  1263. Next
  1264. Next
  1265. End Sub
  1266.  
  1267. ' check for new highscore
  1268.  
  1269. Sub CheckHighscore
  1270. HighScoreTimer.Enabled = 1
  1271. 'If Score(CurrentPlayer)> HSSCore(1)Then
  1272. ' AwardSpecial
  1273. 'End I
  1274. If Score(CurrentPlayer)> HSSCore(5)Then
  1275. NewHighScore Score(CurrentPlayer), CurrentPlayer
  1276. End If
  1277. End Sub
  1278.  
  1279. ' Highscore Timer
  1280.  
  1281. Sub HighScoreTimer_Timer
  1282. If EnteringInitials then
  1283. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1284. ElseIf bGameInPlay then
  1285. SetHSLine 1, "HIGH SCORE"
  1286. SetHSLine 2, HSScore(1)
  1287. SetHSLine 3, HSName(1)
  1288. Me.Enabled = 0
  1289. Else
  1290. ' cycle through high scores
  1291. SetHSLine 1, "HIGH SCORE" & (HSTimerCount + 1)
  1292. SetHSLine 2, HSScore(HSTimerCount + 1)
  1293. SetHSLine 3, HSName(HSTimerCount + 1)
  1294. HSTimerCount = (HSTimerCount + 1)MOD 5
  1295. End If
  1296. End Sub
  1297.  
  1298. ' Enter Highscore initials
  1299.  
  1300. Function GetHSChar(String, Index)
  1301. Dim ThisChar
  1302. Dim FileName
  1303. ThisChar = Mid(String, Index, 1)
  1304. FileName = "PostIt"
  1305. If ThisChar = " " or ThisChar = "" then
  1306. FileName = FileName & "BL"
  1307. ElseIf ThisChar = "<" then
  1308. FileName = FileName & "LT"
  1309. ElseIf ThisChar = "_" then
  1310. FileName = FileName & "SP"
  1311. Else
  1312. FileName = FileName & ThisChar
  1313. End If
  1314. GetHSChar = FileName
  1315. End Function
  1316.  
  1317. Sub SetHsLine(LineNo, String)
  1318. Dim StrLen
  1319. Dim Index
  1320. Dim StartHSArray
  1321. Dim EndHSArray
  1322. Dim xFor
  1323. StartHSArray = array(0, 1, 12, 22)
  1324. EndHSArray = array(0, 11, 21, 31)
  1325. StrLen = len(string)
  1326. Index = 1
  1327. For xFor = StartHSArray(LineNo)to EndHSArray(LineNo)
  1328. Eval("HS" &xFor).imageA = GetHSChar(String, Index)
  1329. Index = Index + 1
  1330. Next
  1331. End Sub
  1332.  
  1333. Sub NewHighScore(NewScore, PlayNum)
  1334. If NewScore> HSScore(5)then
  1335. HighScoreTimer.interval = 500
  1336. AlphaStringPos = 1 ' start with first character "A"
  1337. EnteringInitials = true ' intercept the control keys while entering initials
  1338. InitialString = "" ' initials entered so far, initialize to empty
  1339. SetHSLine 1, "PLAYER " + FormatNumber(PlayNum, 0)
  1340. SetHSLine 2, "ENTER NAME"
  1341. SetHSLine 3, MID(AlphaString, AlphaStringPos, 1)
  1342. HSNewHigh = NewScore
  1343. End If
  1344. End Sub
  1345.  
  1346. Sub CollectInitials(keycode)
  1347. Dim i
  1348. If keycode = LeftFlipperKey Then
  1349. ' back up to previous character
  1350. AlphaStringPos = AlphaStringPos - 1
  1351. If AlphaStringPos <1 then
  1352. AlphaStringPos = len(AlphaString) ' handle wrap from beginning to End
  1353. If InitialString = "" then
  1354. ' Skip the backspace If there are no characters to backspace over
  1355. AlphaStringPos = AlphaStringPos - 1
  1356. End If
  1357. End If
  1358. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1359. PlaySound "fx_Previous"
  1360. ElseIf keycode = RightFlipperKey Then
  1361. ' advance to Next character
  1362. AlphaStringPos = AlphaStringPos + 1
  1363. If AlphaStringPos> len(AlphaString)or(AlphaStringPos = len(AlphaString)and InitialString = "")then
  1364. ' Skip the backspace If there are no characters to backspace over
  1365. AlphaStringPos = 1
  1366. End If
  1367. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1368. PlaySound "fx_Next"
  1369. ElseIf keycode = StartGameKey or keycode = PlungerKey Then
  1370. SelectedChar = MID(AlphaString, AlphaStringPos, 1)
  1371. If SelectedChar = "_" then
  1372. InitialString = InitialString & " "
  1373. PlaySound("fx_Esc")
  1374. ElseIf SelectedChar = "<" then
  1375. InitialString = MID(InitialString, 1, len(InitialString)- 1)
  1376. If len(InitialString) = 0 then
  1377. ' If there are no more characters to back over, don't leave the < displayed
  1378. AlphaStringPos = 1
  1379. End If
  1380. PlaySound("fx_Esc")
  1381. Else
  1382. InitialString = InitialString & SelectedChar
  1383. PlaySound("fx_Enter")
  1384. End If
  1385. If len(InitialString) <3 then
  1386. SetHSLine 3, InitialString & SelectedChar
  1387. End If
  1388. End If
  1389. If len(InitialString) = 3 then
  1390. EnteringInitials = False
  1391. HSScore(5) = HSNewHigh
  1392. HSName(5) = InitialString
  1393. SortHighScore
  1394. HighScoreTimer.interval = 2000
  1395. End If
  1396. End Sub
  1397.  
  1398. '*******************
  1399. ' Realtime updates
  1400. '*******************
  1401.  
  1402. Sub RealTime_Timer
  1403. RollingUpdate
  1404. LeftFlipperTop.RotZ = LeftFlipper.CurrentAngle
  1405. RightFlipperTop.RotZ = RightFlipper.CurrentAngle
  1406. End Sub
  1407.  
  1408. '*********
  1409. ' LUT
  1410. '*********
  1411.  
  1412. Dim bLutActive, LUTImage
  1413. Sub LoadLUT
  1414. bLutActive = False
  1415. x = LoadValue(cGameName, "LUTImage")
  1416. If(x <> "")Then LUTImage = x Else LUTImage = 0
  1417. UpdateLUT
  1418. End Sub
  1419.  
  1420. Sub SaveLUT
  1421. SaveValue cGameName, "LUTImage", LUTImage
  1422. End Sub
  1423.  
  1424. Sub NextLUT:LUTImage = (LUTImage + 1)MOD 10:UpdateLUT:SaveLUT:End Sub
  1425.  
  1426. Sub UpdateLUT
  1427. Select Case LutImage
  1428. Case 0:table1.ColorGradeImage = "LUT0"
  1429. Case 1:table1.ColorGradeImage = "LUT1"
  1430. Case 2:table1.ColorGradeImage = "LUT2"
  1431. Case 3:table1.ColorGradeImage = "LUT3"
  1432. Case 4:table1.ColorGradeImage = "LUT4"
  1433. Case 5:table1.ColorGradeImage = "LUT5"
  1434. Case 6:table1.ColorGradeImage = "LUT6"
  1435. Case 7:table1.ColorGradeImage = "LUT7"
  1436. Case 8:table1.ColorGradeImage = "LUT8"
  1437. Case 9:table1.ColorGradeImage = "LUT9"
  1438. End Select
  1439. End Sub
  1440.  
  1441. '***********************************************************************
  1442. ' *********************************************************************
  1443. ' ********* G A M E C O D E S T A R T S H E R E *********
  1444. ' *********************************************************************
  1445. '***********************************************************************
  1446.  
  1447. Sub VPObjects_Init 'init objects
  1448. TurnOffPlayfieldLights()
  1449. DropPost
  1450. Post2.IsDropped = 1
  1451. End Sub
  1452.  
  1453. ' Dim all the variables
  1454.  
  1455. Sub Game_Init() 'called at the start of a new game
  1456. 'Start music?
  1457. 'Init variables?
  1458. 'Start or init timers
  1459. 'Init lights?
  1460. TurnOffPlayfieldLights()
  1461. Bonus = 0
  1462. AddBonus 1
  1463. DropPost
  1464. End Sub
  1465.  
  1466. Sub StopEndOfBallMode() 'called when the last ball is drained
  1467. End Sub
  1468.  
  1469. Sub ResetNewBallVariables() 'init variables new ball/player
  1470. BonusMultiplier = 1
  1471. DropPost
  1472. End Sub
  1473.  
  1474. Sub ResetNewBallLights() 'init lights for new ball/player
  1475. TurnOffPlayfieldLights()
  1476. XtraBall.SetValue 0
  1477. li012.State = 1
  1478. li032.State = 1
  1479. li033.State = 1
  1480. li009.State = 1
  1481. li003.State = 1
  1482. li011.State = 1
  1483. li001.State = 1
  1484. End Sub
  1485.  
  1486. Sub TurnOffPlayfieldLights()
  1487. Dim a
  1488. For each a in aLights
  1489. a.State = 0
  1490. Next
  1491. End Sub
  1492.  
  1493. ' *********************************************************************
  1494. ' Table Object Hit Events
  1495. ' *********************************************************************
  1496. ' Any target hit Sub will do this:
  1497. ' - play a sound
  1498. ' - do some physical movement
  1499. ' - add a score, bonus
  1500. ' - check some variables/modes this trigger is a member of
  1501. ' - set the "LastSwicthHit" variable in case it is needed later
  1502. ' *********************************************************************
  1503.  
  1504. ' Slingshots
  1505. Dim LStep, RStep
  1506.  
  1507. Sub LeftSlingShot_Slingshot
  1508. If Tilted Then Exit Sub
  1509. PlaySoundAt SoundFXDOF("fx_slingshot", 103, DOFPulse, DOFContactors), Lemk
  1510. LeftSling004.Visible = 1
  1511. Lemk.RotX = 26
  1512. LStep = 0
  1513. LeftSlingShot.TimerEnabled = True
  1514. ' add points
  1515. AddScore 100
  1516. ' some effect?
  1517. End Sub
  1518.  
  1519. Sub LeftSlingShot_Timer
  1520. Select Case LStep
  1521. Case 1:LeftSLing004.Visible = 0:LeftSLing003.Visible = 1:Lemk.RotX = 14
  1522. Case 2:LeftSLing003.Visible = 0:LeftSLing002.Visible = 1:Lemk.RotX = 2
  1523. Case 3:LeftSLing002.Visible = 0:Lemk.RotX = -20:LeftSlingShot.TimerEnabled = 0
  1524. End Select
  1525. LStep = LStep + 1
  1526. End Sub
  1527.  
  1528. Sub RightSlingShot_Slingshot
  1529. If Tilted Then Exit Sub
  1530. PlaySoundAt SoundFXDOF("fx_slingshot", 105, DOFPulse, DOFContactors), Remk
  1531. RightSling004.Visible = 1
  1532. Remk.RotX = 26
  1533. RStep = 0
  1534. RightSlingShot.TimerEnabled = True
  1535. ' add points
  1536. AddScore 100
  1537. ' add effect?
  1538. End Sub
  1539.  
  1540. Sub RightSlingShot_Timer
  1541. Select Case RStep
  1542. Case 1:RightSLing004.Visible = 0:RightSLing003.Visible = 1:Remk.RotX = 14
  1543. Case 2:RightSLing003.Visible = 0:RightSLing002.Visible = 1:Remk.RotX = 2
  1544. Case 3:RightSLing002.Visible = 0:Remk.RotX = -20:RightSlingShot.TimerEnabled = 0
  1545. End Select
  1546. RStep = RStep + 1
  1547. End Sub
  1548.  
  1549. '**************
  1550. ' Rubbers
  1551. '**************
  1552.  
  1553. Sub rsband001_Hit
  1554. If Tilted then Exit Sub
  1555. AddScore 10
  1556. End Sub
  1557.  
  1558. Sub rsband002_Hit
  1559. If Tilted then Exit Sub
  1560. AddScore 10
  1561. End Sub
  1562.  
  1563. '*********
  1564. ' Bumpers
  1565. '*********
  1566.  
  1567. Sub Bumper001_Hit
  1568. If Tilted Then Exit Sub
  1569. PlaySoundAt SoundFXDOF("fx_Bumper", 107, DOFPulse, DOFContactors), bumper001
  1570. AddScore 1000 + 9000 * LBumper1a.State
  1571. End Sub
  1572.  
  1573. Sub Bumper002_Hit
  1574. If Tilted Then Exit Sub
  1575. PlaySoundAt SoundFXDOF("fx_Bumper", 109, DOFPulse, DOFContactors), bumper002
  1576. AddScore 1000 + 9000 * LBumper2a.State
  1577. End Sub
  1578.  
  1579. Sub BumpersOn
  1580. LBumper1a.State = 1
  1581. LBumper1b.State = 1
  1582. LBumper2a.State = 1
  1583. LBumper2b.State = 1
  1584. End Sub
  1585.  
  1586. Sub BumpersOff
  1587. LBumper1a.State = 0
  1588. LBumper1b.State = 0
  1589. LBumper2a.State = 0
  1590. LBumper2b.State = 0
  1591. End Sub
  1592.  
  1593. '*****************
  1594. ' Lanes
  1595. '*****************
  1596.  
  1597. ' inlanes & outlanes
  1598.  
  1599. Sub Trigger001_Hit
  1600. PlaySoundAt "fx_sensor", Trigger001
  1601. If Tilted Then Exit Sub
  1602. AddScore 5000
  1603. If li002.State Then AwardExtraBall
  1604. End Sub
  1605.  
  1606. Sub Trigger002_Hit
  1607. PlaySoundAt "fx_sensor", Trigger002
  1608. If Tilted Then Exit Sub
  1609. AddScore 1000
  1610. AddBonus 1
  1611. BumpersOn
  1612. End Sub
  1613.  
  1614. Sub Trigger003_Hit
  1615. PlaySoundAt "fx_sensor", Trigger003
  1616. If Tilted Then Exit Sub
  1617. AddScore 5000
  1618. If li004.State Then AwardExtraBall
  1619. End Sub
  1620.  
  1621. Sub Trigger004_Hit
  1622. PlaySoundAt "fx_sensor", Trigger004
  1623. If Tilted Then Exit Sub
  1624. Post2.IsDropped = 0
  1625. StartBonusCount
  1626. End Sub
  1627.  
  1628. ' top lanes
  1629.  
  1630. Sub Trigger005_Hit
  1631. PlaySoundAt "fx_sensor", Trigger005
  1632. If Tilted Then Exit Sub
  1633. AddScore 5000
  1634. BumpersOn
  1635. End Sub
  1636.  
  1637. Sub Trigger006_Hit
  1638. PlaySoundAt "fx_sensor", Trigger006
  1639. If Tilted Then Exit Sub
  1640. AddScore 500 + 4500 * li012.State
  1641. If li012.State Then
  1642. li010.State = 1
  1643. li009.State = 0
  1644. li012.State = 0
  1645. BonusMultiplier = 3
  1646. End If
  1647. End Sub
  1648.  
  1649. Sub Trigger007_Hit
  1650. PlaySoundAt "fx_sensor", Trigger007
  1651. If Tilted Then Exit Sub
  1652. AddScore 5000
  1653. End Sub
  1654.  
  1655. Sub Trigger008_Hit
  1656. PlaySoundAt "fx_sensor", Trigger008
  1657. If Tilted Then Exit Sub
  1658. AddScore 3000
  1659. AddBonus 3
  1660. End Sub
  1661.  
  1662. '************************
  1663. ' Targets
  1664. '************************
  1665.  
  1666. Sub Target001_hit
  1667. PlaySoundAtBall "fx_target"
  1668. If Tilted Then Exit Sub
  1669. AddScore 10
  1670. BumpersOff
  1671. End Sub
  1672.  
  1673. Sub Target002_hit
  1674. PlaySoundAtBall "fx_target"
  1675. If Tilted Then Exit Sub
  1676. AddScore 10
  1677. BumpersOff
  1678. End Sub
  1679.  
  1680. Sub Target003_hit
  1681. PlaySoundAtBall "fx_target"
  1682. If Tilted Then Exit Sub
  1683. AddScore 5000 + 45000 * li008.State
  1684. End Sub
  1685.  
  1686. Sub Target004_hit
  1687. PlaySoundAtBall "fx_target"
  1688. If Tilted Then Exit Sub
  1689. AddScore 500
  1690. If li005.State Then AwardSpecial
  1691. End Sub
  1692.  
  1693. Sub Target005_hit
  1694. PlaySoundAtBall "fx_target"
  1695. If Tilted Then Exit Sub
  1696. AddScore 5000 + 45000 * li007.State
  1697. End Sub
  1698.  
  1699. Sub Target006_hit
  1700. PlaySoundAtBall "fx_target"
  1701. If Tilted Then Exit Sub
  1702. AddScore 500
  1703. If li006.State Then AwardSpecial
  1704. End Sub
  1705.  
  1706. '*****************
  1707. ' kickers
  1708. '*****************
  1709.  
  1710. ' left yellow bumper
  1711. Sub LeftHole_Hit
  1712. PlaySoundAt "fx_kicker_enter", LeftHole
  1713. If NOT Tilted Then
  1714. Addscore 500
  1715. li003.State = 0
  1716. li013.State = 1
  1717. li015.State = 1
  1718. li021.State = 1
  1719. CheckBells
  1720. End If
  1721. vpmtimer.addtimer 1000, "ExitLeftHole '"
  1722. End Sub
  1723.  
  1724. Sub ExitLeftHole
  1725. PlaySoundAt SoundFXDOF("fx_kicker", 111, DOFPulse, DOFContactors), LeftHole
  1726. LeftHole.kick 164, 18
  1727. End Sub
  1728.  
  1729. ' center red bumper
  1730. Sub CenterHole_Hit
  1731. PlaySoundAt "fx_kicker_enter", CenterHole
  1732. If NOT Tilted Then
  1733. Addscore 500
  1734. li011.State = 0
  1735. li014.State = 1
  1736. li017.State = 1
  1737. li020.State = 1
  1738. CheckBells
  1739. End If
  1740. vpmtimer.addtimer 1000, "ExitCenterHole '"
  1741. End Sub
  1742.  
  1743. Sub ExitCenterHole
  1744. PlaySoundAt SoundFXDOF("fx_kicker", 112, DOFPulse, DOFContactors), LeftHole
  1745. CenterHole.kick 170, 18
  1746. End Sub
  1747.  
  1748. ' right green bumper
  1749. Sub RightHole_Hit
  1750. PlaySoundAt "fx_kicker_enter", RightHole
  1751. If NOT Tilted Then
  1752. Addscore 500
  1753. li001.State = 0
  1754. li016.State = 1
  1755. li018.State = 1
  1756. li019.State = 1
  1757. CheckBells
  1758. End If
  1759. vpmtimer.addtimer 1000, "ExitRightHole '"
  1760. End Sub
  1761.  
  1762. Sub ExitRightHole
  1763. PlaySoundAt SoundFXDOF("fx_kicker", 113, DOFPulse, DOFContactors), RightHole
  1764. RightHole.kick 195, 18
  1765. End Sub
  1766.  
  1767. Sub CheckBells
  1768. If li013.State AND li014.State Then RisePost
  1769. If li015.State Then li009.State = 0:li010.State = 1 ' lite tripple bonus
  1770. If li015.State AND li016.State Then li002.State = 1:li004.State = 1 ' lite extra ball
  1771. If li017.State AND li018.State Then li007.State = 1:li008.State = 1 ' lite 50,000 points
  1772. If li021.State AND li020.State AND li019.State Then li005.State = 1:li006.State = 1 ' lite Special
  1773. End Sub
  1774.  
  1775. ' Bonus kicker hole
  1776.  
  1777. Dim BallinBonusKicker
  1778. BallinBonusKicker = False
  1779.  
  1780. Sub BonusKicker_Hit
  1781. PlaySoundAt "fx_kicker_enter", BonusKicker
  1782. DOF 119, DOFPulse
  1783. If NOT Tilted Then
  1784. BallinBonusKicker = True
  1785. StartBonusCount
  1786. Else
  1787. BonusKickOut
  1788. End If
  1789. End Sub
  1790.  
  1791. Sub BonusKickOut
  1792. PlaySoundAt SoundFXDOF("fx_kicker", 114, DOFPulse, DOFContactors), BonusKicker
  1793. BallinBonusKicker = False
  1794. BonusKicker.kick 190, 14
  1795. End Sub
  1796.  
  1797. '***************
  1798. ' POST
  1799. '***************
  1800.  
  1801. Sub RisePost
  1802. PlaySoundAt "fx_SolenoidOn", Primitive011
  1803. Post.IsDropped = 0
  1804. End Sub
  1805.  
  1806. Sub DropPost
  1807. PlaySoundAt "fx_SolenoidOff", Primitive011
  1808. Post.IsDropped = 1
  1809. End Sub
  1810.  
  1811. '**************
  1812. ' Buttons
  1813. '**************
  1814.  
  1815. Sub Button001_Hit
  1816. PlaySoundAt "fx_sensor", Button001
  1817. Addscore 10
  1818. AddBonus 1
  1819. End Sub
  1820.  
  1821. Sub Button002_Hit
  1822. PlaySoundAt "fx_sensor", Button002
  1823. Addscore 10
  1824. AddBonus 1
  1825. End Sub
Advertisement
Add Comment
Please, Sign In to add comment