Guest User

Untitled

a guest
Dec 22nd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.80 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 file in order to run this table (installed with the VPX package in the scripts folder)"
  7. On Error Goto 0
  8.  
  9. LoadVPM "01120100","sys80.vbs",3.36
  10.  
  11. Dim bsTrough,gsTrough,FlipperShadows,dtYellow,dtBlue,bsSaucer,xx
  12. FlipperShadows = 1 ' 1 turns on, 0 turns off flipper shadows.
  13.  
  14. Const UseSolenoids=2,UseLamps=1,UseSync=0,UseGI=0,HandleMech=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff",SFlipperOn="FlipperUp",SFlipperOff="FlipperDown"
  15. Const cGameName="rackemup"
  16. Const SCoin="fx_coin"
  17.  
  18. Const shooter=2'ok
  19. Const sdtBlue=5'ok 3 bank targets
  20. Const sdtYellow=6'ok 4 bank targets
  21. Const sCoin1=3'ok
  22. Const sCoin2=4'ok
  23. Const sCoin3=7'ok
  24. Const sknocker=8
  25. Const sOutHole=9'ok
  26. Const swCaptiveBack=64
  27.  
  28. SolCallback(shooter)="bssaucer.solout"
  29. SolCallback(sdtYellow)="dtYellow.SolDropUp"
  30. SolCallback(sdtBlue)="dtBlue.SolDropUp"
  31. SolCallback(sKnocker)="VpmSolSound SoundFX(""knocker"",DOFKnocker),"
  32. SolCallback(sOutHole)="bsTrough.SolOut"
  33.  
  34. SolCallback(sLLFlipper)="SolLFlipper"
  35. SolCallback(sLRFlipper)="SolRFlipper"
  36.  
  37. Sub SolLFlipper(Enabled)
  38. If Enabled Then
  39. PlaySound SoundFX("flipperup2", DOFFlippers), 0, 1, -0.1, 0.05
  40. LeftFlipper.RotateToEnd
  41. Else
  42. PlaySound SoundFX("flipperdown2", DOFFlippers), 0, 1, -0.1, 0.05
  43. LeftFlipper.RotateToStart
  44. End If
  45. End Sub
  46.  
  47. Sub SolRFlipper(Enabled)
  48. If Enabled Then
  49. PlaySound SoundFX("flipperup2", DOFFlippers), 0, 1, 0.1, 0.05
  50. RightFlipper.RotateToEnd
  51. Else
  52. PlaySound SoundFX("flipperdown2", DOFFlippers), 0, 1, 0.1, 0.05
  53. RightFlipper.RotateToStart
  54. End If
  55. End Sub
  56.  
  57. '***********************************************************************
  58. 'Hidden elements
  59. '***********************************************************************
  60.  
  61. Dim DesktopMode: DesktopMode = Table1.ShowDT
  62.  
  63. If DesktopMode = True Then 'Show Desktop components
  64. Ramp16.visible=1
  65. Ramp15.visible=1
  66. Ramp17.visible=1
  67. Primitive52.visible=1
  68. Tornillo24.visible=1
  69. Tornillo25.visible=1
  70. Tornillo26.visible=1
  71. Tornillo27.visible=1
  72. L3b.visible=1
  73. L10.visible=1
  74. L11.visible=1
  75. Else
  76. Ramp16.visible=0
  77. Ramp15.visible=0
  78. Ramp17.visible=0
  79. Primitive52.visible=0
  80. Tornillo24.visible=0
  81. Tornillo25.visible=0
  82. Tornillo26.visible=0
  83. Tornillo27.visible=0
  84. L3b.visible=0
  85. L10.visible=0
  86. L11.visible=0
  87.  
  88. End if
  89.  
  90. '********************************************************************
  91. 'Table Init
  92. '********************************************************************
  93.  
  94. Sub Table1_Init
  95. vpmInit me
  96. With Controller
  97. .GameName = cGameName
  98. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
  99. .SplashInfoLine = "Rack Em Up (Gottlieb 1983)" & vbNewLine & "VPX Table By Kalavera"
  100. .HandleKeyboard = 0
  101. .ShowTitle = 0
  102. .ShowDMDOnly = 1
  103. .ShowFrame = 0
  104. .HandleMechanics = 0
  105. .Hidden = 0
  106. .Games(cGameName).Settings.Value("rol") = 0 '1= rotated display, 0= normal
  107. '.SetDisplayPosition 0,0, GetPlayerHWnd 'restore dmd window position
  108. On Error Resume Next
  109. Controller.SolMask(0) = 0
  110. vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the Timer to renable all the solenoids after 2 seconds
  111. Controller.Run GetPlayerHWnd
  112. On Error Goto 0
  113. End With
  114.  
  115. 'Nudging
  116. vpmNudge.TiltSwitch = 57
  117. vpmNudge.Sensitivity = 3
  118. vpmNudge.TiltObj = Array(Bumper1,Bumper2,Bumper3,LeftSlingshot,RightSlingshot)
  119.  
  120. 'Main Timer init
  121. PinMAMETimer.Interval = PinMAMEInterval
  122. PinMAMETimer.Enabled = 1
  123.  
  124. 'Add a Ball
  125. Set bsTrough=New cvpmBallStack
  126. bsTrough.InitSw 0,67,0,0,0,0,0,0
  127. bsTrough.InitKick BallRelease,62,8
  128. bsTrough.InitExitSnd SoundFX("Ballrelease",DOFContactors),SoundFX("SolOn",DOFContactors)
  129. bsTrough.Balls=1
  130.  
  131. 'drop targets
  132. Set dtBlue=New cvpmDropTarget
  133. dtBlue.InitDrop Array(SW41,SW51,SW61),Array(41,51,61)
  134. dtBlue.InitSnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
  135. dtBlue.CreateEvents "dtBlue"
  136.  
  137. Set dtYellow=New cvpmDropTarget
  138. dtYellow.InitDrop Array(SW40,SW50,SW60,SW70),Array(40,50,60,70)
  139. dtYellow.InitSnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
  140. dtYellow.CreateEvents "dtYellow"
  141. 'Kicker
  142. Set bsSaucer=New cvpmBallStack
  143. bsSaucer.InitSaucer SW65,65,0,42
  144. bsSaucer.InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  145. bsSaucer.KickForceVar=7
  146.  
  147. End Sub
  148.  
  149. Sub Table1_KeyDown(ByVal keycode)
  150. If keycode=RightFlipperKey then Controller.Switch(71)=1
  151. If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25
  152. If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25
  153. If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0, 0.25
  154. If keycode = PlungerKey Then Plunger.PullBack: PlaySound "fx_plungerpull",0,1,0.25,0.25
  155. If vpmKeyDown(keycode)Then Exit Sub
  156. End Sub
  157.  
  158. Sub Table1_KeyUp(ByVal keycode)
  159. If keycode=RightFlipperKey then Controller.Switch(71)=0
  160. If keycode = PlungerKey Then Plunger.Fire: PlaySound "fx_plunger",0,1,0.25,0.25
  161. If vpmKeyUp(keycode)Then Exit Sub
  162. End Sub
  163.  
  164. '***********************************************************************
  165. 'Switchs
  166. '***********************************************************************
  167. Dim Kick1
  168.  
  169. ' Drain hole
  170. Sub Drain_Hit:Playsound "drain":bsTrough.AddBall Me:End Sub
  171.  
  172. 'Rubbers
  173. Sub SW16_Hit:vpmTimer.PulseSw(16):End Sub'rebound
  174. Sub SW16B_Hit:vpmTimer.PulseSw(16):End Sub'rebound
  175.  
  176. 'StandUp Targets
  177. Sub SW55_Hit:vpmTimer.PulseSw(55):End Sub'single target
  178.  
  179. ' Saucers
  180. Sub SW65_Hit:bsSaucer.AddBall 0 : playsound "fx_kicker4": End Sub
  181.  
  182. 'spinners
  183. Sub Spinner_Spin:vpmTimer.PulseSw(64):PlaySound "fx_spinner", 0, 1, 0.05:End Sub
  184.  
  185. ' Droptargets (only sound effect)
  186. Sub sw40_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  187. Sub sw41_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  188. Sub sw50_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  189. Sub sw51_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  190. Sub sw60_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  191. Sub sw61_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  192. Sub sw70_Hit:PlaySound SoundFX("drop", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  193.  
  194. 'Wire Triggers
  195. Sub sw42_Hit:Controller.Switch(42)=1:End Sub '#1 top rollover
  196. Sub sw42_UnHit:Controller.Switch(42)=0:End Sub '
  197. Sub sw43_Hit:Controller.Switch(43)=1:End Sub 'Left Side rollover
  198. Sub sw43_UnHit:Controller.Switch(43)=0:End Sub '
  199. Sub sw44_Hit:Controller.Switch(44)=1:End Sub 'Right return rollover
  200. Sub sw44_UnHit:Controller.Switch(44)=0:End Sub '
  201. Sub sw45_Hit:Controller.Switch(45)=1:End Sub 'Left outside rollover
  202. Sub sw45_unHit:Controller.Switch(45)=0:End Sub '
  203. Sub sw52_Hit:Controller.Switch(52)=1:DOF 104, DOFOn:End Sub '#2 top rollover
  204. Sub sw52_UnHit:Controller.Switch(52)=0:DOF 104, DOFOff:End Sub '
  205. Sub sw53_Hit:Controller.Switch(53)=1:End Sub 'Right side rollover
  206. Sub sw53_UnHit:Controller.Switch(53)=0:End Sub '
  207. Sub sw54_Hit:Controller.Switch(54)=1:End Sub 'Right outside rollover
  208. Sub sw54_UnHit:Controller.Switch(54)=0:End Sub '
  209. Sub sw62_Hit:Controller.Switch(62)=1:End Sub '#3 top rollover
  210. Sub sw62_unHit:Controller.Switch(62)=0:End Sub '
  211. Sub sw72_Hit:Controller.Switch(72)=1:End Sub '#4 top rollover
  212. Sub sw72_unHit:Controller.Switch(72)=0:End Sub '
  213. Sub sw74_Hit:Controller.Switch(74)=1:End Sub 'Left outside rollover
  214. Sub sw74_unHit:Controller.Switch(74)=0:End Sub '
  215. Sub sw75_Hit:Controller.Switch(75)=1:End Sub 'Left inside rollover
  216. Sub sw75_unHit:Controller.Switch(75)=0:End Sub '
  217.  
  218. 'Bumpers
  219. Sub Bumper1_Hit:vpmTimer.PulseSw(52):PlaySound SoundFX("fx_bumper5", DOFContactors): DOF 101, DOFPulse: End Sub
  220. Sub Bumper2_Hit:vpmTimer.PulseSw(52):PlaySound SoundFX("fx_bumper5", DOFContactors): DOF 103, DOFPulse: End Sub
  221. Sub Bumper3_Hit:vpmTimer.PulseSw(52):PlaySound SoundFX("fx_bumper5", DOFContactors): DOF 102, DOFPulse: End Sub
  222.  
  223. '***********************************************************************
  224. 'GI Lights On
  225. '***********************************************************************
  226. Sub Encendido_timer
  227. playsound "encendido"
  228. For each xx in Ambiente:xx.State = 1: Next
  229. me.enabled=false
  230. End Sub
  231.  
  232. '**********************************************************************
  233. 'Pause and Exit
  234. '**********************************************************************
  235.  
  236. Sub Table1_Paused:Controller.Pause = 1:End Sub
  237. Sub Table1_unPaused:Controller.Pause = 0:End Sub
  238. Sub Table1_exit:Controller.stop:End Sub
  239.  
  240. '************************************************************************
  241. 'Lights
  242. '************************************************************************
  243. Lights(3)=Array(L3,L3b) 'Shoot Again
  244. Set Lights(4)=L4 '3x multiplier
  245. Set Lights(5)=L5 '5x mult
  246. Set Lights(6)=L6 '10x mult
  247. Set Lights(7)=L7 'spinner
  248. Set Lights(8)=L8 'special
  249. Set Lights(10)=L10 'High score
  250. Set Lights(11)=L11 'Game Over
  251. Lights(12)=Array(L12,L12b) '#1 target and rollover
  252. Lights(13)=Array(L13,L13b) '#2 target and rollover
  253. Lights(14)=Array(L14,L14b) '#3 target and rollover
  254. Lights(15)=Array(L15,L15b) '#4 target and rollover
  255. Lights(16)=Array(L16,L16b) '#5 target and rollover
  256. Lights(17)=Array(L17,L17b) '#6 target and rollover
  257. Lights(18)=Array(L18,L18b) '#7 target and rollover
  258. Lights(19)=Array(L19,L19b) '#9 target and rollover
  259. Lights(20)=Array(L20,L20b) '#10 target and rollover
  260. Lights(21)=Array(L21,L21b) '#11 target and rollover
  261. Lights(22)=Array(L22,L22b) '#12 target and rollover
  262. Lights(23)=Array(L23,L23b) '#13 target and rollover
  263. Lights(24)=Array(L24,L24b) '#14 target and rollover
  264. Lights(25)=Array(L25,L25b) '#15 target and rollover
  265. Set Lights(26)=L26 '#1 rack
  266. Set Lights(27)=L27 '#2 rack
  267. Set Lights(28)=L28 '#3 rack
  268. Set Lights(29)=L29 '#4 rack
  269. Set Lights(30)=L30 '#5 rack
  270. Set Lights(31)=L31 '#6 rack
  271. Set Lights(32)=L32 '#7 rack
  272. Set Lights(33)=L33 '#8 rack
  273. Set Lights(34)=L34 '#9 rack
  274. Set Lights(35)=L35 '#10 rack
  275. Set Lights(36)=L36 '#11 rack
  276. Set Lights(37)=L37 '#12 rack
  277. Set Lights(38)=L38 '#13 rack
  278. Set Lights(39)=L39 '#14 rack
  279. Set Lights(40)=L40 '#15 rack
  280. Set Lights(41)=L41 '#8 Shooter
  281. Set Lights(42)=L42 '#1 rack
  282. Set Lights(43)=L43 '#2 rack complete
  283. Set Lights(44)=L44 'Spot target extra ball
  284. Set Lights(45)=L45 'Spot target spinner
  285. Set Lights(46)=L46 'Spot target solid
  286. Set Lights(47)=L47 'Spot target stripes
  287.  
  288. '**********************************************************************************************************
  289. 'Digital Display
  290. '**********************************************************************************************************
  291.  
  292. Dim Digits(32)
  293.  
  294. ' 1st Player
  295. Digits(0) = Array(LED142,LED143,LED147,LED146,LED145,LED141,LED144,PIN,LED148)
  296. Digits(1) = Array(LED10,LED11,LED12,LED13,LED14,LED15,LED16,PIN,LED74)
  297. Digits(2) = Array(LED20,LED21,LED22,LED23,LED24,LED25,LED26,PIN,LED75)
  298. Digits(3) = Array(LED30,LED31,LED32,LED33,LED34,LED35,LED36,PIN,LED76)
  299. Digits(4) = Array(LED40,LED41,LED42,LED43,LED44,LED45,LED46,PIN,LED78)
  300. Digits(5) = Array(LED50,LED51,LED52,LED53,LED54,LED55,LED56,PIN,LED79)
  301. Digits(6) = Array(LED60,LED61,LED62,LED63,LED64,LED65,LED66,PIN,LED87)
  302.  
  303. ' 2nd Player
  304. Digits(7) = Array(LED149,LED157,LED168,LED167,LED159,LED169,LED158,PIN,LED177)
  305. Digits(8) = Array(LED80,LED81,LED82,LED83,LED84,LED85,LED86,PIN,LED88)
  306. Digits(9) = Array(LED90,LED91,LED92,LED93,LED94,LED95,LED96,PIN,LED89)
  307. Digits(10) = Array(LED100,LED101,LED102,LED103,LED104,LED105,LED106,PIN,LED97)
  308. Digits(11) = Array(LED110,LED111,LED112,LED113,LED114,LED115,LED116,PIN,LED98)
  309. Digits(12) = Array(LED120,LED121,LED122,LED123,LED124,LED125,LED126,PIN,LED99)
  310. Digits(13) = Array(LED130,LED131,LED132,LED133,LED134,LED135,LED136,PIN,LED107)
  311.  
  312. ' 3rd Player
  313. Digits(14) = Array(LED178,LED179,LED197,LED189,LED188,LED198,LED187,PIN,LED199)
  314. Digits(15) = Array(LED150,LED151,LED152,LED153,LED154,LED155,LED156,PIN,LED108)
  315. Digits(16) = Array(LED160,LED161,LED162,LED163,LED164,LED165,LED166,PIN,LED109)
  316. Digits(17) = Array(LED170,LED171,LED172,LED173,LED174,LED175,LED176,PIN,LED117)
  317. Digits(18) = Array(LED180,LED181,LED182,LED183,LED184,LED185,LED186,PIN,LED118)
  318. Digits(19) = Array(LED190,LED191,LED192,LED193,LED194,LED195,LED196,PIN,LED119)
  319. Digits(20) = Array(LED200,LED201,LED202,LED203,LED204,LED205,LED206,PIN,LED127)
  320.  
  321. ' 4th Player
  322. Digits(21) = Array(LED207,LED208,LED212,LED211,LED210,LED213,LED209,PIN,LED214)
  323. Digits(22) = Array(LED220,LED221,LED222,LED223,LED224,LED225,LED226,PIN,LED128)
  324. Digits(23) = Array(LED230,LED231,LED232,LED233,LED234,LED235,LED236,PIN,LED129)
  325. Digits(24) = Array(LED240,LED241,LED242,LED243,LED244,LED245,LED246,PIN,LED137)
  326. Digits(25) = Array(LED250,LED251,LED252,LED253,LED254,LED255,LED256,PIN,LED138)
  327. Digits(26) = Array(LED260,LED261,LED262,LED263,LED264,LED265,LED266,PIN,LED139)
  328. Digits(27) = Array(LED270,LED271,LED272,LED273,LED274,LED275,LED276,PIN,LED140)
  329.  
  330. ' Credits
  331. Digits(28) = Array(LED4,LED2,LED6,LED7,LED5,LED1,LED3,PIN,LED70)
  332. Digits(29) = Array(LED18,LED9,LED27,LED28,LED19,LED8,LED17,PIN,LED71)
  333. ' Balls
  334. Digits(30) = Array(LED39,LED37,LED48,LED49,LED47,LED29,LED38,PIN,LED72)
  335. Digits(31) = Array(LED67,LED58,LED69,LED77,LED68,LED57,LED59,PIN,LED73)
  336.  
  337. Sub DisplayTimer_Timer
  338. Dim ChgLED,ii,num,chg,stat,obj
  339. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  340. If Not IsEmpty(ChgLED) Then
  341. If DesktopMode = True Then
  342. For ii = 0 To UBound(chgLED)
  343. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  344. if (num < 37) then
  345. For Each obj In Digits(num)
  346. If chg And 1 Then obj.State = stat And 1
  347. chg = chg\2 : stat = stat\2
  348. Next
  349. else
  350. end if
  351. next
  352. end if
  353. end if
  354. End Sub
  355.  
  356.  
  357. '************************************************************************
  358. 'Gate Init ball
  359. '************************************************************************
  360.  
  361. Sub Entrada_Hit()
  362. If ActiveBall.VelY<0 Then
  363. DivDir = -1
  364. PuertaCerrada.IsDropped=1
  365. PuertaAbierta.IsDropped=0
  366. End If
  367. End Sub
  368.  
  369. Sub Retorno_Hit()
  370. DivDir = 1
  371. PuertaCerrada.IsDropped=0
  372. PuertaAbierta.IsDropped=1
  373. End Sub
  374.  
  375. Sub Salida_Hit()
  376. DivDir = 1
  377. PuertaCerrada.IsDropped=0
  378. PuertaAbierta.IsDropped=1
  379. End Sub
  380. Dim DivDir: DivDir=0
  381. Dim DivPos: DivPos = 359
  382. Sub UpdateDiverter_Timer
  383. DivPos = DivPos + DivDir
  384. If DivPos >= 359 then DivPos = 359:DivDir = 0
  385. If DivPos <= 340 then DivPos = 340:DivDir = 0
  386. Puerta.ObjRotZ = DivPos
  387. End Sub
  388.  
  389. '**********Sling Shot Animations
  390. ' Rstep and Lstep are the variables that increment the animation
  391. '****************
  392. Dim RStep, Lstep
  393.  
  394. Sub RightSlingShot_Slingshot
  395. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  396. DOF 106, DOFPulse
  397. RSling.Visible = 0
  398. RSling1.Visible = 1
  399. sling1.rotx = 20
  400. RStep = 0
  401. vpmTimer.PulseSw(73)
  402. RightSlingShot.TimerEnabled = 1
  403. End Sub
  404.  
  405. Sub RightSlingShot_Timer
  406. Select Case RStep
  407. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  408. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0
  409. End Select
  410. RStep = RStep + 1
  411. End Sub
  412.  
  413. Sub LeftSlingShot_Slingshot
  414. PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  415. DOF 105, DOFPulse
  416. LSling.Visible = 0
  417. LSling1.Visible = 1
  418. sling2.rotx = 20
  419. LStep = 0
  420. vpmTimer.PulseSw(73)
  421. LeftSlingShot.TimerEnabled = 1
  422. End Sub
  423.  
  424. Sub LeftSlingShot_Timer
  425. Select Case LStep
  426. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  427. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0
  428. End Select
  429. LStep = LStep + 1
  430. End Sub
  431.  
  432.  
  433. '*********************************************************************
  434. ' Positional Sound Playback Functions
  435. '*********************************************************************
  436.  
  437. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  438. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  439. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  440. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  441. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  442. End Sub
  443.  
  444. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  445. Sub PlaySoundAt(soundname, tableobj)
  446. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  447. End Sub
  448.  
  449. Sub PlaySoundAtBall(soundname)
  450. PlaySoundAt soundname, ActiveBall
  451. End Sub
  452.  
  453.  
  454. '*********************************************************************
  455. ' Supporting Ball & Sound Functions
  456. '*********************************************************************
  457.  
  458. 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
  459. Dim tmp
  460. tmp = tableobj.y * 2 / table1.height-1
  461. If tmp > 0 Then
  462. AudioFade = Csng(tmp ^10)
  463. Else
  464. AudioFade = Csng(-((- tmp) ^10) )
  465. End If
  466. End Function
  467.  
  468. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  469. Dim tmp
  470. tmp = ball.x * 2 / Table1.width-1
  471. If tmp > 0 Then
  472. Pan = Csng(tmp ^10)
  473. Else
  474. Pan = Csng(-((- tmp) ^10) )
  475. End If
  476. End Function
  477.  
  478. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  479. Dim tmp
  480. tmp = tableobj.x * 2 / table1.width-1
  481. If tmp > 0 Then
  482. AudioPan = Csng(tmp ^10)
  483. Else
  484. AudioPan = Csng(-((- tmp) ^10) )
  485. End If
  486. End Function
  487.  
  488. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  489. Vol = Csng(BallVel(ball) ^2 / 150)
  490. End Function
  491.  
  492. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  493. Pitch = BallVel(ball) * 20
  494. End Function
  495.  
  496. Function BallVel(ball) 'Calculates the ball speed
  497. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  498. End Function
  499.  
  500. '*****************************************
  501. ' JP's VP10 Rolling Sounds
  502. '*****************************************
  503.  
  504. Const tnob = 1 ' total number of balls
  505. ReDim rolling(tnob)
  506. InitRolling
  507.  
  508. Sub InitRolling
  509. Dim i
  510. For i = 0 to tnob
  511. rolling(i) = False
  512. Next
  513. End Sub
  514.  
  515. Sub RollingTimer_Timer()
  516. Dim BOT, b
  517. BOT = GetBalls
  518.  
  519. ' stop the sound of deleted balls
  520. For b = UBound(BOT) + 1 to tnob
  521. rolling(b) = False
  522. StopSound("fx_ballrolling" & b)
  523. Next
  524.  
  525. ' exit the sub if no balls on the table
  526. If UBound(BOT) = -1 Then Exit Sub
  527.  
  528. ' play the rolling sound for each ball
  529. For b = 0 to UBound(BOT)
  530. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  531. rolling(b) = True
  532. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  533. Else
  534. If rolling(b) = True Then
  535. StopSound("fx_ballrolling" & b)
  536. rolling(b) = False
  537. End If
  538. End If
  539. Next
  540. End Sub
  541.  
  542. '**********************
  543. ' Ball Collision Sound
  544. '**********************
  545.  
  546. Sub OnBallBallCollision(ball1, ball2, velocity)
  547. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  548. End Sub
  549.  
  550.  
  551. '*****************************************
  552. ' ninuzzu's FLIPPER SHADOWS
  553. '*****************************************
  554.  
  555. sub FlipperTimer_Timer()
  556. FlipperLSh.RotZ = LeftFlipper.currentangle
  557. FlipperRSh.RotZ = RightFlipper.currentangle
  558.  
  559. Flipperizq.rotz=leftFlipper.CurrentAngle +240
  560. Flipperder.rotz=rightFlipper.CurrentAngle +120
  561.  
  562. End Sub
  563.  
  564. '*****************************************
  565. ' ninuzzu's BALL SHADOW
  566. '*****************************************
  567. Dim BallShadow
  568. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  569.  
  570. Sub BallShadowUpdate_timer()
  571. Dim BOT, b
  572. BOT = GetBalls
  573. ' hide shadow of deleted balls
  574. If UBound(BOT)<(tnob-1) Then
  575. For b = (UBound(BOT) + 1) to (tnob-1)
  576. BallShadow(b).visible = 0
  577. Next
  578. End If
  579. ' exit the Sub if no balls on the table
  580. If UBound(BOT) = -1 Then Exit Sub
  581. ' render the shadow for each ball
  582. For b = 0 to UBound(BOT)
  583. If BOT(b).X < Table1.Width/2 Then
  584. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  585. Else
  586. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  587. End If
  588. ballShadow(b).Y = BOT(b).Y + 12
  589. If BOT(b).Z > 20 Then
  590. BallShadow(b).visible = 1
  591. Else
  592. BallShadow(b).visible = 0
  593. End If
  594. Next
  595. End Sub
  596.  
  597.  
  598.  
  599. '************************************
  600. ' What you need to add to your table
  601. '************************************
  602.  
  603. ' a timer called RollingTimer. With a fast interval, like 10
  604. ' one collision sound, in this script is called fx_collide
  605. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  606. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  607.  
  608.  
  609. '******************************************
  610. ' Explanation of the rolling sound routine
  611. '******************************************
  612.  
  613. ' sounds are played based on the ball speed and position
  614.  
  615. ' the routine checks first for deleted balls and stops the rolling sound.
  616.  
  617. ' The For loop goes through all the balls on the table and checks for the ball speed and
  618. ' if the ball is on the table (height lower than 30) then then it plays the sound
  619. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  620.  
  621. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  622. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  623. ' according to the position of the ball on the table.
  624.  
  625.  
  626. '**************************************
  627. ' Explanation of the collision routine
  628. '**************************************
  629.  
  630. ' The collision is built in VP.
  631. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  632. ' 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
  633. ' depending of the speed of the collision.
  634.  
  635.  
  636. Sub Pins_Hit (idx)
  637. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  638. End Sub
  639.  
  640. Sub Madera_Hit (idx)
  641. PlaySound "fx_woodhit", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  642. End Sub
  643.  
  644. Sub Plastico_Hit (idx)
  645. PlaySound "fx_plastichit", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  646. End Sub
  647.  
  648. Sub Targets_Hit (idx)
  649. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  650. End Sub
  651.  
  652. Sub Metals_Thin_Hit (idx)
  653. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  654. End Sub
  655.  
  656. Sub Metals_Medium_Hit (idx)
  657. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  658. End Sub
  659.  
  660. Sub Metals2_Hit (idx)
  661. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  662. End Sub
  663.  
  664. Sub Gates_Hit (idx)
  665. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  666. End Sub
  667.  
  668. Sub Rubbers_Hit(idx)
  669. dim finalspeed
  670. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  671. If finalspeed > 20 then
  672. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  673. End if
  674. If finalspeed >= 6 AND finalspeed <= 20 then
  675. RandomSoundRubber()
  676. End If
  677. End Sub
  678.  
  679. Sub Posts_Hit(idx)
  680. dim finalspeed
  681. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  682. If finalspeed > 16 then
  683. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  684. End if
  685. If finalspeed >= 6 AND finalspeed <= 16 then
  686. RandomSoundRubber()
  687. End If
  688. End Sub
  689.  
  690. Sub RandomSoundRubber()
  691. Select Case Int(Rnd*3)+1
  692. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  693. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  694. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  695. End Select
  696. End Sub
  697.  
  698. Sub LeftFlipper_Collide(parm)
  699. RandomSoundFlipper()
  700. End Sub
  701.  
  702. Sub RightFlipper_Collide(parm)
  703. RandomSoundFlipper()
  704. End Sub
  705.  
  706. Sub RandomSoundFlipper()
  707. Select Case Int(Rnd*3)+1
  708. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  709. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  710. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  711. End Select
  712. End Sub
  713.  
  714. Sub editDips
  715. Dim vpmDips : Set vpmDips = New cvpmDips
  716. With vpmDips
  717. .AddForm 700,400,"Rack em up - DIP switches"
  718. .AddFrame 2,5,190,"Maximum credits",49152,Array("8 credits",0,"10 credits",32768,"15 credits",&H00004000,"25 credits",49152)'dip 15&16
  719. .AddFrame 2,81,190,"Coin chute 1 and 2 control",&H00002000,Array("seperate",0,"same",&H00002000)'dip 14
  720. .AddFrame 2,127,190,"Playfield special",&H00200000,Array("replay",0,"extra ball",&H00200000)'dip 22
  721. .AddFrame 2,173,190,"3rd coin chute credits control",&H20000000,Array("no effect",0,"add 9",&H20000000)'dip 30
  722. .AddFrameExtra 2,219,190,"Attract tune",&H0200,Array("no attract tune",0,"attract tune played every 6 minutes",&H0200)'S-board dip 2
  723. .AddChk 2,270,190,Array("Match feature",&H02000000)'dip 26
  724. .AddChkExtra 2,290,190,Array("Sound test enable",&H0100)'S-board dip 1
  725. .AddFrame 205,5,190,"High game 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
  726. .AddFrame 205,81,190,"Balls per game",&H01000000,Array("5 balls",0,"3 balls",&H01000000)'dip 25
  727. .AddFrame 205,127,190,"Replay limit",&H04000000,Array("no limit",0,"one per game",&H04000000)'dip 27
  728. .AddFrame 205,173,190,"Novelty mode",&H08000000,Array("normal game mode",0,"50,000 points per special/extra ball",&H08000000)'dip 28
  729. .AddFrame 205,219,190,"Game mode",&H10000000,Array("replay",0,"extra ball",&H10000000)'dip 29
  730. .AddChk 205,270,190,Array("Background sound",&H40000000)'dip 31
  731. .AddLabel 50,320,300,20,"After hitting OK, press F3 to reset game with new settings."
  732. End With
  733. Dim extra
  734. extra = Controller.Dip(4) + Controller.Dip(5)*256
  735. extra = vpmDips.ViewDipsExtra(extra)
  736. Controller.Dip(4) = extra And 255
  737. Controller.Dip(5) = (extra And 65280)\256 And 255
  738. End Sub
  739. Set vpmShowDips = GetRef("editDips")
Advertisement
Add Comment
Please, Sign In to add comment