Outhere

Willy's Wonderland ( Goldchicco )2.0

Oct 3rd, 2021 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 96.30 KB | None | 0 0
  1. Option Explicit
  2. Randomize
  3.  
  4. On Error Resume Next
  5. ExecuteGlobal GetTextFile("controller.vbs")
  6. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  7. On Error Goto 0
  8.  
  9. Const cGameName="dvlsdre",UseSolenoids=1,UseLamps=1,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  10.  
  11. LoadVPM "01560000","SYS80.VBS",3.2
  12.  
  13. '///////////////////////-----General Sound Options-----///////////////////////
  14. '// VolumeDial:
  15. '// VolumeDial is the actual global volume multiplier for the mechanical sounds.
  16. '// Values smaller than 1 will decrease mechanical sounds volume.
  17. '// Recommended values should be no greater than 1.
  18.  
  19. Const VolumeDial = 0.8
  20.  
  21. '----- Phsyics Mods -----
  22. Const RubberizerEnabled = 1 '0 = normal flip rubber, 1 = more lively rubber for flips
  23. Const FlipperCoilRampupMode = 1 '0 = fast, 1 = medium, 2 = slow (tap passes should work)
  24. Const TargetBouncerEnabled = 1 '0 = normal standup targets, 1 = bouncy targets
  25. Const TargetBouncerFactor = 0.7 'Level of bounces. 0.0 thru 1.0, higher value is more bounciness (don't go above 1)
  26.  
  27. Dim DesktopMode: DesktopMode = Table1.ShowDT
  28.  
  29. If DesktopMode = True Then 'Show Desktop components
  30. Ramp16.visible=1
  31. Ramp15.visible=1
  32. Primitive13.visible=1
  33. Else
  34. Ramp16.visible=0
  35. Ramp15.visible=0
  36. Primitive13.visible=0
  37. End if
  38. Const NumMusicTracks = 7
  39.  
  40.  
  41. '********************************************************************
  42. ' VR Room Options
  43. '********************************************************************
  44. dim VrUser
  45. dim VRRoom
  46.  
  47. VrUser = 0 '0 - VR off, 1 - VR on
  48.  
  49. VRRoom = 1 '0 - Minimal Room, 1 - Monsters Room
  50. '********************************************************************
  51. ' VR ROOM ENABLE
  52. '********************************************************************
  53. DIM VRObjects
  54. If VrUser = 1 Then
  55. for each VRObjects in VRStuff:VRObjects.visible = 1:Next
  56. Ramp16.visible=0
  57. Ramp15.visible=0
  58. Primitive13.visible=0
  59.  
  60. Else
  61. for each VRObjects in VRStuff:VRObjects.visible = 0:Next
  62. End if
  63.  
  64.  
  65. Sub Setup_room()
  66. If VRRoom = 1 Then
  67. RoomComplex
  68. End If
  69. If VRRoom = 0 Then
  70. RoomMinimal
  71. End If
  72. End Sub
  73.  
  74.  
  75.  
  76. Sub RoomComplex()
  77. for each VRObjects in ComplexRoom : VRObjects.visible = 1 : next
  78. for each VRObjects in BasicRoom : VRObjects.visible = 0 : next
  79. Primary_environment.image = "Sphere"
  80. End Sub
  81.  
  82. Sub RoomMinimal()
  83. for each VRObjects in ComplexRoom : VRObjects.visible = 0 : next
  84. for each VRObjects in BasicRoom : VRObjects.visible = 1 : next
  85. SaveValue "WILLY", "V1.0.0", 1
  86. End Sub
  87.  
  88.  
  89.  
  90.  
  91. '*************************************************************
  92. 'Solenoid Call backs
  93. '**********************************************************************************************************
  94. 'DOF updated by outhere on 10/3/2021
  95. '103 left slingshot
  96. '104 right slingshot
  97. '105 Bumper Back Left
  98. '106 Bumper Back Center
  99. '107 Bumper Back Right
  100. '108 LeftMagnaSave (Left Ball Save Kicker)
  101.  
  102. SolCallback(1) = "DTT.SolDropUp"
  103. SolCallback(2) = "bsKicker.SolOut"
  104. SolCallback(3) = "bsHole.SolOut"
  105. SolCallback(4) = "SolBallSaver"
  106. SolCallback(5) = "DTL.SolDropUp"
  107. SolCallback(6) = "DTR.SolDropUp"
  108. SolCallback(8) = "SolKnocker"
  109. SolCallback(9) = "bsTrough.SolIn"
  110. SolCallback(10) = "Sol10"
  111.  
  112. SolCallback(sLRFlipper) = "SolRFlipper"
  113. SolCallback(sLLFlipper) = "SolLFlipper"
  114.  
  115. Const ReflipAngle = 20
  116.  
  117. Sub SolLFlipper(Enabled)
  118. If Enabled Then
  119. LF.Fire 'leftflipper.rotatetoend
  120. LeftFlipper.RotateToEnd
  121. If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
  122. RandomSoundReflipUpLeft LeftFlipper
  123. Else
  124. SoundFlipperUpAttackLeft LeftFlipper
  125. RandomSoundFlipperUpLeft LeftFlipper
  126. End If
  127. Else
  128. LeftFlipper.RotateToStart
  129. If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
  130. RandomSoundFlipperDownLeft LeftFlipper
  131. End If
  132. FlipperLeftHitParm = FlipperUpSoundLevel
  133. End If
  134. End Sub
  135.  
  136. Sub SolRFlipper(Enabled)
  137. If Enabled Then
  138. RF.Fire 'rightflipper.rotatetoend
  139. RightFlipper.RotateToEnd:RightFlipper1.RotateToEnd
  140. If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
  141. RandomSoundReflipUpRight RightFlipper
  142. Else
  143. SoundFlipperUpAttackRight RightFlipper
  144. RandomSoundFlipperUpRight RightFlipper
  145. End If
  146. Else
  147. RightFlipper.RotateToStart:RightFlipper1.RotateToStart
  148. If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
  149. RandomSoundFlipperDownRight RightFlipper
  150. End If
  151. FlipperRightHitParm = FlipperUpSoundLevel
  152. End If
  153. End Sub
  154.  
  155.  
  156. Sub LeftFlipper_Collide(parm)
  157. CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
  158. LeftFlipperCollide parm
  159. if RubberizerEnabled = 1 then Rubberizer(parm)
  160. if RubberizerEnabled = 2 then Rubberizer2(parm)
  161. End Sub
  162.  
  163. Sub RightFlipper_Collide(parm)
  164. CheckLiveCatch Activeball, RightFlipper, RFCount, parm
  165. RightFlipperCollide parm
  166. if RubberizerEnabled = 1 then Rubberizer(parm)
  167. if RubberizerEnabled = 2 then Rubberizer2(parm)
  168. End Sub
  169.  
  170. ' iaakki Rubberizer
  171. sub Rubberizer(parm)
  172. if parm < 10 And parm > 2 And Abs(activeball.angmomz) < 10 then
  173. 'debug.print "parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
  174. activeball.angmomz = activeball.angmomz * 1.2
  175. activeball.vely = activeball.vely * 1.2
  176. 'debug.print ">> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
  177. Elseif parm <= 2 and parm > 0.2 Then
  178. 'debug.print "* parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
  179. activeball.angmomz = activeball.angmomz * -1.1
  180. activeball.vely = activeball.vely * 1.4
  181. 'debug.print "**** >> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
  182. end if
  183. end sub
  184.  
  185. ' apophis rubberizer
  186. sub Rubberizer2(parm)
  187. if parm < 10 And parm > 2 And Abs(activeball.angmomz) < 10 then
  188. 'debug.print "parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
  189. activeball.angmomz = -activeball.angmomz * 2
  190. activeball.vely = activeball.vely * 1.2
  191. 'debug.print ">> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
  192. Elseif parm <= 2 and parm > 0.2 Then
  193. 'debug.print "* parm: " & parm & " momz: " & activeball.angmomz &" vely: "& activeball.vely
  194. activeball.angmomz = -activeball.angmomz * 0.5
  195. activeball.vely = activeball.vely * (1.2 + rnd(1)/3 )
  196. 'debug.print "**** >> newmomz: " & activeball.angmomz&" newvely: "& activeball.vely
  197. end if
  198. end sub
  199.  
  200. '**********************************************************************************************************
  201.  
  202. 'Solenoid Controlled toys
  203. '**********************************************************************************************************
  204.  
  205. Dim BallSaverActive,FlipperActive
  206. Sub SolBallSaver(Enabled)
  207. if enabled then BallSaverActive = True
  208. End Sub
  209.  
  210. Sub Sol10(Enabled)
  211. FlipperActive = enabled
  212. if not Flipperactive then
  213. LeftFlipper.RotateToStart
  214. RightFlipper.RotateToStart
  215. RightFlipper1.RotateToStart
  216. end if
  217. End Sub
  218.  
  219. Sub SolKnocker(Enabled)
  220. If enabled Then
  221. KnockerSolenoid 'Add knocker position object
  222. End If
  223. End Sub
  224.  
  225. '*****GI Lights On
  226. dim xx
  227. dim gilights
  228. For each xx in GI:xx.State = 1 : Next
  229.  
  230. '**********************************************************************************************************
  231.  
  232. 'Initiate Table
  233. '**********************************************************************************************************
  234.  
  235. Dim bsTrough, bsKicker, bsHole, DTT, DTL, DTR
  236.  
  237. Sub Table1_Init
  238. vpmInit Me
  239. On Error Resume Next
  240. With Controller
  241. .GameName = cGameName
  242. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  243. .SplashInfoLine = "Devil's Dare"&chr(13)&"You Suck"
  244. .HandleMechanics=0
  245. .HandleKeyboard=0
  246. .ShowDMDOnly=1
  247. .ShowFrame=0
  248. .ShowTitle=0
  249. .hidden = 1
  250. .Games(cGameName).Settings.Value("sound") = 0
  251. If Err Then MsgBox Err.Description
  252. End With
  253. On Error Goto 0
  254. Controller.SolMask(0)=0
  255. vpmTimer.AddTimer 2000,"Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
  256. Controller.Run
  257. If Err Then MsgBox Err.Description
  258. On Error Goto 0
  259.  
  260. PinMAMETimer.Interval=PinMAMEInterval
  261. PinMAMETimer.Enabled=1
  262. Playsound"intro"
  263.  
  264. If VrUser = 1 Then
  265. setup_backglass 'setup VR backglass
  266. setup_room 'setup VR room
  267. End If
  268.  
  269.  
  270.  
  271. vpmNudge.TiltSwitch=57
  272. vpmNudge.Sensitivity=5
  273. vpmNudge.TiltObj = Array(Bumper1,Bumper2,Bumper3,LeftslingShot,RightslingShot)
  274.  
  275. Set bsTrough=New cvpmBallStack
  276. bsTrough.InitSw 55,50,99,51,0,0,0,0
  277. bsTrough.InitKick BallRelease,90,5
  278. ' bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  279. bsTrough.Balls=3
  280.  
  281. Set bsKicker=New cvpmBallStack
  282. bsKicker.InitSaucer Kicker,5,0,22
  283. ' bsKicker.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  284.  
  285. Set bsHole=New cvpmBallStack
  286. bsHole.InitSaucer Hole,6,180,5
  287. ' bsHole.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  288.  
  289. set DTT = new cvpmDropTarget
  290. DTT.InitDrop Array(sw4,sw14,sw24), Array(4,14,24)
  291. DTT.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  292.  
  293. set DTL = new cvpmDropTarget
  294. DTL.InitDrop Array(sw0,sw10,sw20,sw30,sw40), Array(0,10,20,30,40)
  295. DTL.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  296.  
  297. set DTR = new cvpmDropTarget
  298. DTR.InitDrop Array(sw1,sw11,sw21,sw31,sw41), Array(1,11,21,31,41)
  299. DTR.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  300.  
  301. BallSaverActive = False
  302. BallSaveKicker.pullback
  303.  
  304. End Sub
  305.  
  306. Sub MusicOn
  307. Dim x
  308. x = INT(NumMusicTracks * Rnd + 1)
  309. PlayMusic "willy\"& x &".mp3"
  310. End Sub
  311.  
  312. Sub Table1_MusicDone()
  313. MusicOn
  314. End Sub
  315.  
  316. Dim Track
  317. Sub NextSong
  318.  
  319. If Track = 0 Then PlayMusic"willy\1.mp3" End If
  320. If Track = 1 Then PlayMusic"willy\2.mp3" End If
  321. If Track = 2 Then PlayMusic"willy\3.mp3" End If
  322. If Track = 3 Then PlayMusic"willy\4.mp3" End If
  323. If Track = 4 Then PlayMusic"willy\5.mp3" End If
  324. If Track = 5 Then PlayMusic"willy\6.mp3" End If
  325. If Track = 6 Then PlayMusic"willy\7.mp3" End If
  326.  
  327. Track = (Track + 1) mod 7
  328. End Sub
  329.  
  330. Sub DrainHit
  331. Dim z
  332. z= INT (5 * RND(1) )
  333. Select Case z
  334. Case 0:PlaySound"calm down"
  335. Case 1:PlaySound"great times"
  336. Case 2:PlaySound"grown man scream"
  337. Case 3:PlaySound"outtahere"
  338. Case 4:Playsound"windex"
  339.  
  340. end select
  341. End Sub
  342.  
  343. Sub CreditSounds
  344. Dim y
  345. y= INT (4 * RND(1) )
  346. Select Case y
  347. Case 0:stopsound"good luck":stopsound"cash":stopsound"few words":stopsound"I got aguy":PlaySound"good luck"
  348. Case 1:stopsound"cash":stopsound"good luck":stopsound"few words":stopsound"I got aguy":PlaySound"cash"
  349. Case 2:stopsound"few words":stopsound"cash":stopsound"good luck":stopsound"I got aguy":PlaySound"few words"
  350. Case 3:stopsound"i got aguy": stopsound"cash":stopsound"few words":stopsound"good luck":PlaySound"I got aguy"
  351.  
  352. end select
  353. End Sub
  354.  
  355. sub bumpers
  356. dim zz
  357. zz= INT (3 * RND(1) )
  358. Select Case zz
  359. Case 0:PlaySound"mxbell0"
  360. Case 1:PlaySound"mxbell0000"
  361. Case 2:PlaySound"mxbell00long"
  362.  
  363. end select
  364. End Sub
  365.  
  366. sub holehit
  367. dim yy
  368. yy= INT (4 * RND(1) )
  369. Select Case yy
  370. Case 0:PlaySound"mxstory1"
  371. Case 1:PlaySound"mxstory2"
  372. Case 2:PlaySound"mxstory3"
  373. Case 3:Playsound"birthdaytime"
  374.  
  375. end select
  376. End Sub
  377.  
  378. '*****************************************************************************************************
  379. ' VR PLUNGER ANIMATION
  380. '
  381. ' Code needed to animate the plunger. If you pull the plunger it will move in VR.
  382. ' IMPORTANT: there are two numeric values in the code that define the postion of the plunger and the
  383. ' range in which it can move. The first numeric value is the actual y position of the plunger primitive
  384. ' and the second is the actual y position + 135 to determine the range in which it can move.
  385. '
  386. ' You need to to select the Primary_plunger primitive you copied from the
  387. ' template and copy the value of the Y position (e.g. 1269.286) into the code.
  388. ' The value that determines the range of the plunger is always the y position + 135 (e.g. 1404).
  389. '
  390. '*****************************************************************************************************
  391.  
  392. Sub TimerPlunger_Timer
  393.  
  394. If VR_Primary_plunger.Y < 2455 then
  395. VR_Primary_plunger.Y = VR_Primary_plunger.Y + 5
  396. End If
  397. End Sub
  398.  
  399. Sub TimerPlunger2_Timer
  400. VR_Primary_plunger.Y = 2320 + (5* Plunger.Position) -20
  401. End Sub
  402.  
  403.  
  404.  
  405. '**********************************************************************************************************
  406. 'Plunger code
  407. '**********************************************************************************************************
  408.  
  409. Sub Table1_KeyDown(ByVal KeyCode)
  410. If keycode = LeftFlipperKey Then FlipperActivate LeftFlipper, LFPress
  411. If keycode = RightFlipperKey Then FlipperActivate RightFlipper, RFPress
  412.  
  413. If KeyCode = RightMagnaSave Then NextSong
  414. If keycode = StartGameKey Then stopsound"staff": StopSound"intro":Playsound"staff"
  415. If keycode = addcreditkey then CreditSounds
  416. If KeyDownHandler(keycode) Then Exit Sub
  417. If KeyCode = PlungerKey Then
  418. TimerPlunger.Enabled = True
  419. TimerPlunger2.Enabled = False
  420. 'aTimerPlunger.Enabled = False
  421. 'aTimerPlunger2.Enabled = True
  422. Plunger.Pullback:SoundPlungerPull()
  423. END If
  424. If keycode = LeftMagnaSave then
  425. if BallSaverActive then
  426. BallSaveKicker.fire
  427. PlaySound SoundFXDOF( "Popper", 108, DOFPulse,DOFContactors) 'Kicker
  428. BallSaveTimer.enabled = True
  429. end if
  430. end if
  431.  
  432. End Sub
  433.  
  434. Sub Table1_KeyUp(ByVal KeyCode)
  435. If KeyUpHandler(keycode) Then Exit Sub
  436. If vpmKeyUp(KeyCode) Then Exit Sub
  437. If keycode = LeftFlipperKey Then FlipperDeActivate LeftFlipper, LFPress
  438. If keycode = RightFlipperKey Then FlipperDeActivate RightFlipper, RFPress
  439.  
  440.  
  441. If KeyCode = PlungerKey Then
  442. Plunger.Fire
  443. TimerPlunger.Enabled = False
  444. TimerPlunger2.Enabled = True
  445. 'aTimerPlunger.Enabled = False
  446. 'aTimerPlunger.Enabled = True
  447. 'VR_Primary_plunger.Y = 2320
  448. If BIPL = 1 Then
  449. SoundPlungerReleaseBall() 'Plunger release sound when there is a ball in shooter lane
  450. Else
  451. SoundPlungerReleaseNoBall() 'Plunger release sound when there is no ball in shooter lane
  452. End If
  453. End If
  454.  
  455. If keycode = LeftMagnaSave then
  456. BallSaveKicker.pullback
  457. end if
  458. End Sub
  459.  
  460.  
  461. '**********************************************************************************************************
  462. ' Fleep BIPL
  463. '**********************************************************************************************************
  464. Dim BIPL : BIPL=0
  465.  
  466. Sub swBIPL_Hit
  467. BIPL = 1
  468. End Sub
  469.  
  470. Sub swBIPL_UnHit
  471. BIPL = 0
  472. End Sub
  473.  
  474. '**********************************************************************************************************
  475.  
  476. ' Drain hole
  477.  
  478. Sub Drain_Hit:bsTrough.addball me:EndMusic:RandomSoundDrain Drain:Playsound"cancrush":DrainHit:End Sub
  479. Sub BallRelease_Unhit:RandomSoundBallRelease BallRelease: End Sub
  480.  
  481. Sub Kicker_Hit:SoundSaucerLock:bsKicker.AddBall 0:holehit: End Sub
  482. Sub Kicker_UnHit:SoundSaucerKick 1, Kicker:End Sub
  483.  
  484. Sub Hole_Hit:SoundSaucerLock:bsHole.AddBall 0:holehit: End Sub
  485. Sub Hole_UnHit:SoundSaucerKick 1, Hole:End Sub
  486.  
  487.  
  488.  
  489. 'Bumpers
  490. Sub Bumper1_Hit : vpmTimer.PulseSw(34) : DOF 105, DOFPulse: RandomSoundBumperTop Bumper1 : End Sub
  491. Sub Bumper2_Hit : vpmTimer.PulseSw(34) : DOF 106, DOFPulse: RandomSoundBumperMiddle Bumper2: End Sub
  492. Sub Bumper3_Hit : vpmTimer.PulseSw(34) : DOF 107, DOFPulse: RandomSoundBumperBottom Bumper3: End Sub
  493.  
  494. 'Drop Targets
  495. Sub sw0_Dropped:DTL.Hit 1:playsound"mxtargets": TargetBouncer Activeball, 1:End Sub
  496. Sub sw10_Dropped:DTL.Hit 2:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  497. Sub sw20_Dropped:DTL.Hit 3:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  498. Sub sw30_Dropped:DTL.Hit 4:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  499. Sub sw40_Dropped:DTL.Hit 5:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  500.  
  501. Sub sw1_Dropped:DTR.Hit 1:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  502. Sub sw11_Dropped:DTR.Hit 2:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  503. Sub sw21_Dropped:DTR.Hit 3:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  504. Sub sw31_Dropped:DTR.Hit 4:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  505. Sub sw41_Dropped:DTR.Hit 5:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  506.  
  507. Sub sw4_Dropped:DTT.Hit 1:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  508. Sub sw14_Dropped:DTT.Hit 2:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  509. Sub sw24_Dropped:DTT.Hit 3:playsound"mxtargets":TargetBouncer Activeball, 1:End Sub
  510.  
  511. 'Stand Up Targets
  512. Sub sw2_Hit : vpmTimer.PulseSw 2 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  513. Sub sw12_Hit : vpmTimer.PulseSw 12 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  514. Sub sw22_Hit : vpmTimer.PulseSw 22 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  515. Sub sw32_Hit : vpmTimer.PulseSw 32 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  516.  
  517. Sub sw45_Hit : vpmTimer.PulseSw 45 : playsound"mxtarget1":TargetBouncer Activeball, 1:End Sub
  518. Sub sw46_Hit : vpmTimer.PulseSw 46 : playsound"mxtarget1":TargetBouncer Activeball, 1:End Sub
  519.  
  520. Sub sw3_Hit : vpmTimer.PulseSw 3: playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  521. Sub sw13_Hit : vpmTimer.PulseSw 13 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  522. Sub sw23_Hit : vpmTimer.PulseSw 23 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  523. Sub sw33_Hit : vpmTimer.PulseSw 33 : playsound"mxtarget4":TargetBouncer Activeball, 1:End Sub
  524.  
  525. Sub sw25_Hit : vpmTimer.PulseSw 25 : playsound"mxtarget1":TargetBouncer Activeball, 1:End Sub
  526. Sub sw25a_Hit : vpmTimer.PulseSw 25 : playsound"mxtarget1":TargetBouncer Activeball, 1:End Sub
  527.  
  528. 'Wire Triggers
  529. Sub sw36_Hit:Controller.Switch(36)=1 : endmusic: playsound"slam": playsound"scarystring":End Sub
  530. Sub sw36_unHit:Controller.Switch(36)=0:End Sub
  531. Sub sw54_Hit:Controller.Switch(54)=1 : playsound"mxwires":End Sub
  532. Sub sw54_unHit:Controller.Switch(54)=0:End Sub
  533. Sub sw53_Hit:Controller.Switch(53)=1 : playsound"mxwires2":End Sub
  534. Sub sw53_unHit:Controller.Switch(53)=0:End Sub
  535. Sub sw42_Hit:Controller.Switch(42)=1 : endmusic: playsound"slam": playsound"scarystring":End Sub
  536. Sub sw42_unHit:Controller.Switch(42)=0:End Sub
  537. Sub sw43_Hit:Controller.Switch(43)=1 : playsound"mxwires":End Sub
  538. Sub sw43_unHit:Controller.Switch(43)=0:End Sub
  539. Sub sw44_Hit:Controller.Switch(44)=1 : playsound"mxwires2":End Sub
  540. Sub sw44_unHit:Controller.Switch(44)=0:End Sub
  541.  
  542. 'Sub cutmusic_hit():EndMusic:end sub
  543. 'sub cutmusic_unhit():MusicOn:end sub
  544. 'Sub cutmusic2_hit():EndMusic:end sub
  545. 'sub cutmusic2_unhit():MusicOn:end sub
  546.  
  547. Sub Launch_Hit():PlaySound "Boing":End Sub
  548. 'Sub Launch_unHit():StopSound "Boing":End Sub
  549.  
  550.  
  551. 'Gate Trigger
  552. Sub sw16_Hit : vpmTimer.PulseSw(16) :End Sub
  553. Sub Gate3_Hit():playsound"beer": musicon : End Sub
  554.  
  555. 'Spinners
  556. Sub sw26_Spin:vpmTimer.PulseSw 26 : playsound"spinner" : End Sub
  557. Sub sw15_Spin:vpmTimer.PulseSw 15 : playsound"spinner" : End Sub
  558.  
  559. 'Scoring Rubbers
  560. Sub sw52a_Slingshot:vpmTimer.PulseSw 52 : playsound"rubber_hit_3" : End Sub
  561. Sub sw52b_Slingshot:vpmTimer.PulseSw 52 : playsound"rubber_hit_3" : End Sub
  562. Sub sw52c_Slingshot:vpmTimer.PulseSw 52 : playsound"rubber_hit_3" : End Sub
  563. Sub sw35a_Slingshot:vpmTimer.PulseSw 35 : playsound"rubber_hit_3" : End Sub
  564. Sub sw35b_Slingshot:vpmTimer.PulseSw 35 : playsound"rubber_hit_3" : End Sub
  565.  
  566.  
  567. '**********Sling Shot Animations
  568. ' Rstep and Lstep are the variables that increment the animation
  569. '****************
  570. Dim RStep, Lstep
  571.  
  572. Sub RightSlingShot_Slingshot
  573. DOF 104, DOFPulse
  574. vpmTimer.PulseSw 52
  575. RandomSoundSlingshotRight SLING1
  576. RSling.Visible = 0
  577. RSling1.Visible = 1
  578. sling1.TransZ = -20
  579. RStep = 0
  580. RightSlingShot.TimerEnabled = 1
  581. End Sub
  582.  
  583. Sub RightSlingShot_Timer
  584. Select Case RStep
  585. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  586. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
  587. End Select
  588. RStep = RStep + 1
  589. End Sub
  590.  
  591. Sub LeftSlingShot_Slingshot
  592. DOF 103, DOFPulse
  593. vpmTimer.PulseSw 52
  594. RandomSoundSlingshotLeft SLING2
  595. LSling.Visible = 0
  596. LSling1.Visible = 1
  597. sling2.TransZ = -20
  598. LStep = 0
  599. LeftSlingShot.TimerEnabled = 1
  600. End Sub
  601.  
  602. Sub LeftSlingShot_Timer
  603. Select Case LStep
  604. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  605. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0:
  606. End Select
  607. LStep = LStep + 1
  608. End Sub
  609.  
  610. '**********************************************************************************************************
  611. ' Map Lights to Array
  612. '**********************************************************************************************************
  613.  
  614. set lights(3) = lamp3 'shoot again pf
  615. set lights(4) = lamp4
  616. set lights(5) = lamp5
  617. set lights(6) = lamp6
  618. set lights(7) = lamp7
  619. set lights(12) = l12
  620. set lights(15) = lamp15
  621. lights(16) = array(L16a,L16b,L16c) 'Bumper Lights
  622. set lights(17) = lamp17
  623. set lights(18) = lamp18
  624. set lights(19) = lamp19
  625. set lights(20) = lamp20
  626. set lights(21) = lamp21
  627. set lights(22) = lamp22
  628. set lights(23) = lamp23
  629. set lights(24) = lamp24
  630. set lights(25) = lamp25
  631. set lights(26) = lamp26
  632. set lights(27) = lamp27
  633. set lights(28) = lamp28
  634. set lights(29) = lamp29
  635. set lights(30) = lamp30
  636. set lights(31) = lamp31
  637. set lights(32) = lamp32
  638. set lights(33) = lamp33
  639. set lights(34) = lamp34
  640. set lights(35) = lamp35
  641. set lights(36) = lamp36
  642. set lights(37) = lamp37
  643. set lights(38) = lamp38
  644. set lights(39) = lamp39
  645. lights(40) = array(lamp40a,lamp40b)
  646. set lights(41) = lamp41
  647. set lights(42) = lamp42
  648. set lights(43) = lamp43
  649. set lights(44) = lamp44
  650. set lights(45) = lamp45
  651. set lights(46) = lamp46
  652. set lights(47) = lamp47
  653.  
  654. 'BackGlass
  655. 'set lights(0) = l0 'ballinplay
  656. 'set lights(1) = l1 'tilt
  657. 'set lights(2) = l2 'shoot again lb = pf
  658. 'set lights(8) = l8 '??? lb
  659. 'set lights(9) = l9 'multi-mode
  660. 'set lights(10) = l10 'highscore
  661. 'set lights(11) = l11 'gameover
  662. 'set lights(12) = l12 'ball release
  663. 'set lights(13) = l13 'multi-bonus
  664. 'set lights(14) = l14 '???
  665.  
  666.  
  667. 'Lamp Callback for Ball Release and Ballsaver
  668. Sub LampTimer_Timer
  669. If (L12.State <> 0) and (not BallRelease.timerenabled) Then
  670. BallRelease.timerenabled = True
  671. bsTrough.ExitSol_On
  672. End if
  673.  
  674. if BallSaverActive then
  675. BallSaveA.state = Lightstateon
  676. BallSaveB.state = Lightstateon
  677. xLBallSaver.state = Lightstateon
  678. else
  679. BallSaveA.state = Lightstateoff
  680. BallSaveB.state = Lightstateoff
  681. xLBallSaver.state = Lightstateoff
  682. end if
  683.  
  684.  
  685.  
  686. xL50.state = controller.switch(50)
  687. xL51.state = controller.switch(51)
  688. xL55.state = controller.switch(55)
  689.  
  690. if controller.switch(51) then 'deactivate on last Ball drain
  691. BallSaverActive = False
  692. end if
  693. End sub
  694.  
  695. Sub BallSaveTimer_Timer
  696. BallSaveTimer.enabled = False
  697. BallSaverActive = False
  698. End Sub
  699.  
  700. Sub BallRelease_timer
  701. BallRelease.timerenabled = False
  702. End Sub
  703.  
  704. '**********************************************************************************************************
  705. ' Backglass Light Displays
  706. '**********************************************************************************************************
  707.  
  708. Dim Digits(44)
  709. Digits(0)=Array(a00,a01,a02,a03,a04,a05,a06,n,a08)
  710. Digits(1)=Array(a10,a11,a12,a13,a14,a15,a16,n,a18)
  711. Digits(2)=Array(a20,a21,a22,a23,a24,a25,a26,n,a28)
  712. Digits(3)=Array(a30,a31,a32,a33,a34,a35,a36,n,a38)
  713. Digits(4)=Array(a40,a41,a42,a43,a44,a45,a46,n,a48)
  714. Digits(5)=Array(a50,a51,a52,a53,a54,a55,a56,n,a58)
  715. Digits(6)=Array(b00,b01,b02,b03,b04,b05,b06,n,b08)
  716.  
  717. Digits(7)=Array(b10,b11,b12,b13,b14,b15,b16,n,b18)
  718. Digits(8)=Array(b20,b21,b22,b23,b24,b25,b26,n,b28)
  719. Digits(9)=Array(b30,b31,b32,b33,b34,b35,b36,n,b38)
  720. Digits(10)=Array(b40,b41,b42,b43,b44,b45,b46,n,b48)
  721. Digits(11)=Array(b50,b51,b52,b53,b54,b55,b56,n,b58)
  722. Digits(12)=Array(c00,c01,c02,c03,c04,c05,c06,n,c08)
  723. Digits(13)=Array(c10,c11,c12,c13,c14,c15,c16,n,c18)
  724.  
  725. Digits(14)=Array(c20,c21,c22,c23,c24,c25,c26,n,c28)
  726. Digits(15)=Array(c30,c31,c32,c33,c34,c35,c36,n,c38)
  727. Digits(16)=Array(c40,c41,c42,c43,c44,c45,c46,n,c48)
  728. Digits(17)=Array(c50,c51,c52,c53,c54,c55,c56,n,c58)
  729. Digits(18)=Array(d00,d01,d02,d03,d04,d05,d06,n,d08)
  730. Digits(19)=Array(d10,d11,d12,d13,d14,d15,d16,n,d18)
  731. Digits(20)=Array(d20,d21,d22,d23,d24,d25,d26,n,d28)
  732.  
  733. Digits(21)=Array(d30,d31,d32,d33,d34,d35,d36,n,d38)
  734. Digits(22)=Array(d40,d41,d42,d43,d44,d45,d46,n,d48)
  735. Digits(23)=Array(d50,d51,d52,d53,d54,d55,d56,n,d58)
  736. Digits(24)=Array(e00,e01,e02,e03,e04,e05,e06,n,e08)
  737. Digits(25)=Array(e10,e11,e12,e13,e14,e15,e16,n,e18)
  738. Digits(26)=Array(f00,f01,f02,f03,f04,f05,f06,n,f08)
  739. Digits(27)=Array(f10,f11,f12,f13,f14,f15,f16,n,f18)
  740.  
  741. 'credit -- Ball In Play
  742. Digits(28) = Array(e2,e3,e7,e4,e5,e1,e6,n,e23)
  743. Digits(29) = Array(e9,e17,e22,e19,e20,e8,e21,n,e24)
  744. Digits(30) = Array(f2,f3,f7,f4,f5,f1,f6,n,f23)
  745. Digits(31) = Array(f9,f17,f22,f19,f20,f8,f21,n,f24)
  746.  
  747.  
  748. Digits(32)=Array(d2,d3,d7,d4,d5,d1,d6,n,d62)
  749. Digits(33)=Array(d9,d17,d37,d19,d27,d8,d29,n,d63)
  750. Digits(34)=Array(d47,d49,d61,d57,d59,d39,d60,n,d64)
  751. Digits(35)=Array(e26,e27,e31,e28,e29,e25,e30,n,e39)
  752. Digits(36)=Array(e33,e34,e38,e35,e36,e32,e37,n,e40)
  753. Digits(37)=Array(f26,f27,f31,f28,f29,f25,f30,n,f39)
  754.  
  755.  
  756. Digits(38)=Array(f33,f34,f38,f35,f36,f32,f37,n,f40)
  757. Digits(39)=Array(d82,d83,d87,d84,d85,d81,d86,n,d85)
  758. Digits(40)=Array(d89,d90,d94,d91,d92,d88,d93,n,d96)
  759. Digits(41)=Array(e58,e59,e63,e60,e61,e57,e62,n,e71)
  760. Digits(42)=Array(e65,e66,e70,e67,e68,e64,e69,n,e72)
  761. Digits(43)=Array(f50,f51,f55,f52,f53,f49,f54,n,f56)
  762.  
  763.  
  764. Sub DisplayTimer_Timer
  765. Dim ChgLED,ii,num,chg,stat,obj
  766. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  767. If Not IsEmpty(ChgLED) Then
  768. If DesktopMode = True Then
  769. For ii = 0 To UBound(chgLED)
  770. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  771. if (num < 44) then
  772. For Each obj In Digits(num)
  773. If chg And 1 Then obj.State = stat And 1
  774. chg = chg\2 : stat = stat\2
  775. Next
  776. else
  777. 'if char(stat) > "" then msg(num) = char(stat)
  778. end if
  779. next
  780. end if
  781. end if
  782. End Sub
  783.  
  784. '**********************************************************************************************************
  785. ' VR Backglass Light Displays
  786. '**********************************************************************************************************
  787.  
  788. Dim xoff,yoff1, yoff2, yoff3, yoff4, yoff5,yoff6, yoff7, zoff,xrot,zscale, xcen,ycen
  789.  
  790. Sub setup_backglass()
  791.  
  792. xoff = -20
  793. yoff1 = 20 ' this is where you adjust the forward/backward position for player 1 score
  794. yoff2 = 20 ' this is where you adjust the forward/backward position for player 2 score
  795. yoff3 = 23 ' this is where you adjust the forward/backward position for player 3 score
  796. yoff4 = 23 ' this is where you adjust the forward/backward position for player 4 score
  797. yoff5 = 46 ' this is where you adjust the forward/backward position for credits and ball in play
  798. yoff6 = 42 ' this is where you adjust the forward/backward position for bonus
  799. yoff7 = 42 ' this is where you adjust the forward/backward position for multiball-bonus and multi-mode
  800. zoff = 699
  801. xrot = -90
  802.  
  803. center_Digits()
  804.  
  805. end sub
  806.  
  807. Sub center_Digits()
  808. Dim ix, xx, yy, yfact, xfact, xobj
  809.  
  810. zscale = 0.0000001
  811.  
  812. xcen = (130 /2) - (92 / 2)
  813. ycen = (780 /2 ) + (203 /2)
  814.  
  815. for ix = 0 to 6
  816. For Each xobj In vrDigits(ix)
  817.  
  818. xx = xobj.x
  819.  
  820. xobj.x = (xoff - xcen) + xx
  821. yy = xobj.y ' get the yoffset before it is changed
  822. xobj.y = yoff1
  823.  
  824. If (yy < 0.) then
  825. yy = yy * -1
  826. end if
  827.  
  828. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  829. xobj.rotx = xrot
  830. Next
  831. Next
  832.  
  833. for ix = 7 to 13
  834. For Each xobj In vrDigits(ix)
  835.  
  836. xx = xobj.x
  837.  
  838. xobj.x = (xoff - xcen) + xx
  839. yy = xobj.y ' get the yoffset before it is changed
  840. xobj.y = yoff2
  841.  
  842. If (yy < 0.) then
  843. yy = yy * -1
  844. end if
  845.  
  846. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  847. xobj.rotx = xrot
  848. Next
  849. Next
  850.  
  851. for ix = 14 to 20
  852. For Each xobj In vrDigits(ix)
  853.  
  854. xx = xobj.x
  855.  
  856. xobj.x = (xoff - xcen) + xx
  857. yy = xobj.y ' get the yoffset before it is changed
  858. xobj.y = yoff3
  859.  
  860. If (yy < 0.) then
  861. yy = yy * -1
  862. end if
  863.  
  864. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  865. xobj.rotx = xrot
  866. Next
  867. Next
  868.  
  869. for ix = 21 to 27
  870. For Each xobj In vrDigits(ix)
  871.  
  872. xx = xobj.x
  873.  
  874. xobj.x = (xoff - xcen) + xx
  875. yy = xobj.y ' get the yoffset before it is changed
  876. xobj.y = yoff4
  877.  
  878. If (yy < 0.) then
  879. yy = yy * -1
  880. end if
  881.  
  882. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  883. xobj.rotx = xrot
  884. Next
  885. Next
  886.  
  887. for ix = 28 to 31
  888. For Each xobj In vrDigits(ix)
  889.  
  890. xx = xobj.x
  891.  
  892. xobj.x = (xoff - xcen) + xx
  893. yy = xobj.y ' get the yoffset before it is changed
  894. xobj.y = yoff5
  895.  
  896. If (yy < 0.) then
  897. yy = yy * -1
  898. end if
  899.  
  900. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  901. xobj.rotx = xrot
  902. Next
  903. Next
  904.  
  905. for ix = 32 to 37
  906. For Each xobj In vrDigits(ix)
  907.  
  908. xx = xobj.x
  909.  
  910. xobj.x = (xoff - xcen) + xx
  911. yy = xobj.y ' get the yoffset before it is changed
  912. xobj.y = yoff6
  913.  
  914. If (yy < 0.) then
  915. yy = yy * -1
  916. end if
  917.  
  918. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  919. xobj.rotx = xrot
  920. Next
  921. Next
  922.  
  923. for ix = 38 to 43
  924. For Each xobj In vrDigits(ix)
  925.  
  926. xx = xobj.x
  927.  
  928. xobj.x = (xoff - xcen) + xx
  929. yy = xobj.y ' get the yoffset before it is changed
  930. xobj.y = yoff7
  931.  
  932. If (yy < 0.) then
  933. yy = yy * -1
  934. end if
  935.  
  936. xobj.height = (zoff - ycen) + yy - (yy * (zscale))
  937. xobj.rotx = xrot
  938. Next
  939. Next
  940.  
  941. end sub
  942.  
  943. Dim vrDigits(44)
  944. vrDigits(0) = Array(LED1x0,LED1x1,LED1x2,LED1x3,LED1x4,LED1x5,LED1x6,led1x7,led1x8)
  945. vrDigits(1) = Array(LED2x0,LED2x1,LED2x2,LED2x3,LED2x4,LED2x5,LED2x6,led2x7,led2x8)
  946. vrDigits(2) = Array(LED3x0,LED3x1,LED3x2,LED3x3,LED3x4,LED3x5,LED3x6,led3x7,led3x8)
  947. vrDigits(3) = Array(LED4x0,LED4x1,LED4x2,LED4x3,LED4x4,LED4x5,LED4x6,led4x7,led4x8)
  948. vrDigits(4) = Array(LED5x0,LED5x1,LED5x2,LED5x3,LED5x4,LED5x5,LED5x6,led5x7,led5x8)
  949. vrDigits(5) = Array(LED6x0,LED6x1,LED6x2,LED6x3,LED6x4,LED6x5,LED6x6,led6x7,led6x8)
  950. vrDigits(6) = Array(LED7x0,LED7x1,LED7x2,LED7x3,LED7x4,LED7x5,LED7x6,led7x7,led7x8)
  951.  
  952. vrDigits(7) = Array(LED8x0,LED8x1,LED8x2,LED8x3,LED8x4,LED8x5,LED8x6,led8x7,led8x8)
  953. vrDigits(8) = Array(LED9x0,LED9x1,LED9x2,LED9x3,LED9x4,LED9x5,LED9x6,led9x7,led9x8)
  954. vrDigits(9) = Array(LED10x0,LED10x1,LED10x2,LED10x3,LED10x4,LED10x5,LED10x6,led10x7,led10x8)
  955. vrDigits(10) = Array(LED11x0,LED11x1,LED11x2,LED11x3,LED11x4,LED11x5,LED11x6,led11x7,led11x8)
  956. vrDigits(11) = Array(LED12x0,LED12x1,LED12x2,LED12x3,LED12x4,LED12x5,LED12x6,led12x7,led12x8)
  957. vrDigits(12) = Array(LED13x0,LED13x1,LED13x2,LED13x3,LED13x4,LED13x5,LED13x6,led13x7,led13x8)
  958. vrDigits(13) = Array(LED14x0,LED14x1,LED14x2,LED14x3,LED14x4,LED14x5,LED14x6,led14x7,led14x8)
  959.  
  960. vrDigits(14) = Array(LED1x000,LED1x001,LED1x002,LED1x003,LED1x004,LED1x005,LED1x006,LED1x007,LED1x008)
  961. vrDigits(15) = Array(LED1x100,LED1x101,LED1x102,LED1x103,LED1x104,LED1x105,LED1x106,LED1x107,LED1x108)
  962. vrDigits(16) = Array(LED1x200,LED1x201,LED1x202,LED1x203,LED1x204,LED1x205,LED1x206,LED1x207,LED1x208)
  963. vrDigits(17) = Array(LED1x300,LED1x301,LED1x302,LED1x303,LED1x304,LED1x305,LED1x306,LED1x307,LED1x308)
  964. vrDigits(18) = Array(LED1x400,LED1x401,LED1x402,LED1x403,LED1x404,LED1x405,LED1x406,LED1x407,LED1x408)
  965. vrDigits(19) = Array(LED1x500,LED1x501,LED1x502,LED1x503,LED1x504,LED1x505,LED1x506,LED1x507,LED1x508)
  966. vrDigits(20) = Array(LED1x600,LED1x601,LED1x602,LED1x603,LED1x604,LED1x605,LED1x606,LED1x607,LED1x608)
  967.  
  968. vrDigits(21) = Array(LED2x000,LED2x001,LED2x002,LED2x003,LED2x004,LED2x005,LED2x006,led2x007,led2x008)
  969. vrDigits(22) = Array(LED2x100,LED2x101,LED2x102,LED2x103,LED2x104,LED2x105,LED2x106,led2x107,led2x108)
  970. vrDigits(23) = Array(LED2x200,LED2x201,LED2x202,LED2x203,LED2x204,LED2x205,LED2x206,led2x207,led2x208)
  971. vrDigits(24) = Array(LED2x300,LED2x301,LED2x302,LED2x303,LED2x304,LED2x305,LED2x306,led2x307,led2x308)
  972. vrDigits(25) = Array(LED2x400,LED2x401,LED2x402,LED2x403,LED2x404,LED2x405,LED2x406,led2x407,led2x408)
  973. vrDigits(26) = Array(LED2x500,LED2x501,LED2x502,LED2x503,LED2x504,LED2x505,LED2x506,led2x507,led2x508)
  974. vrDigits(27) = Array(LED2x600,LED2x601,LED2x602,LED2x603,LED2x604,LED2x605,LED2x606,led2x607,led2x608)
  975.  
  976. 'credit -- Ball In Play
  977. vrDigits(28) = Array(LEDax300,LEDax301,LEDax302,LEDax303,LEDax304,LEDax305,LEDax306)
  978. vrDigits(29) = Array(LEDbx400,LEDbx401,LEDbx402,LEDbx403,LEDbx404,LEDbx405,LEDbx406)
  979. vrDigits(30) = Array(LEDcx500,LEDcx501,LEDcx502,LEDcx503,LEDcx504,LEDcx505,LEDcx506)
  980. vrDigits(31) = Array(LEDdx600,LEDdx601,LEDdx602,LEDdx603,LEDdx604,LEDdx605,LEDdx606)
  981.  
  982. 'Bonus + Multiballbonus/-score
  983. vrDigits(32) = Array(LED3x000,LED3x001,LED3x002,LED3x003,LED3x004,LED3x005,LED3x006,LED3x007,LED3x008)
  984. vrDigits(33) = Array(LED3x100,LED3x101,LED3x102,LED3x103,LED3x104,LED3x105,LED3x106,LED3x107,LED3x108)
  985. vrDigits(34) = Array(LED3x200,LED3x201,LED3x202,LED3x203,LED3x204,LED3x205,LED3x206,LED3x207,LED3x208)
  986. vrDigits(35) = Array(LED3x300,LED3x301,LED3x302,LED3x303,LED3x304,LED3x305,LED3x306,LED3x307,LED3x308)
  987. vrDigits(36) = Array(LED3x400,LED3x401,LED3x402,LED3x403,LED3x404,LED3x405,LED3x406,LED3x407,LED3x408)
  988. vrDigits(37) = Array(LED3x500,LED3x501,LED3x502,LED3x503,LED3x504,LED3x505,LED3x506,LED3x507,LED3x508)
  989.  
  990. vrDigits(38) = Array(LED4x000,LED4x001,LED4x002,LED4x003,LED4x004,LED4x005,LED4x006,LED4x007,LED4x008)
  991. vrDigits(39) = Array(LED4x100,LED4x101,LED4x102,LED4x103,LED4x104,LED4x105,LED4x106,LED4x107,LED4x108)
  992. vrDigits(40) = Array(LED4x200,LED4x201,LED4x202,LED4x203,LED4x204,LED4x205,LED4x206,LED4x207,LED4x208)
  993. vrDigits(41) = Array(LED4x300,LED4x301,LED4x302,LED4x303,LED4x304,LED4x305,LED4x306,LED4x307,LED4x308)
  994. vrDigits(42) = Array(LED4x400,LED4x401,LED4x402,LED4x403,LED4x404,LED4x405,LED4x406,LED4x407,LED4x408)
  995. vrDigits(43) = Array(LED4x500,LED4x501,LED4x502,LED4x503,LED4x504,LED4x505,LED4x506,LED4x507,LED4x508)
  996.  
  997. dim DisplayColor, DisplayColorW
  998.  
  999. 'DisplayColor = RGB(0,255,30) 'Green
  1000. DisplayColor = RGB(255,40,1) 'Red
  1001. DisplayColorW = RGB(255,255,255) 'White
  1002.  
  1003.  
  1004. Sub vrDisplayTimer
  1005. Dim ChgLED, ii, jj, num, chg, stat, obj, b, x
  1006. ChgLED=Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  1007. If Not IsEmpty(ChgLED)Then
  1008. For ii=0 To UBound(chgLED)
  1009. num=chgLED(ii, 0) : chg=chgLED(ii, 1) : stat=chgLED(ii, 2)
  1010. For Each obj In vrDigits(num)
  1011. If chg And 1 Then obj.visible=stat And 1 'if you use the object color for off; turn the display object visible to not visible on the playfield, and uncomment this line out.
  1012. If chg And 1 Then FadeDisplay obj, stat And 1
  1013. chg=chg\2 : stat=stat\2
  1014. Next
  1015. Next
  1016. End If
  1017. End Sub
  1018.  
  1019. Sub FadeDisplay(object, onoff)
  1020.  
  1021. Dim ix
  1022. If OnOff = 1 Then
  1023. For ix = 0 to 31
  1024. For Each Object In vrDigits(ix)
  1025. Object.color = DisplayColor
  1026. Object.Opacity = 8 ' Use 12 if red, 8 if green... looks better.
  1027. Next
  1028. Next
  1029. For ix = 32 to 43
  1030. For Each Object In vrDigits(ix)
  1031. Object.color = DisplayColorW
  1032. Object.Opacity = 8 ' Use 12 if red, 8 if green... looks better.
  1033. Next
  1034. Next
  1035. Else
  1036. Object.Color = RGB(1,1,1)
  1037. Object.Opacity = 6
  1038. End If
  1039. End Sub
  1040.  
  1041. Sub InitDigits()
  1042. dim tmp, x, obj
  1043. for x = 0 to uBound(vrDigits)
  1044. if IsArray(vrDigits(x) ) then
  1045. For each obj in vrDigits(x)
  1046. obj.height = obj.height + 18
  1047. FadeDisplay obj, 0
  1048. next
  1049. end If
  1050. Next
  1051. End Sub
  1052.  
  1053. InitDigits
  1054.  
  1055.  
  1056.  
  1057. '**********************************************************************************************************
  1058. '**********************************************************************************************************
  1059. 'Gottlieb Devils Dare
  1060. 'added by Inkochnito
  1061. Sub editDips
  1062. Dim vpmDips : Set vpmDips = New cvpmDips
  1063. With vpmDips
  1064. .AddForm 700,400,"Devils Dare - DIP switches"
  1065. .AddChk 7,10,100,Array("Match feature",&H02000000)'dip 26
  1066. .AddChkExtra 110,10,100,Array("Speech",&H0020)'SS-board dip 6
  1067. .AddChkExtra 220,10,110,Array("Background sound",&H0010)'SS-board dip 5
  1068. .AddFrame 2,30,190,"Maximum credits",49152,Array("8 credits",0,"10 credits",32768,"15 credits",&H00004000,"25 credits",49152)'dip 15&16
  1069. .AddFrame 2,106,190,"Coin chute 1 and 2 control",&H00002000,Array("seperate",0,"same",&H00002000)'dip 14
  1070. .AddFrame 2,152,190,"Playfield special",&H00200000,Array("replay",0,"extra ball",&H00200000)'dip 22
  1071. .AddFrame 2,198,190,"3rd coin chute credits control",&H20000000,Array("no effect",0,"add 9",&H20000000)'dip 30
  1072. .AddFrame 2,244,190,"High score to date awards",&H00C00000,Array("not displayed and no award",0,"displayed and no award",&H00800000,"displayed and 2 credits",&H00400000,"displayed and 3 credits",&H00C00000)'dip 23&24
  1073. .AddFrameExtra 205,30,190,"Attract Sound",&H000C,Array("off",0,"every 10 seconds",&H0004,"every 2 minutes",&H0008,"every 4 minutes",&H000C)'sounddip 3&4
  1074. .AddFrame 205,106,190,"Balls per game",&H01000000,Array("5 balls",0,"3 balls",&H01000000)'dip 25
  1075. .AddFrame 205,152,190,"Replay limit",&H04000000,Array("no limit",0,"one per ball",&H04000000)'dip 27
  1076. .AddFrame 205,198,190,"Novelty mode",&H08000000,Array("normal game mode",0,"50,000 points per special/extra ball",&H08000000)'dip 28
  1077. .AddFrame 205,244,190,"Game mode",&H10000000,Array("replay",0,"extra ball",&H10000000)'dip 29
  1078. .AddLabel 50,325,300,20,"After hitting OK, press F3 to reset game with new settings."
  1079. End With
  1080. Dim extra
  1081. extra = Controller.Dip(4) + Controller.Dip(5)*256
  1082. extra = vpmDips.ViewDipsExtra(extra)
  1083. Controller.Dip(4) = extra And 255
  1084. Controller.Dip(5) = (extra And 65280)\256 And 255
  1085. End Sub
  1086. Set vpmShowDips = GetRef("editDips")
  1087.  
  1088. '******************************************************
  1089. ' BALL ROLLING AND DROP SOUNDS
  1090. '******************************************************
  1091.  
  1092. Const tnob = 5 ' total number of balls
  1093. ReDim rolling(tnob)
  1094. InitRolling
  1095.  
  1096. Dim DropCount
  1097. ReDim DropCount(tnob)
  1098.  
  1099. Sub InitRolling
  1100. Dim i
  1101. For i = 0 to tnob
  1102. rolling(i) = False
  1103. Next
  1104. End Sub
  1105.  
  1106. Sub RollingTimer_Timer()
  1107. Dim BOT, b
  1108. BOT = GetBalls
  1109.  
  1110. ' stop the sound of deleted balls
  1111. For b = UBound(BOT) + 1 to tnob
  1112. rolling(b) = False
  1113. StopSound("BallRoll_" & b)
  1114. Next
  1115.  
  1116. ' exit the sub if no balls on the table
  1117. If UBound(BOT) = -1 Then Exit Sub
  1118.  
  1119. ' play the rolling sound for each ball
  1120.  
  1121. For b = 0 to UBound(BOT)
  1122. If BallVel(BOT(b)) > 1 AND BOT(b).z < 30 Then
  1123. rolling(b) = True
  1124. PlaySound ("BallRoll_" & b), -1, VolPlayfieldRoll(BOT(b)) * 1.1 * VolumeDial, AudioPan(BOT(b)), 0, PitchPlayfieldRoll(BOT(b)), 1, 0, AudioFade(BOT(b))
  1125.  
  1126. Else
  1127. If rolling(b) = True Then
  1128. StopSound("BallRoll_" & b)
  1129. rolling(b) = False
  1130. End If
  1131. End If
  1132.  
  1133. '***Ball Drop Sounds***
  1134. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  1135. If DropCount(b) >= 5 Then
  1136. DropCount(b) = 0
  1137. If BOT(b).velz > -7 Then
  1138. RandomSoundBallBouncePlayfieldSoft BOT(b)
  1139. Else
  1140. RandomSoundBallBouncePlayfieldHard BOT(b)
  1141. End If
  1142. End If
  1143. End If
  1144. If DropCount(b) < 5 Then
  1145. DropCount(b) = DropCount(b) + 1
  1146. End If
  1147. Next
  1148. End Sub
  1149.  
  1150.  
  1151. '*****************************************
  1152. ' ninuzzu's FLIPPER SHADOWS
  1153. '*****************************************
  1154.  
  1155. sub FlipperTimer_Timer()
  1156. FlipperLSh.RotZ = LeftFlipper.currentangle
  1157. FlipperRSh.RotZ = RightFlipper.currentangle
  1158. If Vruser=1 Then
  1159. vrDisplayTimer
  1160. End If
  1161. 'Primitive Flipper
  1162.  
  1163. FlipperT1.roty = LeftFlipper.currentangle + 237
  1164. FlipperT5.roty = RightFlipper.currentangle + 120
  1165. FlipperT2.roty = RightFlipper1.currentangle + 180
  1166. End Sub
  1167.  
  1168. '*****************************************
  1169. ' ninuzzu's BALL SHADOW
  1170. '*****************************************
  1171.  
  1172. Dim BallShadow
  1173. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  1174.  
  1175. Sub BallShadowUpdate_timer()
  1176. Dim BOT, b
  1177. BOT = GetBalls
  1178. ' hide shadow of deleted balls
  1179. If UBound(BOT)<(tnob-1) Then
  1180. For b = (UBound(BOT) + 1) to (tnob-1)
  1181. BallShadow(b).visible = 0
  1182. Next
  1183. End If
  1184. ' exit the Sub if no balls on the table
  1185. If UBound(BOT) = -1 Then Exit Sub
  1186. ' render the shadow for each ball
  1187. For b = 0 to UBound(BOT)
  1188. If BOT(b).X < Table1.Width/2 Then
  1189. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) + 6
  1190. Else
  1191. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) - 6
  1192. End If
  1193. ballShadow(b).Y = BOT(b).Y + 4
  1194. If BOT(b).Z > 20 Then
  1195. BallShadow(b).visible = 1
  1196. Else
  1197. BallShadow(b).visible = 0
  1198. End If
  1199. Next
  1200. End Sub
  1201.  
  1202. '******************************************************
  1203. ' FLIPPER CORRECTION INITIALIZATION
  1204. ' Start nFOZZY FLIPPERS'
  1205. '******************************************************
  1206.  
  1207. 'Flipper Correction Initialization late 80’s to early 90’s
  1208. dim LF : Set LF = New FlipperPolarity
  1209. dim RF : Set RF = New FlipperPolarity
  1210.  
  1211. InitPolarity
  1212.  
  1213. ''*******************************************
  1214. '' Late 70's to early 80's
  1215. '
  1216. Sub InitPolarity()
  1217. dim x, a : a = Array(LF, RF)
  1218. for each x in a
  1219. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  1220. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  1221. x.enabled = True
  1222. x.TimeDelay = 80
  1223. Next
  1224.  
  1225. AddPt "Polarity", 0, 0, 0
  1226. AddPt "Polarity", 1, 0.05, -2.7
  1227. AddPt "Polarity", 2, 0.33, -2.7
  1228. AddPt "Polarity", 3, 0.37, -2.7
  1229. AddPt "Polarity", 4, 0.41, -2.7
  1230. AddPt "Polarity", 5, 0.45, -2.7
  1231. AddPt "Polarity", 6, 0.576,-2.7
  1232. AddPt "Polarity", 7, 0.66, -1.8
  1233. AddPt "Polarity", 8, 0.743, -0.5
  1234. AddPt "Polarity", 9, 0.81, -0.5
  1235. AddPt "Polarity", 10, 0.88, 0
  1236.  
  1237. addpt "Velocity", 0, 0, 1
  1238. addpt "Velocity", 1, 0.16, 1.06
  1239. addpt "Velocity", 2, 0.41, 1.05
  1240. addpt "Velocity", 3, 0.53, 1'0.982
  1241. addpt "Velocity", 4, 0.702, 0.968
  1242. addpt "Velocity", 5, 0.95, 0.968
  1243. addpt "Velocity", 6, 1.03, 0.945
  1244.  
  1245. LF.Object = LeftFlipper
  1246. LF.EndPoint = EndPointLp
  1247. RF.Object = RightFlipper
  1248. RF.EndPoint = EndPointRp
  1249. End Sub
  1250.  
  1251. Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
  1252. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : End Sub
  1253. Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
  1254. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub
  1255.  
  1256. '******************************************************
  1257. ' FLIPPER CORRECTION FUNCTIONS
  1258. '******************************************************
  1259.  
  1260. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  1261. dim a : a = Array(LF, RF)
  1262. dim x : for each x in a
  1263. x.addpoint aStr, idx, aX, aY
  1264. Next
  1265. End Sub
  1266.  
  1267. Class FlipperPolarity
  1268. Public DebugOn, Enabled
  1269. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  1270. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  1271. private Flipper, FlipperStart,FlipperEnd, FlipperEndY, LR, PartialFlipCoef
  1272. Private Balls(20), balldata(20)
  1273.  
  1274. dim PolarityIn, PolarityOut
  1275. dim VelocityIn, VelocityOut
  1276. dim YcoefIn, YcoefOut
  1277. Public Sub Class_Initialize
  1278. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  1279. Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
  1280. End Sub
  1281.  
  1282. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  1283. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  1284. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  1285. Public Property Let EndPoint(aInput) : FlipperEnd = aInput.x: FlipperEndY = aInput.y: End Property
  1286. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  1287. Public Property Get EndPointY: EndPointY = FlipperEndY : End Property
  1288.  
  1289. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  1290. Select Case aChooseArray
  1291. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  1292. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  1293. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  1294. End Select
  1295. if gametime > 100 then Report aChooseArray
  1296. End Sub
  1297.  
  1298. Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
  1299. if not DebugOn then exit sub
  1300. dim a1, a2 : Select Case aChooseArray
  1301. case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
  1302. Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
  1303. Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
  1304. case else :tbpl.text = "wrong string" : exit sub
  1305. End Select
  1306. dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1307. tbpl.text = str
  1308. End Sub
  1309.  
  1310. Public Sub AddBall(aBall) : dim x : for x = 0 to uBound(balls) : if IsEmpty(balls(x)) then set balls(x) = aBall : exit sub :end if : Next : End Sub
  1311.  
  1312. Private Sub RemoveBall(aBall)
  1313. dim x : for x = 0 to uBound(balls)
  1314. if TypeName(balls(x) ) = "IBall" then
  1315. if aBall.ID = Balls(x).ID Then
  1316. balls(x) = Empty
  1317. Balldata(x).Reset
  1318. End If
  1319. End If
  1320. Next
  1321. End Sub
  1322.  
  1323. Public Sub Fire()
  1324. Flipper.RotateToEnd
  1325. processballs
  1326. End Sub
  1327.  
  1328. Public Property Get Pos 'returns % position a ball. For debug stuff.
  1329. dim x : for x = 0 to uBound(balls)
  1330. if not IsEmpty(balls(x) ) then
  1331. pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
  1332. End If
  1333. Next
  1334. End Property
  1335.  
  1336. Public Sub ProcessBalls() 'save data of balls in flipper range
  1337. FlipAt = GameTime
  1338. dim x : for x = 0 to uBound(balls)
  1339. if not IsEmpty(balls(x) ) then
  1340. balldata(x).Data = balls(x)
  1341. End If
  1342. Next
  1343. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
  1344. PartialFlipCoef = abs(PartialFlipCoef-1)
  1345. End Sub
  1346. Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
  1347.  
  1348. Public Sub PolarityCorrect(aBall)
  1349. if FlipperOn() then
  1350. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  1351.  
  1352. 'y safety Exit
  1353. if aBall.VelY > -8 then 'ball going down
  1354. RemoveBall aBall
  1355. exit Sub
  1356. end if
  1357.  
  1358. 'Find balldata. BallPos = % on Flipper
  1359. for x = 0 to uBound(Balls)
  1360. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  1361. idx = x
  1362. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  1363. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1364. end if
  1365. Next
  1366.  
  1367. If BallPos = 0 Then 'no ball data meaning the ball is entering and exiting pretty close to the same position, use current values.
  1368. BallPos = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  1369. if ballpos > 0.65 then Ycoef = LinearEnvelope(aBall.Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1370. End If
  1371.  
  1372. 'Velocity correction
  1373. if not IsEmpty(VelocityIn(0) ) then
  1374. Dim VelCoef
  1375. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  1376.  
  1377. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  1378.  
  1379. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  1380. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  1381. End If
  1382.  
  1383. 'Polarity Correction (optional now)
  1384. if not IsEmpty(PolarityIn(0) ) then
  1385. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  1386. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  1387.  
  1388. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  1389. 'playsound "fx_knocker"
  1390. End If
  1391. End If
  1392. RemoveBall aBall
  1393. End Sub
  1394. End Class
  1395.  
  1396. '******************************************************
  1397. ' FLIPPER POLARITY AND RUBBER DAMPENER
  1398. ' SUPPORTING FUNCTIONS
  1399. '******************************************************
  1400.  
  1401. ' Used for flipper correction and rubber dampeners
  1402. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  1403. dim x, aCount : aCount = 0
  1404. redim a(uBound(aArray) )
  1405. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  1406. if not IsEmpty(aArray(x) ) Then
  1407. if IsObject(aArray(x)) then
  1408. Set a(aCount) = aArray(x)
  1409. Else
  1410. a(aCount) = aArray(x)
  1411. End If
  1412. aCount = aCount + 1
  1413. End If
  1414. Next
  1415. if offset < 0 then offset = 0
  1416. redim aArray(aCount-1+offset) 'Resize original array
  1417. for x = 0 to aCount-1 'set objects back into original array
  1418. if IsObject(a(x)) then
  1419. Set aArray(x) = a(x)
  1420. Else
  1421. aArray(x) = a(x)
  1422. End If
  1423. Next
  1424. End Sub
  1425.  
  1426. ' Used for flipper correction and rubber dampeners
  1427. Sub ShuffleArrays(aArray1, aArray2, offset)
  1428. ShuffleArray aArray1, offset
  1429. ShuffleArray aArray2, offset
  1430. End Sub
  1431.  
  1432. ' Used for flipper correction, rubber dampeners, and drop targets
  1433. Function BallSpeed(ball) 'Calculates the ball speed
  1434. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  1435. End Function
  1436.  
  1437. ' Used for flipper correction and rubber dampeners
  1438. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  1439. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  1440. Y = M*x+b
  1441. PSlope = Y
  1442. End Function
  1443.  
  1444. ' Used for flipper correction
  1445. Class spoofball
  1446. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  1447. Public Property Let Data(aBall)
  1448. With aBall
  1449. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  1450. id = .ID : mass = .mass : radius = .radius
  1451. end with
  1452. End Property
  1453. Public Sub Reset()
  1454. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  1455. id = Empty : mass = Empty : radius = Empty
  1456. End Sub
  1457. End Class
  1458.  
  1459. ' Used for flipper correction and rubber dampeners
  1460. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  1461. dim y 'Y output
  1462. dim L 'Line
  1463. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  1464. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  1465. Next
  1466. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  1467. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  1468.  
  1469. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  1470. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  1471.  
  1472. LinearEnvelope = Y
  1473. End Function
  1474.  
  1475. ' Used for drop targets and stand up targets
  1476. Function Atn2(dy, dx)
  1477. dim pi
  1478. pi = 4*Atn(1)
  1479.  
  1480. If dx > 0 Then
  1481. Atn2 = Atn(dy / dx)
  1482. ElseIf dx < 0 Then
  1483. If dy = 0 Then
  1484. Atn2 = pi
  1485. Else
  1486. Atn2 = Sgn(dy) * (pi - Atn(Abs(dy / dx)))
  1487. end if
  1488. ElseIf dx = 0 Then
  1489. if dy = 0 Then
  1490. Atn2 = 0
  1491. else
  1492. Atn2 = Sgn(dy) * pi / 2
  1493. end if
  1494. End If
  1495. End Function
  1496.  
  1497. ' Used for drop targets and flipper tricks
  1498. Function Distance(ax,ay,bx,by)
  1499. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1500. End Function
  1501.  
  1502. '******************************************************
  1503. ' FLIPPER TRICKS
  1504. '******************************************************
  1505.  
  1506. RightFlipper.timerinterval=1
  1507. Rightflipper.timerenabled=True
  1508.  
  1509. sub RightFlipper_timer()
  1510. FlipperTricks LeftFlipper, LFPress, LFCount, LFEndAngle, LFState
  1511. FlipperTricks RightFlipper, RFPress, RFCount, RFEndAngle, RFState
  1512. FlipperNudge RightFlipper, RFEndAngle, RFEOSNudge, LeftFlipper, LFEndAngle
  1513. FlipperNudge LeftFlipper, LFEndAngle, LFEOSNudge, RightFlipper, RFEndAngle
  1514. end sub
  1515.  
  1516. Dim LFEOSNudge, RFEOSNudge
  1517.  
  1518. Sub FlipperNudge(Flipper1, Endangle1, EOSNudge1, Flipper2, EndAngle2)
  1519. Dim BOT, b
  1520.  
  1521. If abs(Flipper1.currentangle) < abs(Endangle1) + 3 and EOSNudge1 <> 1 Then
  1522. EOSNudge1 = 1
  1523. If Flipper2.currentangle = EndAngle2 Then
  1524. BOT = GetBalls
  1525. For b = 0 to Ubound(BOT)
  1526. If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper1) Then
  1527. 'Debug.Print "ball in flip1. exit"
  1528. exit Sub
  1529. end If
  1530. Next
  1531. For b = 0 to Ubound(BOT)
  1532. If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper2) Then
  1533. 'debug.print "flippernudge!!"
  1534. BOT(b).velx = BOT(b).velx /1.5
  1535. BOT(b).vely = BOT(b).vely - 1
  1536. end If
  1537. Next
  1538. End If
  1539. Else
  1540. If abs(Flipper1.currentangle) > abs(Endangle1) + 30 then EOSNudge1 = 0
  1541. End If
  1542. End Sub
  1543.  
  1544. '*****************
  1545. ' Maths
  1546. '*****************
  1547. Const Pi = 3.1415927
  1548.  
  1549. Function dSin(degrees)
  1550. dsin = sin(degrees * Pi/180)
  1551. End Function
  1552.  
  1553. Function dCos(degrees)
  1554. dcos = cos(degrees * Pi/180)
  1555. End Function
  1556.  
  1557.  
  1558. '*************************************************
  1559. ' Check ball distance from Flipper for Rem
  1560. '*************************************************
  1561.  
  1562. Function Distance(ax,ay,bx,by)
  1563. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1564. End Function
  1565.  
  1566. Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
  1567. DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
  1568. End Function
  1569.  
  1570. Function Radians(Degrees)
  1571. Radians = Degrees * PI /180
  1572. End Function
  1573.  
  1574. Function AnglePP(ax,ay,bx,by)
  1575. AnglePP = Atn2((by - ay),(bx - ax))*180/PI
  1576. End Function
  1577.  
  1578. Function DistanceFromFlipper(ballx, bally, Flipper)
  1579. DistanceFromFlipper = DistancePL(ballx, bally, Flipper.x, Flipper.y, Cos(Radians(Flipper.currentangle+90))+Flipper.x, Sin(Radians(Flipper.currentangle+90))+Flipper.y)
  1580. End Function
  1581.  
  1582. Function FlipperTrigger(ballx, bally, Flipper)
  1583. Dim DiffAngle
  1584. DiffAngle = ABS(Flipper.currentangle - AnglePP(Flipper.x, Flipper.y, ballx, bally) - 90)
  1585. If DiffAngle > 180 Then DiffAngle = DiffAngle - 360
  1586.  
  1587. If DistanceFromFlipper(ballx,bally,Flipper) < 48 and DiffAngle <= 90 and Distance(ballx,bally,Flipper.x,Flipper.y) < Flipper.Length Then
  1588. FlipperTrigger = True
  1589. Else
  1590. FlipperTrigger = False
  1591. End If
  1592. End Function
  1593.  
  1594. '*************************************************
  1595. ' End - Check ball distance from Flipper for Rem
  1596. '*************************************************
  1597.  
  1598.  
  1599.  
  1600. dim LFPress, RFPress, LFCount, RFCount
  1601. dim LFState, RFState
  1602. dim EOST, EOSA,Frampup, FElasticity,FReturn
  1603. dim RFEndAngle, LFEndAngle
  1604.  
  1605. EOST = leftflipper.eostorque
  1606. EOSA = leftflipper.eostorqueangle
  1607. Frampup = LeftFlipper.rampup
  1608. FElasticity = LeftFlipper.elasticity
  1609. FReturn = LeftFlipper.return
  1610. Const EOSTnew = 1 '0.8
  1611. Const EOSAnew = 1
  1612. Const EOSRampup = 0
  1613. Dim SOSRampup
  1614. Select Case FlipperCoilRampupMode
  1615. Case 0:
  1616. SOSRampup = 2.5
  1617. Case 1:
  1618. SOSRampup = 4.5
  1619. Case 2:
  1620. SOSRampup = 8.5
  1621. End Select
  1622. Const LiveCatch = 16
  1623. Const LiveElasticity = 0.45
  1624. Const SOSEM = 0.815
  1625. Const EOSReturn = 0.035 '0.025
  1626.  
  1627.  
  1628. LFEndAngle = Leftflipper.endangle
  1629. RFEndAngle = RightFlipper.endangle
  1630.  
  1631. Sub FlipperActivate(Flipper, FlipperPress)
  1632. FlipperPress = 1
  1633. Flipper.Elasticity = FElasticity
  1634.  
  1635. Flipper.eostorque = EOST
  1636. Flipper.eostorqueangle = EOSA
  1637. End Sub
  1638.  
  1639. Sub FlipperDeactivate(Flipper, FlipperPress)
  1640. FlipperPress = 0
  1641. Flipper.eostorqueangle = EOSA
  1642. Flipper.eostorque = EOST*EOSReturn/FReturn
  1643.  
  1644.  
  1645. If Abs(Flipper.currentangle) <= Abs(Flipper.endangle) + 0.1 Then
  1646. Dim BOT, b
  1647. BOT = GetBalls
  1648.  
  1649. For b = 0 to UBound(BOT)
  1650. If Distance(BOT(b).x, BOT(b).y, Flipper.x, Flipper.y) < 55 Then 'check for cradle
  1651. If BOT(b).vely >= -0.4 Then BOT(b).vely = -0.4
  1652. End If
  1653. Next
  1654. End If
  1655. End Sub
  1656.  
  1657. Sub FlipperTricks (Flipper, FlipperPress, FCount, FEndAngle, FState)
  1658. Dim Dir
  1659. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1660.  
  1661. If Abs(Flipper.currentangle) > Abs(Flipper.startangle) - 0.05 Then
  1662. If FState <> 1 Then
  1663. Flipper.rampup = SOSRampup
  1664. Flipper.endangle = FEndAngle - 3*Dir
  1665. Flipper.Elasticity = FElasticity * SOSEM
  1666. FCount = 0
  1667. FState = 1
  1668. End If
  1669. ElseIf Abs(Flipper.currentangle) <= Abs(Flipper.endangle) and FlipperPress = 1 then
  1670. if FCount = 0 Then FCount = GameTime
  1671.  
  1672. If FState <> 2 Then
  1673. Flipper.eostorqueangle = EOSAnew
  1674. Flipper.eostorque = EOSTnew
  1675. Flipper.rampup = EOSRampup
  1676. Flipper.endangle = FEndAngle
  1677. FState = 2
  1678. End If
  1679. Elseif Abs(Flipper.currentangle) > Abs(Flipper.endangle) + 0.01 and FlipperPress = 1 Then
  1680. If FState <> 3 Then
  1681. Flipper.eostorque = EOST
  1682. Flipper.eostorqueangle = EOSA
  1683. Flipper.rampup = Frampup
  1684. Flipper.Elasticity = FElasticity
  1685. FState = 3
  1686. End If
  1687.  
  1688. End If
  1689. End Sub
  1690.  
  1691. Const LiveDistanceMin = 30 'minimum distance in vp units from flipper base live catch dampening will occur
  1692. Const LiveDistanceMax = 117 'maximum distance in vp units from flipper base live catch dampening will occur (tip protection)
  1693.  
  1694. Sub CheckLiveCatch(ball, Flipper, FCount, parm) 'Experimental new live catch
  1695. Dim Dir
  1696. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1697. Dim LiveCatchBounce 'If live catch is not perfect, it won't freeze ball totally
  1698. Dim CatchTime : CatchTime = GameTime - FCount
  1699.  
  1700. if CatchTime <= LiveCatch and parm > 6 and ABS(Flipper.x - ball.x) > LiveDistanceMin and ABS(Flipper.x - ball.x) < LiveDistanceMax Then
  1701. if CatchTime <= LiveCatch*0.8 Then 'Perfect catch only when catch time happens in the beginning of the window
  1702. LiveCatchBounce = 0
  1703. else
  1704. LiveCatchBounce = Abs((LiveCatch/2) - CatchTime) 'Partial catch when catch happens a bit late
  1705. end If
  1706.  
  1707. 'debug.print "Live catch! Bounce: " & LiveCatchBounce
  1708.  
  1709. If LiveCatchBounce = 0 and ball.velx * Dir > 0 Then ball.velx = 0
  1710. ball.vely = LiveCatchBounce * (16 / LiveCatch) ' Multiplier for inaccuracy bounce
  1711. ball.angmomx= 0
  1712. ball.angmomy= 0
  1713. ball.angmomz= 0
  1714. End If
  1715. End Sub
  1716.  
  1717. '*****************************************************************************************************
  1718. 'END nFOZZY FLIPPERS'
  1719.  
  1720.  
  1721. 'PHYSICS DAMPENERS
  1722.  
  1723. 'These are data mined bounce curves,
  1724. 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
  1725. 'Requires tracking ballspeed to calculate COR
  1726.  
  1727. Sub dPosts_Hit(idx)
  1728. RubbersD.dampen Activeball
  1729. End Sub
  1730.  
  1731. Sub dSleeves_Hit(idx)
  1732. SleevesD.Dampen Activeball
  1733. End Sub
  1734.  
  1735.  
  1736. dim RubbersD : Set RubbersD = new Dampener 'frubber
  1737. RubbersD.name = "Rubbers"
  1738. RubbersD.debugOn = False 'shows info in textbox "TBPout"
  1739. RubbersD.Print = False 'debug, reports in debugger (in vel, out cor)
  1740. 'cor bounce curve (linear)
  1741. 'for best results, try to match in-game velocity as closely as possible to the desired curve
  1742. 'RubbersD.addpoint 0, 0, 0.935 'point# (keep sequential), ballspeed, CoR (elasticity)
  1743. RubbersD.addpoint 0, 0, 0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
  1744. RubbersD.addpoint 1, 3.77, 0.96
  1745. RubbersD.addpoint 2, 5.76, 0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
  1746. RubbersD.addpoint 3, 15.84, 0.874
  1747. RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
  1748.  
  1749. dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
  1750. SleevesD.name = "Sleeves"
  1751. SleevesD.debugOn = False 'shows info in textbox "TBPout"
  1752. SleevesD.Print = False 'debug, reports in debugger (in vel, out cor)
  1753. SleevesD.CopyCoef RubbersD, 0.85
  1754.  
  1755. Class Dampener
  1756. Public Print, debugOn 'tbpOut.text
  1757. public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
  1758. Public ModIn, ModOut
  1759. Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
  1760.  
  1761. Public Sub AddPoint(aIdx, aX, aY)
  1762. ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
  1763. if gametime > 100 then Report
  1764. End Sub
  1765.  
  1766. public sub Dampen(aBall)
  1767. if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
  1768. dim RealCOR, DesiredCOR, str, coef
  1769. DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
  1770. RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
  1771. coef = desiredcor / realcor
  1772. if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
  1773. "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
  1774. if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)
  1775.  
  1776. aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
  1777. if debugOn then TBPout.text = str
  1778. End Sub
  1779.  
  1780. Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
  1781. dim x : for x = 0 to uBound(aObj.ModIn)
  1782. addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
  1783. Next
  1784. End Sub
  1785.  
  1786.  
  1787. Public Sub Report() 'debug, reports all coords in tbPL.text
  1788. if not debugOn then exit sub
  1789. dim a1, a2 : a1 = ModIn : a2 = ModOut
  1790. dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1791. TBPout.text = str
  1792. End Sub
  1793.  
  1794.  
  1795. End Class
  1796.  
  1797. '******************************************************
  1798. ' TRACK ALL BALL VELOCITIES
  1799. ' FOR RUBBER DAMPENER AND DROP TARGETS
  1800. '******************************************************
  1801.  
  1802. dim cor : set cor = New CoRTracker
  1803.  
  1804. Class CoRTracker
  1805.  
  1806. public ballvel, ballvelx, ballvely
  1807.  
  1808. Private Sub Class_Initialize : redim ballvel(0) : redim ballvelx(0): redim ballvely(0) : End Sub
  1809.  
  1810. Public Sub Update() 'tracks in-ball-velocity
  1811. dim str, b, AllBalls, highestID : allBalls = getballs
  1812.  
  1813. for each b in allballs
  1814. if b.id >= HighestID then highestID = b.id
  1815. Next
  1816.  
  1817. if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
  1818. if uBound(ballvelx) < highestID then redim ballvelx(highestID) 'set bounds
  1819. if uBound(ballvely) < highestID then redim ballvely(highestID) 'set bounds
  1820.  
  1821. for each b in allballs
  1822. ballvel(b.id) = BallSpeed(b)
  1823. ballvelx(b.id) = b.velx
  1824. ballvely(b.id) = b.vely
  1825. Next
  1826. End Sub
  1827. End Class
  1828.  
  1829.  
  1830. Sub RDampen_Timer()
  1831. Cor.Update
  1832. End Sub
  1833.  
  1834. '******************************************************
  1835. ' TargetBouncer for targets and posts by Iaakki, Wrd1972, Apophis
  1836. '******************************************************
  1837.  
  1838. sub TargetBouncer(aBall,defvalue)
  1839. dim zMultiplier, vel, vratio
  1840. if TargetBouncerEnabled <> 0 and aball.z < 30 then
  1841. 'debug.print "velx: " & aball.velx & " vely: " & aball.vely & " velz: " & aball.velz
  1842. vel = BallSpeed(aBall)
  1843. If aball.velx=0 then vratio=1 else vratio= aball.vely/aball.velx
  1844. Select Case Int(Rnd * 6) + 1
  1845. Case 1: zMultiplier = 0.1*defvalue
  1846. Case 2: zMultiplier = 0.2*defvalue
  1847. Case 3: zMultiplier = 0.3*defvalue
  1848. Case 4: zMultiplier = 0.4*defvalue
  1849. Case 5: zMultiplier = 0.5*defvalue
  1850. Case 6: zMultiplier = 0.6*defvalue
  1851. End Select
  1852. aBall.velz = abs(vel * zMultiplier * TargetBouncerFactor)
  1853. aBall.velx = sgn(aBall.velx) * sqr(abs((vel^2 - aBall.velz^2)/(1+vratio^2)))
  1854. aBall.vely = aBall.velx * vratio
  1855. 'debug.print "---> velx: " & aball.velx & " vely: " & aball.vely & " velz: " & aball.velz
  1856. 'debug.print "conservation check: " & BallSpeed(aBall)/vel
  1857. end if
  1858. end sub
  1859.  
  1860. '//////////////////////////// MECHANICAL SOUNDS ///////////////////////////
  1861. '// This part in the script is an entire block that is dedicated to the physics sound system.
  1862. '// Various scripts and sounds that may be pretty generic and could suit other WPC systems, but the most are tailored specifically for this table.
  1863.  
  1864. '/////////////////////////////// SOUNDS PARAMETERS //////////////////////////////
  1865. Dim GlobalSoundLevel, CoinSoundLevel, PlungerReleaseSoundLevel, PlungerPullSoundLevel, NudgeLeftSoundLevel
  1866. Dim NudgeRightSoundLevel, NudgeCenterSoundLevel, StartButtonSoundLevel, RollingSoundFactor
  1867.  
  1868. CoinSoundLevel = 1 'volume level; range [0, 1]
  1869. NudgeLeftSoundLevel = 1 'volume level; range [0, 1]
  1870. NudgeRightSoundLevel = 1 'volume level; range [0, 1]
  1871. NudgeCenterSoundLevel = 1 'volume level; range [0, 1]
  1872. StartButtonSoundLevel = 0.1 'volume level; range [0, 1]
  1873. PlungerReleaseSoundLevel = 0.8 '1 wjr 'volume level; range [0, 1]
  1874. PlungerPullSoundLevel = 1 'volume level; range [0, 1]
  1875. RollingSoundFactor = 1.1/5
  1876.  
  1877. '///////////////////////-----Solenoids, Kickers and Flash Relays-----///////////////////////
  1878. Dim FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel, FlipperUpAttackLeftSoundLevel, FlipperUpAttackRightSoundLevel
  1879. Dim FlipperUpSoundLevel, FlipperDownSoundLevel, FlipperLeftHitParm, FlipperRightHitParm
  1880. Dim SlingshotSoundLevel, BumperSoundFactor, KnockerSoundLevel
  1881.  
  1882. FlipperUpAttackMinimumSoundLevel = 0.010 'volume level; range [0, 1]
  1883. FlipperUpAttackMaximumSoundLevel = 0.635 'volume level; range [0, 1]
  1884. FlipperUpSoundLevel = 1.0 'volume level; range [0, 1]
  1885. FlipperDownSoundLevel = 0.45 'volume level; range [0, 1]
  1886. FlipperLeftHitParm = FlipperUpSoundLevel 'sound helper; not configurable
  1887. FlipperRightHitParm = FlipperUpSoundLevel 'sound helper; not configurable
  1888. SlingshotSoundLevel = 0.95 'volume level; range [0, 1]
  1889. BumperSoundFactor = 4.25 'volume multiplier; must not be zero
  1890. KnockerSoundLevel = 1 'volume level; range [0, 1]
  1891.  
  1892. '///////////////////////-----Ball Drops, Bumps and Collisions-----///////////////////////
  1893. Dim RubberStrongSoundFactor, RubberWeakSoundFactor, RubberFlipperSoundFactor,BallWithBallCollisionSoundFactor
  1894. Dim BallBouncePlayfieldSoftFactor, BallBouncePlayfieldHardFactor, PlasticRampDropToPlayfieldSoundLevel, WireRampDropToPlayfieldSoundLevel, DelayedBallDropOnPlayfieldSoundLevel
  1895. Dim WallImpactSoundFactor, MetalImpactSoundFactor, SubwaySoundLevel, SubwayEntrySoundLevel, ScoopEntrySoundLevel
  1896. Dim SaucerLockSoundLevel, SaucerKickSoundLevel
  1897.  
  1898. BallWithBallCollisionSoundFactor = 3.2 'volume multiplier; must not be zero
  1899. RubberStrongSoundFactor = 0.055/5 'volume multiplier; must not be zero
  1900. RubberWeakSoundFactor = 0.075/5 'volume multiplier; must not be zero
  1901. RubberFlipperSoundFactor = 0.075/5 'volume multiplier; must not be zero
  1902. BallBouncePlayfieldSoftFactor = 0.025 'volume multiplier; must not be zero
  1903. BallBouncePlayfieldHardFactor = 0.025 'volume multiplier; must not be zero
  1904. DelayedBallDropOnPlayfieldSoundLevel = 0.8 'volume level; range [0, 1]
  1905. WallImpactSoundFactor = 0.075 'volume multiplier; must not be zero
  1906. MetalImpactSoundFactor = 0.075/3
  1907. SaucerLockSoundLevel = 0.8
  1908. SaucerKickSoundLevel = 0.8
  1909.  
  1910. '///////////////////////-----Gates, Spinners, Rollovers and Targets-----///////////////////////
  1911.  
  1912. Dim GateSoundLevel, TargetSoundFactor, SpinnerSoundLevel, RolloverSoundLevel, DTSoundLevel
  1913.  
  1914. GateSoundLevel = 0.5/5 'volume level; range [0, 1]
  1915. TargetSoundFactor = 0.0025 * 10 'volume multiplier; must not be zero
  1916. DTSoundLevel = 0.25 'volume multiplier; must not be zero
  1917. RolloverSoundLevel = 0.25 'volume level; range [0, 1]
  1918.  
  1919. '///////////////////////-----Ball Release, Guides and Drain-----///////////////////////
  1920. Dim DrainSoundLevel, BallReleaseSoundLevel, BottomArchBallGuideSoundFactor, FlipperBallGuideSoundFactor
  1921.  
  1922. DrainSoundLevel = 0.8 'volume level; range [0, 1]
  1923. BallReleaseSoundLevel = 1 'volume level; range [0, 1]
  1924. BottomArchBallGuideSoundFactor = 0.2 'volume multiplier; must not be zero
  1925. FlipperBallGuideSoundFactor = 0.015 'volume multiplier; must not be zero
  1926.  
  1927. '///////////////////////-----Loops and Lanes-----///////////////////////
  1928. Dim ArchSoundFactor
  1929. ArchSoundFactor = 0.025/5 'volume multiplier; must not be zero
  1930.  
  1931.  
  1932. '///////////////////////////// SOUND PLAYBACK FUNCTIONS ////////////////////////////
  1933. '///////////////////////////// POSITIONAL SOUND PLAYBACK METHODS ////////////////////////////
  1934. ' Positional sound playback methods will play a sound, depending on the X,Y position of the table element or depending on ActiveBall object position
  1935. ' These are similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  1936. ' For surround setup - positional sound playback functions will fade between front and rear surround channels and pan between left and right channels
  1937. ' For stereo setup - positional sound playback functions will only pan between left and right channels
  1938. ' For mono setup - positional sound playback functions will not pan between left and right channels and will not fade between front and rear channels
  1939.  
  1940. ' PlaySound full syntax - PlaySound(string, int loopcount, float volume, float pan, float randompitch, int pitch, bool useexisting, bool restart, float front_rear_fade)
  1941. ' Note - These functions will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  1942. Sub PlaySoundAtLevelStatic(playsoundparams, aVol, tableobj)
  1943. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
  1944. End Sub
  1945.  
  1946. Sub PlaySoundAtLevelExistingStatic(playsoundparams, aVol, tableobj)
  1947. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
  1948. End Sub
  1949.  
  1950. Sub PlaySoundAtLevelStaticLoop(playsoundparams, aVol, tableobj)
  1951. PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
  1952. End Sub
  1953.  
  1954. Sub PlaySoundAtLevelStaticRandomPitch(playsoundparams, aVol, randomPitch, tableobj)
  1955. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
  1956. End Sub
  1957.  
  1958. Sub PlaySoundAtLevelActiveBall(playsoundparams, aVol)
  1959. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 0, 0, AudioFade(ActiveBall)
  1960. End Sub
  1961.  
  1962. Sub PlaySoundAtLevelExistingActiveBall(playsoundparams, aVol)
  1963. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 1, 0, AudioFade(ActiveBall)
  1964. End Sub
  1965.  
  1966. Sub PlaySoundAtLeveTimerActiveBall(playsoundparams, aVol, ballvariable)
  1967. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 0, 0, AudioFade(ballvariable)
  1968. End Sub
  1969.  
  1970. Sub PlaySoundAtLevelTimerExistingActiveBall(playsoundparams, aVol, ballvariable)
  1971. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 1, 0, AudioFade(ballvariable)
  1972. End Sub
  1973.  
  1974. Sub PlaySoundAtLevelRoll(playsoundparams, aVol, pitch)
  1975. PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
  1976. End Sub
  1977.  
  1978. ' Previous Positional Sound Subs
  1979.  
  1980. Sub PlaySoundAt(soundname, tableobj)
  1981. PlaySound soundname, 1, 1 * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  1982. End Sub
  1983.  
  1984. Sub PlaySoundAtVol(soundname, tableobj, aVol)
  1985. PlaySound soundname, 1, aVol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  1986. End Sub
  1987.  
  1988. Sub PlaySoundAtBall(soundname)
  1989. PlaySoundAt soundname, ActiveBall
  1990. End Sub
  1991.  
  1992. Sub PlaySoundAtBallVol (Soundname, aVol)
  1993. Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 1, AudioFade(ActiveBall)
  1994. End Sub
  1995.  
  1996. Sub PlaySoundAtBallVolM (Soundname, aVol)
  1997. Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 0, AudioFade(ActiveBall)
  1998. End Sub
  1999.  
  2000. Sub PlaySoundAtVolLoops(sound, tableobj, Vol, Loops)
  2001. PlaySound sound, Loops, Vol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  2002. End Sub
  2003.  
  2004.  
  2005. ' *********************************************************************
  2006. ' Fleep Supporting Ball & Sound Functions
  2007. ' *********************************************************************
  2008.  
  2009. Dim tablewidth, tableheight : tablewidth = table1.width : tableheight = table1.height
  2010.  
  2011. Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
  2012. Dim tmp
  2013. tmp = tableobj.y * 2 / tableheight-1
  2014. If tmp > 0 Then
  2015. AudioFade = Csng(tmp ^10)
  2016. Else
  2017. AudioFade = Csng(-((- tmp) ^10) )
  2018. End If
  2019. End Function
  2020.  
  2021. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  2022. Dim tmp
  2023. tmp = tableobj.x * 2 / tablewidth-1
  2024. If tmp > 0 Then
  2025. AudioPan = Csng(tmp ^10)
  2026. Else
  2027. AudioPan = Csng(-((- tmp) ^10) )
  2028. End If
  2029. End Function
  2030.  
  2031. Function Vol(ball) ' Calculates the volume of the sound based on the ball speed
  2032. Vol = Csng(BallVel(ball) ^2)
  2033. End Function
  2034.  
  2035. Function Volz(ball) ' Calculates the volume of the sound based on the ball speed
  2036. Volz = Csng((ball.velz) ^2)
  2037. End Function
  2038.  
  2039. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  2040. Pitch = BallVel(ball) * 20
  2041. End Function
  2042.  
  2043. Function BallVel(ball) 'Calculates the ball speed
  2044. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  2045. End Function
  2046.  
  2047. Function VolPlayfieldRoll(ball) ' Calculates the roll volume of the sound based on the ball speed
  2048. VolPlayfieldRoll = RollingSoundFactor * 0.0005 * Csng(BallVel(ball) ^3)
  2049. End Function
  2050.  
  2051. Function PitchPlayfieldRoll(ball) ' Calculates the roll pitch of the sound based on the ball speed
  2052. PitchPlayfieldRoll = BallVel(ball) ^2 * 15
  2053. End Function
  2054.  
  2055. Function RndInt(min, max)
  2056. RndInt = Int(Rnd() * (max-min + 1) + min)' Sets a random number integer between min and max
  2057. End Function
  2058.  
  2059. Function RndNum(min, max)
  2060. RndNum = Rnd() * (max-min) + min' Sets a random number between min and max
  2061. End Function
  2062.  
  2063. '///////////////////////////// GENERAL SOUND SUBROUTINES ////////////////////////////
  2064. Sub SoundStartButton()
  2065. PlaySound ("Start_Button"), 0, StartButtonSoundLevel, 0, 0.25
  2066. End Sub
  2067.  
  2068. Sub SoundNudgeLeft()
  2069. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeLeftSoundLevel * VolumeDial, -0.1, 0.25
  2070. End Sub
  2071.  
  2072. Sub SoundNudgeRight()
  2073. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeRightSoundLevel * VolumeDial, 0.1, 0.25
  2074. End Sub
  2075.  
  2076. Sub SoundNudgeCenter()
  2077. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeCenterSoundLevel * VolumeDial, 0, 0.25
  2078. End Sub
  2079.  
  2080.  
  2081. Sub SoundPlungerPull()
  2082. PlaySoundAtLevelStatic ("Plunger_Pull_1"), PlungerPullSoundLevel, Plunger
  2083. End Sub
  2084.  
  2085. Sub SoundPlungerReleaseBall()
  2086. PlaySoundAtLevelStatic ("Plunger_Release_Ball"), PlungerReleaseSoundLevel, Plunger
  2087. End Sub
  2088.  
  2089. Sub SoundPlungerReleaseNoBall()
  2090. PlaySoundAtLevelStatic ("Plunger_Release_No_Ball"), PlungerReleaseSoundLevel, Plunger
  2091. End Sub
  2092.  
  2093.  
  2094. '///////////////////////////// KNOCKER SOLENOID ////////////////////////////
  2095. Sub KnockerSolenoid()
  2096. PlaySoundAtLevelStatic SoundFX("Knocker_1",DOFKnocker), KnockerSoundLevel, KnockerPosition
  2097. End Sub
  2098.  
  2099. '///////////////////////////// DRAIN SOUNDS ////////////////////////////
  2100. Sub RandomSoundDrain(drainswitch)
  2101. PlaySoundAtLevelStatic ("Drain_" & Int(Rnd*11)+1), DrainSoundLevel, drainswitch
  2102. End Sub
  2103.  
  2104. '///////////////////////////// TROUGH BALL RELEASE SOLENOID SOUNDS ////////////////////////////
  2105.  
  2106. Sub RandomSoundBallRelease(drainswitch)
  2107. PlaySoundAtLevelStatic SoundFX("BallRelease" & Int(Rnd*7)+1, DOFContactors), BallReleaseSoundLevel, drainswitch
  2108. End Sub
  2109.  
  2110. '///////////////////////////// SLINGSHOT SOLENOID SOUNDS ////////////////////////////
  2111. Sub RandomSoundSlingshotLeft(sling)
  2112. PlaySoundAtLevelStatic SoundFX("Sling_L" & Int(Rnd*10)+1, DOFContactors), SlingshotSoundLevel, Sling
  2113. End Sub
  2114.  
  2115. Sub RandomSoundSlingshotRight(sling)
  2116. PlaySoundAtLevelStatic SoundFX("Sling_R" & Int(Rnd*8)+1, DOFContactors), SlingshotSoundLevel, Sling
  2117. End Sub
  2118.  
  2119.  
  2120. '///////////////////////////// BUMPER SOLENOID SOUNDS ////////////////////////////
  2121. Sub RandomSoundBumperTop(Bump)
  2122. PlaySoundAtLevelStatic SoundFX("Bumpers_Top_" & Int(Rnd*5)+1, DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2123. End Sub
  2124.  
  2125. Sub RandomSoundBumperMiddle(Bump)
  2126. PlaySoundAtLevelStatic SoundFX("Bumpers_Middle_" & Int(Rnd*5)+1, DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2127. End Sub
  2128.  
  2129. Sub RandomSoundBumperBottom(Bump)
  2130. PlaySoundAtLevelStatic SoundFX("Bumpers_Bottom_" & Int(Rnd*5)+1, DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2131. End Sub
  2132.  
  2133.  
  2134. '///////////////////////////// FLIPPER BATS SOUND SUBROUTINES ////////////////////////////
  2135. '///////////////////////////// FLIPPER BATS SOLENOID ATTACK SOUND ////////////////////////////
  2136. Sub SoundFlipperUpAttackLeft(flipper)
  2137. FlipperUpAttackLeftSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
  2138. PlaySoundAtLevelStatic ("Flipper_Attack-L01"), FlipperUpAttackLeftSoundLevel, flipper
  2139. End Sub
  2140.  
  2141. Sub SoundFlipperUpAttackRight(flipper)
  2142. FlipperUpAttackRightSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
  2143. PlaySoundAtLevelStatic ("Flipper_Attack-R01"), FlipperUpAttackLeftSoundLevel, flipper
  2144. End Sub
  2145.  
  2146. '///////////////////////////// FLIPPER BATS SOLENOID CORE SOUND ////////////////////////////
  2147. Sub RandomSoundFlipperUpLeft(flipper)
  2148. PlaySoundAtLevelStatic SoundFX("Flipper_L0" & Int(Rnd*9)+1,DOFFlippers), FlipperLeftHitParm, Flipper
  2149. End Sub
  2150.  
  2151. Sub RandomSoundFlipperUpRight(flipper)
  2152. PlaySoundAtLevelStatic SoundFX("Flipper_R0" & Int(Rnd*9)+1,DOFFlippers), FlipperRightHitParm, Flipper
  2153. End Sub
  2154.  
  2155. Sub RandomSoundReflipUpLeft(flipper)
  2156. PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_L0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
  2157. End Sub
  2158.  
  2159. Sub RandomSoundReflipUpRight(flipper)
  2160. PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_R0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
  2161. End Sub
  2162.  
  2163. Sub RandomSoundFlipperDownLeft(flipper)
  2164. PlaySoundAtLevelStatic SoundFX("Flipper_Left_Down_" & Int(Rnd*7)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
  2165. End Sub
  2166.  
  2167. Sub RandomSoundFlipperDownRight(flipper)
  2168. PlaySoundAtLevelStatic SoundFX("Flipper_Right_Down_" & Int(Rnd*8)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
  2169. End Sub
  2170.  
  2171. '///////////////////////////// FLIPPER BATS BALL COLLIDE SOUND ////////////////////////////
  2172.  
  2173. Sub LeftFlipperCollide(parm)
  2174. FlipperLeftHitParm = parm/10
  2175. If FlipperLeftHitParm > 1 Then
  2176. FlipperLeftHitParm = 1
  2177. End If
  2178. FlipperLeftHitParm = FlipperUpSoundLevel * FlipperLeftHitParm
  2179. RandomSoundRubberFlipper(parm)
  2180. End Sub
  2181.  
  2182. Sub RightFlipperCollide(parm)
  2183. FlipperRightHitParm = parm/10
  2184. If FlipperRightHitParm > 1 Then
  2185. FlipperRightHitParm = 1
  2186. End If
  2187. FlipperRightHitParm = FlipperUpSoundLevel * FlipperRightHitParm
  2188. RandomSoundRubberFlipper(parm)
  2189. End Sub
  2190.  
  2191. Sub RandomSoundRubberFlipper(parm)
  2192. PlaySoundAtLevelActiveBall ("Flipper_Rubber_" & Int(Rnd*7)+1), parm * RubberFlipperSoundFactor
  2193. End Sub
  2194.  
  2195. '///////////////////////////// ROLLOVER SOUNDS ////////////////////////////
  2196. Sub RandomSoundRollover()
  2197. PlaySoundAtLevelActiveBall ("Rollover_" & Int(Rnd*4)+1), RolloverSoundLevel
  2198. End Sub
  2199.  
  2200. Sub Rollovers_Hit(idx)
  2201. RandomSoundRollover
  2202. End Sub
  2203.  
  2204. '///////////////////////////// VARIOUS PLAYFIELD SOUND SUBROUTINES ////////////////////////////
  2205. '///////////////////////////// RUBBERS AND POSTS ////////////////////////////
  2206. '///////////////////////////// RUBBERS - EVENTS ////////////////////////////
  2207. Sub Rubbers_Hit(idx)
  2208. dim finalspeed
  2209. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2210. If finalspeed > 5 then
  2211. RandomSoundRubberStrong 1
  2212. End if
  2213. If finalspeed <= 5 then
  2214. RandomSoundRubberWeak()
  2215. End If
  2216. End Sub
  2217.  
  2218. '///////////////////////////// RUBBERS AND POSTS - STRONG IMPACTS ////////////////////////////
  2219. Sub RandomSoundRubberStrong(voladj)
  2220. Select Case Int(Rnd*10)+1
  2221. Case 1 : PlaySoundAtLevelActiveBall ("Rubber_Strong_1"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2222. Case 2 : PlaySoundAtLevelActiveBall ("Rubber_Strong_2"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2223. Case 3 : PlaySoundAtLevelActiveBall ("Rubber_Strong_3"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2224. Case 4 : PlaySoundAtLevelActiveBall ("Rubber_Strong_4"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2225. Case 5 : PlaySoundAtLevelActiveBall ("Rubber_Strong_5"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2226. Case 6 : PlaySoundAtLevelActiveBall ("Rubber_Strong_6"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2227. Case 7 : PlaySoundAtLevelActiveBall ("Rubber_Strong_7"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2228. Case 8 : PlaySoundAtLevelActiveBall ("Rubber_Strong_8"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2229. Case 9 : PlaySoundAtLevelActiveBall ("Rubber_Strong_9"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2230. Case 10 : PlaySoundAtLevelActiveBall ("Rubber_1_Hard"), Vol(ActiveBall) * RubberStrongSoundFactor * 0.6*voladj
  2231. End Select
  2232. End Sub
  2233.  
  2234. '///////////////////////////// RUBBERS AND POSTS - WEAK IMPACTS ////////////////////////////
  2235. Sub RandomSoundRubberWeak()
  2236. PlaySoundAtLevelActiveBall ("Rubber_" & Int(Rnd*9)+1), Vol(ActiveBall) * RubberWeakSoundFactor
  2237. End Sub
  2238.  
  2239. '///////////////////////////// WALL IMPACTS ////////////////////////////
  2240. Sub Walls_Hit(idx)
  2241. dim finalspeed
  2242. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2243. If finalspeed > 5 then
  2244. RandomSoundRubberStrong 1
  2245. End if
  2246. If finalspeed <= 5 then
  2247. RandomSoundRubberWeak()
  2248. End If
  2249. End Sub
  2250.  
  2251. Sub RandomSoundWall()
  2252. dim finalspeed
  2253. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2254. If finalspeed > 16 then
  2255. Select Case Int(Rnd*5)+1
  2256. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_1"), Vol(ActiveBall) * WallImpactSoundFactor
  2257. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_2"), Vol(ActiveBall) * WallImpactSoundFactor
  2258. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_5"), Vol(ActiveBall) * WallImpactSoundFactor
  2259. Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_7"), Vol(ActiveBall) * WallImpactSoundFactor
  2260. Case 5 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_9"), Vol(ActiveBall) * WallImpactSoundFactor
  2261. End Select
  2262. End if
  2263. If finalspeed >= 6 AND finalspeed <= 16 then
  2264. Select Case Int(Rnd*4)+1
  2265. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_3"), Vol(ActiveBall) * WallImpactSoundFactor
  2266. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
  2267. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
  2268. Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
  2269. End Select
  2270. End If
  2271. If finalspeed < 6 Then
  2272. Select Case Int(Rnd*3)+1
  2273. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
  2274. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
  2275. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
  2276. End Select
  2277. End if
  2278. End Sub
  2279.  
  2280. '///////////////////////////// METAL TOUCH SOUNDS ////////////////////////////
  2281. Sub RandomSoundMetal()
  2282. PlaySoundAtLevelActiveBall ("Metal_Touch_" & Int(Rnd*13)+1), Vol(ActiveBall) * MetalImpactSoundFactor
  2283. End Sub
  2284.  
  2285. '///////////////////////////// METAL - EVENTS ////////////////////////////
  2286.  
  2287. Sub Metals_Hit (idx)
  2288. RandomSoundMetal
  2289. End Sub
  2290.  
  2291. Sub ShooterDiverter_collide(idx)
  2292. RandomSoundMetal
  2293. End Sub
  2294.  
  2295. '///////////////////////////// BOTTOM ARCH BALL GUIDE ////////////////////////////
  2296. '///////////////////////////// BOTTOM ARCH BALL GUIDE - SOFT BOUNCES ////////////////////////////
  2297. Sub RandomSoundBottomArchBallGuide()
  2298. dim finalspeed
  2299. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2300. If finalspeed > 16 then
  2301. PlaySoundAtLevelActiveBall ("Apron_Bounce_"& Int(Rnd*2)+1), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2302. End if
  2303. If finalspeed >= 6 AND finalspeed <= 16 then
  2304. Select Case Int(Rnd*2)+1
  2305. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2306. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2307. End Select
  2308. End If
  2309. If finalspeed < 6 Then
  2310. Select Case Int(Rnd*2)+1
  2311. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2312. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Medium_3"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2313. End Select
  2314. End if
  2315. End Sub
  2316.  
  2317. '///////////////////////////// BOTTOM ARCH BALL GUIDE - HARD HITS ////////////////////////////
  2318. Sub RandomSoundBottomArchBallGuideHardHit()
  2319. PlaySoundAtLevelActiveBall ("Apron_Hard_Hit_" & Int(Rnd*3)+1), BottomArchBallGuideSoundFactor * 0.25
  2320. End Sub
  2321.  
  2322. Sub Apron_Hit (idx)
  2323. If Abs(cor.ballvelx(activeball.id) < 4) and cor.ballvely(activeball.id) > 7 then
  2324. RandomSoundBottomArchBallGuideHardHit()
  2325. Else
  2326. RandomSoundBottomArchBallGuide
  2327. End If
  2328. End Sub
  2329.  
  2330. '///////////////////////////// FLIPPER BALL GUIDE ////////////////////////////
  2331. Sub RandomSoundFlipperBallGuide()
  2332. dim finalspeed
  2333. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2334. If finalspeed > 16 then
  2335. Select Case Int(Rnd*2)+1
  2336. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Hard_1"), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2337. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Hard_2"), Vol(ActiveBall) * 0.8 * FlipperBallGuideSoundFactor
  2338. End Select
  2339. End if
  2340. If finalspeed >= 6 AND finalspeed <= 16 then
  2341. PlaySoundAtLevelActiveBall ("Apron_Medium_" & Int(Rnd*3)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2342. End If
  2343. If finalspeed < 6 Then
  2344. PlaySoundAtLevelActiveBall ("Apron_Soft_" & Int(Rnd*7)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2345. End If
  2346. End Sub
  2347.  
  2348. '///////////////////////////// TARGET HIT SOUNDS ////////////////////////////
  2349. Sub RandomSoundTargetHitStrong()
  2350. PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+5,DOFTargets), Vol(ActiveBall) * 0.45 * TargetSoundFactor
  2351. End Sub
  2352.  
  2353. Sub RandomSoundTargetHitWeak()
  2354. PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+1,DOFTargets), Vol(ActiveBall) * TargetSoundFactor
  2355. End Sub
  2356.  
  2357. Sub PlayTargetSound()
  2358. dim finalspeed
  2359. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2360. If finalspeed > 10 then
  2361. RandomSoundTargetHitStrong()
  2362. RandomSoundBallBouncePlayfieldSoft Activeball
  2363. Else
  2364. RandomSoundTargetHitWeak()
  2365. End If
  2366. End Sub
  2367.  
  2368. Sub Targets_Hit (idx)
  2369. PlayTargetSound
  2370. End Sub
  2371.  
  2372. '///////////////////////////// BALL BOUNCE SOUNDS ////////////////////////////
  2373. Sub RandomSoundBallBouncePlayfieldSoft(aBall)
  2374. Select Case Int(Rnd*9)+1
  2375. Case 1 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_1"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
  2376. Case 2 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
  2377. Case 3 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_3"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.8, aBall
  2378. Case 4 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_4"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
  2379. Case 5 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_5"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
  2380. Case 6 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_1"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2381. Case 7 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2382. Case 8 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_5"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2383. Case 9 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_7"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.3, aBall
  2384. End Select
  2385. End Sub
  2386.  
  2387. Sub RandomSoundBallBouncePlayfieldHard(aBall)
  2388. PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_" & Int(Rnd*7)+1), volz(aBall) * BallBouncePlayfieldHardFactor, aBall
  2389. End Sub
  2390.  
  2391. '///////////////////////////// DELAYED DROP - TO PLAYFIELD - SOUND ////////////////////////////
  2392. Sub RandomSoundDelayedBallDropOnPlayfield(aBall)
  2393. Select Case Int(Rnd*5)+1
  2394. Case 1 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_1_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2395. Case 2 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_2_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2396. Case 3 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_3_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2397. Case 4 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_4_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2398. Case 5 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_5_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2399. End Select
  2400. End Sub
  2401.  
  2402. '///////////////////////////// BALL GATES AND BRACKET GATES SOUNDS ////////////////////////////
  2403.  
  2404. Sub SoundPlayfieldGate()
  2405. PlaySoundAtLevelStatic ("Gate_FastTrigger_" & Int(Rnd*2)+1), GateSoundLevel, Activeball
  2406. End Sub
  2407.  
  2408. Sub SoundHeavyGate()
  2409. PlaySoundAtLevelStatic ("Gate_2"), GateSoundLevel, Activeball
  2410. End Sub
  2411.  
  2412. Sub Gates_hit(idx)
  2413. SoundHeavyGate
  2414. End Sub
  2415.  
  2416. Sub GatesWire_hit(idx)
  2417. SoundPlayfieldGate
  2418. End Sub
  2419.  
  2420. '///////////////////////////// LEFT LANE ENTRANCE - SOUNDS ////////////////////////////
  2421.  
  2422. Sub RandomSoundLeftArch()
  2423. PlaySoundAtLevelActiveBall ("Arch_L" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
  2424. End Sub
  2425.  
  2426. Sub RandomSoundRightArch()
  2427. PlaySoundAtLevelActiveBall ("Arch_R" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
  2428. End Sub
  2429.  
  2430.  
  2431. Sub Arch1_hit()
  2432. If Activeball.velx > 1 Then SoundPlayfieldGate
  2433. StopSound "Arch_L1"
  2434. StopSound "Arch_L2"
  2435. StopSound "Arch_L3"
  2436. StopSound "Arch_L4"
  2437. End Sub
  2438.  
  2439. Sub Arch1_unhit()
  2440. If activeball.velx < -8 Then
  2441. RandomSoundRightArch
  2442. End If
  2443. End Sub
  2444.  
  2445. Sub Arch2_hit()
  2446. If Activeball.velx < 1 Then SoundPlayfieldGate
  2447. StopSound "Arch_R1"
  2448. StopSound "Arch_R2"
  2449. StopSound "Arch_R3"
  2450. StopSound "Arch_R4"
  2451. End Sub
  2452.  
  2453. Sub Arch2_unhit()
  2454. If activeball.velx > 10 Then
  2455. RandomSoundLeftArch
  2456. End If
  2457. End Sub
  2458.  
  2459. '///////////////////////////// SAUCERS (KICKER HOLES) ////////////////////////////
  2460.  
  2461. Sub SoundSaucerLock()
  2462. PlaySoundAtLevelStatic ("Saucer_Enter_" & Int(Rnd*2)+1), SaucerLockSoundLevel, Activeball
  2463. End Sub
  2464.  
  2465. Sub SoundSaucerKick(scenario, saucer)
  2466. Select Case scenario
  2467. Case 0: PlaySoundAtLevelStatic SoundFX("Saucer_Empty", DOFContactors), SaucerKickSoundLevel, saucer
  2468. Case 1: PlaySoundAtLevelStatic SoundFX("Saucer_Kick", DOFContactors), SaucerKickSoundLevel, saucer
  2469. End Select
  2470. End Sub
  2471.  
  2472. '///////////////////////////// BALL COLLISION SOUND ////////////////////////////
  2473. Sub OnBallBallCollision(ball1, ball2, velocity)
  2474. Dim snd
  2475. Select Case Int(Rnd*7)+1
  2476. Case 1 : snd = "Ball_Collide_1"
  2477. Case 2 : snd = "Ball_Collide_2"
  2478. Case 3 : snd = "Ball_Collide_3"
  2479. Case 4 : snd = "Ball_Collide_4"
  2480. Case 5 : snd = "Ball_Collide_5"
  2481. Case 6 : snd = "Ball_Collide_6"
  2482. Case 7 : snd = "Ball_Collide_7"
  2483. End Select
  2484.  
  2485. PlaySound (snd), 0, Csng(velocity) ^2 / 200 * BallWithBallCollisionSoundFactor * VolumeDial, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  2486. End Sub
  2487.  
  2488.  
  2489. '/////////////////////////////////////////////////////////////////
  2490. ' End Mechanical Sounds
  2491. '/////////////////////////////////////////////////////////////////
  2492.  
  2493. ' Thalamus : Exit in a clean and proper way
  2494. Sub Table1_exit()
  2495. If B2SOn Then
  2496. Controller.Pause = False
  2497. Controller.Stop
  2498. End If
  2499. End Sub
  2500.  
Add Comment
Please, Sign In to add comment