Arngrim

SMB

Mar 14th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.47 KB | None | 0 0
  1. '*************************************
  2. 'Super Mario Brothers - IPDB No. 2579
  3. '© Gottlieb 1992
  4. 'VPX by ninuzzu/Tom Tower
  5. 'Script by edizzle/ninuzzu
  6. ' Thanks to zany for the domes and flippers models
  7. ' Thanks to VPDev Team for the freaking amazing VPX
  8. '************************************
  9. Option Explicit
  10. Randomize
  11.  
  12. Dim Ballsize,BallMass
  13. BallSize = 51
  14. BallMass = (Ballsize^3)/125000
  15.  
  16. Dim DesktopMode:DesktopMode = Table1.ShowDT
  17. Dim UseVPMDMD:UseVPMDMD = DesktopMode
  18.  
  19. On Error Resume Next
  20. ExecuteGlobal GetTextFile("controller.vbs")
  21. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  22. On Error Goto 0
  23.  
  24. LoadVPM "01560000", "gts3.VBS", 3.26
  25.  
  26. '********************
  27. 'Standard definitions
  28. '********************
  29.  
  30. Const UseSolenoids = 2
  31. Const UseLamps = 0
  32. Const UseSync = 0
  33.  
  34. 'Standard Sounds
  35. Const SSolenoidOn = "Solenoid"
  36. Const SSolenoidOff = ""
  37. Const SCoin = "fx_coin"
  38.  
  39. '******************************************************
  40. ' TABLE INIT
  41. '******************************************************
  42.  
  43. Const cGameName= "smb3"
  44. Dim dtDrop
  45.  
  46. Sub Table1_Init
  47. With Controller
  48. .GameName = cGameName
  49. .SplashInfoLine = "Super Mario Bros. (Gottlieb 1994)"
  50. .HandleKeyboard = 0
  51. .ShowTitle = 0
  52. .ShowDMDOnly = 1
  53. .ShowFrame = 0
  54. .HandleMechanics = 0
  55. .Hidden = 0 'DesktopMode
  56. On Error Resume Next
  57. .Run GetPlayerHWnd
  58. If Err Then MsgBox Err.Description
  59. On Error Goto 0
  60. End With
  61.  
  62. '************ Main Timer init ********************
  63.  
  64. PinMAMETimer.Interval = PinMAMEInterval
  65. PinMAMETimer.Enabled = 1
  66.  
  67. '************ Nudging **************************
  68.  
  69. vpmNudge.TiltSwitch = 151
  70. vpmNudge.Sensitivity = 3
  71. vpmNudge.TiltObj = Array(Bumper1, Bumper2, Bumper3, LeftSlingShot, RightSlingShot)
  72.  
  73. '************ Lower Droptarget
  74. Set dtDrop = new cvpmDropTarget
  75. With dtDrop
  76. .InitDrop Array(sw30), Array(30)
  77. .Initsnd SoundFX("droptarget",DOFDropTargets), SoundFX("resetdrop",DOFContactors)
  78. End With
  79.  
  80. '************ Trough **************************
  81. Slot1.CreateSizedballWithMass Ballsize/2,Ballmass
  82. Slot2.CreateSizedballWithMass Ballsize/2,Ballmass
  83. Slot3.CreateSizedballWithMass Ballsize/2,Ballmass
  84. Controller.Switch(34) = 1
  85.  
  86. '************ Misc Stuff ******************
  87. sw30.IsDropped=1
  88. Lkick.collidable=0
  89. Rkick.collidable=0
  90. LeftRail.visible = DesktopMode
  91. RightRail.visible = DesktopMode
  92.  
  93. Select Case DesktopMode
  94. Case 0
  95. Apron.material = "Apron"
  96. Case 1
  97. Apron.material = "ApronDT"
  98. End Select
  99. End Sub
  100.  
  101. '******************************************************
  102. ' KEYS
  103. '******************************************************
  104.  
  105. Sub Table1_KeyDown(ByVal keycode)
  106. If keycode = StartGameKey Then Controller.Switch(4)= 1
  107. ' If BIP = 0 then Controller.Switch(4)= 1
  108. ' If BIP = 1 AND Controller.Switch(32) Then Controller.Switch(4) = 1
  109. ' End If
  110. If keycode = LeftFlipperKey Then Controller.Switch(45) = 1
  111. If keycode = RightFlipperKey Then Controller.Switch(47) = 1
  112. If keycode = LeftTiltKey Then Nudge 90, 3:PlaySound SoundFX("fx_nudge", 0)
  113. If keycode = RightTiltKey Then Nudge 270, 3:PlaySound SoundFX("fx_nudge", 0)
  114. If keycode = CenterTiltKey Then Nudge 0, 3:PlaySound SoundFX("fx_nudge", 0)
  115. If keycode = PlungerKey Then Controller.Switch(5)=1
  116. If vpmKeyDown(keycode) Then Exit Sub
  117. End Sub
  118.  
  119. Sub Table1_KeyUp(ByVal keycode)
  120. If keycode = StartGameKey Then Controller.Switch(4) = 0
  121. If keycode = LeftFlipperKey Then Controller.Switch(45) = 0
  122. If keycode = RightFlipperKey Then Controller.Switch(47) = 0
  123. If keycode = PlungerKey Then Controller.Switch(5)=0
  124. If vpmKeyUp(keycode) Then Exit Sub
  125. End Sub
  126.  
  127. Sub Table1_Paused: Controller.Pause = 1:End Sub
  128. Sub Table1_UnPaused: Controller.Pause = 0:End Sub
  129. Sub Table1_Exit(): Controller.Stop:End Sub
  130.  
  131. '******************************************************
  132. ' SOLENOIDS
  133. '******************************************************
  134.  
  135. ' SolCallback(1) = "" '1 - Left Pop Bumper
  136. ' SolCallback(2) = "" '2 - Top Pop Bumper
  137. ' SolCallback(3) = "" '3 - Bottom Pop Bumper
  138. ' SolCallback(4) = "" '4 - Left Slingshot
  139. ' SolCallback(5) = "" '5 - Right Slingshot
  140. SolCallback(6) = "dtDrop.SolDropUp" '6 - Shield Reset
  141. SolCallback(7) = "dtDrop.SolDropDown" '7 - Shield Trip
  142. SolCallback(8) = "Ballsave" '8 - Kicksave
  143. SolCallback(9) = "Shooter" '9 - Shooter
  144. SolCallback(10) = "LeftKicker" '10 - Left upkicker
  145. SolCallback(11) = "RightKicker" '11 - Right Upkicker
  146. SolCallback(12) = "UpperKicker" '12 - Upper upkicker
  147. SolCallback(13) = "SetLamp 153," '13 - Mario speaking Flasher
  148. SolCallback(14) = "SetLamp 154," '14 - Mario speaking Flasher
  149. SolCallback(15) = "SetLamp 155," '15 - castle/princess ??????
  150. SolCallback(16) = "SetLamp 156," '16 - luigi and yoshi????????
  151. SolCallback(17) = "Setlamp 157," '17 - Left Ramp Flash
  152. SolCallback(18) = "SetLamp 158," '18 - Right Ramp Flash
  153. SolCallback(19) = "SetLamp 159," '19 - Mario Cave Flash (x2)
  154. SolCallback(20) = "SetLamp 160," '20 - Castle Flash (x2)
  155. SolCallback(21) = "SetLamp 161," '21 - Bottom Left Flash
  156. SolCallback(22) = "SetLamp 162," '22 - Upper Left Flash
  157. SolCallback(23) = "SetLamp 163," '23 - Upper Center Flash (x2)
  158. SolCallback(24) = "SetLamp 164," '24 - Upper Right Flash (x2)
  159. SolCallback(25) = "CastleRotate" '25 - Motor Relay
  160. SolCallback(26) = "GIRelay" '26 - LightBox Relay
  161. SolCallback(28) = "ReleaseBall" '28 - Ball Release
  162. SolCallback(29) = "SolOuthole" '29 - Outhole
  163. SolCallback(30) = "SolKnocker" '30 - Knocker
  164. SolCallback(31) = "TiltRelay" '31 - Tilt
  165. SolCallback(32) = "vpmNudge.SolGameOn" '32 - Game Over Relay
  166.  
  167. SolCallback(sLRFlipper) = "SolRFlipper"
  168. SolCallback(sLLFlipper) = "SolLFlipper"
  169.  
  170. '******************************************************
  171. ' TROUGH BASED ON FOZZY'S
  172. '******************************************************
  173.  
  174. Sub Slot3_Hit():Controller.Switch(34) = 1:UpdateTrough:End Sub
  175. Sub Slot3_UnHit():Controller.Switch(34) = 0:UpdateTrough:End Sub
  176. Sub Slot2_UnHit():UpdateTrough:End Sub
  177. Sub Slot1_UnHit():UpdateTrough:End Sub
  178.  
  179. Sub UpdateTrough()
  180. UpdateTroughTimer.Interval = 300
  181. UpdateTroughTimer.Enabled = 1
  182. End Sub
  183.  
  184. Sub UpdateTroughTimer_Timer()
  185. If Slot1.BallCntOver = 0 Then Slot2.kick 60, 9
  186. If Slot2.BallCntOver = 0 Then Slot3.kick 60, 9
  187. Me.Enabled = 0
  188. End Sub
  189.  
  190. '******************************************************
  191. ' DRAIN & RELEASE
  192. '******************************************************
  193.  
  194. Dim BIP : BIP = 0
  195.  
  196. Sub Drain_Hit()
  197. PlaySound "fx_drain"
  198. UpdateTrough
  199. BIP = BIP - 1
  200. Controller.Switch(33) = 1
  201. End Sub
  202.  
  203. Sub Drain_UnHit()
  204. Controller.Switch(33) = 0
  205. End Sub
  206.  
  207. Sub SolOuthole(enabled)
  208. If enabled Then
  209. Drain.kick 60,20
  210. PlaySound SoundFX(SSolenoidOn,DOFContactors)
  211. End If
  212. End Sub
  213.  
  214. Sub ReleaseBall(enabled)
  215. If enabled Then
  216. PlaySound SoundFX("fx_ballrel",DOFContactors)
  217. Slot1.kick 60, 9
  218. UpdateTrough
  219. BIP = BIP + 1
  220. End If
  221. End Sub
  222.  
  223. '******************************************************
  224. ' LEFT KICKER
  225. '******************************************************
  226.  
  227. Sub LeftKicker(enabled)
  228. If enabled Then
  229. sw16a.kick 0,35,1.56
  230. Controller.Switch(16) = 0
  231. vpmTimer.AddTimer 500, "sw16.enabled=1'"
  232. vpmTimer.AddTimer 600, "Lkick.collidable=0'"
  233. Playsound SoundFX("scoopexit",DOFContactors)
  234. End If
  235. End Sub
  236.  
  237. Sub sw16a_hit()
  238. PlaySound "fx_kicker_catch"
  239. Controller.Switch(16) = 1
  240. sw16.enabled=0
  241. Lkick.collidable=1
  242. End Sub
  243.  
  244. Sub sw16_hit: PlaySound "kicker_enter": End Sub
  245.  
  246. '******************************************************
  247. ' RIGHT KICKER
  248. '******************************************************
  249.  
  250. Sub RightKicker(enabled)
  251. If enabled Then
  252. sw26a.kick 0,52,1.56
  253. Controller.Switch(26) = 0
  254. vpmTimer.AddTimer 500, "sw26.enabled=1'"
  255. vpmTimer.AddTimer 600, "Rkick.collidable=0'"
  256. Playsound SoundFX("scoopexit",DOFContactors)
  257. End If
  258. End Sub
  259.  
  260. sub sw26a_hit
  261. StopSound "fx_subway"
  262. PlaySound "fx_kicker_catch"
  263. Controller.Switch(26) = 1
  264. sw26.enabled= 0
  265. Rkick.collidable=1
  266. End sub
  267.  
  268. Sub sw26_hit: PlaySound "kicker_enter": End Sub
  269. Sub sw27_hit: vpmTimer.PulseSw 27:PlaySound "kicker_enter": End Sub
  270. Sub TrSubway_hit: PlaySound "fx_subway" : End sub
  271.  
  272. '******************************************************
  273. ' TOP KICKER
  274. '******************************************************
  275.  
  276. Sub UpperKicker(enabled)
  277. If enabled Then
  278. sw36.kick 0,35,1.56
  279. Controller.Switch(36) = 0
  280. Playsound SoundFX("vuk_exit",DOFContactors)
  281. End If
  282. End Sub
  283.  
  284. Sub sw36_hit: PlaySound "vuk_enter" : Controller.Switch(36) = 1 : End sub
  285.  
  286. '******************************************************
  287. ' BALLSAVER (based on PacDude's)
  288. '******************************************************
  289.  
  290. Sub BallSave(enabled) : If enabled Then PlaySound SoundFX(SSolenoidOn,DOFContactors) :BallSaver.enabled = True:Else BallSaver.enabled = False:End If: End Sub
  291. Sub BallSaver_Hit() : PlaySound SoundFX(SSolenoidOn,DOFContactors) : BallSaver.kick 0,35+(rnd*20) : BallSaver.enabled = False : End Sub
  292.  
  293. '******************************************************
  294. ' AUTOPLUNGER
  295. '******************************************************
  296.  
  297. Sub Shooter(Enabled)
  298. If Enabled Then
  299. Plunger.Fire
  300. PlaySound SoundFX("fx_plunger2",DOFContactors)
  301. End If
  302. End Sub
  303.  
  304. '******************************************************
  305. ' KNOCKER
  306. '******************************************************
  307.  
  308. Sub SolKnocker(enabled)
  309. If enabled Then
  310. PlaySound SoundFX("knocker",DOFKnocker)
  311. End If
  312. End Sub
  313.  
  314. '******************************************************
  315. ' NFOZZY'S FLIPPERS
  316. '******************************************************
  317.  
  318. Dim returnspeed, lfstep, rfstep
  319. returnspeed = LeftFlipper.return
  320. lfstep = 1
  321. rfstep = 1
  322.  
  323. Sub SolLFlipper(Enabled)
  324. If Enabled Then
  325. PlaySound SoundFX("fx_flipper1",DOFFlippers), 0, 1, -0.1, 0.25
  326. LeftFlipper.RotateToEnd
  327. Flipper1.RotateToEnd
  328. Else
  329. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, -0.1, 0.25
  330. LeftFlipper.RotateToStart
  331. Flipper1.RotateToStart
  332. LeftFlipper.TimerEnabled = 1
  333. LeftFlipper.TimerInterval = 16
  334. LeftFlipper.return = returnspeed * 0.5
  335. End If
  336. End Sub
  337.  
  338. Sub SolRFlipper(Enabled)
  339. If Enabled Then
  340. PlaySound SoundFX("fx_flipper2",DOFFlippers), 0, 1, 0.1, 0.25
  341. RightFlipper.RotateToEnd
  342. Else
  343. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, 0.1, 0.25
  344. RightFlipper.RotateToStart
  345. RightFlipper.TimerEnabled = 1
  346. RightFlipper.TimerInterval = 16
  347. RightFlipper.return = returnspeed * 0.5
  348. End If
  349. End Sub
  350.  
  351. Sub LeftFlipper_timer()
  352. select case lfstep
  353. Case 1: LeftFlipper.return = returnspeed * 0.6 :lfstep = lfstep + 1
  354. Case 2: LeftFlipper.return = returnspeed * 0.7 :lfstep = lfstep + 1
  355. Case 3: LeftFlipper.return = returnspeed * 0.8 :lfstep = lfstep + 1
  356. Case 4: LeftFlipper.return = returnspeed * 0.9 :lfstep = lfstep + 1
  357. Case 5: LeftFlipper.return = returnspeed * 1 :lfstep = lfstep + 1
  358. Case 6: LeftFlipper.timerenabled = 0 : lfstep = 1
  359. end select
  360. end sub
  361.  
  362. Sub RightFlipper_timer()
  363. select case rfstep
  364. Case 1: RightFlipper.return = returnspeed * 0.6 :rfstep = rfstep + 1
  365. Case 2: RightFlipper.return = returnspeed * 0.7 :rfstep = rfstep + 1
  366. Case 3: RightFlipper.return = returnspeed * 0.8 :rfstep = rfstep + 1
  367. Case 4: RightFlipper.return = returnspeed * 0.9 :rfstep = rfstep + 1
  368. Case 5: RightFlipper.return = returnspeed * 1 :rfstep = rfstep + 1
  369. Case 6: RightFlipper.timerenabled = 0 : rfstep = 1
  370. end select
  371. end sub
  372.  
  373. '******************************************************
  374. ' BUMPERS
  375. '******************************************************
  376.  
  377. Dim dirRing1:dirRing1 = -1
  378. Dim dirRing2:dirRing2 = -1
  379. Dim dirRing3:dirRing3 = -1
  380.  
  381. Sub Bumper1_Hit:PlaySound SoundFX("fx_bumper1",DOFContactors):Me.TimerEnabled = 1:vpmTimer.PulseSw 10:Me.TimerInterval = 20:End Sub
  382. Sub Bumper2_Hit:PlaySound SoundFX("fx_bumper2",DOFContactors):Me.TimerEnabled = 1:vpmTimer.PulseSw 12:Me.TimerInterval = 20:End Sub
  383. Sub Bumper3_Hit:PlaySound SoundFX("fx_bumper3",DOFContactors):Me.TimerEnabled = 1:vpmTimer.PulseSw 11:Me.TimerInterval = 20:End Sub
  384.  
  385. Sub Bumper1_timer()
  386. BRing1.Z = BRing1.Z + (5 * dirRing1)
  387. If BRing1.Z <= -10 Then dirRing1 = 1
  388. If BRing1.Z >= 25 Then
  389. dirRing1 = -1
  390. BRing1.Z = 25
  391. Me.TimerEnabled = 0
  392. End If
  393. End Sub
  394.  
  395. Sub Bumper2_timer()
  396. BRing2.Z = BRing2.Z + (5 * dirRing2)
  397. If BRing2.Z <= -10 Then dirRing2 = 1
  398. If BRing2.Z >= 25 Then
  399. dirRing2 = -1
  400. BRing2.Z = 25
  401. Me.TimerEnabled = 0
  402. End If
  403. End Sub
  404.  
  405. Sub Bumper3_timer()
  406. BRing3.Z = BRing3.Z + (5 * dirRing3)
  407. If BRing3.Z <= -10 Then dirRing3 = 1
  408. If BRing3.Z >= 25 Then
  409. dirRing3 = -1
  410. BRing3.Z = 25
  411. Me.TimerEnabled = 0
  412. End If
  413. End Sub
  414.  
  415. '******************************************************
  416. ' SLINGSHOTS
  417. '******************************************************
  418.  
  419. Dim RStep, Lstep
  420.  
  421. Sub LeftSlingShot_Slingshot
  422. PlaySound SoundFX("SlingshotLeft",DOFContactors), 0, 1, -0.05, 0.05
  423. vpmTimer.PulseSw 13
  424. LSling.Visible = 0
  425. LSling1.Visible = 1
  426. sling1.TransZ = -20
  427. LStep = 0
  428. Me.TimerEnabled = 1
  429. End Sub
  430.  
  431. Sub LeftSlingShot_Timer
  432. Select Case LStep
  433. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling1.TransZ = -10
  434. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling1.TransZ = 0:Me.TimerEnabled = 0
  435. End Select
  436. LStep = LStep + 1
  437. End Sub
  438.  
  439. Sub RightSlingShot_Slingshot
  440. PlaySound SoundFX("SlingshotRight",DOFContactors), 0, 1, 0.05, 0.05
  441. vpmTimer.PulseSw 14
  442. RSling.Visible = 0
  443. RSling1.Visible = 10
  444. sling2.TransZ = -2
  445. RStep = 0
  446. Me.TimerEnabled = 1
  447. End Sub
  448.  
  449. Sub RightSlingShot_Timer
  450. Select Case RStep
  451. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling2.TransZ = -10
  452. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling2.TransZ = 0:Me.TimerEnabled = 0
  453. End Select
  454. RStep = RStep + 1
  455. End Sub
  456.  
  457. '******************************************************
  458. ' SWITCHES
  459. '******************************************************
  460.  
  461. '******* Targets ******************
  462. Sub sw20_Hit:vpmTimer.PulseSw 20:End Sub
  463. Sub sw21_Hit:vpmTimer.PulseSw 21:End Sub
  464. Sub sw21a_Hit:vpmTimer.PulseSw 21:End Sub
  465. Sub sw22_Hit:vpmTimer.PulseSw 22:End Sub
  466. Sub sw23_Hit:vpmTimer.PulseSw 23:End Sub
  467. Sub sw24_Hit:vpmTimer.PulseSw 24:End Sub
  468. Sub sw30_hit:DTdrop.Hit 1:End Sub
  469.  
  470. '******* Opto Switches ******************
  471. Sub sw17_Hit:Controller.Switch(17) = 1:End Sub
  472. Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
  473.  
  474. '******* Rollover Switches ******************
  475.  
  476. Sub sw32_Hit:Controller.Switch(32) = 1:PlaySound "rollover":End Sub
  477. Sub sw32_UnHit:Controller.Switch(32) = 0:End Sub
  478. Sub sw40_Hit:Controller.Switch(40) = 1:PlaySound "rollover":End Sub
  479. Sub sw40_UnHit:Controller.Switch(40) = 0:End Sub
  480. Sub sw41_Hit:Controller.Switch(41) = 1:PlaySound "rollover":End Sub
  481. Sub sw41_UnHit:Controller.Switch(41) = 0:End Sub
  482. Sub sw42_Hit:Controller.Switch(42) = 1:PlaySound "rollover":End Sub
  483. Sub sw42_UnHit:Controller.Switch(42) = 0:End Sub
  484. Sub sw43_Hit:Controller.Switch(43) = 1:PlaySound "rollover":End Sub
  485. Sub sw43_UnHit:Controller.Switch(43) = 0:End Sub
  486. Sub sw44_Hit:Controller.Switch(44) = 1:PlaySound "rollover":End Sub
  487. Sub sw44_UnHit:Controller.Switch(44) = 0:End Sub
  488. Sub sw46_Hit:Controller.Switch(46) = 1:PlaySound "rollover":End Sub
  489. Sub sw46_UnHit:Controller.Switch(46) = 0:End Sub
  490.  
  491. '******************************************************
  492. ' Castle Animation
  493. '******************************************************
  494.  
  495. Dim discAngle:discAngle=0
  496. Dim stepAngle, stopRotation
  497.  
  498. Sub CastleRotate(enabled)
  499. If Enabled Then
  500. CastleTimer.Enabled = 1
  501. stepAngle=15
  502. stopRotation=0
  503. Else
  504. stopRotation=1
  505. End If
  506. End Sub
  507.  
  508. Sub CastleTimer_Timer()
  509. discAngle = discAngle + stepAngle
  510. If discAngle >= 360 Then
  511. discAngle = discAngle - 360
  512. End If
  513. Prim_Castle.RotZ = 360 - discAngle
  514. If stopRotation Then
  515. stepAngle = stepAngle - 0.1
  516. If stepAngle <= 0 Then
  517. CastleTimer.Enabled = 0
  518. End If
  519. End If
  520. Prim_CastleDecal.RotZ = Prim_Castle.RotZ
  521. Prim_CastleBolts.RotZ = -Prim_Castle.RotZ
  522. End Sub
  523.  
  524. '******************************************************
  525. ' RealTime Updates
  526. '******************************************************
  527.  
  528. Set MotorCallback = GetRef("GameTimer")
  529.  
  530. Sub GameTimer
  531. UpdateMechs
  532. RollingSoundUpdate
  533. ' BallShadowUpdate
  534. End Sub
  535.  
  536. Sub UpdateMechs
  537. Prim_LeftFlipper.RotY=LeftFlipper.currentangle-90
  538. Prim_RightFlipper.RotY=RightFlipper.currentangle-90
  539. Prim_Flipper1.RotY=Flipper1.currentangle-90
  540. FlipperLSh.RotZ = LeftFlipper.currentangle
  541. FlipperRSh.RotZ = RightFlipper.currentangle
  542. FlipperL1Sh.RotZ = Flipper1.currentangle
  543. End Sub
  544.  
  545. '***************************************************
  546. ' JP's VP10 Fading Lamps & Flashers
  547. ' Based on PD's Fading Light System
  548. ' SetLamp 0 is Off
  549. ' SetLamp 1 is On
  550. ' fading for non opacity objects is 4 steps
  551. '***************************************************
  552.  
  553. Dim LampState(200), FadingLevel(200)
  554. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  555.  
  556. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  557. LampTimer.Interval = 10 'lamp fading speed
  558. LampTimer.Enabled = 1
  559.  
  560. ' Lamp & Flasher Timers
  561.  
  562. Sub LampTimer_Timer()
  563. Dim chgLamp, num, chg, ii
  564. chgLamp = Controller.ChangedLamps
  565. If Not IsEmpty(chgLamp) Then
  566. For ii = 0 To UBound(chgLamp)
  567. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  568. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  569. Next
  570. End If
  571. UpdateLamps
  572. End Sub
  573.  
  574. Sub InitLamps()
  575. Dim x
  576. For x = 0 to 200
  577. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  578. FadingLevel(x) = 4 ' used to track the fading state
  579. FlashSpeedUp(x) = 0.5 ' faster speed when turning on the flasher
  580. FlashSpeedDown(x) = 0.35 ' slower speed when turning off the flasher
  581. FlashMax(x) = 1 ' the maximum value when on, usually 1
  582. FlashMin(x) = 0 ' the minimum value when off, usually 0
  583. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  584. Next
  585. End Sub
  586.  
  587. Sub UpdateLamps
  588. NFadeL 0, l0
  589. NFadeL 1, l1
  590. if L1.state=1 then bulb8.blenddisablelighting=5
  591. if L1.state=0 then bulb8.blenddisablelighting=0
  592. NFadeL 2, l2
  593. if L2.state=1 then bulb9.blenddisablelighting=5
  594. if L2.state=0 then bulb9.blenddisablelighting=0
  595. NFadeL 3, l3
  596. if L3.state=1 then bulb10.blenddisablelighting=5
  597. if L3.state=0 then bulb10.blenddisablelighting=0
  598. NFadeL 4, l4
  599. if L4.state=1 then bulb11.blenddisablelighting=5
  600. if L4.state=0 then bulb11.blenddisablelighting=0
  601. NFadeL 5, l5
  602. if L5.state=1 then bulb12.blenddisablelighting=5
  603. if L5.state=0 then bulb12.blenddisablelighting=0
  604. NFadeL 6, l6
  605. if L6.state=1 then bulb13.blenddisablelighting=5
  606. if L6.state=0 then bulb13.blenddisablelighting=0
  607. NFadeL 7, l7
  608. if L7.state=1 then bulb14.blenddisablelighting=5
  609. if L7.state=0 then bulb14.blenddisablelighting=0
  610.  
  611. NFadeL 10, l10
  612. NFadeL 11, l11
  613. NFadeL 12, l12
  614. NFadeL 13, l13
  615. NFadeL 14, l14
  616. NFadeL 15, l15
  617. NFadeL 16, l16
  618. NFadeL 17, l17
  619.  
  620. NFadeL 20, l20
  621. NFadeL 21, l21
  622. NFadeL 22, l22
  623. NFadeL 23, l23
  624. NFadeL 24, l24
  625. NFadeL 25, l25
  626. NFadeL 26, l26
  627. NFadeL 27, l27
  628.  
  629. NFadeL 30, l30
  630. NFadeL 31, l31
  631. NFadeL 32, l32
  632. NFadeL 33, l33
  633. NFadeL 34, l34
  634. NFadeL 35, l35
  635. NFadeL 36, l36
  636. NFadeL 37, l37
  637.  
  638. NFadeL 40, l40
  639. NFadeL 41, l41
  640. NFadeL 42, l42
  641. NFadeL 43, l43
  642. NFadeL 44, l44
  643. NFadeLm 45, l45
  644. NFadeLm 45, l45a
  645. NFadeL 45, l45b
  646. NFadeLm 46, l46
  647. NFadeLm 46, l46a
  648. NFadeL 46, l46b
  649. NFadeLm 47, l47
  650. NFadeLm 47, l47a
  651. NFadeL 47, l47b
  652.  
  653. NFadeL 50, l50
  654. NFadeL 51, l51
  655. NFadeL 52, l52
  656. NFadeL 53, l53
  657. NFadeL 54, l54
  658. NFadeL 55, l55
  659. NFadeL 56, l56
  660. NFadeL 57, l57
  661.  
  662. NFadeL 60, l60
  663. NFadeL 61, l61
  664. NFadeL 62, l62
  665. NFadeL 63, l63
  666. NFadeL 64, l64
  667. NFadeL 65, l65
  668. NFadeL 66, l66
  669. NFadeL 67, l67
  670.  
  671. NFadeL 70, l70
  672. NFadeL 71, l71
  673. NFadeL 72, l72
  674. NFadeL 73, l73
  675. NFadeL 74, l74
  676. NFadeL 75, l75
  677. NFadeL 76, l76
  678. NFadeL 77, l77
  679.  
  680. NFadeL 81, l81
  681. if L81.state=1 then bulb1.blenddisablelighting=8
  682. if L81.state=0 then bulb1.blenddisablelighting=0
  683. NFadeL 82, l82
  684. if L82.state=1 then bulb2.blenddisablelighting=8
  685. if L82.state=0 then bulb2.blenddisablelighting=0
  686. NFadeL 83, l83
  687. if L83.state=1 then bulb3.blenddisablelighting=8
  688. if L83.state=0 then bulb3.blenddisablelighting=0
  689. NFadeL 84, l84
  690. if L84.state=1 then bulb4.blenddisablelighting=8
  691. if L84.state=0 then bulb4.blenddisablelighting=0
  692. NFadeL 85, l85
  693. if L85.state=1 then bulb5.blenddisablelighting=8
  694. if L85.state=0 then bulb5.blenddisablelighting=0
  695. NFadeL 86, l86
  696. if L86.state=1 then bulb6.blenddisablelighting=8
  697. if L86.state=0 then bulb6.blenddisablelighting=0
  698. NFadeL 87, l87
  699. if L87.state=1 then bulb7.blenddisablelighting=8
  700. if L87.state=0 then bulb7.blenddisablelighting=0
  701.  
  702. NFadeL 90, l90
  703. NFadeL 91, l91
  704. NFadeL 92, l92
  705. NFadeL 93, l93
  706. NFadeL 94, l94
  707. NFadeL 95, l95
  708. NFadeL 96, l96
  709. NFadeL 97, l97
  710.  
  711. 'Mario speaking Flasher (x2)
  712. NFadeLm 153, f13
  713. Flash 153, f13a
  714. NFadeL 154, f14
  715. ' castle/princess ??????
  716. NFadeLm 155, f15
  717. Flash 155, f15a
  718. 'luigi and yoshi????????
  719. NFadeLm 156, f16
  720. NFadeLm 156, f16a
  721. Flashm 156, f16b
  722. Flash 156, f16c
  723. 'Left Ramp Flasher
  724. NFadeLm 157, f17
  725. NFadeLm 157, f17a
  726. NFadeLm 157, f17b
  727. Flash 157,f17c
  728. if f17.state=1 then Prim_Dome2.blenddisablelighting=10
  729. if F17.state=0 then Prim_Dome2.blenddisablelighting=0
  730. 'Right Ramp Flasher
  731. NFadeLm 158, f18
  732. NFadeLm 158, f18a
  733. NFadeLm 158, f18c
  734. Flash 158, f18b
  735. if f18.state=1 then Prim_Dome4.blenddisablelighting=10
  736. if F18.state=0 then Prim_Dome4.blenddisablelighting=0
  737.  
  738. 'Mario's Cave PF Flashers (2)
  739. NFadeL 159, f19
  740. 'Castle Flashers
  741. NFadeLm 160, f20
  742. NFadeLm 160, f20a
  743. NFadeLm 160, f20b
  744. Flashm 160, f20c
  745. Flash 160, f20d
  746. if f20.state=1 then Prim_Castle.blenddisablelighting=0.3
  747. if F20.state=0 then Prim_Castle.blenddisablelighting=0
  748.  
  749. 'Left Kicker Flasher
  750. NFadeL 161, f21
  751. 'Upper Left Flasher
  752. NFadeLm 162, f22
  753. NFadeLm 162, f22a
  754. Flashm 162, f22b
  755. Flash 162, f22c
  756. if f22.state=1 then Prim_Dome5.blenddisablelighting=10
  757. if F22.state=0 then Prim_Dome5.blenddisablelighting=0
  758.  
  759. 'Upper Center Flashers (2)
  760. NFadeLm 163, f23
  761. NFadeLm 163, f23a
  762. NFadeLm 163, f23b
  763. NFadeLm 163, f23e
  764. NFadeLm 163, f23f
  765. Flashm 163, f23c
  766. Flashm 163, f23d
  767. Flash 163, f23g
  768. if f23.state=1 then Prim_Dome1.blenddisablelighting=10:Prim_Dome6.blenddisablelighting=10
  769. if F23.state=0 then Prim_Dome1.blenddisablelighting=0:Prim_Dome6.blenddisablelighting=0
  770. 'Upper Right Flashers (2)
  771. NFadeLm 164, f24
  772. NFadeLm 164, f24a
  773. NFadeLm 164, f24b
  774. NFadeLm 164, f24e
  775. Flashm 164, f24c
  776. Flashm 164, f24d
  777. Flash 164, f24f
  778. if f24.state=1 then Prim_Dome3.blenddisablelighting=10:Prim_Dome7.blenddisablelighting=10
  779. if F24.state=0 then Prim_Dome3.blenddisablelighting=0:Prim_Dome7.blenddisablelighting=0
  780.  
  781. End Sub
  782.  
  783. Sub SetLamp(nr, value)
  784. If value <> LampState(nr) Then
  785. LampState(nr) = abs(value)
  786. FadingLevel(nr) = abs(value) + 4
  787. End If
  788. End Sub
  789.  
  790. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  791.  
  792. Sub NFadeL(nr, object)
  793. Select Case FadingLevel(nr)
  794. Case 4:object.state = 0:FadingLevel(nr) = 0
  795. Case 5:object.state = 1:FadingLevel(nr) = 1
  796. End Select
  797. End Sub
  798.  
  799. Sub NFadeLm(nr, object) ' used for multiple lights
  800. Select Case FadingLevel(nr)
  801. Case 4:object.state = 0
  802. Case 5:object.state = 1
  803. End Select
  804. End Sub
  805.  
  806. 'Lights, Ramps & Primitives used as 4 step fading lights
  807. 'a,b,c,d are the images used from on to off
  808.  
  809. Sub FadeObj(nr, object, a, b, c, d)
  810. Select Case FadingLevel(nr)
  811. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  812. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  813. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  814. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  815. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  816. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  817. End Select
  818. End Sub
  819.  
  820. Sub FadeObjm(nr, object, a, b, c, d)
  821. Select Case FadingLevel(nr)
  822. Case 4:object.image = b
  823. Case 5:object.image = a
  824. Case 9:object.image = c
  825. Case 13:object.image = d
  826. End Select
  827. End Sub
  828.  
  829. Sub NFadeObj(nr, object, a, b)
  830. Select Case FadingLevel(nr)
  831. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  832. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  833. End Select
  834. End Sub
  835.  
  836. Sub NFadeObjm(nr, object, a, b)
  837. Select Case FadingLevel(nr)
  838. Case 4:object.image = b
  839. Case 5:object.image = a
  840. End Select
  841. End Sub
  842.  
  843. ' Flasher objects
  844.  
  845. Sub Flash(nr, object)
  846. Select Case FadingLevel(nr)
  847. Case 4 'off
  848. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  849. If FlashLevel(nr) < FlashMin(nr) Then
  850. FlashLevel(nr) = FlashMin(nr)
  851. FadingLevel(nr) = 0 'completely off
  852. End if
  853. Object.IntensityScale = FlashLevel(nr)
  854. Case 5 ' on
  855. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  856. If FlashLevel(nr) > FlashMax(nr) Then
  857. FlashLevel(nr) = FlashMax(nr)
  858. FadingLevel(nr) = 1 'completely on
  859. End if
  860. Object.IntensityScale = FlashLevel(nr)
  861. End Select
  862. End Sub
  863.  
  864. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  865. Object.IntensityScale = FlashLevel(nr)
  866. End Sub
  867.  
  868. '******************************************************
  869. ' GENERAL ILLUMINATION
  870. '******************************************************
  871.  
  872. Dim xx
  873.  
  874. Sub GIRelay(enabled)
  875. If Enabled Then
  876. for each xx in GI:xx.State=0:Next
  877. for each xx in GIbulbs:xx.intensityscale=0:Next
  878. Table1.ColorGradeImage = "ColorGrade_1"
  879. Playsound "fx_relay_off"
  880. Else
  881. for each xx in GI:xx.State=1:Next
  882. for each xx in GIbulbs:xx.intensityscale=1:Next
  883. Table1.ColorGradeImage = "ColorGrade_8"
  884. Playsound "fx_relay_on"
  885. End If
  886. End Sub
  887.  
  888. Sub TiltRelay(enabled)
  889. If Enabled Then
  890. for each xx in GI:xx.State=0:Next
  891. for each xx in GIbulbs:xx.intensityscale=0:Next
  892. Table1.ColorGradeImage = "ColorGrade_1"
  893. Playsound "fx_relay_off"
  894. Else
  895. for each xx in GI:xx.State=1:Next
  896. for each xx in GIbulbs:xx.intensityscale=1:Next
  897. Table1.ColorGradeImage = "ColorGrade_8"
  898. Playsound "fx_relay_on"
  899. End If
  900. End Sub
  901.  
  902. '******************************************************
  903. ' Supporting Ball & Sound Functions
  904. '******************************************************
  905.  
  906. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  907. Vol = Csng(BallVel(ball) ^2 / 2000)
  908. End Function
  909.  
  910. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  911. Dim tmp
  912. tmp = ball.x * 2 / table1.width-1
  913. If tmp > 0 Then
  914. Pan = Csng(tmp ^10)
  915. Else
  916. Pan = Csng(-((- tmp) ^10) )
  917. End If
  918. End Function
  919.  
  920. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  921. Pitch = BallVel(ball) * 20
  922. End Function
  923.  
  924. Function BallVel(ball) 'Calculates the ball speed
  925. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  926. End Function
  927.  
  928. '******************************************************
  929. ' JP's VP10 Rolling Sounds
  930. '******************************************************
  931.  
  932. Const tnob = 3 ' total number of balls
  933. ReDim rolling(tnob)
  934. InitRolling
  935.  
  936. Sub InitRolling
  937. Dim i
  938. For i = 0 to tnob
  939. rolling(i) = False
  940. Next
  941. End Sub
  942.  
  943. Sub RollingSoundUpdate()
  944. Dim BOT, b
  945. BOT = GetBalls
  946.  
  947. ' stop the sound of deleted balls
  948. For b = UBound(BOT) + 1 to tnob
  949. rolling(b) = False
  950. StopSound("fx_ballrolling" & b)
  951. Next
  952.  
  953. ' exit the sub if no balls on the table
  954. If UBound(BOT) = -1 Then Exit Sub
  955.  
  956. ' play the rolling sound for each ball
  957. For b = 0 to UBound(BOT)
  958. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  959. rolling(b) = True
  960. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  961. Else
  962. If rolling(b) = True Then
  963. StopSound("fx_ballrolling" & b)
  964. rolling(b) = False
  965. End If
  966. End If
  967. Next
  968. End Sub
  969.  
  970. '*****************************************
  971. ' Ball Shadow
  972. '*****************************************
  973.  
  974. Dim BallShadow
  975. BallShadow = Array (BallShadow1, BallShadow2, BallShadow3)
  976.  
  977. Sub BallShadowUpdate()
  978. Dim BOT, b, shadowZ
  979. BOT = GetBalls
  980.  
  981. ' render the shadow for each ball
  982. For b = 0 to UBound(BOT)
  983. If BOT(b).X < Table1.Width/2 Then
  984. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 10
  985. Else
  986. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 10
  987. End If
  988.  
  989. If BOT(b).Z < 10 and BOT(b).Z>90 then BallShadow(b).Z = 1 else BallShadow(b).Z=BOT(b).z-20
  990.  
  991. BallShadow(b).Y = BOT(b).Y + 40
  992. If BOT(b).Z > 20 Then
  993. BallShadow(b).visible = 1
  994. Else
  995. BallShadow(b).visible = 0
  996. End If
  997. Next
  998. End Sub
  999.  
  1000. '******************************************************
  1001. ' JP's VP10 Ball Collision Sound
  1002. '******************************************************
  1003.  
  1004. Sub OnBallBallCollision(ball1, ball2, velocity)
  1005. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  1006. End Sub
  1007.  
  1008. '******************************************************
  1009. ' JF's Sound Routines
  1010. '******************************************************
  1011.  
  1012. Sub Pins_Hit (idx)
  1013. PlaySound "pinhit_low", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  1014. End Sub
  1015.  
  1016. Sub Targets_Hit (idx)
  1017. PlaySound SoundFX("target",DOFTargets)
  1018. End Sub
  1019.  
  1020. Sub Rubbers_Hit(idx)
  1021. dim finalspeed
  1022. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1023. If finalspeed > 20 then
  1024. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1025. End if
  1026. If finalspeed >= 6 AND finalspeed <= 20 then
  1027. RandomSoundRubber()
  1028. End If
  1029. End Sub
  1030.  
  1031. Sub Posts_Hit(idx)
  1032. dim finalspeed
  1033. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1034. If finalspeed > 16 then
  1035. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1036. End if
  1037. If finalspeed >= 6 AND finalspeed <= 16 then
  1038. RandomSoundRubber()
  1039. End If
  1040. End Sub
  1041.  
  1042. Sub RandomSoundRubber()
  1043. Select Case Int(Rnd*3)+1
  1044. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1045. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1046. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1047. End Select
  1048. End Sub
  1049.  
  1050. Sub LeftFlipper_Collide(parm)
  1051. RandomSoundFlipper()
  1052. End Sub
  1053.  
  1054. Sub RightFlipper_Collide(parm)
  1055. RandomSoundFlipper()
  1056. End Sub
  1057.  
  1058. Sub Flipper1_Collide(parm)
  1059. RandomSoundFlipper()
  1060. End Sub
  1061.  
  1062. Sub RandomSoundFlipper()
  1063. Select Case Int(Rnd*3)+1
  1064. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1065. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1066. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1067. End Select
  1068. End Sub
  1069.  
  1070. '******************************************************
  1071. ' Balldrop & Ramp Sound
  1072. '******************************************************
  1073.  
  1074. Sub BallHitSound(dummy):PlaySound "fx_ball_bounce":End Sub
  1075. Sub LRampEnter_Hit():Playsound "ramp_enter":End Sub
  1076. Sub RRampEnter_Hit():Playsound "ramp_enter":End Sub
  1077. Sub RRampEnter1_Hit():Playsound "ramp_enter":End Sub
  1078.  
  1079. Sub LMRampRolling_Hit():Playsound "WireRamp":End Sub
  1080. Sub RRampRolling_Hit():Playsound "ramp_rolling":End Sub
  1081.  
  1082. Sub CenterDrop_Hit():If activeball.z > 60 Then vpmTimer.AddTimer 200, "BallHitSound":End If:End Sub
  1083. Sub LMRamp_Hit():StopSound "WireRamp":vpmTimer.AddTimer 150, "BallHitSound":End Sub
  1084. Sub RRamp_Hit():StopSound "ramp_rolling":vpmTimer.AddTimer 150, "BallHitSound":End Sub
Advertisement
Add Comment
Please, Sign In to add comment