Arngrim

Bushido

Dec 29th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.21 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="bushidoa",UseSolenoids=1,UseLamps=1,UseSync=1,SCoin="Coin3"
  10.  
  11. LoadVPM "01130000","SPINBALL.VBS",3.10
  12.  
  13.  
  14.  
  15. '*************************************************************
  16. 'Solenoid Call backs
  17. '**********************************************************************************************************
  18.  
  19. 'SolCallback(1)= 'Credit Button Light
  20. 'SolCallback(2)= 'Coin Lockout
  21. SolCallBack(3)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker)," 'Knocker
  22. SolCallback(4)= "bsTrough.SolIn" 'Outhole
  23. SolCallback(5)= "GameStart" 'Flipper Enable
  24. 'SolCallBack(6)= "vpmSolSound ""Jet3""," 'Right Bumper
  25. 'SolCallBack(7)= "vpmSolSound ""Jet3""," 'Middle Bumper
  26. SolCallBack(8)= "dtL.SolDropUp" 'Left Target Bank
  27. SolCallback(9)= "bsTrough.SolOut" 'Ball Release
  28. SolCallBack(10)= "SolLockRelease" 'Lock Ball Release
  29. SolCallback(13)= "bsThrower.SolOut" 'Ball Launch to Ramp
  30. SolCallBack(14)= "dtR.SolDropUp" 'Right Target Bank
  31. 'SolCallBack(15)= "vpmSolSound ""Sling""," 'Right Slingshot - commented out and added to hit event
  32. 'SolCallBack(16)= "vpmSolSound ""Jet3""," 'Bottom Bumper
  33.  
  34. SolCallback(sLRFlipper) = "SolRFlipper"
  35. SolCallback(sLLFlipper) = "SolLFlipper"
  36.  
  37. Sub SolLFlipper(Enabled)
  38. If Enabled Then
  39. PlaySound SoundFX("fx_Flipperup",DOFContactors):LeftFlipper.RotateToEnd
  40. Else
  41. PlaySound SoundFX("fx_Flipperdown",DOFContactors):LeftFlipper.RotateToStart
  42. End If
  43. End Sub
  44.  
  45. Sub SolRFlipper(Enabled)
  46. If Enabled Then
  47. PlaySound SoundFX("fx_Flipperup",DOFContactors):RightFlipper.RotateToEnd
  48. Else
  49. PlaySound SoundFX("fx_Flipperdown",DOFContactors):RightFlipper.RotateToStart
  50. End If
  51. End Sub
  52.  
  53. 'Playfield GI
  54. '*****GI Lights On
  55. dim xx
  56. For each xx in GI:xx.State = 1: Next
  57.  
  58. Sub GameStart(Enabled)
  59. vpmNudge.SolGameOn Enabled
  60. End Sub
  61.  
  62. '**********************************************************************************************************
  63.  
  64. 'Initiate Table
  65. '**********************************************************************************************************
  66.  
  67. Dim bsTrough, dtL, dtR, bsThrower
  68.  
  69. Sub Table1_Init
  70. vpmInit Me
  71. On Error Resume Next
  72. With Controller
  73. .GameName = cGameName
  74. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  75. .SplashInfoLine = ""&chr(13)&"You Suck"
  76. .HandleMechanics=0
  77. .HandleKeyboard=0
  78. .ShowDMDOnly=1
  79. .ShowFrame=0
  80. .ShowTitle=0
  81. .hidden = 0
  82. .Games(cGameName).Settings.Value("sound")=1
  83. '.PuPHide = 1
  84. On Error Resume Next
  85. .Run GetPlayerHWnd
  86. If Err Then MsgBox Err.Description
  87. On Error Goto 0
  88. End With
  89. On Error Goto 0
  90.  
  91. PinMAMETimer.Interval=PinMAMEInterval
  92. PinMAMETimer.Enabled=1
  93.  
  94. vpmNudge.TiltSwitch=33
  95. vpmNudge.Sensitivity=2
  96. vpmNudge.TiltObj=Array(Bumper1,Bumper2,Bumper3,RightSlingshot)
  97.  
  98. Set bsTrough=New cvpmBallStack
  99. bsTrough.InitSw 71,31,64,70,0,0,0,0
  100. bsTrough.InitKick BallRelease,50,6
  101. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  102. bsTrough.Balls=3
  103.  
  104. Set bsThrower=New cvpmBallStack
  105. bsThrower.InitSaucer sw50,50,0,25
  106. bsThrower.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  107.  
  108. Set dtL=New cvpmDropTarget
  109. dtL.InitDrop Array(sw52,sw51,sw53),Array(52,51,53)
  110. dtL.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  111.  
  112. Set dtR=New cvpmDropTarget
  113. dtR.InitDrop Array(sw56,sw54,sw55),Array(56,54,55)
  114. dtR.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  115.  
  116. vpmMapLights AllLights
  117.  
  118. L2.IsDropped=1
  119. L3.IsDropped=1
  120.  
  121. End Sub
  122.  
  123.  
  124. '**********************************************************************************************************
  125. 'Plunger code
  126. '**********************************************************************************************************
  127. Sub Table1_KeyDown(ByVal KeyCode)
  128. If keycode = LeftMagnaSave Then bLutActive = True
  129. If keycode = RightMagnaSave Then
  130. If bLutActive Then NextLUT: End If
  131. End If
  132. If KeyCode=keyInsertCoin1 Or KeyCode=keyInsertCoin2 or KeyCode=keyInsertCoin3 Then
  133. Controller.Switch(30)=1
  134. Exit Sub
  135. End If
  136.  
  137. If KeyCode=RightFlipperKey Then Controller.Switch(45)=1
  138. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  139. If KeyDownHandler(keycode) Then Exit Sub
  140. End Sub
  141.  
  142. Sub Table1_KeyUp(ByVal KeyCode)
  143. If keycode = LeftMagnaSave Then bLutActive = False
  144. If KeyCode=keyInsertCoin1 Or KeyCode=keyInsertCoin2 or KeyCode=keyInsertCoin3 Then
  145. Controller.Switch(30)=0
  146. Exit Sub
  147. End If
  148.  
  149. If KeyCode=RightFlipperKey Then Controller.Switch(45)=0
  150. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  151. If KeyUpHandler(keycode) Then Exit Sub
  152. End Sub
  153.  
  154. '********************************************************************************************************
  155.  
  156. ' Drain hole and kickers
  157. Sub Drain_Hit:bsTrough.AddBall Me : playsound"drain" : End Sub
  158. Sub sw50_Hit:bsThrower.AddBall 0 : playsound "popper_ball": End Sub
  159.  
  160. 'Drop Targets
  161. Sub Sw52_Dropped:dtL.Hit 1 :End Sub
  162. Sub Sw51_Dropped:dtL.Hit 2 :End Sub
  163. Sub Sw53_Dropped:dtL.Hit 3 :End Sub
  164.  
  165. Sub Sw56_Dropped:dtR.Hit 1 :End Sub
  166. Sub Sw54_Dropped:dtR.Hit 2 :End Sub
  167. Sub Sw55_Dropped:dtR.Hit 3 :End Sub
  168.  
  169. 'Wire Triggers
  170. Sub SW32_Hit:Controller.Switch(32)=1 : playsound"rollover" : End Sub
  171. Sub SW32_unHit:Controller.Switch(32)=0:End Sub
  172. Sub SW41_Hit:Controller.Switch(4)=1 : playsound"rollover" : End Sub
  173. Sub SW41_unHit:Controller.Switch(4)=0:End Sub
  174. Sub SW41a_Hit:Controller.Switch(4)=1 : playsound"rollover" : End Sub
  175. Sub SW41s_unHit:Controller.Switch(4)=0:End Sub
  176. Sub SW42_Hit:Controller.Switch(42)=1 : playsound"rollover" : End Sub
  177. Sub SW42_unHit:Controller.Switch(42)=0:End Sub
  178. Sub SW43_Hit:Controller.Switch(43)=1 : playsound"rollover" : End Sub
  179. Sub SW43_unHit:Controller.Switch(43)=0:End Sub
  180. Sub SW44_Hit:Controller.Switch(44)=1 : playsound"rollover" : End Sub
  181. Sub SW44_unHit:Controller.Switch(44)=0:End Sub
  182. Sub SW60_Hit:Controller.Switch(60)=1 : playsound"rollover" : End Sub
  183. Sub SW60_unHit:Controller.Switch(60)=0:End Sub
  184. Sub SW72_Hit:Controller.Switch(72)=1 : playsound"rollover" : End Sub
  185. Sub SW72_unHit:Controller.Switch(72)=0:End Sub
  186. Sub SW73_Hit:Controller.Switch(73)=1 : playsound"rollover" : End Sub
  187. Sub SW73_unHit:Controller.Switch(73)=0:End Sub
  188. Sub SW74_Hit:Controller.Switch(74)=1 : playsound"rollover" : End Sub
  189. Sub SW74_unHit:Controller.Switch(74)=0:End Sub
  190. Sub SW75_Hit:Controller.Switch(75)=1 : playsound"rollover" : End Sub
  191. Sub SW75_unHit:Controller.Switch(75)=0:End Sub
  192. Sub SW87_Hit:Controller.Switch(87)=1 : playsound"rollover" : End Sub
  193. Sub SW87_unHit:Controller.Switch(87)=0:End Sub
  194.  
  195. 'Ramp Triggers
  196. Sub SW65_Hit:Controller.Switch(65)=1 : playsound"rollover" : End Sub
  197. Sub SW65_unHit:Controller.Switch(65)=0:End Sub
  198. Sub SW67_Hit:Controller.Switch(67)=1 : playsound"rollover" : End Sub
  199. Sub SW67_unHit:Controller.Switch(67)=0:End Sub
  200. Sub SW77_Hit:Controller.Switch(77)=1 : playsound"rollover" : End Sub
  201. Sub SW77_unHit:Controller.Switch(77)=0:End Sub
  202. Sub SW86_Hit:Controller.Switch(86)=1 : playsound"rollover" : End Sub
  203. Sub SW86_unHit:Controller.Switch(86)=0:End Sub
  204.  
  205. 'Bumpers
  206. Sub Bumper1_Hit:vpmTimer.PulseSw 40 : PlayBumperSound : End Sub
  207. Sub Bumper2_Hit:vpmTimer.PulseSw 66 : PlayBumperSound : End Sub
  208. Sub Bumper3_Hit:vpmTimer.PulseSw 76 : PlayBumperSound : End Sub
  209.  
  210. Sub PlayBumperSound()
  211. Select Case Int(Rnd*3)+1
  212. Case 1 : PlaySound SoundFX("fx_bumper_1",DOFContactors)
  213. Case 2 : PlaySound SoundFX("fx_bumper_2",DOFContactors)
  214. Case 3 : PlaySound SoundFX("fx_bumper_3",DOFContactors)
  215. End Select
  216. End Sub
  217.  
  218. 'Stand Up Targets
  219. Sub S47_Hit:vpmTimer.PulseSw 47:PlaySound"target":End Sub
  220. Sub S57_Hit:vpmTimer.PulseSw 57:PlaySound"target":End Sub
  221. Sub S61_Hit:vpmTimer.PulseSw 61:PlaySound"target":End Sub
  222. Sub S62_Hit:vpmTimer.PulseSw 62:PlaySound"target":End Sub
  223. Sub S63_Hit:vpmTimer.PulseSw 63:PlaySound"target":End Sub
  224.  
  225. '********** Gates **********
  226.  
  227. Sub Gate1_Hit:PlaySound "Gate5":End Sub
  228. Sub Gate2_Hit:PlaySound "Gate5":End Sub
  229. Sub Gate3_Hit:PlaySound "Gate5":End Sub
  230. Sub Gate4_Hit:PlaySound "Gate5":End Sub
  231. Sub Gate5_Hit:PlaySound "Gate5":End Sub
  232. Sub Gate6_Hit:PlaySound "Gate5":End Sub
  233. Sub Gate7_Hit:PlaySound "Gate5":End Sub
  234.  
  235. '********************************************************************************************************
  236. ' Lock Ball Release
  237. '********************************************************************************************************
  238. Dim LockPos
  239. LockPos=0
  240. Dim MasterLock
  241. MasterLock=Array(L3,L1,L2,L3,L1,L2,L3,L1,L2)
  242. Dim LockedBalls(3)
  243. LockedBalls(0)=0:LockedBalls(1)=0:LockedBalls(2)=0:LockedBalls(3)=0
  244. Dim Release
  245. Release=0
  246.  
  247. Sub SolLockRelease(Enabled)
  248. If Enabled Then
  249. Flipper1.RotateToEnd
  250. Release=1
  251. Else
  252. Flipper1.RotateToStart
  253. Release=0
  254. End If
  255. End Sub
  256.  
  257. Sub Timer2_Timer
  258. MasterLock(LockPos).IsDropped=1
  259. CheckLocked
  260. LockPos=LockPos+1
  261. If LockPos>8 Then LockPos=0
  262. ruleta.RotY = -40*LockPos +40
  263. prueba.RotZ = -40*LockPos +40
  264. MasterLock(LockPos).IsDropped=0
  265. End Sub
  266.  
  267.  
  268. Sub Kicker3_Hit:Kicker3.DestroyBall:Kicker1.CreateBall:LockedBalls(3)=1:Timer2_Timer:End Sub
  269. 'Sub Trigger1_Hit:ActiveBall.VelY=3:End Sub
  270.  
  271. Sub CheckLocked
  272. L1A.DestroyBall:L1B.DestroyBall:L1C.DestroyBall:L1D.DestroyBall:L1E.DestroyBall
  273. L1F.DestroyBall:L1G.DestroyBall:L1H.DestroyBall:L1I.DestroyBall
  274. Select Case LockPos
  275. Case 0:Controller.Switch(85)=1:If LockedBalls(3)=1 And LockedBalls(0)=0 Then
  276. Kicker1.DestroyBall
  277. LockedBalls(0)=1
  278. LockedBalls(3)=0
  279. Else
  280. Kicker1.Kick 320,5
  281. End If
  282. If LockedBalls(0)=1 Then L1A.CreateBall.Image="L1APic"
  283. If LockedBalls(1)=1 Then L1D.CreateBall.Image="L1DPic"
  284. If LockedBalls(2)=1 Then L1G.CreateBall
  285. Case 1:Controller.Switch(85)=0:If LockedBalls(3)=1 And LockedBalls(0)=0 Then
  286. Kicker1.DestroyBall
  287. LockedBalls(0)=1
  288. LockedBalls(3)=0
  289. Else
  290. Kicker1.Kick 320,5
  291. End If
  292.  
  293. If LockedBalls(0)=1 Then L1B.CreateBall.Image="L1BPic"
  294. If LockedBalls(1)=1 Then L1E.CreateBall.Image="L1EPic"
  295. If LockedBalls(2)=1 Then L1H.CreateBall
  296. Case 2:Kicker1.Kick 320,5:LockedBalls(3)=0
  297. If LockedBalls(0)=1 Then L1C.CreateBall.Image="L1CPic"
  298. If LockedBalls(1)=1 Then L1F.CreateBall
  299. If LockedBalls(2)=1 Then L1I.CreateBall.Image="L1IPic"
  300. If Release=1 Then
  301. L1F.Kick 250,15
  302. LockedBalls(1)=0
  303. End If
  304. Case 3:Controller.Switch(83)=1:If LockedBalls(3)=1 And LockedBalls(2)=0 Then
  305. Kicker1.DestroyBall
  306. LockedBalls(2)=1
  307. LockedBalls(3)=0
  308. Else
  309. Kicker1.Kick 320,5
  310. End If
  311. If LockedBalls(0)=1 Then L1D.CreateBall.Image="L1DPic"
  312. If LockedBalls(1)=1 Then L1G.CreateBall
  313. If LockedBalls(2)=1 Then L1A.CreateBall.Image="L1APic"
  314. Case 4:Controller.Switch(83)=0::If LockedBalls(3)=1 And LockedBalls(2)=0 Then
  315. Kicker1.DestroyBall
  316. LockedBalls(2)=1
  317. LockedBalls(3)=0
  318. Else
  319. Kicker1.Kick 320,5
  320. End If
  321. If LockedBalls(0)=1 Then L1E.CreateBall.Image="L1EPic"
  322. If LockedBalls(1)=1 Then L1H.CreateBall
  323. If LockedBalls(2)=1 Then L1B.CreateBall.Image="L1BPic"
  324. Case 5:Kicker1.Kick 320,5:LockedBalls(3)=0
  325. If LockedBalls(0)=1 Then L1F.CreateBall
  326. If LockedBalls(1)=1 Then L1I.CreateBall.Image="L1IPic"
  327. If LockedBalls(2)=1 Then L1C.CreateBall.Image="L1CPic"
  328. If Release=1 Then
  329. L1F.Kick 250,15
  330. LockedBalls(0)=0
  331. End If
  332. Case 6:Controller.Switch(84)=1:If LockedBalls(3)=1 And LockedBalls(1)=0 Then
  333. Kicker1.DestroyBall
  334. LockedBalls(1)=1
  335. LockedBalls(3)=0
  336. Else
  337. Kicker1.Kick 320,5
  338. End If
  339. If LockedBalls(0)=1 Then L1G.CreateBall
  340. If LockedBalls(1)=1 Then L1A.CreateBall.Image="L1APic"
  341. If LockedBalls(2)=1 Then L1D.CreateBall.Image="L1DPic"
  342. Case 7:Controller.Switch(84)=0:If LockedBalls(3)=1 And LockedBalls(1)=0 Then
  343. Kicker1.DestroyBall
  344. LockedBalls(1)=1
  345. LockedBalls(3)=0
  346. Else
  347. Kicker1.Kick 320,5
  348. End If
  349. If LockedBalls(0)=1 Then L1H.CreateBall
  350. If LockedBalls(1)=1 Then L1B.CreateBall.Image="L1BPic"
  351. If LockedBalls(2)=1 Then L1E.CreateBall.Image="L1EPic"
  352. Case 8:Kicker1.Kick 320,5:LockedBalls(3)=0
  353. If LockedBalls(0)=1 Then L1I.CreateBall.Image="L1IPic"
  354. If LockedBalls(1)=1 Then L1C.CreateBall.Image="L1CPic"
  355. If LockedBalls(2)=1 Then L1F.CreateBall
  356. If Release=1 Then
  357. L1F.Kick 250,15
  358. LockedBalls(2)=0
  359. End If
  360. End Select
  361. Controller.Switch(82)=LockedBalls(0)
  362. Controller.Switch(80)=LockedBalls(1)
  363. Controller.Switch(81)=LockedBalls(2)
  364. End Sub
  365.  
  366.  
  367. '********************************************************************************************************
  368. 'Objects controlled by light state
  369. '********************************************************************************************************
  370.  
  371. 'Lock Switches
  372. '80/83 top -- 80=Feeler Yellow, 83=Passage by Zero
  373. '81/84 left -- 81=Feeler Red, 84=Passage by Zero
  374. '82/85 right -- 82=Feeler Violet, 85=Passage by Zero
  375. Set LampCallback=GetRef("UpdateMultipleLamps")
  376. Dim StartLock,StopLock,SLock1,SLock2
  377. SLock1=0:SLock2=0
  378.  
  379. Sub UpdateMultipleLamps
  380.  
  381. StopLock=Light23.State
  382. If StopLock<>SLock2 Then
  383. If StopLock=1 Then
  384. Timer2.Enabled=0
  385. SLock2=StopLock
  386. Exit Sub
  387. End If
  388. End If
  389. SLock2=StopLock
  390. StartLock=Light24.State
  391. If StartLock<>SLock1 Then
  392. If StartLock=1 Then
  393. Timer2.Enabled=1
  394. Else
  395. Timer2.Enabled=0
  396. End If
  397. End If
  398. SLock1=StartLock
  399. End Sub
  400.  
  401. '********************************************************************************************************
  402. '********************************************************************************************************
  403.  
  404. 'Inder Bushido
  405. 'added by Inkochnito
  406. Sub editDips
  407. Dim vpmDips:Set vpmDips=New cvpmDips
  408. With vpmDips
  409. .AddForm 700,400,"Bushido - DIP switches"
  410. .AddFrame 2,0,190,"Credits per coin",&H0000000F,Array("1 coin - 1 credit && 2 coin - 3 credits",&H0000000A,"2 coin - 1 credit && 4 coin - 3 credits",&H0000000F,"2 coin - 1 credit",&H0000000D,"1 coin - 1 credit",&H00000009)'SL1-4,3,2,1 (dip 1,2,3,4)
  411. .AddFrame 2,76,190,"Extra ball stays lit for",49152,Array("8 seconds",0,"10 seconds",32768,"12 seconds",&H00004000,"15 seconds",49152)'SL2-5&6 (dip 16&15)
  412. .AddFrame 2,152,190,"Balls per game",&H00000800,Array ("3 balls",0,"5 balls",&H00000800)'SL2-1 (dip 12)
  413. .AddFrame 205,0,190,"Replay threshold",&H000000B0,Array("100 million points",0,"150 million points",&H00000080,"200 million points",&H00000040,"250 million points",&H000000B0)'SL1-5&6 (dip 8&7)
  414. .AddFrame 205,76,190,"Handicap value",&H00000300,Array("250 million points",0,"300 million points",&H00000100,"350 million points",&H00000200,"400 million points",&H00000300)'SL2-3&4 (dip 10&9)
  415. .AddLabel 50,205,300,20,"After hitting OK, press F3 to reset game with new settings."
  416. .ViewDips
  417. End With
  418. End Sub
  419. Set vpmShowDips=GetRef("editDips")
  420.  
  421.  
  422. '**********Sling Shot Animations
  423. ' Rstep and Lstep are the variables that increment the animation
  424. '****************
  425. Dim RStep, Lstep
  426.  
  427. Sub RightSlingShot_Slingshot
  428. vpmTimer.PulseSw 46
  429. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  430. RSling.Visible = 0
  431. RSling1.Visible = 1
  432. sling1.rotx = 20
  433. RStep = 0
  434. RightSlingShot.TimerEnabled = 1
  435. End Sub
  436.  
  437. Sub RightSlingShot_Timer
  438. Select Case RStep
  439. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  440. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
  441. End Select
  442. RStep = RStep + 1
  443. End Sub
  444.  
  445. '*************
  446. ' JP'S LUT
  447. '*************
  448.  
  449. Dim bLutActive, LUTImage
  450. Sub LoadLUT
  451. Dim x
  452. x = LoadValue(cGameName, "LUTImage")
  453. If(x <> "") Then LUTImage = x Else LUTImage = 0
  454. UpdateLUT
  455. End Sub
  456.  
  457. Sub SaveLUT
  458. SaveValue cGameName, "LUTImage", LUTImage
  459. End Sub
  460.  
  461. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  462.  
  463. Sub UpdateLUT
  464. Select Case LutImage
  465. Case 0: table1.ColorGradeImage = "LUT0"
  466. Case 1: table1.ColorGradeImage = "LUT1"
  467. Case 2: table1.ColorGradeImage = "LUT2"
  468. Case 3: table1.ColorGradeImage = "LUT3"
  469. Case 4: table1.ColorGradeImage = "LUT4"
  470. Case 5: table1.ColorGradeImage = "LUT5"
  471. Case 6: table1.ColorGradeImage = "LUT6"
  472. Case 7: table1.ColorGradeImage = "LUT7"
  473. Case 8: table1.ColorGradeImage = "LUT8"
  474. Case 9: table1.ColorGradeImage = "LUT9"
  475.  
  476. End Select
  477. End Sub
  478.  
  479.  
  480. '*********************************************************************
  481. ' Positional Sound Playback Functions
  482. '*********************************************************************
  483.  
  484. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  485. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  486. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  487. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  488. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  489. End Sub
  490.  
  491. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  492. Sub PlaySoundAt(soundname, tableobj)
  493. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  494. End Sub
  495.  
  496. Sub PlaySoundAtBall(soundname)
  497. PlaySoundAt soundname, ActiveBall
  498. End Sub
  499.  
  500.  
  501. '*********************************************************************
  502. ' Supporting Ball & Sound Functions
  503. '*********************************************************************
  504.  
  505. 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
  506. Dim tmp
  507. tmp = tableobj.y * 2 / table1.height-1
  508. If tmp > 0 Then
  509. AudioFade = Csng(tmp ^10)
  510. Else
  511. AudioFade = Csng(-((- tmp) ^10) )
  512. End If
  513. End Function
  514.  
  515. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  516. Dim tmp
  517. tmp = tableobj.x * 2 / table1.width-1
  518. If tmp > 0 Then
  519. AudioPan = Csng(tmp ^10)
  520. Else
  521. AudioPan = Csng(-((- tmp) ^10) )
  522. End If
  523. End Function
  524.  
  525. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  526. Vol = Csng(BallVel(ball) ^2 / 2000)
  527. End Function
  528.  
  529. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  530. Pitch = BallVel(ball) * 20
  531. End Function
  532.  
  533. Function BallVel(ball) 'Calculates the ball speed
  534. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  535. End Function
  536.  
  537.  
  538. '********************************************************************
  539. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  540. '********************************************************************
  541.  
  542. Const tnob = 5 ' total number of balls
  543. ReDim rolling(tnob)
  544. InitRolling
  545.  
  546. Sub InitRolling
  547. Dim i
  548. For i = 0 to tnob
  549. rolling(i) = False
  550. Next
  551. End Sub
  552.  
  553. Sub RollingTimer_Timer()
  554. Dim BOT, b
  555. BOT = GetBalls
  556.  
  557. ' stop the sound of deleted balls
  558. For b = UBound(BOT) + 1 to tnob
  559. rolling(b) = False
  560. StopSound("fx_ballrolling" & b)
  561. Next
  562.  
  563. ' exit the sub if no balls on the table
  564. If UBound(BOT) = -1 Then Exit Sub
  565.  
  566. For b = 0 to UBound(BOT)
  567. ' play the rolling sound for each ball
  568. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  569. rolling(b) = True
  570. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  571. Else
  572. If rolling(b) = True Then
  573. StopSound("fx_ballrolling" & b)
  574. rolling(b) = False
  575. End If
  576. End If
  577.  
  578. ' play ball drop sounds
  579. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  580. PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  581. End If
  582. Next
  583. End Sub
  584.  
  585. '**********************
  586. ' Ball Collision Sound
  587. '**********************
  588.  
  589. Sub OnBallBallCollision(ball1, ball2, velocity)
  590. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  591. End Sub
  592.  
  593.  
  594.  
  595. '*****************************************
  596. ' ninuzzu's FLIPPER SHADOWS
  597. '*****************************************
  598.  
  599. sub FlipperTimer_Timer()
  600. FlipperLSh.RotZ = LeftFlipper.currentangle
  601. FlipperRSh.RotZ = RightFlipper.currentangle
  602. LFPrim.RotY = LeftFlipper.CurrentAngle
  603. RFPrim.RotY = RightFlipper.CurrentAngle
  604.  
  605. End Sub
  606.  
  607. '*****************************************
  608. ' ninuzzu's BALL SHADOW
  609. '*****************************************
  610. Dim BallShadow
  611. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  612.  
  613. Sub BallShadowUpdate_timer()
  614. Dim BOT, b
  615. BOT = GetBalls
  616. ' hide shadow of deleted balls
  617. If UBound(BOT)<(tnob-1) Then
  618. For b = (UBound(BOT) + 1) to (tnob-1)
  619. BallShadow(b).visible = 0
  620. Next
  621. End If
  622. ' exit the Sub if no balls on the table
  623. If UBound(BOT) = -1 Then Exit Sub
  624. ' render the shadow for each ball
  625. For b = 0 to UBound(BOT)
  626. If BOT(b).X < Table1.Width/2 Then
  627. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  628. Else
  629. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  630. End If
  631. ballShadow(b).Y = BOT(b).Y + 12
  632. If BOT(b).Z > 20 Then
  633. BallShadow(b).visible = 1
  634. Else
  635. BallShadow(b).visible = 0
  636. End If
  637. Next
  638. End Sub
  639.  
  640.  
  641.  
  642. '************************************
  643. ' What you need to add to your table
  644. '************************************
  645.  
  646. ' a timer called RollingTimer. With a fast interval, like 10
  647. ' one collision sound, in this script is called fx_collide
  648. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  649. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  650.  
  651.  
  652. '******************************************
  653. ' Explanation of the rolling sound routine
  654. '******************************************
  655.  
  656. ' sounds are played based on the ball speed and position
  657.  
  658. ' the routine checks first for deleted balls and stops the rolling sound.
  659.  
  660. ' The For loop goes through all the balls on the table and checks for the ball speed and
  661. ' if the ball is on the table (height lower than 30) then then it plays the sound
  662. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  663.  
  664. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  665. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  666. ' according to the position of the ball on the table.
  667.  
  668.  
  669. '**************************************
  670. ' Explanation of the collision routine
  671. '**************************************
  672.  
  673. ' The collision is built in VP.
  674. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  675. ' 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
  676. ' depending of the speed of the collision.
  677.  
  678.  
  679. Sub Pins_Hit (idx)
  680. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  681. End Sub
  682.  
  683. Sub Targets_Hit (idx)
  684. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  685. End Sub
  686.  
  687. Sub Metals_Thin_Hit (idx)
  688. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  689. End Sub
  690.  
  691. Sub Metals_Medium_Hit (idx)
  692. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  693. End Sub
  694.  
  695. Sub Metals2_Hit (idx)
  696. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  697. End Sub
  698.  
  699. Sub Gates_Hit (idx)
  700. PlaySound "Gate5", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  701. End Sub
  702.  
  703. Sub Spinner_Spin
  704. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  705. End Sub
  706.  
  707. Sub Rubbers_Hit(idx)
  708. dim finalspeed
  709. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  710. If finalspeed > 20 then
  711. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  712. End if
  713. If finalspeed >= 6 AND finalspeed <= 20 then
  714. RandomSoundRubber()
  715. End If
  716. End Sub
  717.  
  718. Sub Posts_Hit(idx)
  719. dim finalspeed
  720. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  721. If finalspeed > 16 then
  722. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  723. End if
  724. If finalspeed >= 6 AND finalspeed <= 16 then
  725. RandomSoundRubber()
  726. End If
  727. End Sub
  728.  
  729. Sub RandomSoundRubber()
  730. Select Case Int(Rnd*3)+1
  731. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  732. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  733. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  734. End Select
  735. End Sub
  736.  
  737. Sub LeftFlipper_Collide(parm)
  738. RandomSoundFlipper()
  739. End Sub
  740.  
  741. Sub RightFlipper_Collide(parm)
  742. RandomSoundFlipper()
  743. End Sub
  744.  
  745. Sub RandomSoundFlipper()
  746. Select Case Int(Rnd*3)+1
  747. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  748. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  749. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  750. End Select
  751. End Sub
  752.  
  753.  
  754. ' Ramps sounds
  755. Sub RampSound1_Hit: PlaySound "fx_metalrolling1": End Sub
  756. Sub RampSound3_Hit: PlaySound "fx_metalrolling1": End Sub
  757. Sub RampSound9_Hit: PlaySound "fx_plasticrolling1": End Sub
  758. Sub RampSound10_Hit: PlaySound "fx_plasticrolling1": End Sub
  759. ' Stop Ramps Sounds
  760. Sub RampSound2_Hit: StopSound "fx_metalrolling1": End Sub
  761. Sub RampSound4_Hit: StopSound "fx_metalrolling1": End Sub
  762. Sub RampSound5_Hit: StopSound "fx_metalrolling1": End Sub
  763. Sub RampSound6_Hit: StopSound "fx_plasticrolling1": End Sub
  764. Sub RampSound7_Hit: StopSound "fx_plasticrolling1": End Sub
  765. Sub RampSound8_Hit: StopSound "fx_plasticrolling1": End Sub
  766. Sub RampSound11_Hit: StopSound "fx_plasticrolling1": End Sub
  767. Sub RampSound12_Hit: StopSound "fx_plasticrolling1": End Sub
  768.  
  769.  
  770. Sub Table1_Exit
  771. If B2SOn Then Controller.Stop
  772. End Sub
Advertisement
Add Comment
Please, Sign In to add comment