Arngrim

Dark Shadow

Mar 20th, 2022
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.77 KB | None | 0 0
  1. '############################################################################################
  2. '############################################################################################
  3. '####### ########
  4. '####### Dark Shadow ########
  5. '####### (Nuova Bell Games 1986) ########
  6. '####### ########
  7. '############################################################################################
  8. '############################################################################################
  9. '
  10. ' Version 1.0
  11. '
  12. ' Thanks go to:
  13. ' Peter Blakemore from www.specialwhenlit.co.uk for providing lots of detailed images and gameplay videos.
  14. ' The videos can still be found on Youtube
  15. ' Joey2001 for playtesting the table fine tuning the flipper settings.
  16.  
  17. Option Explicit
  18.  
  19. On Error Resume Next
  20. ExecuteGlobal GetTextFile("controller.vbs")
  21. 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)"
  22. On Error Goto 0
  23. Randomize
  24.  
  25. '-----------------------------------
  26. '------ Global Configurations -----
  27. '-----------------------------------
  28.  
  29. Const FreePlay = True 'adds a coin on StartGame
  30. Const VolumeMultiplier = 2 'adjust the general sound volume of table objects and ball rolling
  31. Const MotorSound = True 'Play a sound while the target motor is running
  32. Const DimGI=10 'set GI lights intensity (base value is 10)
  33. Const EnableUpperPost = True 'add a Post below the top left target. The hole is there but I am not sure if it was installed on the production run
  34. Const EasyUpperFlipper = False 'increases the end angle of the upper flipper to allow direct target hits and easier cradled balls
  35.  
  36.  
  37. Const cGameName = "darkshad"
  38. Const UseSolenoids=1,UseLamps=1,SSolenoidOn="SolOn",SSolenoidOff="SolOff",SFlipperOn="",SFlipperOff="",SCoin="coin3"
  39. LoadVPM "01560000","nuova.vbs",3.2
  40.  
  41.  
  42. '-------------------------------
  43. '------ Keybord Handler ------
  44. '-------------------------------
  45. Dim i
  46. Sub Table1_KeyDown(ByVal keycode)
  47.  
  48. If keycode = PlungerKey Then
  49. Plunger.PullBack
  50. PlaySound "plungerpull",0,1,AudioPan(Plunger),0.25,0,0,1,AudioFade(Plunger)
  51. End If
  52.  
  53. If keycode = LeftFlipperKey Then
  54. if flipperactive then
  55. LeftFlipper.RotateToEnd
  56. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
  57. end if
  58. End If
  59.  
  60. If keycode = RightFlipperKey Then
  61. controller.switch(12) = 1
  62. if flipperactive then
  63. RightFlipper.RotateToEnd
  64. URightFlipper.RotateToEnd
  65. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
  66. end if
  67. End If
  68.  
  69. if FreePlay and keycode = Startgamekey then
  70. vpmtimer.pulsesw 9
  71. end if
  72.  
  73. if keycode = LeftMagnaSave then
  74. ' controller.Switch(-7) = True
  75. end if
  76.  
  77.  
  78. If vpmKeyDown(KeyCode) Then Exit Sub
  79.  
  80. ' Manual Ball Control
  81. If keycode = 46 Then ' C Key
  82. If EnableBallControl = 1 Then
  83. EnableBallControl = 0
  84. Else
  85. EnableBallControl = 1
  86. End If
  87. End If
  88. If EnableBallControl = 1 Then
  89. If keycode = 48 Then ' B Key
  90. If BCboost = 1 Then
  91. BCboost = BCboostmulti
  92. Else
  93. BCboost = 1
  94. End If
  95. End If
  96. If keycode = 203 Then BCleft = 1 ' Left Arrow
  97. If keycode = 200 Then BCup = 1 ' Up Arrow
  98. If keycode = 208 Then BCdown = 1 ' Down Arrow
  99. If keycode = 205 Then BCright = 1 ' Right Arrow
  100. End If
  101. End Sub
  102.  
  103. Sub Table1_KeyUp(ByVal keycode)
  104. If keycode = PlungerKey Then
  105. Plunger.Fire
  106. PlaySound "plunger",0,1,AudioPan(Plunger),0.25,0,0,1,AudioFade(Plunger)
  107. End If
  108.  
  109. If keycode = LeftFlipperKey Then
  110. LeftFlipper.RotateToStart
  111. if flipperactive then
  112. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
  113. end if
  114. End If
  115.  
  116. If keycode = RightFlipperKey Then
  117. controller.switch(12) = 0
  118. RightFlipper.RotateToStart
  119. URightFlipper.RotateToStart
  120. if flipperactive then
  121. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
  122. end if
  123. End If
  124.  
  125. if keycode = LeftMagnaSave then
  126. controller.Switch(-7) = False
  127. end if
  128.  
  129. If vpmKeyUp(KeyCode) Then Exit Sub
  130.  
  131. 'Manual Ball Control
  132. If EnableBallControl = 1 Then
  133. If keycode = 203 Then BCleft = 0 ' Left Arrow
  134. If keycode = 200 Then BCup = 0 ' Up Arrow
  135. If keycode = 208 Then BCdown = 0 ' Down Arrow
  136. If keycode = 205 Then BCright = 0 ' Right Arrow
  137. End If
  138.  
  139. End Sub
  140.  
  141.  
  142. '-----------------------------------
  143. '------ Solenoid Assignment ------
  144. '-----------------------------------
  145.  
  146. SolCallback(19)="Sol_GameOn"
  147. SolCallback(15)="vpmSolSound SoundFX(""knocker"",DOFKnocker),"
  148. SolCallback(14)="bsTrough.SolOut"
  149. SolCallback(11)="Sol_DT"
  150. SolCallback(10)="Sol_Kicker"
  151. SolCallback(18)="Sol_Motor"
  152.  
  153. SolCallback(17)="Sol_Diverter"
  154.  
  155. Dim KickerBall
  156. Sub KickerArea_Hit
  157. Set KickerBall = ActiveBall
  158. Controller.Switch(5) = 1
  159. End Sub
  160. Sub KickerArea_Unhit:Controller.Switch(5) = 0:End Sub
  161.  
  162. Randomize
  163. Sub Sol_Kicker(Enabled)
  164. if enabled and (KickerArea.ballcntover > 0) Then
  165. PlaySound SoundFX("popper_ball",DOFContactors),0,1,AudioPan(P_Kicker),0.25,0,0,1,AudioFade(P_Kicker)
  166. KickerBall.vely = - 35 - (15 * rnd)
  167. P_Kicker.TransZ = -40
  168. KickerArea.timerenabled = True
  169. end If
  170. End Sub
  171.  
  172. Sub KickerArea_timer
  173. KickerArea.timerenabled = False
  174. P_Kicker.TransZ = 0
  175. End Sub
  176.  
  177. Sub Sol_Motor(Enabled)
  178. Dim ii
  179. MotorTimer.enabled = enabled
  180. End Sub
  181.  
  182. Sub Sol_Diverter(Enabled)
  183. if enabled Then
  184. Diverter_Open.isdropped = True
  185. Diverter_Closed.isdropped = False
  186. Diverter1.rotatetostart
  187. Diverter2.rotatetostart
  188. Else
  189. Diverter_Open.isdropped = False
  190. Diverter_Closed.isdropped = True
  191. Diverter1.rotatetoend
  192. Diverter2.rotatetoend
  193. end If
  194. S17.state = abs(not Enabled)
  195. End Sub
  196.  
  197. ' this code is avoiding stuck balls behind or on the drop targets
  198. Sub Sol_DT(Enabled)
  199. if enabled Then
  200. DTTrigger.timerenabled = True
  201. end If
  202. End Sub
  203.  
  204. Sub DTTrigger_Timer
  205. if DTTrigger.ballcntover = 0 Then
  206. DropTargetBank.DropSol_On
  207. DTTrigger.timerenabled = False
  208. end if
  209. End Sub
  210.  
  211. Flipperactive = False
  212. Sub Sol_GameOn(enabled)
  213. VpmNudge.SolGameOn enabled
  214. Flipperactive = enabled
  215. if not Flipperactive Then
  216. LeftFlipper.RotateToStart
  217. URightFlipper.RotateToStart
  218. RightFlipper.RotateToStart
  219. end If
  220. end sub
  221.  
  222. 'SolCallback(sLLFlipper)="vpmSolFlipper LeftFlipper,Nothing,"
  223. 'SolCallback(sLRFlipper)="vpmSolFlipper RightFlipper,URightFlipper,"
  224.  
  225. for each obj in DimGICol
  226. obj.intensity = DimGI
  227. Next
  228. for each obj in GI
  229. obj.state = 1
  230. Next
  231. for each obj in GIBulbs
  232. obj.state = 1
  233. Next
  234.  
  235. '--------------------------
  236. '------ Table Init ------
  237. '--------------------------
  238.  
  239. Dim DesktopMode: DesktopMode = Table1.ShowDT
  240. If DesktopMode = True Then 'Show Desktop components
  241. Ramp17.visible=1
  242. Ramp16.visible=1
  243. Ramp15.visible=1
  244. SideWood.visible=1
  245. Else
  246. Ramp17.visible=0
  247. Ramp16.visible=0
  248. Ramp15.visible=0
  249. SideWood.visible=0
  250. End if
  251.  
  252. P_upperpost.visible = enableUpperPost
  253. UpperPostRubber.visible = enableUpperPost
  254. UpperPostWall.isdropped = not enableUpperPost
  255.  
  256. if EasyUpperFlipper Then
  257. URightFlipper.endangle = -78
  258. End If
  259.  
  260. Dim bsTrough,obj,DropTargetBank,Flipperactive
  261. Sub Table1_init
  262. vpminit me
  263.  
  264. Controller.GameName=cGameName
  265. Controller.SplashInfoLine="Dark Shadow" & vbNewLine & "created by mfuegemann"
  266. Controller.HandleKeyboard=False
  267. Controller.ShowTitle=0
  268. Controller.ShowFrame=0
  269. Controller.ShowDMDOnly=1
  270. 'Controller.Hidden = 1 'enable to hide DMD if You use a B2S backglass
  271.  
  272. ' DMD position for 3 Monitor Setup
  273. ' Controller.Games(cGameName).Settings.Value("dmd_pos_x")=3850 'set this to 0 if You cannot find the DMD
  274. ' Controller.Games(cGameName).Settings.Value("dmd_pos_y")=300 'set this to 0 if You cannot find the DMD
  275. ' Controller.Games(cGameName).Settings.Value("dmd_width")=505
  276. ' Controller.Games(cGameName).Settings.Value("dmd_height")=155
  277. ' Controller.Games(cGameName).Settings.Value("rol")=0
  278. ' Controller.Games(cGameName).Settings.Value("ddraw") = 0 'set to 0 if You have problems with DMD showing or table stutter
  279.  
  280. Controller.HandleMechanics=0
  281. Controller.Run
  282. If Err Then MsgBox Err.Description
  283. On Error Goto 0
  284.  
  285. PinMAMETimer.Interval=PinMAMEInterval
  286. PinMAMETimer.Enabled = true
  287.  
  288. vpmNudge.TiltSwitch=15
  289. vpmNudge.Sensitivity=5
  290. vpmNudge.TiltObj = Array(Bumper1,Bumper2,LeftSlingShot,RightSlingShot)
  291.  
  292. vpmMapLights AllLights
  293.  
  294. Set bsTrough=New cvpmBallStack
  295. bsTrough.InitSw 0,8,0,0,0,0,0,0 '0.1 = Switch 0
  296. bsTrough.InitKick BallRelease,90,5
  297. bsTrough.InitExitSnd SoundFX("BallRel",DOFContactors),SoundFX("Solenoid",DOFContactors)
  298. bsTrough.Balls=1
  299.  
  300. set DropTargetBank = new cvpmDropTarget
  301. DropTargetBank.InitDrop Array(DT1,DT2,DT3,DT4), Array(17,18,19,20)
  302. DropTargetBank.InitSnd SoundFX("Targetdrop1",DOFContactors),SoundFX("TargetBankreset1",DOFContactors)
  303. DropTargetBank.CreateEvents "DropTargetBank"
  304.  
  305. Diverter_Open.isdropped = True
  306. Diverter_Closed.isdropped = False
  307. End Sub
  308.  
  309. Sub Table1_Exit()
  310. Controller.Pause = False
  311. Controller.Stop
  312. End Sub
  313.  
  314. '------------------------------
  315. '------ Trough Handler ------
  316. '------------------------------
  317. Sub Drain_Hit()
  318. PlaySound "drain",0,1,AudioPan(Drain),0.25,0,0,1,AudioFade(Drain)
  319. bsTrough.AddBall Me
  320. End Sub
  321.  
  322. '------------------------------
  323. '------ Switch Handler ------
  324. '------------------------------
  325. Sub TopHole_Hit:bsTopHole.addball Me:End Sub
  326.  
  327. Sub Bumper1_Hit:vpmtimer.pulsesw(14):End Sub
  328. Sub Bumper2_Hit:vpmtimer.pulsesw(28):End Sub
  329.  
  330. Sub Spinner1_Spin:vpmtimer.pulsesw(7):End Sub
  331.  
  332. Sub MovingTargetCol_hit(idx):vpmtimer.pulsesw(26):HitMoveTarget:End Sub
  333.  
  334. Sub LeftOutlane_Hit:Controller.Switch(37) = 1:DOF 103, DOFOn:End Sub
  335. Sub LeftOutlane_Unhit:Controller.Switch(37) = 0:DOF 103, DOFOff:End Sub
  336. Sub RightOutlane_Hit:Controller.Switch(25) = 1:End Sub
  337. Sub RightOutlane_Unhit:Controller.Switch(25) = 0:End Sub
  338. Sub Leftinlane_Hit:Controller.Switch(1) = 1:DOF 101, DOFOn:End Sub
  339. Sub Leftinlane_Unhit:Controller.Switch(1) = 0:DOF 101, DOFOff:End Sub
  340. Sub Rightinlane_Hit:Controller.Switch(1) = 1:DOF 102, DOFOn:End Sub
  341. Sub Rightinlane_Unhit:Controller.Switch(1) = 0:DOF 102, DOFOff:End Sub
  342.  
  343. Sub EnterPlayfield_Hit:Controller.Switch(33) = 1:End Sub
  344. Sub EnterPlayfield_Unhit:Controller.Switch(33) = 0:End Sub
  345.  
  346. Sub LeftTarget1_hit:vpmtimer.pulsesw(21):End Sub
  347. Sub LeftTarget2_hit:vpmtimer.pulsesw(22):End Sub
  348. Sub LeftTarget3_hit:vpmtimer.pulsesw(23):End Sub
  349. Sub LeftTarget4_hit:vpmtimer.pulsesw(24):End Sub
  350.  
  351. Sub TopRollover1_Hit:Controller.Switch(2) = 1:End Sub
  352. Sub TopRollover1_Unhit:Controller.Switch(2) = 0:End Sub
  353. Sub TopRollover2_Hit:Controller.Switch(3) = 1:End Sub
  354. Sub TopRollover2_Unhit:Controller.Switch(3) = 0:End Sub
  355. Sub TopRollover3_Hit:Controller.Switch(4) = 1:End Sub
  356. Sub TopRollover3_Unhit:Controller.Switch(4) = 0:End Sub
  357.  
  358. Sub TopTarget_Hit:vpmtimer.pulsesw(38):End Sub
  359. Sub RightTarget_Hit:vpmtimer.pulsesw(37):DOF 104, DOFPulse:End Sub
  360.  
  361.  
  362.  
  363. '-----------------------------
  364. '------ Moving Target ------
  365. '-----------------------------
  366.  
  367. Dim MovingDir,MTargets,MTargetsX,MTPos,ArrayPos,MTInterval,MTargetWalls,MTy,Pi,MTSpan,MotorAngle,MotorAngle2,LastPos,UpperLoopStartAngle,UpperLoopEndAngle
  368. Pi = 3.1415926535897932
  369. MotorAngle = 270
  370. MTPos = MT001.x
  371. MTy = MT001.y
  372. MTInterval = (MT019.x-MT001.x)/18
  373. MTSpan = MT019.x-MT001.x
  374. LastPos = -1
  375. MTargets = Array(MT001,MT002,MT003,MT004,MT005,MT006,MT007,MT008,MT009,MT010,MT011,MT012,MT013,MT014,MT015,MT016,MT017,MT018,MT019)
  376. MTargetsX = Array(MT020,MT021,MT022,MT023,MT024,MT025,MT026,MT027,MT028,MT029,MT030,MT031,MT032,MT033,MT034,MT035,MT036,MT037,MT038)
  377. MTargetWalls = Array(MTW01,MTW02,MTW03,MTW04,MTW05,MTW06,MTW07,MTW08,MTW09,MTW10,MTW11,MTW12,MTW13,MTW14,MTW15,MTW16,MTW17,MTW18,MTW19)
  378.  
  379. UpperLoopStartAngle = 255
  380. UpperLoopEndAngle = 105
  381.  
  382. Sub MotorTimer_Timer
  383. MotorAngle = MotorAngle + 1
  384. if MotorAngle > 359 Then
  385. MotorAngle = 0
  386. End If
  387.  
  388. 'convert the rotating motor into lateral movement
  389. MTPos = MT001.x + ((MTSpan / 2) * (Sin(MotorAngle * Pi / 180) + 1))
  390. ArrayPos = cint((MTPos-MT001.x)/(MTInterval))
  391.  
  392. if ArrayPos > 18 Then
  393. ArrayPos = 18
  394. End If
  395. if ArrayPos < 0 Then
  396. ArrayPos = 0
  397. End If
  398.  
  399. 'visibility updates only if necessary
  400. if LastPos <> ArrayPos Then
  401. LastPos = ArrayPos
  402. for i=0 to 18
  403. MTargets(i).visible = False
  404. MTargetsX(i).visible = False
  405. MTargetWalls(i).isdropped = True
  406. Next
  407.  
  408. 'activate the second "hit" row if target has been hit
  409. if MTMoveTimer.enabled Then
  410. MTargetsX(ArrayPos).visible = True
  411. Else
  412. MTargets(ArrayPos).visible = True
  413. End If
  414. MTargetWalls(ArrayPos).isdropped = False
  415. end if
  416.  
  417. if MotorSound Then
  418. PlaySound SoundFX("metalhit_thin",DOFContactors),0,0.0002,0,0.25,0,0,1,AudioFade(MT001)
  419. End If
  420. End Sub
  421.  
  422. Sub HitMoveTarget
  423. DOF 105, DOFPulse
  424. MTMoveTimer.enabled = False
  425. MTMoveTimer.enabled = True
  426. End Sub
  427.  
  428. Sub MTMoveTimer_Timer
  429. MTMoveTimer.enabled = False
  430. End Sub
  431.  
  432.  
  433.  
  434. '**********Sling Shot Animations
  435. ' Rstep and Lstep are the variables that increment the animation
  436. '****************
  437. Dim RStep, Lstep
  438.  
  439. Sub RightSlingShot_Slingshot
  440. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05
  441. vpmtimer.pulsesw(13)
  442. RSling.Visible = 0
  443. RSling1.Visible = 1
  444. sling1.TransZ = -20
  445. RStep = 0
  446. RightSlingShot.TimerEnabled = 1
  447. End Sub
  448.  
  449. Sub RightSlingShot_Timer
  450. Select Case RStep
  451. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  452. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0
  453. End Select
  454. RStep = RStep + 1
  455. End Sub
  456.  
  457. Sub LeftSlingShot_Slingshot
  458. PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05
  459. vpmtimer.pulsesw(29)
  460. LSling.Visible = 0
  461. LSling1.Visible = 1
  462. sling2.TransZ = -20
  463. LStep = 0
  464. LeftSlingShot.TimerEnabled = 1
  465. End Sub
  466.  
  467. Sub LeftSlingShot_Timer
  468. Select Case LStep
  469. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  470. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0
  471. End Select
  472. LStep = LStep + 1
  473. End Sub
  474.  
  475.  
  476. '*********************************************************************
  477. ' Positional Sound Playback Functions
  478. '*********************************************************************
  479.  
  480. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  481. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  482. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  483. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  484. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  485. End Sub
  486.  
  487. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  488. Sub PlaySoundAt(soundname, tableobj)
  489. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  490. End Sub
  491.  
  492. Sub PlaySoundAtBall(soundname)
  493. PlaySoundAt soundname, ActiveBall
  494. End Sub
  495.  
  496.  
  497. '*********************************************************************
  498. ' Supporting Ball & Sound Functions
  499. '*********************************************************************
  500.  
  501. 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
  502. Dim tmp
  503. tmp = tableobj.y * 2 / Table1.height-1
  504. If tmp > 0 Then
  505. AudioFade = Csng(tmp ^10)
  506. Else
  507. AudioFade = Csng(-((- tmp) ^10) )
  508. End If
  509. End Function
  510.  
  511. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "Table1" is the name of the table
  512. Dim tmp
  513. tmp = tableobj.x * 2 / Table1.width-1
  514. If tmp > 0 Then
  515. AudioPan = Csng(tmp ^10)
  516. Else
  517. AudioPan = Csng(-((- tmp) ^10) )
  518. End If
  519. End Function
  520.  
  521. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  522. Vol = Csng(BallVel(ball) ^2 / 300) * VolumeMultiplier
  523. End Function
  524.  
  525. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  526. Pitch = BallVel(ball) * 20
  527. End Function
  528.  
  529. Function BallVel(ball) 'Calculates the ball speed
  530. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  531. End Function
  532.  
  533.  
  534.  
  535. '*****************************************
  536. ' JP's VP10 Rolling Sounds
  537. '*****************************************
  538.  
  539. Const tnob = 5 ' total number of balls
  540. ReDim rolling(tnob)
  541. InitRolling
  542.  
  543. Sub InitRolling
  544. Dim i
  545. For i = 0 to tnob
  546. rolling(i) = False
  547. Next
  548. End Sub
  549.  
  550. Sub RollingTimer_Timer()
  551. Dim BOT, b
  552. BOT = GetBalls
  553.  
  554. ' stop the sound of deleted balls
  555. For b = UBound(BOT) + 1 to tnob
  556. rolling(b) = False
  557. StopSound("fx_ballrolling" & b)
  558. Next
  559.  
  560. ' exit the sub if no balls on the table
  561. If UBound(BOT) = -1 Then Exit Sub
  562.  
  563. ' play the rolling sound for each ball
  564. For b = 0 to UBound(BOT)
  565. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  566. rolling(b) = True
  567. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  568. Else
  569. If rolling(b) = True Then
  570. StopSound("fx_ballrolling" & b)
  571. rolling(b) = False
  572. End If
  573. End If
  574. Next
  575. End Sub
  576.  
  577. '**********************
  578. ' Ball Collision Sound
  579. '**********************
  580.  
  581. Sub OnBallBallCollision(ball1, ball2, velocity)
  582. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  583. End Sub
  584.  
  585.  
  586. '*****************************************
  587. ' ninuzzu's FLIPPER SHADOWS
  588. '*****************************************
  589. sub FlipperTimer_Timer()
  590. FlipperLSh.RotZ = LeftFlipper.currentangle
  591. FlipperRSh.RotZ = RightFlipper.currentangle
  592. FlipperURSh.RotZ = URightFlipper.currentangle
  593. End Sub
  594.  
  595. '*****************************************
  596. ' ninuzzu's BALL SHADOW
  597. '*****************************************
  598. Dim BallShadow
  599. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  600.  
  601. Sub BallShadowUpdate_timer()
  602. Dim BOT, b
  603. BOT = GetBalls
  604. ' hide shadow of deleted balls
  605. If UBound(BOT)<(tnob-1) Then
  606. For b = (UBound(BOT) + 1) to (tnob-1)
  607. BallShadow(b).visible = 0
  608. Next
  609. End If
  610. ' exit the Sub if no balls on the table
  611. If UBound(BOT) = -1 Then Exit Sub
  612. ' render the shadow for each ball
  613. For b = 0 to UBound(BOT)
  614. If BOT(b).X < Table1.Width/2 Then
  615. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  616. Else
  617. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  618. End If
  619. ballShadow(b).Y = BOT(b).Y + 12
  620. If BOT(b).Z > 20 Then
  621. BallShadow(b).visible = 1
  622. Else
  623. BallShadow(b).visible = 0
  624. End If
  625. Next
  626. End Sub
  627.  
  628.  
  629.  
  630. '************************************
  631. ' What you need to add to your table
  632. '************************************
  633.  
  634. ' a timer called RollingTimer. With a fast interval, like 10
  635. ' one collision sound, in this script is called fx_collide
  636. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  637. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  638.  
  639.  
  640. '******************************************
  641. ' Explanation of the rolling sound routine
  642. '******************************************
  643.  
  644. ' sounds are played based on the ball speed and position
  645.  
  646. ' the routine checks first for deleted balls and stops the rolling sound.
  647.  
  648. ' The For loop goes through all the balls on the table and checks for the ball speed and
  649. ' if the ball is on the table (height lower than 30) then then it plays the sound
  650. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  651.  
  652. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  653. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  654. ' according to the position of the ball on the table.
  655.  
  656.  
  657. '**************************************
  658. ' Explanation of the collision routine
  659. '**************************************
  660.  
  661. ' The collision is built in VP.
  662. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  663. ' 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
  664. ' depending of the speed of the collision.
  665.  
  666.  
  667. Sub Pins_Hit (idx)
  668. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  669. End Sub
  670.  
  671. Sub Targets_Hit (idx)
  672. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  673. End Sub
  674.  
  675. Sub Metals_Thin_Hit (idx)
  676. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  677. End Sub
  678.  
  679. Sub Metals_Medium_Hit (idx)
  680. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  681. End Sub
  682.  
  683. Sub Metals2_Hit (idx)
  684. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  685. End Sub
  686.  
  687. Sub Gates_Hit (idx)
  688. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  689. End Sub
  690.  
  691. Sub Spinner_Spin
  692. PlaySound "fx_spinner", 0, 0.5, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  693. End Sub
  694.  
  695. Sub Rubbers_Hit(idx)
  696. dim finalspeed
  697. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  698. If finalspeed > 20 then
  699. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  700. End if
  701. If finalspeed >= 2 AND finalspeed <= 20 then
  702. RandomSoundRubber()
  703. End If
  704. End Sub
  705.  
  706. Sub Posts_Hit(idx)
  707. dim finalspeed
  708. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  709. If finalspeed > 16 then
  710. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  711. End if
  712. If finalspeed >= 3 AND finalspeed <= 16 then
  713. RandomSoundRubber()
  714. End If
  715. End Sub
  716.  
  717. Sub RandomSoundRubber()
  718. Select Case Int(Rnd*3)+1
  719. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  720. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  721. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  722. End Select
  723. End Sub
  724.  
  725. Sub LeftFlipper_Collide(parm)
  726. RandomSoundFlipper()
  727. End Sub
  728.  
  729. Sub RightFlipper_Collide(parm)
  730. RandomSoundFlipper()
  731. End Sub
  732.  
  733. Sub URightFlipper_Collide(parm)
  734. RandomSoundFlipper()
  735. End Sub
  736.  
  737. Sub RandomSoundFlipper()
  738. Select Case Int(Rnd*3)+1
  739. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  740. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  741. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  742. End Select
  743. End Sub
  744.  
  745.  
  746.  
  747. '*****************************************
  748. ' rothbauerw's Manual Ball Control
  749. '*****************************************
  750.  
  751. Dim BCup, BCdown, BCleft, BCright
  752. Dim ControlBallInPlay, ControlActiveBall, EnableBallControl
  753. Dim BCvel, BCyveloffset, BCboostmulti, BCboost
  754.  
  755. BCboost = 1 'Do Not Change - default setting
  756. BCvel = 4 'Controls the speed of the ball movement
  757. BCyveloffset = -0.01 'Offsets the force of gravity to keep the ball from drifting vertically on the table, should be negative
  758. BCboostmulti = 3 'Boost multiplier to ball veloctiy (toggled with the B key)
  759.  
  760. ControlBallInPlay = false
  761.  
  762. Sub StartBallControl_Hit()
  763. Set ControlActiveBall = ActiveBall
  764. ControlBallInPlay = true
  765. End Sub
  766.  
  767. Sub StopBallControl_Hit()
  768. ControlBallInPlay = false
  769. End Sub
  770.  
  771. Sub BallControlTimer_Timer()
  772. If EnableBallControl and ControlBallInPlay then
  773. If BCright = 1 Then
  774. ControlActiveBall.velx = BCvel*BCboost
  775. ElseIf BCleft = 1 Then
  776. ControlActiveBall.velx = -BCvel*BCboost
  777. Else
  778. ControlActiveBall.velx = 0
  779. End If
  780.  
  781. If BCup = 1 Then
  782. ControlActiveBall.vely = -BCvel*BCboost
  783. ElseIf BCdown = 1 Then
  784. ControlActiveBall.vely = BCvel*BCboost
  785. Else
  786. ControlActiveBall.vely = bcyveloffset
  787. End If
  788. End If
  789. End Sub
  790.  
  791.  
  792. '-------------------------------
  793. '------ DIP Switch Menu ------
  794. '-------------------------------
  795.  
  796. Sub editDips
  797. Dim vpmDips:Set vpmDips=New cvpmDips
  798. With vpmDips
  799. .AddForm 200,280,"Dark Shadows DIP switches"
  800. .AddFrame 0, 0,270,"Balls per game",&HC0000000,Array("2 balls",&HC0000000,"3 balls",0,"4 balls",&H80000000,"5 balls",&H40000000)
  801. .AddChk 5,80,270,Array("Match feature",&H08000000)
  802. .AddChk 5,100,270,Array("Show credits",&H04000000)
  803.  
  804. .AddLabel 0,130,280,20,"After hitting OK, press F3 to reset game with new settings."
  805. .ViewDips
  806. End With
  807. End Sub
  808. Set vpmShowDips=GetRef("editDips")
  809.  
  810.  
Advertisement
Add Comment
Please, Sign In to add comment