Outhere

El Dorado City of Gold 1.2

Jul 2nd, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.00 KB | None | 0 0
  1.  
  2. Option Explicit
  3. Randomize
  4.  
  5. On Error Resume Next
  6. ExecuteGlobal GetTextFile("controller.vbs")
  7. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  8. On Error Goto 0
  9.  
  10. Const cGameName="eldorado",UseSolenoids=2,UseLamps=1,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  11.  
  12. LoadVPM "01120100", "sys80.vbs", 3.02
  13. Dim DesktopMode:DesktopMode = Table1.ShowDT
  14.  
  15. ' Thalamus 2020 June : Improved directional sounds
  16. ' !! NOTE : Table not verified yet !!
  17.  
  18. ' Outhere 2020 June: Add DOF for the Bumpers and Slingshots
  19. ' Slingshot Left 101
  20. ' Slingshot Right 102
  21. ' Bumper 103
  22. ' Bumper 104
  23.  
  24. ' Options
  25. ' Volume devided by - lower gets higher sound
  26.  
  27. Const VolDiv = 5000 ' Lower number, louder ballrolling/collition sound
  28. Const VolCol = 10 ' Ball collition divider ( voldiv/volcol )
  29.  
  30. '*************************************************************
  31. 'Solenoid Call backs
  32. '**********************************************************************************************************
  33.  
  34. SolCallback(5) = "dtRBank.SolDropUp"
  35. SolCallback(6) = "dtTbank.SolDropUp"
  36. solcallback(8) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  37. solcallback(9) = "bsTrough.SolOut"
  38.  
  39. SolCallback(sLRFlipper) = "SolRFlipper"
  40. SolCallback(sLLFlipper) = "SolLFlipper"
  41.  
  42. Sub SolLFlipper(Enabled)
  43. If Enabled Then
  44. PlaySoundAtVol"fx_Flipperup", LeftFlipper, 1:LeftFlipper.RotateToEnd:LeftFlipper1.RotateToEnd
  45. Else
  46. PlaySoundAtVol "fx_Flipperdown", LeftFlipper, 1:LeftFlipper.RotateToStart:LeftFlipper1.RotateToStart
  47. End If
  48. End Sub
  49.  
  50. Sub SolRFlipper(Enabled)
  51. If Enabled Then
  52. PlaySoundAtVol"fx_Flipperup", RightFlipper, 1:RightFlipper.RotateToEnd:RightFlipper1.RotateToEnd
  53. Else
  54. PlaySoundAtVol "fx_Flipperdown", RightFlipper, 1:RightFlipper.RotateToStart:RightFlipper1.RotateToStart
  55. End If
  56. End Sub
  57. '**********************************************************************************************************
  58. '**********************************************************************************************************
  59. '**********************************************************************************************************
  60. 'Primitive Flipper Code
  61.  
  62. Sub FlipperTimer_Timer
  63. FlipperT1.roty = LeftFlipper.currentangle + 90
  64. FlipperT2.roty = LeftFlipper.currentangle + 110
  65. FlipperT5.roty = RightFlipper.currentangle + 90
  66. FlipperT3.roty = RightFlipper1.currentangle - 90
  67. End Sub
  68.  
  69.  
  70. '**********************************************************************************************************
  71.  
  72. 'Solenoid Controlled toys
  73. '**********************************************************************************************************
  74.  
  75.  
  76. '*****GI Lights On
  77. dim xx
  78. For each xx in GI:xx.State = 1: Next
  79.  
  80.  
  81. '**********************************************************************************************************
  82.  
  83. 'Initiate Table
  84. '**********************************************************************************************************
  85. Dim bsTrough, dtRBank, dtTBank
  86.  
  87. Sub Table1_Init
  88. vpmInit Me
  89. On Error Resume Next
  90. With Controller
  91. .GameName = cGameName
  92. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  93. .SplashInfoLine = "El Dorado City of Gold (Gottlieb)"&chr(13)&"You Suck"
  94. .HandleMechanics=0
  95. .HandleKeyboard=0
  96. .ShowDMDOnly=1
  97. .ShowFrame=0
  98. .ShowTitle=0
  99. .hidden = 0
  100. On Error Resume Next
  101. Controller.SolMask(0)=0
  102. vpmTimer.AddTimer 2000,"Controller.SolMask(0)=&Hffffffff'"
  103. .Run GetPlayerHWnd
  104. If Err Then MsgBox Err.Description
  105. On Error Goto 0
  106. End With
  107. On Error Goto 0
  108.  
  109. PinMAMETimer.Interval = PinMAMEInterval
  110. PinMAMETimer.Enabled = 1
  111.  
  112. ' Nudging
  113. vpmNudge.TiltSwitch = 57
  114. vpmNudge.Sensitivity = 1
  115. vpmNudge.TiltObj = Array(Bumper1, Bumper2, LeftSlingshot, RightSlingshot)
  116.  
  117. ' Trough
  118. Set bsTrough = New cvpmBallStack
  119. bsTrough.InitSw 0, 67, 0, 0, 0, 0, 0, 0
  120. bsTrough.InitKick BallRelease, 80, 6
  121. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  122. bsTrough.Balls = 1
  123.  
  124. ' Top Drop targets
  125. set dtTBank = new cvpmdroptarget
  126. dtTBank.InitDrop Array(sw0, sw10, sw20, sw30, sw40, sw1, sw11, sw21, sw31, sw41), Array(0, 10, 20, 30, 40, 1, 11, 21, 31, 41)
  127. dtTBank.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  128.  
  129. ' Right Drop targets
  130. set dtRBank = new cvpmdroptarget
  131. dtRBank.InitDrop Array(sw2, sw12, sw22, sw32, sw42), Array(2, 12, 22, 32, 42)
  132. dtRBank.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  133.  
  134. End Sub
  135.  
  136. '**********************************************************************************************************
  137. 'Plunger code
  138. '**********************************************************************************************************
  139.  
  140. Sub Table1_KeyDown(ByVal KeyCode)
  141. If KeyDownHandler(keycode) Then Exit Sub
  142. If keycode = PlungerKey Then Plunger.Pullback:playsoundAtVol"plungerpull", Plunger, 1
  143. End Sub
  144.  
  145. Sub Table1_KeyUp(ByVal KeyCode)
  146. If KeyUpHandler(keycode) Then Exit Sub
  147. If keycode = PlungerKey Then Plunger.Fire:PlaySoundAtVol"plunger", Plunger, 1
  148. End Sub
  149.  
  150. '**********************************************************************************************************
  151.  
  152. 'Drain & holes
  153. Sub Drain_Hit:playsoundAtVol"drain", Drain, 1:bsTrough.addball me:End Sub
  154.  
  155. 'Bumpers
  156. Sub Bumper1_Hit : vpmTimer.PulseSw(55) : PlaySound SoundFX("fx_bumper1", DOFContactors): DOF 103, DOFPulse: End Sub
  157. Sub Bumper2_Hit : vpmTimer.PulseSw(55) : PlaySound SoundFX("fx_bumper1", DOFContactors): DOF 104, DOFPulse: End Sub
  158.  
  159.  
  160. 'Wire Triggers
  161. Sub sw53_Hit:Controller.Switch(53) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  162. Sub sw53_UnHit:Controller.Switch(53) = 0:End Sub
  163. Sub sw63_Hit:Controller.Switch(63) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  164. Sub sw63_UnHit:Controller.Switch(63) = 0:End Sub
  165. Sub sw54_Hit:Controller.Switch(54) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  166. Sub sw54_UnHit:Controller.Switch(54) = 0:End Sub
  167. Sub sw64_Hit:Controller.Switch(64) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  168. Sub sw64_UnHit:Controller.Switch(64) = 0:End Sub
  169. Sub sw52_Hit:Controller.Switch(52) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  170. Sub sw52_UnHit:Controller.Switch(52) = 0:End Sub
  171. Sub sw62_Hit:Controller.Switch(62) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  172. Sub sw62_UnHit:Controller.Switch(62) = 0:End Sub
  173. Sub sw61_Hit:Controller.Switch(61) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  174. Sub sw61_UnHit:Controller.Switch(61) = 0:End Sub
  175. Sub sw50_Hit:Controller.Switch(50) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  176. Sub sw50_UnHit:Controller.Switch(50) = 0:End Sub
  177. Sub sw60_Hit:Controller.Switch(60) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  178. Sub sw60_UnHit:Controller.Switch(60) = 0:End Sub
  179. Sub sw51_Hit:Controller.Switch(51) = 1 : playsoundAtVol"rollover" , ActiveBall, 1: End Sub
  180. Sub sw51_UnHit:Controller.Switch(51) = 0:End Sub
  181.  
  182.  
  183. ' Stand Up Targets
  184. Sub sw65_Hit:vpmTimer.PulseSw 65:End Sub
  185. Sub sw65a_Hit:vpmTimer.PulseSw 65:End Sub
  186.  
  187.  
  188. ' Droptargets
  189. Sub sw0_Dropped :dtTBank.hit 1:End Sub
  190. Sub sw10_Dropped:dtTBank.hit 2:End Sub
  191. Sub sw20_Dropped:dtTBank.hit 3:End Sub
  192. Sub sw30_Dropped:dtTBank.hit 4:End Sub
  193. Sub sw40_Dropped:dtTBank.hit 5:End Sub
  194. Sub sw1_Dropped:dtTBank.hit 6:End Sub
  195. Sub sw11_Dropped:dtTBank.hit 7:End Sub
  196. Sub sw21_Dropped:dtTBank.hit 8:End Sub
  197. Sub sw31_Dropped:dtTBank.hit 9:End Sub
  198. Sub sw41_Dropped:dtTBank.hit 10:End Sub
  199.  
  200. Sub sw2_Dropped:dtRBank.hit 1:End Sub
  201. Sub sw12_Dropped:dtRBank.hit 2:End Sub
  202. Sub sw22_Dropped:dtRBank.hit 3:End Sub
  203. Sub sw32_Dropped:dtRBank.hit 4:End Sub
  204. Sub sw42_Dropped:dtRBank.hit 5:End Sub
  205.  
  206.  
  207. ' Slings & Rubbers
  208. Sub Sling1_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  209. Sub Sling2_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  210. Sub Sling3_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  211. Sub Sling4_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  212. Sub Sling5_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  213. Sub Sling6_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  214. Sub Sling7_SlingShot:vpmTimer.PulseSw 66:PlaySoundAtVol "fx_rubber2", ActiveBall, .12:End Sub
  215.  
  216. '************************************************************************************************************************
  217. '************************************************************************************************************************
  218.  
  219. '************************************************************************************************************************
  220. '************************************************************************************************************************
  221. 'NFadeL 2, l2 'always on
  222. Set Lights(3) = l3
  223. Set Lights(4) = l4
  224. Set Lights(5) = l5
  225. Set Lights(6) = l6
  226. Set Lights(7) = l7
  227. Set Lights(12) = l12
  228. Set Lights(13) = l13
  229. Set Lights(14) = l14
  230. Set Lights(15) = l15
  231. Set Lights(16) = l16
  232. Set Lights(17) = l17
  233. Set Lights(18) = l18
  234. Set Lights(19) = l19
  235. Set Lights(20) = l20
  236. Set Lights(21) = l21
  237. Set Lights(22) = l22
  238. Set Lights(23) = l23
  239. Set Lights(24) = l24
  240. Set Lights(25) = l25
  241. Set Lights(26) = l26
  242. Set Lights(27) = l27
  243. Set Lights(28) = l28
  244. Set Lights(29) = l29
  245. Set Lights(30) = l30
  246. Set Lights(31) = l31
  247. Set Lights(32) = l32
  248. Set Lights(33) = l33
  249. Set Lights(34) = l34
  250. Set Lights(35) = l35
  251. Set Lights(36) = l36
  252. Set Lights(37) = l37
  253. Set Lights(38) = l38
  254. Set Lights(39) = l39
  255. Set Lights(40) = l40
  256. Set Lights(41) = l41
  257. Set Lights(42) = l42
  258. Set Lights(43) = l43
  259. Set Lights(44) = l44
  260. Set Lights(45) = l45
  261. Set Lights(46) = l46
  262. Set Lights(47) = l47
  263. 'Lights(90) = array(l90,l90a) 'bumper 1
  264. 'Lights(91) = array(l91,l91a) 'bumper 2
  265.  
  266. 'BackGlass
  267. 'Set Lights(10) = l10 'Highscore
  268. 'Set Lights(11) = l11 'GAME OVER
  269.  
  270.  
  271. 'Gottlieb El Dorado City of Gold
  272.  
  273. Sub editDips
  274. Dim vpmDips:Set vpmDips = New cvpmDips
  275. With vpmDips
  276. .AddForm 700, 400, "El Dorado City of Gold - DIP switches"
  277. .AddFrame 2, 2, 190, "Maximum credits", 49152, Array("8 credits", 0, "10 credits", 32768, "15 credits", &H00004000, "20 credits", 49152) 'dip 15&16
  278. .AddFrame 2, 80, 190, "Coin chute 1 and 2 control", &H00002000, Array("seperate", 0, "same", &H00002000) 'dip 14
  279. .AddFrame 2, 126, 190, "Playfield special", &H00200000, Array("replay", 0, "extra ball", &H00200000) 'dip 22
  280. .AddFrame 2, 172, 190, "Game mode", &H10000000, Array("replay", 0, "extra ball", &H10000000) 'dip 29
  281. .AddChk 2, 227, 190, Array("Match feature", &H02000000) 'dip 26
  282. .AddChk 2, 248, 190, Array("Background sound", &H40000000) 'dip 31
  283. .AddFrame 205, 2, 190, "High score to date awards", &H00C00000, Array("not displayed and no award", 0, "displayed and no award", &H00800000, "displayed and 2 replays", &H00400000, "displayed and 3 replays", &H00C00000) 'dip 23&24
  284. .AddFrame 205, 80, 190, "Balls per game", &H01000000, Array("5 balls", 0, "3 balls", &H01000000) 'dip 25
  285. .AddFrame 205, 126, 190, "Replay limit", &H04000000, Array("no limit", 0, "one per ball", &H04000000) 'dip 27
  286. .AddFrame 205, 172, 190, "Novelty", &H08000000, Array("normal", 0, "points", &H0800000) 'dip 28
  287. .AddFrame 205, 218, 190, "3rd coin chute credits control", &H20000000, Array("no effect", 0, "add 9", &H20000000) 'dip 30
  288. .AddLabel 50, 270, 300, 20, "After hitting OK, press F3 to reset game with new settings."
  289. .ViewDips
  290. End With
  291. End Sub
  292. Set vpmShowDips = GetRef("editDips")
  293.  
  294.  
  295. ' ********************************************************************************************************************************
  296. ' ********************************************************************************************************************************
  297. 'Start of VPX Call Back Functions
  298. ' ********************************************************************************************************************************
  299. ' ********************************************************************************************************************************
  300.  
  301. '**********Sling Shot Animations
  302. ' Rstep and Lstep are the variables that increment the animation
  303. '****************
  304. Dim RStep, Lstep
  305.  
  306. Sub RightSlingShot_Slingshot
  307. vpmTimer.PulseSw 66
  308. PlaySoundAtVol SoundFX("right_slingshot",DOFContactors), sling1, 1
  309. DOF 102, DOFPulse
  310. RSling.Visible = 0
  311. RSling1.Visible = 1
  312. sling1.TransZ = -20
  313. RStep = 0
  314. RightSlingShot.TimerEnabled = 1
  315. End Sub
  316.  
  317. Sub RightSlingShot_Timer
  318. Select Case RStep
  319. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  320. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
  321. End Select
  322. RStep = RStep + 1
  323. End Sub
  324.  
  325. Sub LeftSlingShot_Slingshot
  326. vpmTimer.PulseSw 66
  327. PlaySoundAtVol SoundFX("left_slingshot",DOFContactors), sling2, 1
  328. DOF 101, DOFPulse
  329. LSling.Visible = 0
  330. LSling1.Visible = 1
  331. sling2.TransZ = -20
  332. LStep = 0
  333. LeftSlingShot.TimerEnabled = 1
  334. End Sub
  335.  
  336. Sub LeftSlingShot_Timer
  337. Select Case LStep
  338. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  339. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0:
  340. End Select
  341. LStep = LStep + 1
  342. End Sub
  343.  
  344. ' *******************************************************************************************************
  345. ' Positional Sound Playback Functions by DJRobX, Rothbauerw, Thalamus and Herweh
  346. ' PlaySound sound, 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  347. ' *******************************************************************************************************
  348.  
  349. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  350. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  351. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  352.  
  353. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  354. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  355. End Sub
  356.  
  357. ' Set position as table object (Use object or light but NOT wall) and Vol to 1
  358.  
  359. Sub PlaySoundAt(soundname, tableobj)
  360. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  361. End Sub
  362.  
  363. ' set position as table object and Vol + RndPitch manually
  364.  
  365. Sub PlaySoundAtVolPitch(sound, tableobj, Vol, RndPitch)
  366. PlaySound sound, 1, Vol, AudioPan(tableobj), RndPitch, 0, 0, 1, AudioFade(tableobj)
  367. End Sub
  368.  
  369. 'Set all as per ball position & speed.
  370.  
  371. Sub PlaySoundAtBall(soundname)
  372. PlaySoundAt soundname, ActiveBall
  373. End Sub
  374.  
  375. 'Set position as table object and Vol manually.
  376.  
  377. Sub PlaySoundAtVol(sound, tableobj, Volume)
  378. PlaySound sound, 1, Volume, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  379. End Sub
  380.  
  381. 'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
  382.  
  383. Sub PlaySoundAtBallVol(sound, VolMult)
  384. PlaySound sound, 0, Vol(ActiveBall) * VolMult, AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  385. End Sub
  386.  
  387. Sub PlaySoundAtBallAbsVol(sound, VolMult)
  388. PlaySound sound, 0, VolMult, AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  389. End Sub
  390.  
  391. ' requires rampbump1 to 7 in Sound Manager
  392.  
  393. Sub RandomBump(voladj, freq)
  394. Dim BumpSnd:BumpSnd= "rampbump" & CStr(Int(Rnd*7)+1)
  395. PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
  396. End Sub
  397.  
  398. ' set position as bumperX and Vol manually. Allows rapid repetition/overlaying sound
  399.  
  400. Sub PlaySoundAtBumperVol(sound, tableobj, Vol)
  401. PlaySound sound, 1, Vol, AudioPan(tableobj), 0,0,1, 1, AudioFade(tableobj)
  402. End Sub
  403.  
  404. Sub PlaySoundAtBOTBallZ(sound, BOT)
  405. PlaySound sound, 0, ABS(BOT.velz)/17, Pan(BOT), 0, Pitch(BOT), 1, 0, AudioFade(BOT)
  406. End Sub
  407.  
  408. ' play a looping sound at a location with volume
  409. Sub PlayLoopSoundAtVol(sound, tableobj, Vol)
  410. PlaySound sound, -1, Vol, AudioPan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
  411. End Sub
  412.  
  413. '*********************************************************************
  414. ' Supporting Ball & Sound Functions
  415. '*********************************************************************
  416.  
  417. Function RndNum(min, max)
  418. RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
  419. End Function
  420.  
  421. 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
  422. Dim tmp
  423. On Error Resume Next
  424. tmp = tableobj.y * 2 / table1.height-1
  425. If tmp > 0 Then
  426. AudioFade = Csng(tmp ^10)
  427. Else
  428. AudioFade = Csng(-((- tmp) ^10) )
  429. End If
  430. End Function
  431.  
  432. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  433. Dim tmp
  434. On Error Resume Next
  435. tmp = tableobj.x * 2 / table1.width-1
  436. If tmp > 0 Then
  437. AudioPan = Csng(tmp ^10)
  438. Else
  439. AudioPan = Csng(-((- tmp) ^10) )
  440. End If
  441. End Function
  442.  
  443. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  444. Dim tmp
  445. On Error Resume Next
  446. tmp = ball.x * 2 / table1.width-1
  447. If tmp > 0 Then
  448. Pan = Csng(tmp ^10)
  449. Else
  450. Pan = Csng(-((- tmp) ^10) )
  451. End If
  452. End Function
  453.  
  454. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  455. Vol = Csng(BallVel(ball) ^2 / VolDiv)
  456. End Function
  457.  
  458. Function VolMulti(ball,Multiplier) ' Calculates the Volume of the sound based on the ball speed
  459. VolMulti = Csng(BallVel(ball) ^2 / 150 ) * Multiplier
  460. End Function
  461.  
  462. Function DVolMulti(ball,Multiplier) ' Calculates the Volume of the sound based on the ball speed
  463. DVolMulti = Csng(BallVel(ball) ^2 / 150 ) * Multiplier
  464. debug.print DVolMulti
  465. End Function
  466.  
  467. Function BallRollVol(ball) ' Calculates the Volume of the sound based on the ball speed
  468. BallRollVol = Csng(BallVel(ball) ^2 / (80000 - (79900 * Log(RollVol) / Log(100))))
  469. End Function
  470.  
  471. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  472. Pitch = BallVel(ball) * 20
  473. End Function
  474.  
  475. Function BallVel(ball) 'Calculates the ball speed
  476. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  477. End Function
  478.  
  479. Function BallVelZ(ball) 'Calculates the ball speed in the -Z
  480. BallVelZ = INT((ball.VelZ) * -1 )
  481. End Function
  482.  
  483. Function VolZ(ball) ' Calculates the Volume of the sound based on the ball speed in the Z
  484. VolZ = Csng(BallVelZ(ball) ^2 / 200)*1.2
  485. End Function
  486.  
  487. '*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
  488.  
  489. Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
  490. Dim AB, BC, CD, DA
  491. AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
  492. BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
  493. CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
  494. DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
  495.  
  496. If (AB <= 0 AND BC <=0 AND CD <= 0 AND DA <= 0) Or (AB >= 0 AND BC >=0 AND CD >= 0 AND DA >= 0) Then
  497. InRect = True
  498. Else
  499. InRect = False
  500. End If
  501. End Function
  502.  
  503.  
  504. '*****************************************
  505. ' JP's VP10 Rolling Sounds
  506. '*****************************************
  507.  
  508. Const tnob = 5 ' total number of balls
  509. ReDim rolling(tnob)
  510. InitRolling
  511.  
  512. Sub InitRolling
  513. Dim i
  514. For i = 0 to tnob
  515. rolling(i) = False
  516. Next
  517. End Sub
  518.  
  519. Sub RollingTimer_Timer()
  520. Dim BOT, b
  521. BOT = GetBalls
  522.  
  523. ' stop the sound of deleted balls
  524. For b = UBound(BOT) + 1 to tnob
  525. rolling(b) = False
  526. StopSound("fx_ballrolling" & b)
  527. Next
  528.  
  529. ' exit the sub if no balls on the table
  530. For b = 0 to UBound(BOT)
  531. If BallVel(BOT(b) ) > 1 Then
  532. rolling(b) = True
  533. if BOT(b).z < 30 Then ' Ball on playfield
  534. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), AudioPan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
  535. Else ' Ball on raised ramp
  536. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) )*.5, AudioPan(BOT(b) ), 0, Pitch(BOT(b) )+50000, 1, 0, AudioFade(BOT(b) )
  537. End If
  538. Else
  539. If rolling(b) = True Then
  540. StopSound("fx_ballrolling" & b)
  541. rolling(b) = False
  542. End If
  543. End If
  544. Next
  545. End Sub
  546.  
  547. '**********************
  548. ' Ball Collision Sound
  549. '**********************
  550.  
  551. Sub OnBallBallCollision(ball1, ball2, velocity)
  552. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / (VolDiv/VolCol), AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  553. End Sub
  554.  
  555. '************************************
  556. ' What you need to add to your table
  557. '************************************
  558.  
  559. ' a timer called RollingTimer. With a fast interval, like 10
  560. ' one collision sound, in this script is called fx_collide
  561. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  562. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  563.  
  564.  
  565. '******************************************
  566. ' Explanation of the rolling sound routine
  567. '******************************************
  568.  
  569. ' sounds are played based on the ball speed and position
  570.  
  571. ' the routine checks first for deleted balls and stops the rolling sound.
  572.  
  573. ' The For loop goes through all the balls on the table and checks for the ball speed and
  574. ' if the ball is on the table (height lower than 30) then then it plays the sound
  575. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  576.  
  577. ' The sound is played using the VOL, PAN and PITCH functions, so the volume and pitch of the sound
  578. ' will change according to the ball speed, and the PAN function will change the stereo position according
  579. ' to the position of the ball on the table.
  580.  
  581.  
  582. '**************************************
  583. ' Explanation of the collision routine
  584. '**************************************
  585.  
  586. ' The collision is built in VP.
  587. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  588. ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning
  589. ' depending of the speed of the collision.
  590.  
  591.  
  592. Sub Pins_Hit (idx)
  593. PlaySound "pinhit_low", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  594. End Sub
  595.  
  596. Sub Targets_Hit (idx)
  597. PlaySound "target", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  598. End Sub
  599.  
  600. Sub Metals_Thin_Hit (idx)
  601. PlaySound "metalhit_thin", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  602. End Sub
  603.  
  604. Sub Metals_Medium_Hit (idx)
  605. PlaySound "metalhit_medium", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  606. End Sub
  607.  
  608. Sub Metals2_Hit (idx)
  609. PlaySound "metalhit2", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  610. End Sub
  611.  
  612. Sub Gates_Hit (idx)
  613. PlaySound "gate4", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  614. End Sub
  615.  
  616. Sub Gate2_Hit():PlaySound "gate4":End Sub
  617.  
  618. Sub Spinner_Spin
  619. PlaySound "fx_spinner",0,.25,0,0.25
  620. End Sub
  621.  
  622. Sub Rubbers_Hit(idx)
  623. dim finalspeed
  624. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  625. If finalspeed > 20 then
  626. PlaySound "fx_rubber2", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  627. End if
  628. If finalspeed >= 6 AND finalspeed <= 20 then
  629. RandomSoundRubber()
  630. End If
  631. End Sub
  632.  
  633. Sub Posts_Hit(idx)
  634. dim finalspeed
  635. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  636. If finalspeed > 16 then
  637. PlaySound "fx_rubber2", 0, VolMulti(ActiveBall,.15), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  638. End if
  639. If finalspeed >= 6 AND finalspeed <= 16 then
  640. RandomSoundRubber()
  641. End If
  642. End Sub
  643.  
  644. Sub RandomSoundRubber()
  645. Select Case Int(Rnd*3)+1
  646. Case 1 : PlaySound "rubber_hit_1", 0, VolMulti(ActiveBall,.2), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  647. Case 2 : PlaySound "rubber_hit_2", 0, VolMulti(ActiveBall,.2), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  648. Case 3 : PlaySound "rubber_hit_3", 0, VolMulti(ActiveBall,.2), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  649. End Select
  650. End Sub
  651.  
  652. Sub LeftFlipper_Collide(parm)
  653. RandomSoundFlipper()
  654. End Sub
  655.  
  656. Sub RightFlipper_Collide(parm)
  657. RandomSoundFlipper()
  658. End Sub
  659.  
  660. Sub RandomSoundFlipper()
  661. Select Case Int(Rnd*3)+1
  662. Case 1 : PlaySound "flip_hit_1", 0, VolMulti(ActiveBall,.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  663. Case 2 : PlaySound "flip_hit_2", 0, VolMulti(ActiveBall,.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  664. Case 3 : PlaySound "flip_hit_3", 0, VolMulti(ActiveBall,.1), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  665. End Select
  666. End Sub
  667.  
  668. ' Thalamus : Exit in a clean and proper way
  669. Sub Table1_exit()
  670. Controller.Pause = False
  671. Controller.Stop
  672. End Sub
Advertisement
Add Comment
Please, Sign In to add comment