Outhere

Luck Smile (jpsalas_Inder 1976) 4p_1.0

Dec 5th, 2021 (edited)
109
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 / 4 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 = "lucksmile4" ' B2S name
  50. Const MaxPlayers = 4 ' 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. CreditsReel.SetValue Credits
  1055. UpdateCredits
  1056. end if
  1057. End Sub
  1058.  
  1059. Sub UpdateCredits
  1060. PlaySound "fx_relay"
  1061. CreditsReel.SetValue credits
  1062. CreditsReel2.SetValue credits
  1063. If B2SOn then
  1064. Controller.B2SSetCredits Credits
  1065. end if
  1066. End Sub
  1067.  
  1068. Sub UpdateBallInPlay
  1069. Select Case Balls
  1070. Case 0:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1071. Case 1:bip1.State = 1:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1072. Case 2:bip1.State = 0:bip2.State = 1:bip3.State = 0:bip4.State = 0:bip5.State = 0
  1073. Case 3:bip1.State = 0:bip2.State = 0:bip3.State = 1:bip4.State = 0:bip5.State = 0
  1074. Case 4:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 1:bip5.State = 0
  1075. Case 5:bip1.State = 0:bip2.State = 0:bip3.State = 0:bip4.State = 0:bip5.State = 1
  1076. End Select
  1077. If B2SOn then
  1078. Controller.B2SSetBallInPlay Balls
  1079. end if
  1080. End Sub
  1081.  
  1082. Sub UpdatePlayersPlaying
  1083. Select Case PlayersPlayingGame
  1084. Case 0:cp1.State = 0:cp2.State = 0:cp3.State = 0:cp4.State = 0
  1085. Case 1:cp1.State = 1:cp2.State = 0:cp3.State = 0:cp4.State = 0
  1086. Case 2:cp1.State = 1:cp2.State = 1:cp3.State = 0:cp4.State = 0
  1087. Case 3:cp1.State = 1:cp2.State = 1:cp3.State = 1:cp4.State = 0
  1088. Case 4:cp1.State = 1:cp2.State = 1:cp3.State = 1:cp4.State = 1
  1089. End Select
  1090. If B2SOn then
  1091. Controller.B2SSetCanPLay PlayersPlayingGame
  1092. end if
  1093. End Sub
  1094.  
  1095. Sub UpdateCurrentPlayer
  1096. Select Case CurrentPlayer
  1097. Case 0:pl1.State = 0:pl2.State = 0:pl3.State = 0:pl4.State = 0
  1098. Case 1:pl1.State = 1:pl2.State = 0:pl3.State = 0:pl4.State = 0
  1099. Case 2:pl1.State = 0:pl2.State = 1:pl3.State = 0:pl4.State = 0
  1100. Case 3:pl1.State = 0:pl2.State = 0:pl3.State = 1:pl4.State = 0
  1101. Case 4:pl1.State = 0:pl2.State = 0:pl3.State = 0:pl4.State = 1
  1102. End Select
  1103. If B2SOn then
  1104. Controller.B2SSetPLayerUp CurrentPlayer
  1105. end if
  1106. End Sub
  1107.  
  1108. '*************************
  1109. ' Specials
  1110. '*************************
  1111.  
  1112. Sub AwardExtraBall()
  1113. If NOT bExtraBallWonThisBall Then
  1114. PlaySound "fx_knocker"
  1115. ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) + 1
  1116. bExtraBallWonThisBall = True
  1117. XtraBall.SetValue 1
  1118. Else
  1119. Addscore 5000
  1120. END If
  1121. End Sub
  1122.  
  1123. Sub AwardSpecial()
  1124. PlaySound "fx_knocker"
  1125. AddCredits 1
  1126. End Sub
  1127.  
  1128. Sub AwardAddaBall()
  1129. If BallsRemaining(CurrentPlayer) <11 Then
  1130. PlaySound "fx_knocker"
  1131. BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer) + 1
  1132. UpdateBallInPlay
  1133. End If
  1134. End Sub
  1135.  
  1136. ' ********************************
  1137. ' Attract Mode
  1138. ' ********************************
  1139. ' use the"Blink Pattern" of each light
  1140.  
  1141. Sub StartAttractMode()
  1142. Dim x
  1143. bAttractMode = True
  1144. For each x in aLights
  1145. x.State = 2
  1146. Next
  1147. GameOverR.SetValue 1
  1148. 'update current player and balls
  1149. End Sub
  1150.  
  1151. Sub StopAttractMode()
  1152. Dim x
  1153. bAttractMode = False
  1154. TurnOffPlayfieldLights
  1155. ResetScores
  1156. GameOverR.SetValue 0
  1157. End Sub
  1158.  
  1159. '*************************************
  1160. ' Highscore Routines
  1161. ' Based og Black's and GNMOD's code
  1162. '*************************************
  1163.  
  1164. Dim EnteringInitials
  1165. EnteringInitials = False
  1166.  
  1167. Dim SelectedChar ' character under the "cursor" when entering initials
  1168. Dim HSTimerCount: HSTimerCount = 0
  1169. Dim InitialString ' the string holding the player's initials as they're entered
  1170. Dim AlphaString: AlphaString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_<"
  1171. Dim AlphaStringPos ' pointer to AlphaString, move Forward and backward with flipper keys
  1172. Dim HSNewHigh ' The new score to be recorded
  1173. Dim HSScore(5) ' High Scores read in from config file
  1174. Dim HSName(5) ' High Score Initials read in from config file
  1175.  
  1176. ' default high scores
  1177. HSScore(1) = 250000
  1178. HSScore(2) = 240000
  1179. HSScore(3) = 230000
  1180. HSScore(4) = 220000
  1181. HSScore(5) = 210000
  1182.  
  1183. HSName(1) = "AAA"
  1184. HSName(2) = "ZZZ"
  1185. HSName(3) = "XXX"
  1186. HSName(4) = "ABC"
  1187. HSName(5) = "BBB"
  1188.  
  1189. ' Load Highscores
  1190.  
  1191. Sub Loadhs
  1192. Dim FileObj
  1193. Dim ScoreFile, TextStr
  1194. Dim check0, x
  1195.  
  1196. Set FileObj = CreateObject("Scripting.FileSystemObject")
  1197. If Not FileObj.FolderExists(UserDirectory)then
  1198. Credits = 0
  1199. Exit Sub
  1200. End If
  1201. If Not FileObj.FileExists(UserDirectory & cGameName& ".txt")then
  1202. Credits = 0
  1203. Exit Sub
  1204. End If
  1205. Set ScoreFile = FileObj.GetFile(UserDirectory & cGameName& ".txt")
  1206. Set TextStr = ScoreFile.OpenAsTextStream(1, 0)
  1207. If(TextStr.AtEndOfStream = True)then
  1208. Exit Sub
  1209. End If
  1210. check0 = Int(textStr.readLine)
  1211. If check0 = 0 then
  1212. Credits = Int(textstr.readline)
  1213. For x = 1 to 5
  1214. HSScore(x) = Int(textstr.readline)
  1215. Next
  1216. For x = 1 to 5
  1217. HSName(x) = textstr.readline
  1218. Next
  1219. End If
  1220. TextStr.Close
  1221. Set ScoreFile = Nothing
  1222. Set FileObj = Nothing
  1223. SortHighscore 'added to fix a previous error
  1224. End Sub
  1225.  
  1226. ' Save Highscores
  1227.  
  1228. Sub Savehs
  1229. Dim FileObj
  1230. Dim ScoreFile
  1231. Dim x
  1232. Set FileObj = CreateObject("Scripting.FileSystemObject")
  1233. If Not FileObj.FolderExists(UserDirectory)then
  1234. Exit Sub
  1235. End If
  1236. Set ScoreFile = FileObj.CreateTextFile(UserDirectory & cGameName& ".txt", True)
  1237. ScoreFile.WriteLine 0
  1238. ScoreFile.WriteLine Credits
  1239. For x = 1 to 5
  1240. scorefile.writeline HSScore(x)
  1241. Next
  1242. For x = 1 to 5
  1243. scorefile.writeline HSName(x)
  1244. Next
  1245. ScoreFile.Close
  1246. Set ScoreFile = Nothing
  1247. Set FileObj = Nothing
  1248. End Sub
  1249.  
  1250. ' Sort Highscores
  1251.  
  1252. Sub SortHighscore
  1253. Dim tmp, tmp2, i, j
  1254. For i = 1 to 5
  1255. For j = 1 to 4
  1256. If HSScore(j) <HSScore(j + 1)Then
  1257. tmp = HSScore(j + 1)
  1258. tmp2 = HSName(j + 1)
  1259. HSScore(j + 1) = HSScore(j)
  1260. HSName(j + 1) = HSName(j)
  1261. HSScore(j) = tmp
  1262. HSName(j) = tmp2
  1263. End If
  1264. Next
  1265. Next
  1266. End Sub
  1267.  
  1268. ' check for new highscore
  1269.  
  1270. Sub CheckHighscore
  1271. HighScoreTimer.Enabled = 1
  1272. 'If Score(CurrentPlayer)> HSSCore(1)Then
  1273. ' AwardSpecial
  1274. 'End I
  1275. If Score(CurrentPlayer)> HSSCore(5)Then
  1276. NewHighScore Score(CurrentPlayer), CurrentPlayer
  1277. End If
  1278. End Sub
  1279.  
  1280. ' Highscore Timer
  1281.  
  1282. Sub HighScoreTimer_Timer
  1283. If EnteringInitials then
  1284. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1285. ElseIf bGameInPlay then
  1286. SetHSLine 1, "HIGH SCORE"
  1287. SetHSLine 2, HSScore(1)
  1288. SetHSLine 3, HSName(1)
  1289. Me.Enabled = 0
  1290. Else
  1291. ' cycle through high scores
  1292. SetHSLine 1, "HIGH SCORE" & (HSTimerCount + 1)
  1293. SetHSLine 2, HSScore(HSTimerCount + 1)
  1294. SetHSLine 3, HSName(HSTimerCount + 1)
  1295. HSTimerCount = (HSTimerCount + 1)MOD 5
  1296. End If
  1297. End Sub
  1298.  
  1299. ' Enter Highscore initials
  1300.  
  1301. Function GetHSChar(String, Index)
  1302. Dim ThisChar
  1303. Dim FileName
  1304. ThisChar = Mid(String, Index, 1)
  1305. FileName = "PostIt"
  1306. If ThisChar = " " or ThisChar = "" then
  1307. FileName = FileName & "BL"
  1308. ElseIf ThisChar = "<" then
  1309. FileName = FileName & "LT"
  1310. ElseIf ThisChar = "_" then
  1311. FileName = FileName & "SP"
  1312. Else
  1313. FileName = FileName & ThisChar
  1314. End If
  1315. GetHSChar = FileName
  1316. End Function
  1317.  
  1318. Sub SetHsLine(LineNo, String)
  1319. Dim StrLen
  1320. Dim Index
  1321. Dim StartHSArray
  1322. Dim EndHSArray
  1323. Dim xFor
  1324. StartHSArray = array(0, 1, 12, 22)
  1325. EndHSArray = array(0, 11, 21, 31)
  1326. StrLen = len(string)
  1327. Index = 1
  1328. For xFor = StartHSArray(LineNo)to EndHSArray(LineNo)
  1329. Eval("HS" &xFor).imageA = GetHSChar(String, Index)
  1330. Index = Index + 1
  1331. Next
  1332. End Sub
  1333.  
  1334. Sub NewHighScore(NewScore, PlayNum)
  1335. If NewScore> HSScore(5)then
  1336. HighScoreTimer.interval = 500
  1337. AlphaStringPos = 1 ' start with first character "A"
  1338. EnteringInitials = true ' intercept the control keys while entering initials
  1339. InitialString = "" ' initials entered so far, initialize to empty
  1340. SetHSLine 1, "PLAYER " + FormatNumber(PlayNum, 0)
  1341. SetHSLine 2, "ENTER NAME"
  1342. SetHSLine 3, MID(AlphaString, AlphaStringPos, 1)
  1343. HSNewHigh = NewScore
  1344. End If
  1345. End Sub
  1346.  
  1347. Sub CollectInitials(keycode)
  1348. Dim i
  1349. If keycode = LeftFlipperKey Then
  1350. ' back up to previous character
  1351. AlphaStringPos = AlphaStringPos - 1
  1352. If AlphaStringPos <1 then
  1353. AlphaStringPos = len(AlphaString) ' handle wrap from beginning to End
  1354. If InitialString = "" then
  1355. ' Skip the backspace If there are no characters to backspace over
  1356. AlphaStringPos = AlphaStringPos - 1
  1357. End If
  1358. End If
  1359. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1360. PlaySound "fx_Previous"
  1361. ElseIf keycode = RightFlipperKey Then
  1362. ' advance to Next character
  1363. AlphaStringPos = AlphaStringPos + 1
  1364. If AlphaStringPos> len(AlphaString)or(AlphaStringPos = len(AlphaString)and InitialString = "")then
  1365. ' Skip the backspace If there are no characters to backspace over
  1366. AlphaStringPos = 1
  1367. End If
  1368. SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
  1369. PlaySound "fx_Next"
  1370. ElseIf keycode = StartGameKey or keycode = PlungerKey Then
  1371. SelectedChar = MID(AlphaString, AlphaStringPos, 1)
  1372. If SelectedChar = "_" then
  1373. InitialString = InitialString & " "
  1374. PlaySound("fx_Esc")
  1375. ElseIf SelectedChar = "<" then
  1376. InitialString = MID(InitialString, 1, len(InitialString)- 1)
  1377. If len(InitialString) = 0 then
  1378. ' If there are no more characters to back over, don't leave the < displayed
  1379. AlphaStringPos = 1
  1380. End If
  1381. PlaySound("fx_Esc")
  1382. Else
  1383. InitialString = InitialString & SelectedChar
  1384. PlaySound("fx_Enter")
  1385. End If
  1386. If len(InitialString) <3 then
  1387. SetHSLine 3, InitialString & SelectedChar
  1388. End If
  1389. End If
  1390. If len(InitialString) = 3 then
  1391. EnteringInitials = False
  1392. HSScore(5) = HSNewHigh
  1393. HSName(5) = InitialString
  1394. SortHighScore
  1395. HighScoreTimer.interval = 2000
  1396. End If
  1397. End Sub
  1398.  
  1399. '*******************
  1400. ' Realtime updates
  1401. '*******************
  1402.  
  1403. Sub RealTime_Timer
  1404. RollingUpdate
  1405. LeftFlipperTop.RotZ = LeftFlipper.CurrentAngle
  1406. RightFlipperTop.RotZ = RightFlipper.CurrentAngle
  1407. End Sub
  1408.  
  1409. '*********
  1410. ' LUT
  1411. '*********
  1412.  
  1413. Dim bLutActive, LUTImage
  1414. Sub LoadLUT
  1415. bLutActive = False
  1416. x = LoadValue(cGameName, "LUTImage")
  1417. If(x <> "")Then LUTImage = x Else LUTImage = 0
  1418. UpdateLUT
  1419. End Sub
  1420.  
  1421. Sub SaveLUT
  1422. SaveValue cGameName, "LUTImage", LUTImage
  1423. End Sub
  1424.  
  1425. Sub NextLUT:LUTImage = (LUTImage + 1)MOD 10:UpdateLUT:SaveLUT:End Sub
  1426.  
  1427. Sub UpdateLUT
  1428. Select Case LutImage
  1429. Case 0:table1.ColorGradeImage = "LUT0"
  1430. Case 1:table1.ColorGradeImage = "LUT1"
  1431. Case 2:table1.ColorGradeImage = "LUT2"
  1432. Case 3:table1.ColorGradeImage = "LUT3"
  1433. Case 4:table1.ColorGradeImage = "LUT4"
  1434. Case 5:table1.ColorGradeImage = "LUT5"
  1435. Case 6:table1.ColorGradeImage = "LUT6"
  1436. Case 7:table1.ColorGradeImage = "LUT7"
  1437. Case 8:table1.ColorGradeImage = "LUT8"
  1438. Case 9:table1.ColorGradeImage = "LUT9"
  1439. End Select
  1440. End Sub
  1441.  
  1442. '***********************************************************************
  1443. ' *********************************************************************
  1444. ' ********* G A M E C O D E S T A R T S H E R E *********
  1445. ' *********************************************************************
  1446. '***********************************************************************
  1447.  
  1448. Sub VPObjects_Init 'init objects
  1449. TurnOffPlayfieldLights()
  1450. DropPost
  1451. Post2.IsDropped = 1
  1452. End Sub
  1453.  
  1454. ' Dim all the variables
  1455.  
  1456. Sub Game_Init() 'called at the start of a new game
  1457. 'Start music?
  1458. 'Init variables?
  1459. 'Start or init timers
  1460. 'Init lights?
  1461. TurnOffPlayfieldLights()
  1462. Bonus = 0
  1463. AddBonus 1
  1464. DropPost
  1465. End Sub
  1466.  
  1467. Sub StopEndOfBallMode() 'called when the last ball is drained
  1468. End Sub
  1469.  
  1470. Sub ResetNewBallVariables() 'init variables new ball/player
  1471. BonusMultiplier = 1
  1472. DropPost
  1473. End Sub
  1474.  
  1475. Sub ResetNewBallLights() 'init lights for new ball/player
  1476. TurnOffPlayfieldLights()
  1477. XtraBall.SetValue 0
  1478. li012.State = 1
  1479. li032.State = 1
  1480. li033.State = 1
  1481. li009.State = 1
  1482. li003.State = 1
  1483. li011.State = 1
  1484. li001.State = 1
  1485. End Sub
  1486.  
  1487. Sub TurnOffPlayfieldLights()
  1488. Dim a
  1489. For each a in aLights
  1490. a.State = 0
  1491. Next
  1492. End Sub
  1493.  
  1494. ' *********************************************************************
  1495. ' Table Object Hit Events
  1496. ' *********************************************************************
  1497. ' Any target hit Sub will do this:
  1498. ' - play a sound
  1499. ' - do some physical movement
  1500. ' - add a score, bonus
  1501. ' - check some variables/modes this trigger is a member of
  1502. ' - set the "LastSwicthHit" variable in case it is needed later
  1503. ' *********************************************************************
  1504.  
  1505. ' Slingshots
  1506. Dim LStep, RStep
  1507.  
  1508. Sub LeftSlingShot_Slingshot
  1509. If Tilted Then Exit Sub
  1510. PlaySoundAt SoundFXDOF("fx_slingshot", 103, DOFPulse, DOFContactors), Lemk
  1511. LeftSling004.Visible = 1
  1512. Lemk.RotX = 26
  1513. LStep = 0
  1514. LeftSlingShot.TimerEnabled = True
  1515. ' add points
  1516. AddScore 100
  1517. ' some effect?
  1518. End Sub
  1519.  
  1520. Sub LeftSlingShot_Timer
  1521. Select Case LStep
  1522. Case 1:LeftSLing004.Visible = 0:LeftSLing003.Visible = 1:Lemk.RotX = 14
  1523. Case 2:LeftSLing003.Visible = 0:LeftSLing002.Visible = 1:Lemk.RotX = 2
  1524. Case 3:LeftSLing002.Visible = 0:Lemk.RotX = -20:LeftSlingShot.TimerEnabled = 0
  1525. End Select
  1526. LStep = LStep + 1
  1527. End Sub
  1528.  
  1529. Sub RightSlingShot_Slingshot
  1530. If Tilted Then Exit Sub
  1531. PlaySoundAt SoundFXDOF("fx_slingshot", 105, DOFPulse, DOFContactors), Remk
  1532. RightSling004.Visible = 1
  1533. Remk.RotX = 26
  1534. RStep = 0
  1535. RightSlingShot.TimerEnabled = True
  1536. ' add points
  1537. AddScore 100
  1538. ' add effect?
  1539. End Sub
  1540.  
  1541. Sub RightSlingShot_Timer
  1542. Select Case RStep
  1543. Case 1:RightSLing004.Visible = 0:RightSLing003.Visible = 1:Remk.RotX = 14
  1544. Case 2:RightSLing003.Visible = 0:RightSLing002.Visible = 1:Remk.RotX = 2
  1545. Case 3:RightSLing002.Visible = 0:Remk.RotX = -20:RightSlingShot.TimerEnabled = 0
  1546. End Select
  1547. RStep = RStep + 1
  1548. End Sub
  1549.  
  1550. '**************
  1551. ' Rubbers
  1552. '**************
  1553.  
  1554. Sub rsband001_Hit
  1555. If Tilted then Exit Sub
  1556. AddScore 10
  1557. End Sub
  1558.  
  1559. Sub rsband002_Hit
  1560. If Tilted then Exit Sub
  1561. AddScore 10
  1562. End Sub
  1563.  
  1564. '*********
  1565. ' Bumpers
  1566. '*********
  1567.  
  1568. Sub Bumper001_Hit
  1569. If Tilted Then Exit Sub
  1570. PlaySoundAt SoundFXDOF("fx_Bumper", 107, DOFPulse, DOFContactors), bumper001
  1571. AddScore 1000 + 9000 * LBumper1a.State
  1572. End Sub
  1573.  
  1574. Sub Bumper002_Hit
  1575. If Tilted Then Exit Sub
  1576. PlaySoundAt SoundFXDOF("fx_Bumper", 109, DOFPulse, DOFContactors), bumper002
  1577. AddScore 1000 + 9000 * LBumper2a.State
  1578. End Sub
  1579.  
  1580. Sub BumpersOn
  1581. LBumper1a.State = 1
  1582. LBumper1b.State = 1
  1583. LBumper2a.State = 1
  1584. LBumper2b.State = 1
  1585. End Sub
  1586.  
  1587. Sub BumpersOff
  1588. LBumper1a.State = 0
  1589. LBumper1b.State = 0
  1590. LBumper2a.State = 0
  1591. LBumper2b.State = 0
  1592. End Sub
  1593.  
  1594. '*****************
  1595. ' Lanes
  1596. '*****************
  1597.  
  1598. ' inlanes & outlanes
  1599.  
  1600. Sub Trigger001_Hit
  1601. PlaySoundAt "fx_sensor", Trigger001
  1602. If Tilted Then Exit Sub
  1603. AddScore 5000
  1604. If li002.State Then AwardExtraBall
  1605. End Sub
  1606.  
  1607. Sub Trigger002_Hit
  1608. PlaySoundAt "fx_sensor", Trigger002
  1609. If Tilted Then Exit Sub
  1610. AddScore 1000
  1611. AddBonus 1
  1612. BumpersOn
  1613. End Sub
  1614.  
  1615. Sub Trigger003_Hit
  1616. PlaySoundAt "fx_sensor", Trigger003
  1617. If Tilted Then Exit Sub
  1618. AddScore 5000
  1619. If li004.State Then AwardExtraBall
  1620. End Sub
  1621.  
  1622. Sub Trigger004_Hit
  1623. PlaySoundAt "fx_sensor", Trigger004
  1624. If Tilted Then Exit Sub
  1625. Post2.IsDropped = 0
  1626. StartBonusCount
  1627. End Sub
  1628.  
  1629. ' top lanes
  1630.  
  1631. Sub Trigger005_Hit
  1632. PlaySoundAt "fx_sensor", Trigger005
  1633. If Tilted Then Exit Sub
  1634. AddScore 5000
  1635. BumpersOn
  1636. End Sub
  1637.  
  1638. Sub Trigger006_Hit
  1639. PlaySoundAt "fx_sensor", Trigger006
  1640. If Tilted Then Exit Sub
  1641. AddScore 500 + 4500 * li012.State
  1642. If li012.State Then
  1643. li010.State = 1
  1644. li009.State = 0
  1645. li012.State = 0
  1646. BonusMultiplier = 3
  1647. End If
  1648. End Sub
  1649.  
  1650. Sub Trigger007_Hit
  1651. PlaySoundAt "fx_sensor", Trigger007
  1652. If Tilted Then Exit Sub
  1653. AddScore 5000
  1654. End Sub
  1655.  
  1656. Sub Trigger008_Hit
  1657. PlaySoundAt "fx_sensor", Trigger008
  1658. If Tilted Then Exit Sub
  1659. AddScore 3000
  1660. AddBonus 3
  1661. End Sub
  1662.  
  1663. '************************
  1664. ' Targets
  1665. '************************
  1666.  
  1667. Sub Target001_hit
  1668. PlaySoundAtBall "fx_target"
  1669. If Tilted Then Exit Sub
  1670. AddScore 10
  1671. BumpersOff
  1672. End Sub
  1673.  
  1674. Sub Target002_hit
  1675. PlaySoundAtBall "fx_target"
  1676. If Tilted Then Exit Sub
  1677. AddScore 10
  1678. BumpersOff
  1679. End Sub
  1680.  
  1681. Sub Target003_hit
  1682. PlaySoundAtBall "fx_target"
  1683. If Tilted Then Exit Sub
  1684. AddScore 5000 + 45000 * li008.State
  1685. End Sub
  1686.  
  1687. Sub Target004_hit
  1688. PlaySoundAtBall "fx_target"
  1689. If Tilted Then Exit Sub
  1690. AddScore 500
  1691. If li005.State Then AwardSpecial
  1692. End Sub
  1693.  
  1694. Sub Target005_hit
  1695. PlaySoundAtBall "fx_target"
  1696. If Tilted Then Exit Sub
  1697. AddScore 5000 + 45000 * li007.State
  1698. End Sub
  1699.  
  1700. Sub Target006_hit
  1701. PlaySoundAtBall "fx_target"
  1702. If Tilted Then Exit Sub
  1703. AddScore 500
  1704. If li006.State Then AwardSpecial
  1705. End Sub
  1706.  
  1707. '*****************
  1708. ' kickers
  1709. '*****************
  1710.  
  1711. ' left yellow bumper
  1712. Sub LeftHole_Hit
  1713. PlaySoundAt "fx_kicker_enter", LeftHole
  1714. If NOT Tilted Then
  1715. Addscore 500
  1716. li003.State = 0
  1717. li013.State = 1
  1718. li015.State = 1
  1719. li021.State = 1
  1720. CheckBells
  1721. End If
  1722. vpmtimer.addtimer 1000, "ExitLeftHole '"
  1723. End Sub
  1724.  
  1725. Sub ExitLeftHole
  1726. PlaySoundAt SoundFXDOF("fx_kicker", 111, DOFPulse, DOFContactors), LeftHole
  1727. LeftHole.kick 164, 18
  1728. End Sub
  1729.  
  1730. ' center red bumper
  1731. Sub CenterHole_Hit
  1732. PlaySoundAt "fx_kicker_enter", CenterHole
  1733. If NOT Tilted Then
  1734. Addscore 500
  1735. li011.State = 0
  1736. li014.State = 1
  1737. li017.State = 1
  1738. li020.State = 1
  1739. CheckBells
  1740. End If
  1741. vpmtimer.addtimer 1000, "ExitCenterHole '"
  1742. End Sub
  1743.  
  1744. Sub ExitCenterHole
  1745. PlaySoundAt SoundFXDOF("fx_kicker", 112, DOFPulse, DOFContactors), LeftHole
  1746. CenterHole.kick 170, 18
  1747. End Sub
  1748.  
  1749. ' right green bumper
  1750. Sub RightHole_Hit
  1751. PlaySoundAt "fx_kicker_enter", RightHole
  1752. If NOT Tilted Then
  1753. Addscore 500
  1754. li001.State = 0
  1755. li016.State = 1
  1756. li018.State = 1
  1757. li019.State = 1
  1758. CheckBells
  1759. End If
  1760. vpmtimer.addtimer 1000, "ExitRightHole '"
  1761. End Sub
  1762.  
  1763. Sub ExitRightHole
  1764. PlaySoundAt SoundFXDOF("fx_kicker", 113, DOFPulse, DOFContactors), RightHole
  1765. RightHole.kick 195, 18
  1766. End Sub
  1767.  
  1768. Sub CheckBells
  1769. If li013.State AND li014.State Then RisePost
  1770. If li015.State Then li009.State = 0:li010.State = 1 ' lite tripple bonus
  1771. If li015.State AND li016.State Then li002.State = 1:li004.State = 1 ' lite extra ball
  1772. If li017.State AND li018.State Then li007.State = 1:li008.State = 1 ' lite 50,000 points
  1773. If li021.State AND li020.State AND li019.State Then li005.State = 1:li006.State = 1 ' lite Special
  1774. End Sub
  1775.  
  1776. ' Bonus kicker hole
  1777.  
  1778. Dim BallinBonusKicker
  1779. BallinBonusKicker = False
  1780.  
  1781. Sub BonusKicker_Hit
  1782. PlaySoundAt "fx_kicker_enter", BonusKicker
  1783. DOF 117, DOFPulse
  1784. If NOT Tilted Then
  1785. BallinBonusKicker = True
  1786. StartBonusCount
  1787. Else
  1788. BonusKickOut
  1789. End If
  1790. End Sub
  1791.  
  1792. Sub BonusKickOut
  1793. PlaySoundAt SoundFXDOF("fx_kicker", 114, DOFPulse, DOFContactors), BonusKicker
  1794. BallinBonusKicker = False
  1795. BonusKicker.kick 190, 14
  1796. End Sub
  1797.  
  1798. '***************
  1799. ' POST
  1800. '***************
  1801.  
  1802. Sub RisePost
  1803. PlaySoundAt "fx_SolenoidOn", Primitive011
  1804. Post.IsDropped = 0
  1805. End Sub
  1806.  
  1807. Sub DropPost
  1808. PlaySoundAt "fx_SolenoidOff", Primitive011
  1809. Post.IsDropped = 1
  1810. End Sub
  1811.  
  1812. '**************
  1813. ' Buttons
  1814. '**************
  1815.  
  1816. Sub Button001_Hit
  1817. PlaySoundAt "fx_sensor", Button001
  1818. Addscore 10
  1819. AddBonus 1
  1820. End Sub
  1821.  
  1822. Sub Button002_Hit
  1823. PlaySoundAt "fx_sensor", Button002
  1824. Addscore 10
  1825. AddBonus 1
  1826. End Sub
Add Comment
Please, Sign In to add comment