Arngrim

Untitled

Mar 6th, 2020
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.62 KB | None | 0 0
  1. ' Bram Stoker's Dracula / IPD No. 3072 / April, 1993 / 4 Players
  2. ' VP91x 1.03 by JPSalas 2011
  3. ' Magnet script by Dorsolas/Lander's script, with just a small modification
  4.  
  5. '
  6. '01010111 01101001 01101110 01101110 01100101 01110010 01110011 00100000
  7. '01100100 01101111 01101110 00100111 01110100 00100000 01110011 01100101
  8. '01101100 01101100 00100000 01010110 01010000 01011000 00100000 01110100
  9. '01100001 01100010 01101100 0110F0101 01110011 00101110
  10. '
  11.  
  12. ' Thalamus 2018-07-19
  13. ' Added/Updated "Positional Sound Playback Functions" and "Supporting Ball & Sound Functions"
  14. ' Changed UseSolenoids=1 to 2
  15. ' Thalamus 2018-08-10 : Improved directional sounds
  16. ' Missing outlane sound in table
  17. ' !! NOTE : Table not verified yet !!
  18.  
  19. Option Explicit
  20. Randomize
  21.  
  22. On Error Resume Next
  23. ExecuteGlobal GetTextFile("Controller.vbs")
  24. If Err Then MsgBox "Unable to open Controller.vbs. Ensure that it is in the Scripts folder of Visual Pinball."
  25. On Error Goto 0
  26.  
  27. ' Thalamus 2018-11-01 : Improved directional sounds
  28. ' !! NOTE : Table not verified yet !!
  29.  
  30. ' Options
  31. ' Volume devided by - lower gets higher sound
  32.  
  33. Const VolDiv = 8000 ' Lower number, louder ballrolling/collition sound
  34. Const VolCol = 40 ' Ball collition divider ( voldiv/volcol )
  35.  
  36. ' The rest of the values are multipliers
  37. '
  38. ' .5 = lower volume
  39. ' 1.5 = higher volume
  40.  
  41. Const VolBump = 1 ' Bumpers volume.
  42. Const VolRol = 1 ' Rollovers volume.
  43. Const VolGates = 1 ' Gates volume.
  44. Const VolMetal = 3 ' Metals volume.
  45. Const VolRB = 1 ' Rubber bands volume.
  46. Const VolRH = 2 ' Rubber hits volume.
  47. Const VolPo = 1 ' Rubber posts volume.
  48. Const VolPi = 1 ' Rubber pins volume.
  49. Const VolPlast = 1 ' Plastics volume.
  50. Const VolTarg = 1 ' Targets volume.
  51. Const VolWood = 1 ' Woods volume.
  52. Const VolKick = 1 ' Kicker volume.
  53. Const VolSpin = 1.5 ' Spinners volume.
  54. Const VolFlip = 1 ' Flipper volume.
  55.  
  56.  
  57. Dim dtxx
  58. Dim DesktopMode:DesktopMode = Table1.ShowDT
  59.  
  60. If DesktopMode = True Then
  61. Ramp15.visible = 1
  62. Ramp16.visible = 1
  63. SideWood.visible = 1
  64. For each dtxx in Dflasher:dtxx.Visible = 1:next
  65. l58.Intensity = 0
  66. l58a.Intensity = 0
  67. l21.Intensity = 0
  68. l22.Intensity = 0
  69. else
  70. For each dtxx in Dflasher:dtxx.Visible = 0:next
  71. l58.Intensity = 50
  72. l58a.Intensity = 25
  73. l21.Intensity = 20
  74. l22.Intensity = 20
  75. Ramp15.visible = 0
  76. Ramp16.visible = 0
  77. SideWood.visible = 0
  78. End If
  79.  
  80. Dim VarHidden, UseVPMDMD
  81. Const UseVPMModSol = 1
  82. If Table1.ShowDT = true then
  83. UseVPMDMD = true
  84. VarHidden = 1
  85. else
  86. UseVPMDMD = False
  87. VarHidden = 0
  88. end if
  89.  
  90. LoadVPM "01560000", "WPC.VBS", 3.26
  91.  
  92. ' Thalamus - for Fast Flip v2
  93. 'NoUpperRightFlipper
  94. 'NoUpperLeftFlipper1
  95.  
  96. '********************
  97. 'Standard definitions
  98. '********************
  99.  
  100. Const UseSolenoids = 2
  101. Const UseLamps = 1
  102. Const UseSync = 0
  103. Const HandleMech = 0
  104.  
  105. ' Standard Sounds
  106. Const SSolenoidOn = "Solenoid"
  107. Const SSolenoidOff = ""
  108. Const SFlipperOn = "FlipperUp"
  109. Const SFlipperOff = "FlipperDown"
  110. Const SCoin = "Coin"
  111.  
  112. Set GiCallback2 = GetRef("UpdateGI2")
  113.  
  114. Dim bsTrough, bsCryptPopper, bsBLPopper, bsCastlePopper, bsCoffinPopper
  115. Dim mMagnet, dtLDrop, bsCastleLock, x, bumper1, bumper2, bumper3, plungerIM
  116.  
  117.  
  118. On Error Resume Next
  119. Dim i
  120. For i=0 To 127
  121. Execute "Set Lights(" & i & ") = L" & i
  122. Next
  123.  
  124. Lights(58)=Array(L58,L58A)
  125.  
  126. '************
  127. ' Table init.
  128. '************
  129.  
  130. Const cGameName = "drac_l1"
  131.  
  132. Sub Table1_Init
  133. vpmInit Me
  134. With Controller
  135. .GameName = cGameName
  136. If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
  137. .SplashInfoLine = "Bram Stoker's Dracula, Williams, 1993" & vbNewLine & "VP91x table by JPSalas v1.03"
  138. .Games(cGameName).Settings.Value("rol") = 0 'rotated left
  139. .HandleKeyboard = 0
  140. .ShowTitle = 0
  141. .ShowDMDOnly = 1
  142. .ShowFrame = 0
  143. .HandleMechanics = 0
  144. .Hidden = Desktopmode
  145. On Error Resume Next
  146. .Run GetPlayerHWnd
  147. If Err Then MsgBox Err.Description
  148. On Error Goto 0
  149. .Switch(22) = 1 'close coin door
  150. .Switch(24) = 1 'and keep it close
  151. End With
  152.  
  153. ' Nudging
  154. vpmNudge.TiltSwitch = 14
  155. vpmNudge.Sensitivity = 1
  156. vpmNudge.TiltObj = Array(bumper1, bumper2, bumper3, LeftSlingshot, RightSlingshot)
  157.  
  158. ' Trough
  159. Set bsTrough = New cvpmBallStack
  160. With bsTrough
  161. .InitSw 48, 41, 42, 43, 44, 0, 0, 0
  162. .InitKick BallRelease, 90, 4
  163. .InitEntrySnd "Solenoid", "Solenoid"
  164. .InitExitSnd SoundFX("ballrel",DOFContactors), SoundFX("Solenoid",DOFContactors)
  165. .Balls = 4
  166. End With
  167.  
  168. ' Crypt Popper
  169. set bsCryptPopper = new cvpmBallStack
  170. With bsCryptPopper
  171. .InitSw 0, 56, 0, 0, 0, 0, 0, 0
  172. .InitKick sw56, 78, 10
  173. .KickForceVar = 2
  174. .KickAngleVar = 5
  175. .KickBalls = 2
  176. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  177. .Balls = 0
  178. End With
  179.  
  180. ' Wire Ramp Popper
  181. set bsBLPopper = new cvpmBallStack
  182. With bsBLPopper
  183. .InitSw 0, 55, 0, 0, 0, 0, 0, 0
  184. .InitKick sw55, 180, 1
  185. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  186. .Balls = 0
  187. End With
  188.  
  189. ' Castle Popper
  190. set bsCastlePopper = new cvpmBallStack
  191. With bsCastlePopper
  192. .InitSw 0, 71, 0, 0, 0, 0, 0, 0
  193. .InitKick sw71, 210, 10
  194. .KickForceVar = 1
  195. .KickAngleVar = 5
  196. .KickBalls = 2
  197. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  198. End With
  199.  
  200. ' Coffin Popper
  201. set bsCoffinPopper = new cvpmBallStack
  202. With bsCoffinPopper
  203. .InitSw 0, 72, 0, 0, 0, 0, 0, 0
  204. .InitKick sw72, 180, 1
  205. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  206. End With
  207.  
  208. ' Mist Magnet
  209. Set mMagnet = New cMagnet
  210. ' mMagnet.InitMagnet Magnet, 5
  211. mMagnet.InitMagnet Magnet, 3.7 ' Thalamus
  212. mMagnet.Size = 60
  213. ' mMagnet.Size = 50
  214. MagnetPos = 0:SetMagnetPosition
  215.  
  216. ' Drop target
  217. Set dtLDrop = New cvpmDropTarget
  218. With dtLDrop
  219. .InitDrop sw15, 15
  220. .InitSnd SoundFX("droptarget_l",DOFDropTargets), SoundFX("Solenoid",DOFDropTargets)
  221. .CreateEvents "dtLDrop"
  222. End With
  223.  
  224. ' Castle Lock
  225. Set bsCastleLock = new cvpmBallStack
  226. With bsCastleLock
  227. .initsw 0, 53, 54, 57, 0, 0, 0, 0
  228. .InitKick CastleLock, 135, 1
  229. End With
  230.  
  231.  
  232. ' Main Timer init
  233. PinMAMETimer.Interval = PinMAMEInterval
  234. PinMAMETimer.Enabled = 1
  235.  
  236. Plunger.Pullback
  237. Wdivert.Isdropped = 1
  238.  
  239. End Sub
  240.  
  241. Sub table1_Paused:Controller.Pause = 1:End Sub
  242. Sub table1_unPaused:Controller.Pause = 0:End Sub
  243.  
  244. '**********
  245. ' Keys
  246. '**********
  247.  
  248. Sub table1_KeyDown(ByVal Keycode)
  249.  
  250. If keycode = LeftFlipperKey Then LFPress = 1
  251. If keycode = RightFlipperKey Then rfpress = 1
  252.  
  253. 'If keycode = 3 Then SetFlash 131,1
  254. If keycode = PlungerKey Then Controller.Switch(34) = 1
  255.  
  256. If keycode = LeftTiltKey Then
  257. Nudge 90, 2
  258. End If
  259. If keycode = RightTiltKey Then
  260. Nudge 270, 2
  261. End If
  262. If keycode = CenterTiltKey Then
  263. Nudge 0, 2
  264. End If
  265.  
  266. If vpmKeyDown(keycode) Then Exit Sub
  267. End Sub
  268.  
  269. Sub table1_KeyUp(ByVal Keycode)
  270.  
  271. If keycode = LeftFlipperKey Then
  272. lfpress = 0
  273. leftflipper.eostorqueangle = EOSA
  274. leftflipper.eostorque = EOST
  275. End If
  276. If keycode = RightFlipperKey Then
  277. rfpress = 0
  278. rightflipper.eostorqueangle = EOSA
  279. rightflipper.eostorque = EOST
  280. End If
  281.  
  282. 'If keycode = 3 Then SetFlash 131,0
  283. If keycode = PlungerKey Then Controller.Switch(34) = 0
  284. If vpmKeyUp(keycode) Then Exit Sub
  285. End Sub
  286.  
  287.  
  288. '*********
  289. ' Switches
  290. '*********
  291.  
  292. ' Slings & div switches
  293. Dim LStep, RStep
  294.  
  295. Sub LeftSlingShot_Slingshot
  296. PlaySound SoundFX("slingshot",DOFContactors), 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(sling2)
  297. vpmTimer.PulseSw 64
  298. LSling.Visible = 0
  299. LSling1.Visible = 1
  300. sling2.TransZ = -20
  301. LStep = 0
  302. LeftSlingShot.TimerEnabled = 1
  303. LeftSlingShot.TimerInterval = 10
  304. End Sub
  305.  
  306. Sub LeftSlingShot_Timer
  307. Select Case LStep
  308. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  309. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0
  310. End Select
  311. LStep = LStep + 1
  312. End Sub
  313.  
  314. Sub RightSlingShot_Slingshot
  315. PlaySound SoundFX("slingshot",DOFContactors), 0, 0.3, 0.1, 0.25, 0, 1, AudioFade(sling1)
  316. vpmTimer.PulseSw 65
  317. RSling.Visible = 0
  318. RSling1.Visible = 1
  319. sling1.TransZ = -20
  320. RStep = 0
  321. RightSlingShot.TimerEnabled = 1
  322. RightSlingShot.TimerInterval = 10
  323. End Sub
  324.  
  325. Sub RightSlingShot_Timer
  326. Select Case RStep
  327. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  328. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0
  329. End Select
  330. RStep = RStep + 1
  331. End Sub
  332.  
  333.  
  334. ' Bumpers
  335. Sub Bumper1_Hit:vpmTimer.PulseSw 61:PlaySoundAtVol SoundFX("bumper",DOFContactors), ActiveBall, VolBump:End Sub
  336. ' Sub Bumper1_Hit:vpmTimer.PulseSw 61:PlaySound "bumper", 0, 0.1, 0, 0.25, 0, 1, AudioFade(ActiveBall):End Sub
  337. Sub Bumper1_Timer()
  338. Select Case bump1
  339. Case 1:Ring1a.IsDropped = 0:bump1 = 2
  340. Case 2:Ring1b.IsDropped = 0:Ring1a.IsDropped = 1:bump1 = 3
  341. Case 3:Ring1c.IsDropped = 0:Ring1b.IsDropped = 1:bump1 = 4
  342. Case 4:Ring1c.IsDropped = 1:Me.TimerEnabled = 0
  343. End Select
  344. End Sub
  345.  
  346. Sub Bumper2_Hit:vpmTimer.PulseSw 62:PlaySoundAtVol SoundFX("bumper",DOFContactors), ActiveBall, VolBump:End Sub
  347. ' Sub Bumper2_Hit:vpmTimer.PulseSw 62:PlaySound "bumper", 0, 0.1, -0.1, 0.25, 0, 1, AudioFade(ActiveBall):End Sub
  348. Sub Bumper2_Timer()
  349. Select Case bump2
  350. Case 1:Ring2a.IsDropped = 0:bump2 = 2
  351. Case 2:Ring2b.IsDropped = 0:Ring2a.IsDropped = 1:bump2 = 3
  352. Case 3:Ring2c.IsDropped = 0:Ring2b.IsDropped = 1:bump2 = 4
  353. Case 4:Ring2c.IsDropped = 1:Me.TimerEnabled = 0
  354. End Select
  355. End Sub
  356.  
  357. Sub Bumper3_Hit:vpmTimer.PulseSw 63:PlaySoundAtVol SoundFX("bumper",DOFContactors), ActiveBall, VolBump:End Sub
  358. ' Sub Bumper3_Hit:vpmTimer.PulseSw 63:PlaySound "bumper", 0, 0.1, 0.1, 0.25, 0, 1, AudioFade(ActiveBall):End Sub
  359. Sub Bumper3_Timer()
  360. Select Case bump3
  361. Case 1:Ring3a.IsDropped = 0:bump3 = 2
  362. Case 2:Ring3b.IsDropped = 0:Ring3a.IsDropped = 1:bump3 = 3
  363. Case 3:Ring3c.IsDropped = 0:Ring3b.IsDropped = 1:bump3 = 4
  364. Case 4:Ring3c.IsDropped = 1:Me.TimerEnabled = 0
  365. End Select
  366. End Sub
  367.  
  368. ' Drain holes, vuks & saucers
  369. Sub Drain_Hit:PlaysoundAt "drain",Drain:bsTrough.AddBall Me:End Sub
  370. Sub Drain1_Hit:PlaysoundAt "drain",Drain1:ClearBallID:bsTrough.AddBall Me:End Sub
  371. Sub Drain2_Hit:PlaysoundAt "drain",Drain2:ClearBallID:bsTrough.AddBall Me:End Sub
  372. Sub Drain3_Hit:PlaysoundAt "drain",Drain3:ClearBallID:bsTrough.AddBall Me:End Sub
  373. Sub Drain4_Hit:PlaysoundAt "drain",Drain4:ClearBallID:bsTrough.AddBall Me:End Sub
  374.  
  375. 'Sub sw72a_Hit:PlaySoundAt "fx_Hole2", sw72a:bsCoffinPopper.addball Me:End Sub
  376.  
  377. Dim rball
  378.  
  379. Sub sw72a_Hit:PlaySoundAtVol "fx_Hole2", sw72a, 1:me.destroyball:set rball = me.createball:drop.enabled = 1:End Sub
  380.  
  381. Sub drop_timer()
  382. If rball.Z <= -50 Then
  383. me.enabled = 0
  384. drop2.enabled = 1
  385. End If
  386. rball.Z = rball.Z - 1
  387. End Sub
  388.  
  389. Sub drop2_timer()
  390. sw72a.destroyball
  391. bsCoffinPopper.addball rball
  392. me.enabled = 0
  393. End Sub
  394.  
  395. Sub sw71_Hit
  396. PlaySound "hole_enter", 0, 0.3, 0.1, 0.25, 0, 1, AudioFade(sw71)
  397. 'ClearBallID
  398. vpmTimer.PulseSwitch 71, 0, 0
  399. mMagnet.RemoveBall ActiveBall
  400. Me.destroyball
  401. bsCastlePopper.AddBall Me
  402. End Sub
  403.  
  404. Sub sw58_Hit
  405. PlaySound "hole_enter", 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(sw58)
  406. 'ClearBallID
  407. Me.DestroyBall
  408. PlaySoundAt "subway2", sw58
  409. vpmTimer.PulseSwitch 58, 1250, "bsBLPopper.AddBall 0 '"
  410. End Sub
  411.  
  412. Sub sw56_Hit
  413. PlaySound "hole_enter", 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(sw56)
  414. 'ClearBallID
  415. vpmTimer.PulseSwitch 56, 100, 0
  416. mMagnet.RemoveBall ActiveBall
  417. bsCryptPopper.AddBall Me
  418. End Sub
  419.  
  420. Sub sw56a_Hit
  421. PlaySound "hole_enter", 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(sw56a)
  422. 'ClearBallID
  423. mMagnet.RemoveBall ActiveBall
  424. bsCryptPopper.AddBall Me
  425. End Sub
  426.  
  427. Sub CastleLock_Hit()
  428. PlaysoundAt "metalhit2", CastleLock
  429. 'ClearBallID
  430. bsCastleLock.AddBall Me
  431. End Sub
  432.  
  433. ' Rollovers & Ramp Switches
  434. Sub sw35_Hit:Controller.Switch(35) = 1:PlaySoundAt "sensor",sw35:End Sub
  435. Sub sw35_UnHit:Controller.Switch(35) = 0:PlaySoundAt "outlane",sw35:End Sub
  436.  
  437. Sub sw36_Hit:Controller.Switch(36) = 1:PlaySoundAt "sensor",sw36:End Sub
  438. Sub sw36_UnHit:Controller.Switch(36) = 0:End Sub
  439.  
  440. Sub sw37_Hit:Controller.Switch(37) = 1:PlaySoundAt "sensor",sw37:End Sub
  441. Sub sw37_UnHit:Controller.Switch(37) = 0:End Sub
  442.  
  443. Sub sw38_Hit:Controller.Switch(38) = 1:PlaySoundAt "sensor",sw38:End Sub
  444. Sub sw38_UnHit:Controller.Switch(38) = 0:PlaySoundAt "outlane",sw38:End Sub
  445.  
  446. Sub sw25_Hit:Controller.Switch(25) = 1:PlaySoundAt "sensor",sw25:End Sub
  447. Sub sw25_UnHit:Controller.Switch(25) = 0:End Sub
  448.  
  449. Sub sw26_Hit:Controller.Switch(26) = 1:PlaySoundAt "sensor",sw26:End Sub
  450. Sub sw26_Unhit:Controller.Switch(26) = 0:End Sub
  451.  
  452. Sub sw27_Hit:Controller.Switch(27) = 1:PlaySoundAt "sensor",sw27:End Sub
  453. Sub sw27_Unhit:Controller.Switch(27) = 0:End Sub
  454.  
  455. Sub sw16_Hit:Controller.Switch(16) = 1:PlaySoundAt "sensor",sw16:End Sub
  456. Sub sw16_Unhit:Controller.Switch(16) = 0:End Sub
  457.  
  458. Sub sw28_Hit:Controller.Switch(28) = 1:PlaySoundAt "gate",sw28:End Sub
  459. Sub sw28_Unhit:Controller.Switch(28) = 0:PlaySound "metalrolling", 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(sw28):End Sub
  460.  
  461. Sub sw84_Hit:Controller.Switch(84) = 1:PlaySoundAt "gate",sw84:End Sub
  462. Sub sw84_Unhit:Controller.Switch(84) = 0:PlaySoundAt "metalrolling",sw84:End Sub
  463.  
  464. Sub sw85_Hit:Controller.Switch(85) = 1:PlaySoundAt "gate",sw85:End Sub
  465. Sub sw85_Unhit:Controller.Switch(85) = 0:PlaySoundAt "metalrolling",sw85:End Sub
  466.  
  467. Sub sw31_Hit:Controller.Switch(31) = 1:PlaySoundAt "sensor",sw31:End Sub
  468. Sub sw31_Unhit:Controller.Switch(31) = 0:End Sub
  469.  
  470. Sub sw51_Hit:Controller.Switch(51) = 1:PlaySoundAt "sensor",sw51:End Sub
  471. Sub sw51_Unhit:Controller.Switch(51) = 0:End Sub
  472.  
  473. Sub sw52_Hit:Controller.Switch(52) = 1:PlaySoundAt "sensor",sw52:End Sub
  474. Sub sw52_Unhit:Controller.Switch(52) = 0:End Sub
  475.  
  476. Sub sw73_Hit
  477. Controller.Switch(73) = 1
  478. If ActiveBall.VelY < -25 Then
  479. PlaySoundAt "Subway2",sw73
  480. End If
  481. End Sub
  482.  
  483. Sub sw73_Unhit:Controller.Switch(73) = 0:End Sub
  484.  
  485. Sub sw17_Hit:Controller.Switch(17) = 1:End Sub
  486. Sub sw17_Unhit:Controller.Switch(17) = 0:End Sub
  487.  
  488. ' Targets
  489. Sub sw66_Hit:vpmTimer.PulseSw 66:PlaySoundAt SoundFX("target",DOFTargets),sw66:End Sub
  490. Sub sw66_Timer:sw66.IsDropped = 0:End Sub
  491.  
  492. Sub sw67_Hit:vpmTimer.PulseSw 67:PlaySoundAt SoundFX("target",DOFTargets),sw67:End Sub
  493. Sub sw67_Timer:sw67.IsDropped = 0:End Sub
  494.  
  495. Sub sw68_Hit:vpmTimer.PulseSw 68:PlaySoundAt SoundFX("target",DOFTargets),sw68:End Sub
  496. Sub sw68_Timer:sw68.IsDropped = 0:End Sub
  497.  
  498. Sub sw86_Hit:vpmTimer.PulseSw 86:PlaySoundAt SoundFX("target",DOFTargets),sw86:End Sub
  499. Sub sw86_Timer:sw86.IsDropped = 0:End Sub
  500.  
  501. Sub sw87_Hit:vpmTimer.PulseSw 87:PlaySoundAt SoundFX("target",DOFTargets),sw87:End Sub
  502. Sub sw87_Timer:sw87.IsDropped = 0:End Sub
  503.  
  504. Sub sw88_Hit:vpmTimer.PulseSw 88:PlaySoundAt SoundFX("target",DOFTargets),sw88:End Sub
  505. Sub sw88_Timer:sw88.IsDropped = 0:Me.TimerEnabled = 0:End Sub
  506.  
  507. ' Gates
  508. Sub Gate2_Hit():PlaySoundAtVol "gate",Gate2, VolGates:End Sub
  509. Sub Gate4_Hit():PlaySoundAtVol "gate",Gate4, VolGates:End Sub
  510. Sub Gate6_Hit():PlaySoundAtVol "gate",Gate6, VolGates:End Sub
  511.  
  512. ' Ramps helpers
  513. Sub RHelp1_Hit()
  514. StopSound "metalrolling"
  515. PlaySoundAtVol "ballhit", ActiveBall, 1
  516. End Sub
  517.  
  518. Sub RHelp2_Hit()
  519. StopSound "metalrolling"
  520. PlaySoundAtVol "ballhit", ActiveBall, 1
  521. End Sub
  522.  
  523. Sub RHelp3_Hit()
  524. StopSound "metalrolling"
  525. PlaySoundAtVol "ballhit", ActiveBall, 1
  526. End Sub
  527.  
  528. '*********
  529. 'Solenoids
  530. '*********
  531.  
  532. SolCallback(1) = "Auto_Plunger"
  533. SolCallback(2) = "bsCoffinPopper.SolOut"
  534. SolCallback(3) = "bsCastlePopper.SolOut"
  535. SolCallback(4) = "SolRRampDown"
  536. SolCallback(5) = "bsCryptPopper.SolOut"
  537. SolCallback(6) = "bsBLPopper.SolOut"
  538. SolCallback(7) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  539. SolCallback(8) = "SolShooterRamp"
  540. SolCallback(14) = "SolRRampUp"
  541. SolCallback(15) = "bsTrough.SolIn"
  542. SolCallback(16) = "bsTrough.SolOut"
  543.  
  544. SolModCallback(17) = "Sol117"
  545. SolModCallback(18) = "Sol118"
  546. SolModCallback(19) = "Sol119"
  547. SolModCallback(20) = "Sol120"
  548. SolModCallback(21) = "Sol121"
  549. SolModCallback(22) = "Sol122"
  550. SolModCallback(23) = "Sol123"
  551. SolModCallback(24) = "Sol124"
  552. SolCallback(25) = "dtLDrop.SolDropUp"
  553. SolCallback(27) = "SolMistMagnet"
  554. SolCallback(33) = "solTopDiverter"
  555. SolCallback(34) = "SolRGate"
  556. SolCallback(35) = "bsCastleLock.SolOut"
  557. SolCallback(36) = "SolLGate"
  558.  
  559. Sub Auto_Plunger(Enabled)
  560. If Enabled Then
  561. Plunger.Fire
  562. ' PlaySound "solenoid", 0, 0.3, 0.1, 0.25
  563. PlaySoundAtVol SoundFX("Autoplunger",DOFContactors), Plunger, 1
  564. Else
  565. Plunger.PullBack
  566. End If
  567. End Sub
  568.  
  569. '*************
  570. ' Moving Ramp
  571. '*************
  572.  
  573. Dim RRampDir, RRAmpCurrPos, RRamp
  574. RRampCurrPos = 0 ' down
  575. RRampDir = 1 '1 is up -1 is down dir
  576. Controller.Switch(77) = False
  577. 'RightRamp.Collidable = True
  578.  
  579. Sub SolRRampUp(Enabled)
  580. If Enabled Then
  581. RRampDir = 1
  582. Controller.Switch(77) = True
  583. RightRamp.Collidable = False
  584. UpdateRamp.Enabled = True
  585. ''SetLamp 116, 1
  586. playsound SoundFX("diverter",DOFContactors), 0, 0.3, 0.1, 0.25
  587. End If
  588. End Sub
  589.  
  590. Sub SolRRampDown(Enabled)
  591. If Enabled Then
  592. RRampDir = -1
  593. Controller.Switch(77) = False
  594. RightRamp.Collidable = True
  595. UpdateRamp.Enabled = True
  596. ''SetLamp 116, 0
  597. playsound SoundFX("diverter",DOFContactors), 0, 0.3, 0.1, 0.25
  598. End If
  599. End sub
  600.  
  601. Sub UpdateRamp_Timer
  602. RRampCurrPos = RRampCurrPos + RRampDir
  603. If RRampCurrPos> 10 Then
  604. RRampCurrPos = 10
  605. UpdateRamp.Enabled = 0
  606. End If
  607. If RRampCurrPos <0 Then
  608. RRampCurrPos = 0
  609. UpdateRamp.Enabled = 0
  610. End If
  611. RightRamp2.HeightBottom = RRampCurrPos *5
  612. CoffinLiftRampOpaque.RotX = RRampCurrPos -11
  613. CoffinLiftRamp.RotX = RRampCurrPos -11
  614. Refresh.State = 1
  615. Refresh.State = 0
  616. End Sub
  617.  
  618. ' Shooter Ramp
  619.  
  620. Sub SolShooterRamp(Enabled)
  621. If Enabled Then
  622. sramp2.Collidable = 0
  623. dirsrt = 1:shootramp.enabled = 1
  624. Playsound SoundFX("solenoid",DOFContactors), 0, 0.3, 0.1, 0.25
  625. Else
  626. sramp2.Collidable = 1
  627. dirsrt = 2:shootramp.enabled = 1
  628. Playsound SoundFX("solenoid",DOFContactors), 0, 0.3, 0.1, 0.25
  629. End If
  630. End Sub
  631.  
  632. ' Top Ramp Diverter
  633.  
  634. Sub SolTopDiverter(Enabled)
  635. Playsound SoundFX("Diverter",DOFContactors)
  636. If Enabled Then
  637. 'diverter1.isdropped = False
  638. 'Controller.Switch(78) = True
  639.  
  640. wDivert.isdropped = 0
  641. ddir = 1:Divert.enabled = 1
  642. Else
  643. 'diverter1.isdropped = True
  644. 'Controller.Switch(78) = False
  645. WDivert.isdropped = 1
  646. ddir = 2:Divert.enabled = 1
  647. End If
  648. End sub
  649.  
  650. Dim FlashState(200), FlashLevel(200)
  651. Dim FlashSpeedUp, FlashSpeedDown
  652. 'Dim x
  653.  
  654. FlashInit()
  655. FlasherTimer.Interval = 10 'flash fading speed
  656. FlasherTimer.Enabled = 1
  657.  
  658. Sub FlashInit
  659. Dim i
  660. For i = 0 to 200
  661. FlashState(i) = 0
  662. FlashLevel(i) = 0
  663. Next
  664.  
  665. FlashSpeedUp = 500 ' fast speed when turning on the flasher
  666. FlashSpeedDown = 100 ' slow speed when turning off the flasher, gives a smooth fading
  667. AllFlashOff()
  668. End Sub
  669.  
  670. Sub AllFlashOff
  671. Dim i
  672. For i = 0 to 200
  673. FlashState(i) = 0
  674. Next
  675. End Sub
  676.  
  677. Sub Flash(nr, object)
  678. Select Case FlashState(nr)
  679. Case 0 'off
  680. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown
  681. If FlashLevel(nr) < 0 Then
  682. FlashLevel(nr) = 0
  683. FlashState(nr) = -1 'completely off
  684. End if
  685. Object.opacity = FlashLevel(nr)
  686. Case 1 ' on
  687. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp
  688. If FlashLevel(nr) > 1000 Then
  689. FlashLevel(nr) = 1000
  690. FlashState(nr) = -2 'completely on
  691. End if
  692. Object.opacity = FlashLevel(nr)
  693. End Select
  694. End Sub
  695.  
  696. Sub Flashm(nr, object) 'multiple flashers, it doesn't change the flashstate
  697. Select Case FlashState(nr)
  698. Case 0 'off
  699. Object.opacity = FlashLevel(nr)
  700. Case 1 ' on
  701. Object.opacity = FlashLevel(nr)
  702. End Select
  703. End Sub
  704.  
  705. Sub SetFlash(nr, stat)
  706. FlashState(nr) = ABS(stat)
  707. End Sub
  708.  
  709. Sub FlasherTimer_Timer()
  710. Flash 161, f61
  711. Flash 162, f62
  712. Flash 163, f63
  713. Flashm 158, f58
  714. Flash 158, f58a
  715. Flashm 121, F121
  716. Flash 121, F121a
  717. Flashm 122, F122
  718. Flash 122, F122a
  719. End Sub
  720.  
  721. Dim ddir
  722.  
  723. Sub Divert_Timer()
  724. Select Case ddir
  725. Case 1:
  726. If Diverter.Z = -315 Then
  727. me.enabled = 0
  728. Controller.Switch(78) = True
  729. Diverter.Z = -315
  730. End If
  731. Diverter.Z = Diverter.Z - 1
  732. Case 2:
  733. If Diverter.Z = -280 Then
  734. me.enabled = 0
  735. Controller.Switch(78) = False
  736. Diverter.Z = -280
  737. End If
  738. Diverter.Z = Diverter.Z + 1
  739. End Select
  740. End Sub
  741.  
  742.  
  743. ' Mist Gates
  744.  
  745. Sub SolLGate(Enabled)
  746. If Enabled then
  747. LGate.open = 1
  748. Wall_LO.isdropped = 1
  749. else
  750. LGate.open = 0
  751. Wall_LO.isdropped = 0
  752. End If
  753. End Sub
  754.  
  755. Sub SolRGate(Enabled)
  756. If Enabled then
  757. RGate.open = 1
  758. 'Light51.state = 1
  759. 'RGate.Move 1, 1, 90
  760. RGateWall.IsDropped = True
  761. else
  762. RGate.open = 0
  763. 'Light51.state = 0
  764. 'RGate.Move 0, 1, 0
  765. RGateWall.IsDropped = False
  766. End If
  767. End Sub
  768.  
  769. Sub Sol117(Level)
  770. dim Enabled:Enabled = Level > 0
  771. F17.State=Enabled
  772. F17.Intensity = (Level * 15 / 255)
  773. F17a.State=Enabled
  774. F17a.Intensity = (Level * 15 / 255)
  775. F17b.State=Enabled
  776. F17b.Intensity = (Level * 15 / 255)
  777. End Sub
  778. Sub Sol118(Level)
  779. dim Enabled:Enabled = Level > 0
  780. F18.State=(Enabled)
  781. F18.Intensity = (Level * 15 / 255)
  782. F18a.State=(Enabled)
  783. F18a.Intensity = (Level * 15 / 255)
  784. End Sub
  785.  
  786. Sub Sol119(Level)
  787. dim Enabled:Enabled = Level > 0
  788. F19.State=(Enabled)
  789. F19.Intensity = (Level * 15 / 255)
  790. F19a.State=(Enabled)
  791. F19a.Intensity = (Level * 15 / 255)
  792. End Sub
  793.  
  794. Sub Sol120(Level)
  795. dim Enabled:Enabled = Level > 0
  796. F20.State=(Enabled)
  797. F20.Intensity = (Level * 15 / 255)
  798. F20a.State=(Enabled)
  799. F20a.Intensity = (Level * 15 / 255)
  800. End Sub
  801.  
  802. Sub Sol121(Level)
  803. dim Enabled:Enabled = Level > 0
  804. F21.State=(Enabled)
  805. F21.Intensity = (Level * 15 / 255)
  806. F21a.State=(Enabled)
  807. F21a.Intensity = (Level * 15 / 255)
  808. End Sub
  809.  
  810. Sub Sol122(Level)
  811. dim Enabled:Enabled = Level > 0
  812. F22.State=(Enabled)
  813. F22.Intensity = (Level * 15 / 255)
  814. F22a.State=(Enabled)
  815. F22a.Intensity = (Level * 15 / 255)
  816. End Sub
  817.  
  818. Sub Sol123(Level)
  819. dim Enabled:Enabled = Level > 0
  820. F23.State=(Enabled)
  821. F23.Intensity = (Level * 15 / 255)
  822. F23a.State=(Enabled)
  823. F23a.Intensity = (Level * 15 / 255)
  824. End Sub
  825.  
  826. Sub Sol124(Level)
  827. dim Enabled:Enabled = Level > 0
  828. F24.State=(Enabled)
  829. F24.Intensity = (Level * 15 / 255)
  830. End Sub
  831.  
  832. '**************
  833. ' Flipper Subs
  834. '**************
  835.  
  836. SolCallback(sLRFlipper) = "SolRFlipper"
  837. SolCallback(sLLFlipper) = "SolLFlipper"
  838.  
  839. Sub SolLFlipper(Enabled)
  840. If Enabled Then
  841. PlaySoundAt SoundFX("flipperup",DOFFlippers),LeftFlipper:LF.fire ':LeftFlipper.RotateToEnd
  842. Else
  843. PlaySoundAt SoundFX("flipperdown",DOFFlippers),LeftFlipper:LeftFlipper.RotateToStart
  844. End If
  845. End Sub
  846.  
  847. Sub SolRFlipper(Enabled)
  848. If Enabled Then
  849. PlaySoundAt SoundFX("flipperup",DOFFlippers),RightFlipper:RF.fire' :RightFlipper.RotateToEnd
  850. Else
  851. PlaySoundAt SoundFX("flipperdown",DOFFlippers),RightFlipper:RightFlipper.RotateToStart
  852. End If
  853. End Sub
  854.  
  855. '***********
  856. ' Update GI
  857. '***********
  858.  
  859. Dim gistep, xxx
  860. gistep = 1 / 8
  861.  
  862. Sub UpdateGI2(no, step)
  863.  
  864. Select Case no
  865.  
  866. Case 0
  867.  
  868. For each xxx in GIBOT:xxx.IntensityScale = gistep * step:next
  869.  
  870. Case 1
  871.  
  872. For each xxx in GITOP:xxx.IntensityScale = gistep * step:next
  873.  
  874. Case 2
  875.  
  876. For each xxx in GIMID:xxx.IntensityScale = gistep * step:next
  877.  
  878. Case 4
  879.  
  880. Light80.IntensityScale = gistep * step
  881.  
  882. End Select
  883. End Sub
  884.  
  885. '*******************************
  886. ' Mist Magnet
  887. ' taken from Lander's table
  888. ' with only a small modification
  889. '*******************************
  890.  
  891. '-------------------------------
  892. ' Magnet Simulator Class
  893. ' (07/10/2001 Dorsola)
  894. ' Modified for Dracula (08/16/2001) by Dorsola
  895. '-------------------------------
  896.  
  897. class cMagnet
  898. Private cX, cY, cStrength, cRange
  899. private cBalls, cClaimed
  900. private cTempX, cTempY
  901.  
  902. Private Sub Class_Initialize()
  903. set cBalls = CreateObject("Scripting.Dictionary")
  904. cRange = 1
  905. cStrength = 0
  906. End Sub
  907.  
  908. Public Sub InitMagnet(aTrigger, inStrength)
  909. cX = aTrigger.X
  910. cY = aTrigger.Y
  911. cRange = aTrigger.Radius
  912. cStrength = inStrength
  913. End Sub
  914.  
  915. Public Sub MoveTo(inX, inY)
  916. cX = inX
  917. cY = inY
  918. End Sub
  919.  
  920. Public Property Get X:X = cX:End Property
  921. Public Property Get Y:Y = cY:End Property
  922. Public Property Get Strength:Strength = cStrength:End Property
  923. Public Property Get Size:Size = cRange:End Property
  924. Public Property Get Range:Range = cRange:End Property
  925. Public Property Get Balls:Balls = cBalls.Keys:End Property
  926.  
  927. Public Property Let X(inX):cX = inX:End Property
  928. Public Property Let Y(inY):cY = inY:End Property
  929. Public Property Let Strength(inStrength):cStrength = inStrength:End Property
  930. Public Property Let Size(inSize):cRange = inSize:End Property
  931. Public Property Let Range(inSize):cRange = inSize:End Property
  932.  
  933. Public Sub AddBall(aBall)
  934. cBalls.Item(aBall) = 0
  935. End Sub
  936.  
  937. Public Sub RemoveBall(aBall)
  938. ' This function tags balls for removal, but does not remove them.
  939. ' Another sub will be called to remove tagged objects from the dictionary.
  940. If cBalls.Exists(aBall) then
  941. if cClaimed then
  942. cBalls.Item(aBall) = 1
  943. else
  944. cBalls.Remove(aBall)
  945. end if
  946. end if
  947. End Sub
  948.  
  949. Public Sub Claim():cClaimed = True:End Sub
  950.  
  951. Public Sub Release()
  952. cClaimed = False
  953. Dim tempobj
  954. for each tempobj in cBalls.Keys
  955. if cBalls.Item(tempobj) = 1 then cBalls.Remove(tempobj)
  956. next
  957. End Sub
  958.  
  959. Public Sub ProcessBalls()
  960. Dim tempObj
  961. for each tempObj in cBalls.Keys:AttractBall tempObj:next
  962. End Sub
  963.  
  964. Public Function GetDist(aBall)
  965. on error resume next
  966. if aBall is Nothing then
  967. GetDist = 100000
  968. else
  969. cTempX = aBall.X - cX
  970. cTempY = aBall.Y - cY
  971. GetDist = Sqr(cTempX * cTempX + cTempY * cTempY)
  972. if Err then GetDist = 100000
  973. end if
  974. End Function
  975.  
  976. Public Sub AttractBall(aBall)
  977. if aBall is Nothing then Exit Sub
  978. Dim Dist
  979. Dist = GetDist(aBall)
  980. if Dist> cRange then Exit Sub
  981.  
  982. ' Attract ball toward magnet center (cX,cY).
  983.  
  984. ' Attraction force is determined by distance from center, and strength of magnet.
  985.  
  986. Dim Force, Ratio
  987. Ratio = Dist / (1.5 * cRange)
  988.  
  989. ' TODO: Figure out how to dampen the force when ball is near center and
  990. ' at low velocity, so that balls don't jitter on the magnets.
  991. ' Also shore up instability on moving magnet.
  992.  
  993. Force = cStrength * exp(-0.2 / Ratio) / (Ratio * Ratio * 56)
  994. aBall.VelX = (aBall.VelX - cTempX * Force / Dist) * 0.985
  995. aBall.VelY = (aBall.VelY - cTempY * Force / Dist) * 0.985
  996. End Sub
  997. End Class
  998.  
  999. '-----------------------------------------------
  1000. ' Mist Multiball - courtesy of Dorsola
  1001. '-----------------------------------------------
  1002.  
  1003. ' Method: Since any ball that can block the Mist opto is necessarily in the Mist Magnet's trigger area,
  1004. ' we automatically have access to all balls in this range. We can therefore check each ball's position
  1005. ' against a line equation and see if it happens to be blocking the opto, and set the switch accordingly.
  1006. ' This requires a timer loop.
  1007.  
  1008. Dim MagnetOn
  1009. MagnetOn = false
  1010.  
  1011. Sub MistTimer_Timer()
  1012. ' Endpoints of the line are (108,1247) and (908,895)
  1013. ' Slope: m = (y2-y1)/(x2-x1) = -0.44
  1014. ' Y-intercept: b = y1 - m*x1 = 1294.52
  1015.  
  1016. mMagnet.Claim
  1017.  
  1018. Dim obj, CheckState, x, TargetY
  1019. CheckState = 0
  1020. on error resume next
  1021. for each obj in mMagnet.Balls
  1022. ' y = mx+b (m=slope, b=yint)
  1023. TargetY = (-0.44) * obj.X + 1250.52
  1024. if(obj.Y> TargetY - 25) and(obj.Y <TargetY + 25) then CheckState = 1
  1025. next
  1026. on error goto 0
  1027.  
  1028. Controller.Switch(82) = CheckState
  1029.  
  1030. if MagnetOn then mMagnet.ProcessBalls
  1031.  
  1032. mMagnet.Release
  1033. End Sub
  1034.  
  1035. Sub SolMistMagnet(enabled)
  1036. MagnetOn = enabled
  1037. End Sub
  1038.  
  1039. Sub Magnet_Hit()
  1040. mMagnet.AddBall ActiveBall
  1041. End Sub
  1042.  
  1043. Sub Magnet_UnHit()
  1044. mMagnet.RemoveBall ActiveBall
  1045. End Sub
  1046.  
  1047. '------------------------
  1048. ' Handle the Mist Motor
  1049. '------------------------
  1050. ' Method: Treat motor's position as a number from right to left (0-500)
  1051. ' and compute its position based on the line equation given above.
  1052.  
  1053. const motorx1 = 880
  1054. const motorx2 = 108
  1055. const motorxrange = 800
  1056. const motory1 = 850
  1057. const motory2 = 1200
  1058. const motoryrange = -312
  1059. const motorslope = -0.44
  1060. const motoryint = 1249.52
  1061.  
  1062. ' Endpoints of the line are (108,1247) and (908,895)
  1063. ' Slope: m = (y2-y1)/(x2-x1) = -0.44
  1064. ' Y-intercept: b = y1 - m*x1 = 1294.52
  1065.  
  1066. Dim MagnetPos, MagnetDir
  1067. MagnetPos = 0:MagnetDir = 0
  1068.  
  1069. ' Coding for MagnetDir: 0 = left, 1 = right, toggle at endpoints.
  1070.  
  1071. Sub MotorTimer_Timer()
  1072. if Controller.Solenoid(28) then
  1073. if MagnetDir = 0 then
  1074. 'MagnetPos = MagnetPos + 1
  1075. MagnetPos = MagnetPos + .55 ' Thalamus
  1076. 'mist lights
  1077. Select Case MagnetPos \ 33
  1078. Case 0:ml1.State = 0:ml2.State = 0:ml3.State = 0:ml4.State = 0
  1079. ml5.State = 0:ml6.State = 0:ml7.State = 0:ml8.State = 0
  1080. ml9.State = 0:ml10.State = 0:ml11.State = 0:ml12.State = 0:ml13.State = 0
  1081. Case 1:ml13.State = 1
  1082. Case 2:ml12.State = 1:ml13.State = 0
  1083. Case 3:ml11.State = 1:ml12.State = 0
  1084. Case 4:ml10.State = 1:ml11.State = 0
  1085. Case 5:ml9.State = 1:ml10.State = 0
  1086. Case 6:ml8.State = 1:ml9.State = 0
  1087. Case 7:ml7.State = 1:ml8.State = 0
  1088. Case 8:ml6.State = 1:ml7.State = 0
  1089. Case 9:ml5.State = 1:ml6.State = 0
  1090. Case 10:ml4.State = 1:ml5.State = 0
  1091. Case 11:ml3.State = 1:ml4.State = 0
  1092. Case 12:ml2.State = 1:ml3.State = 0
  1093. Case 13:ml1.State = 1:ml2.State = 0
  1094. Case 14:ml1.State = 0
  1095. End Select
  1096.  
  1097. if MagnetPos >= 500 then
  1098. MagnetPos = 500
  1099. MagnetDir = 1
  1100. end if
  1101. else
  1102. MagnetPos = MagnetPos - 1
  1103. Select Case MagnetPos \ 33
  1104. Case 0:ml1.State = 0:ml2.State = 0:ml3.State = 0:ml4.State = 0
  1105. ml5.State = 0:ml6.State = 0:ml7.State = 0:ml8.State = 0
  1106. ml9.State = 0:ml10.State = 0:ml11.State = 0:ml12.State = 0:ml13.State = 0
  1107. Case 1:ml13.State = 0
  1108. Case 2:ml12.State = 0:ml13.State = 1
  1109. Case 3:ml11.State = 0:ml12.State = 1
  1110. Case 4:ml10.State = 0:ml11.State = 1
  1111. Case 5:ml9.State = 0:ml10.State = 1
  1112. Case 6:ml8.State = 0:ml9.State = 1
  1113. Case 7:ml7.State = 0:ml8.State = 1
  1114. Case 8:ml6.State = 0:ml7.State = 1
  1115. Case 9:ml5.State = 0:ml6.State = 1
  1116. Case 10:ml4.State = 0:ml5.State = 1
  1117. Case 11:ml3.State = 0:ml4.State = 1
  1118. Case 12:ml2.State = 0:ml3.State = 1
  1119. Case 13:ml1.State = 0:ml2.State = 1
  1120. Case 14:ml1.State = 1
  1121. End Select
  1122. if MagnetPos <= 0 then
  1123. MagnetPos = 0
  1124. MagnetDir = 0
  1125. end if
  1126. end if
  1127.  
  1128. SetMagnetPosition
  1129. Controller.Switch(81) = (MagnetPos> 490)
  1130. Controller.Switch(83) = (MagnetPos <10)
  1131. end if
  1132. End Sub
  1133.  
  1134. Sub SetMagnetPosition()
  1135. mMagnet.X = motorx1 -(motorxrange * (MagnetPos / 500) )
  1136. ' mMagnet.X = motorx1 -(motorxrange * (MagnetPos / 600) )
  1137. mMagnet.Y = motorslope * mMagnet.X + motoryint
  1138. If MagnetPos MOD 33 = 0 Then
  1139. MotorTimer.Interval = 80
  1140. Else
  1141. MotorTimer.Interval = 8
  1142. 'MotorTimer.Interval = 10
  1143. End If
  1144. End Sub
  1145.  
  1146.  
  1147. '******************************************
  1148. ' Use the motor callback to call div subs
  1149. '******************************************
  1150.  
  1151. Set MotorCallback = GetRef("RealTimeUpdates")
  1152.  
  1153. Sub RealTimeUpdates()
  1154. LFLogo.RotY = LeftFlipper.CurrentAngle
  1155. RFlogo.RotY = RightFlipper.CurrentAngle
  1156. WireGateLR.RotX=Spinner2.currentangle
  1157. WireGateLR1.RotX=Spinner1.currentangle
  1158. WireGateLR3.RotY=Spinner3.currentangle
  1159.  
  1160. If L61.State = 1 Then
  1161. setflash 161,1
  1162. else
  1163. setflash 161,0
  1164. End If
  1165.  
  1166. If L62.State = 1 Then
  1167. setflash 162,1
  1168. else
  1169. setflash 162,0
  1170. End If
  1171.  
  1172. If L63.State = 1 Then
  1173. setflash 163,1
  1174. else
  1175. setflash 163,0
  1176. End If
  1177.  
  1178. If l58.state = 1 Then
  1179. setflash 158,1
  1180. else
  1181. setflash 158,0
  1182. End If
  1183.  
  1184. If l21.state = 1 Then
  1185. setflash 121,1
  1186. else
  1187. setflash 121,0
  1188. End If
  1189.  
  1190. If l22.state = 1 Then
  1191. setflash 122,1
  1192. else
  1193. setflash 122,0
  1194. End If
  1195.  
  1196. End Sub
  1197.  
  1198. Sub Trigger55off_Hit:sw55.Enabled=0:End Sub
  1199. Sub Trigger55on_Hit:sw55.Enabled=1:End Sub
  1200.  
  1201. Sub LHD_Hit()
  1202. PlaySound "ball_bounce", 0, 0.3, -0.1, 0.25, 0, 1, AudioFade(LHD)
  1203. End Sub
  1204.  
  1205. Sub CHD_Hit()
  1206. PlaySound "ball_bounce", 0, 0.3, 0, 0.25, 0, 1, AudioFade(CHD)
  1207. StopSound "metalrolling"
  1208. End Sub
  1209. Sub CHM_Hit()
  1210. PlaySound "metalrolling", 0, 0.3, 0, 0.25, 0, 1, AudioFade(CHM)
  1211. End Sub
  1212.  
  1213. Sub RHD_Hit()
  1214. StopSound "subway2"
  1215. PlaySound "ball_bounce", 0, 0.3, 0.1, 0.25, 0, 1, AudioFade(RHD)
  1216. End Sub
  1217.  
  1218. Dim dirsrt
  1219.  
  1220. Sub shootramp_Timer()
  1221. Select Case dirsrt
  1222. Case 1:
  1223. If ramp_sl.heightbottom = 60 Then
  1224. me.enabled = 0
  1225. ramp_sl.heightbottom = 60
  1226. End If
  1227. ramp_sl.heightbottom = ramp_sl.heightbottom + 1
  1228. Liftramp.ObjRotx = LiftRamp.ObjRotx + 0.25
  1229. LiftRampRod.Z = LiftRampRod.Z + 0.25
  1230. Primitive108.ObjRotx = Primitive108.ObjRotx + 0.25
  1231. Primitive285.ObjRotx = Primitive285.ObjRotx + 0.25
  1232. Case 2:
  1233. If ramp_sl.heightbottom = 0 Then
  1234. me.enabled = 0
  1235. ramp_sl.heightbottom = 0
  1236. End If
  1237. ramp_sl.heightbottom = ramp_sl.heightbottom - 1
  1238. Liftramp.ObjRotx = LiftRamp.ObjRotx - 0.25
  1239. LiftRampRod.Z = LiftRampRod.Z - 0.25
  1240. Primitive108.ObjRotx = Primitive108.ObjRotx - 0.25
  1241. Primitive285.ObjRotx = Primitive285.ObjRotx - 0.25
  1242. End Select
  1243. End Sub
  1244.  
  1245.  
  1246. Sub sw55_UnHit(): StopSound "subway2" : End Sub
  1247.  
  1248. ' *******************************************************************************************************
  1249. ' Positional Sound Playback Functions by DJRobX and Rothbauerw
  1250. ' PlaySound sound, 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  1251. ' *******************************************************************************************************
  1252.  
  1253. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  1254. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  1255. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  1256.  
  1257. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  1258. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  1259. End Sub
  1260.  
  1261. ' Set position as table object (Use object or light but NOT wall) and Vol to 1
  1262.  
  1263. Sub PlaySoundAt(soundname, tableobj)
  1264. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  1265. End Sub
  1266.  
  1267. 'Set all as per ball position & speed.
  1268.  
  1269. Sub PlaySoundAtBall(soundname)
  1270. PlaySoundAt soundname, ActiveBall
  1271. End Sub
  1272.  
  1273. 'Set position as table object and Vol manually.
  1274.  
  1275. Sub PlaySoundAtVol(sound, tableobj, Volume)
  1276. PlaySound sound, 1, Volume, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  1277. End Sub
  1278.  
  1279. 'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
  1280.  
  1281. Sub PlaySoundAtBallVol(sound, VolMult)
  1282. PlaySound sound, 0, Vol(ActiveBall) * VolMult, AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  1283. End Sub
  1284.  
  1285. 'Set position as bumperX and Vol manually.
  1286.  
  1287. Sub PlaySoundAtBumperVol(sound, tableobj, Vol)
  1288. PlaySound sound, 1, Vol, AudioPan(tableobj), 0,0,1, 1, AudioFade(tableobj)
  1289. End Sub
  1290.  
  1291. Sub PlaySoundAtBOTBallZ(sound, BOT)
  1292. PlaySound sound, 0, ABS(BOT.velz)/17, Pan(BOT), 0, Pitch(BOT), 1, 0, AudioFade(BOT)
  1293. End Sub
  1294.  
  1295. '*********************************************************************
  1296. ' Supporting Ball & Sound Functions
  1297. '*********************************************************************
  1298.  
  1299. Function RndNum(min, max)
  1300. RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
  1301. End Function
  1302.  
  1303. 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
  1304. Dim tmp
  1305. On Error Resume Next
  1306. tmp = tableobj.y * 2 / table1.height-1
  1307. If tmp > 0 Then
  1308. AudioFade = Csng(tmp ^10)
  1309. Else
  1310. AudioFade = Csng(-((- tmp) ^10) )
  1311. End If
  1312. End Function
  1313.  
  1314. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  1315. Dim tmp
  1316. On Error Resume Next
  1317. tmp = tableobj.x * 2 / table1.width-1
  1318. If tmp > 0 Then
  1319. AudioPan = Csng(tmp ^10)
  1320. Else
  1321. AudioPan = Csng(-((- tmp) ^10) )
  1322. End If
  1323. End Function
  1324.  
  1325. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  1326. Dim tmp
  1327. On Error Resume Next
  1328. tmp = ball.x * 2 / table1.width-1
  1329. If tmp > 0 Then
  1330. Pan = Csng(tmp ^10)
  1331. Else
  1332. Pan = Csng(-((- tmp) ^10) )
  1333. End If
  1334. End Function
  1335.  
  1336. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  1337. Vol = Csng(BallVel(ball) ^2 / VolDiv)
  1338. End Function
  1339.  
  1340. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  1341. Pitch = BallVel(ball) * 20
  1342. End Function
  1343.  
  1344. Function BallVel(ball) 'Calculates the ball speed
  1345. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  1346. End Function
  1347.  
  1348. Function BallVelZ(ball) 'Calculates the ball speed in the -Z
  1349. BallVelZ = INT((ball.VelZ) * -1 )
  1350. End Function
  1351.  
  1352. Function VolZ(ball) ' Calculates the Volume of the sound based on the ball speed in the Z
  1353. VolZ = Csng(BallVelZ(ball) ^2 / 200)*1.2
  1354. End Function
  1355.  
  1356. '*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
  1357.  
  1358. Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
  1359. Dim AB, BC, CD, DA
  1360. AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
  1361. BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
  1362. CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
  1363. DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
  1364.  
  1365. If (AB <= 0 AND BC <=0 AND CD <= 0 AND DA <= 0) Or (AB >= 0 AND BC >=0 AND CD >= 0 AND DA >= 0) Then
  1366. InRect = True
  1367. Else
  1368. InRect = False
  1369. End If
  1370. End Function
  1371.  
  1372. '*****************************************
  1373. ' JP's VP10 Rolling Sounds
  1374. '*****************************************
  1375.  
  1376. Const tnob = 5 ' total number of balls
  1377. ReDim rolling(tnob)
  1378. InitRolling
  1379.  
  1380. Sub InitRolling
  1381. Dim i
  1382. For i = 0 to tnob
  1383. rolling(i) = False
  1384. Next
  1385. End Sub
  1386.  
  1387. Sub RollingTimer_Timer()
  1388. Dim BOT, b
  1389. BOT = GetBalls
  1390.  
  1391. ' stop the sound of deleted balls
  1392. For b = UBound(BOT) + 1 to tnob
  1393. rolling(b) = False
  1394. StopSound("fx_ballrolling" & b)
  1395. Next
  1396.  
  1397. ' exit the sub if no balls on the table
  1398. If UBound(BOT) = -1 Then Exit Sub
  1399.  
  1400. ' play the rolling sound for each ball
  1401.  
  1402. For b = 0 to UBound(BOT)
  1403. If BallVel(BOT(b) ) > 1 Then
  1404. rolling(b) = True
  1405. if BOT(b).z < 30 Then ' Ball on playfield
  1406. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), AudioPan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
  1407. Else ' Ball on raised ramp
  1408. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) )*.7, AudioPan(BOT(b) ), 0, Pitch(BOT(b) )+50000, 1, 0, AudioFade(BOT(b) )
  1409. End If
  1410. Else
  1411. If rolling(b) = True Then
  1412. StopSound("fx_ballrolling" & b)
  1413. rolling(b) = False
  1414. End If
  1415. End If
  1416. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  1417. PlaySoundAtBOTBallZ "fx_ball_drop" & b, BOT(b)
  1418. End If
  1419. Next
  1420. End Sub
  1421.  
  1422. '**********************
  1423. ' Ball Collision Sound
  1424. '**********************
  1425.  
  1426. Sub OnBallBallCollision(ball1, ball2, velocity)
  1427. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / (VolDiv/VolCol), AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  1428. End Sub
  1429.  
  1430. Sub Pins_Hit (idx)
  1431. PlaySound "pinhit_low", 0, Vol(ActiveBall)*VolPi, Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  1432. End Sub
  1433.  
  1434. Sub Targets_Hit (idx)
  1435. PlaySound SoundFX("target",DOFTargets), 0, Vol(ActiveBall)*VolTarg, Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  1436. End Sub
  1437.  
  1438. Sub Metals_Thin_Hit (idx)
  1439. PlaySound "metalhit_thin", 0, Vol(ActiveBall)*VolMetal, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1440. End Sub
  1441.  
  1442. Sub Metals_Medium_Hit (idx)
  1443. PlaySound "metalhit_medium", 0, Vol(ActiveBall)*VolMetal, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1444. End Sub
  1445.  
  1446. Sub Metalhit2_Hit (idx)
  1447. PlaySound "metalhit2", 0, Vol(ActiveBall)*VolMetal, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1448. End Sub
  1449.  
  1450. Sub Gates_Hit (idx)
  1451. PlaySound "gate4", 0, Vol(ActiveBall)*VolGates, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1452. End Sub
  1453.  
  1454. Sub Metalhit2_Hit (idx)
  1455. PlaySound "fx_metalhit2", 0, Vol(ActiveBall)*VolMetal, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1456. End Sub
  1457.  
  1458. Sub Spinner_Spin
  1459. PlaySoundAtVol "fx_spinner", Spinner, VolSpin
  1460. End Sub
  1461.  
  1462. 'Sub Rubbers_Hit(idx)
  1463. ' dim finalspeed
  1464. ' finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1465. ' If finalspeed > 20 then
  1466. ' PlaySound "fx_rubber2", 0, Vol(ActiveBall)*VoLRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1467. ' End if
  1468. ' If finalspeed >= 6 AND finalspeed <= 20 then
  1469. ' RandomSoundRubber()
  1470. ' End If
  1471. 'End Sub
  1472.  
  1473. 'Sub Posts_Hit(idx)
  1474. ' dim finalspeed
  1475. ' finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1476. ' If finalspeed > 16 then
  1477. ' PlaySound "fx_rubber2", 0, Vol(ActiveBall)*VolPo, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1478. ' End if
  1479. ' If finalspeed >= 6 AND finalspeed <= 16 then
  1480. ' RandomSoundRubber()
  1481. ' End If
  1482. 'End Sub
  1483.  
  1484. Sub RubberPins_Hit(idx)
  1485. dim finalspeed
  1486. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1487. If finalspeed > 20 then
  1488. PlaySound "rubber_hit_3", 0, Vol(ActiveBall)*VoLRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1489. End if
  1490. If finalspeed >= 6 AND finalspeed <= 20 then
  1491. RandomSoundRubber()
  1492. End If
  1493. End Sub
  1494.  
  1495. Sub RubberBands_Hit(idx)
  1496. RandomSoundRubber
  1497. End Sub
  1498.  
  1499. Sub RandomSoundRubber()
  1500. Select Case Int(Rnd*3)+1
  1501. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1502. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1503. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1504. End Select
  1505. End Sub
  1506.  
  1507. Sub LRubberPins_Hit(idx)
  1508. dim finalspeed
  1509. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1510. If finalspeed > 20 then
  1511. PlaySound "rubber_hit_3", 0, Vol(ActiveBall)*VoLRH, Pan(ActiveBall), 0, Pitch(ActiveBall)-20000, 1, 0, AudioFade(ActiveBall)
  1512. End if
  1513. If finalspeed >= 6 AND finalspeed <= 20 then
  1514. LRandomSoundRubber()
  1515. End If
  1516. End Sub
  1517.  
  1518. Sub LRandomSoundRubber()
  1519. Select Case Int(Rnd*3)+1
  1520. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)-20000, 1, 0, AudioFade(ActiveBall)
  1521. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)-20000, 1, 0, AudioFade(ActiveBall)
  1522. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)-20000, 1, 0, AudioFade(ActiveBall)
  1523. End Select
  1524. End Sub
  1525.  
  1526. ' **** Ramp
  1527.  
  1528. Sub RampTriggers_Hit(idx)
  1529. dim finalspeed
  1530. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1531. debug.print finalspeed
  1532. If finalspeed >= 6 Then
  1533. RandomRampBumps()
  1534. End If
  1535. End Sub
  1536.  
  1537. Sub RandomRampBumps()
  1538. Select Case Int(Rnd*3)+1
  1539. Case 1 : PlaySound "fx_rampbump1", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)+30000, 1, 0, AudioFade(ActiveBall)
  1540. Case 2 : PlaySound "fx_rampbump2", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)+30000, 1, 0, AudioFade(ActiveBall)
  1541. Case 3 : PlaySound "fx_rampbump3", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall)+30000, 1, 0, AudioFade(ActiveBall)
  1542. End Select
  1543. End Sub
  1544.  
  1545. Sub LeftFlipper_Collide(parm)
  1546. RandomSoundFlipper()
  1547. End Sub
  1548.  
  1549. Sub RightFlipper_Collide(parm)
  1550. RandomSoundFlipper()
  1551. End Sub
  1552.  
  1553. Sub Trigger001_Hit
  1554. PlaySound "ramp_hit3", 0, RndNum(50,100)/100 , Pan(ActiveBall), 0, Pitch(ActiveBall)*RndNum(1,8000), AudioFade(Trigger001)
  1555. End Sub
  1556.  
  1557. Sub Trigger002_Hit
  1558. If RightRamp.Collidable = True Then PlaySound "ramp_hit3", 0, RndNum(50,100)/100 , Pan(ActiveBall), 0, Pitch(ActiveBall)*RndNum(1,8000), AudioFade(Trigger002)
  1559. End Sub
  1560.  
  1561.  
  1562. Sub RandomSoundFlipper()
  1563. Select Case Int(Rnd*3)+1
  1564. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1565. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1566. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall)*VolRH, Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1567. End Select
  1568. End Sub
  1569.  
  1570. Sub Table1_Exit
  1571. Controller.Stop
  1572. End Sub
  1573.  
  1574. dim LFPress, RFPress, EOST, EOSA, EOSTnew, EOSAnew
  1575. dim FStrength, Frampup, FElasticity, EOSRampup, SOSRampup
  1576. dim RFEndAngle, LFEndAngle, LFCount, RFCount, LiveCatch
  1577.  
  1578. EOST = leftflipper.eostorque
  1579. EOSA = leftflipper.eostorqueangle
  1580. FStrength = LeftFlipper.strength
  1581. Frampup = LeftFlipper.rampup
  1582. FElasticity = LeftFlipper.elasticity
  1583. EOSTnew = 1.0 'FEOST
  1584. EOSAnew = 0.2
  1585. EOSRampup = 1.5
  1586. SOSRampup = 8.5
  1587. LiveCatch = 12
  1588.  
  1589. LFEndAngle = Leftflipper.endangle
  1590. RFEndAngle = RightFlipper.endangle
  1591.  
  1592. RightFlipper.timerinterval=1
  1593. rightflipper.timerenabled=True
  1594.  
  1595. sub RightFlipper_timer()
  1596.  
  1597. If leftflipper.currentangle = leftflipper.endangle and LFPress = 1 then
  1598. leftflipper.eostorqueangle = EOSAnew
  1599. leftflipper.eostorque = EOSTnew
  1600. LeftFlipper.rampup = EOSRampup
  1601. if LFCount < LiveCatch Then
  1602. LFCount = LFCount + 1
  1603. leftflipper.Elasticity = 0.1
  1604. If LeftFlipper.endangle <> LFEndAngle Then leftflipper.endangle = LFEndAngle
  1605. Else
  1606. leftflipper.Elasticity = FElasticity
  1607. end if
  1608. elseif leftflipper.currentangle > leftflipper.startangle - 0.05 Then
  1609. leftflipper.rampup = SOSRampup
  1610. leftflipper.endangle = LFEndAngle - 3
  1611. leftflipper.Elasticity = FElasticity
  1612. LFCount = 0
  1613. elseif leftflipper.currentangle > leftflipper.endangle + 0.01 Then
  1614. leftflipper.eostorque = EOST
  1615. leftflipper.eostorqueangle = EOSA
  1616. LeftFlipper.rampup = Frampup
  1617. leftflipper.Elasticity = FElasticity
  1618. end if
  1619.  
  1620. If rightflipper.currentangle = rightflipper.endangle and RFPress = 1 then
  1621. rightflipper.eostorqueangle = EOSAnew
  1622. rightflipper.eostorque = EOSTnew
  1623. RightFlipper.rampup = EOSRampup
  1624. if RFCount < LiveCatch Then
  1625. RFCount = RFCount + 1
  1626. rightflipper.Elasticity = 0.1
  1627. If RightFlipper.endangle <> RFEndAngle Then rightflipper.endangle = RFEndAngle
  1628. Else
  1629. rightflipper.Elasticity = FElasticity
  1630. end if
  1631. elseif rightflipper.currentangle < rightflipper.startangle + 0.05 Then
  1632. rightflipper.rampup = SOSRampup
  1633. rightflipper.endangle = RFEndAngle + 3
  1634. rightflipper.Elasticity = FElasticity
  1635. RFCount = 0
  1636. elseif rightflipper.currentangle < rightflipper.endangle - 0.01 Then
  1637. rightflipper.eostorque = EOST
  1638. rightflipper.eostorqueangle = EOSA
  1639. RightFlipper.rampup = Frampup
  1640. rightflipper.Elasticity = FElasticity
  1641. end if
  1642.  
  1643. end sub
  1644.  
  1645. ' Flipper-Init-mid-90s-and-later
  1646.  
  1647. dim LF : Set LF = New FlipperPolarity
  1648. dim RF : Set RF = New FlipperPolarity
  1649.  
  1650. InitPolarity
  1651.  
  1652. Sub InitPolarity()
  1653. dim x, a : a = Array(LF, RF)
  1654. for each x in a
  1655. 'safety coefficient (diminishes polarity correction only)
  1656. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  1657. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  1658.  
  1659. x.enabled = True
  1660. x.TimeDelay = 44
  1661. Next
  1662.  
  1663. 'rf.report "Velocity"
  1664. addpt "Velocity", 0, 0, 1
  1665. addpt "Velocity", 1, 0.2, 1.07
  1666. addpt "Velocity", 2, 0.41, 1.05
  1667. addpt "Velocity", 3, 0.44, 1
  1668. addpt "Velocity", 4, 0.65, 1.0'0.982
  1669. addpt "Velocity", 5, 0.702, 0.968
  1670. addpt "Velocity", 6, 0.95, 0.968
  1671. addpt "Velocity", 7, 1.03, 0.945
  1672.  
  1673. 'rf.report "Polarity"
  1674. AddPt "Polarity", 0, 0, -4.7
  1675. AddPt "Polarity", 1, 0.16, -4.7
  1676. AddPt "Polarity", 2, 0.33, -4.7
  1677. AddPt "Polarity", 3, 0.37, -4.7
  1678. AddPt "Polarity", 4, 0.41, -4.7
  1679. AddPt "Polarity", 5, 0.45, -4.7
  1680. AddPt "Polarity", 6, 0.576,-4.7
  1681. AddPt "Polarity", 7, 0.66, -2.8
  1682. AddPt "Polarity", 8, 0.743, -1.5
  1683. AddPt "Polarity", 9, 0.81, -1.5
  1684. AddPt "Polarity", 10, 0.88, 0
  1685.  
  1686. LF.Object = LeftFlipper
  1687. LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
  1688. RF.Object = RightFlipper
  1689. RF.EndPoint = EndPointRp
  1690. End Sub
  1691.  
  1692. 'Trigger Hit - .AddBall activeball
  1693. 'Trigger UnHit - .PolarityCorrect activeball
  1694.  
  1695. Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
  1696. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : End Sub
  1697. Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
  1698. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub
  1699.  
  1700.  
  1701. '******************************************************
  1702. ' FLIPPER CORRECTION SUPPORTING FUNCTIONS
  1703. '******************************************************
  1704.  
  1705. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  1706. dim a : a = Array(LF, RF)
  1707. dim x : for each x in a
  1708. x.addpoint aStr, idx, aX, aY
  1709. Next
  1710. End Sub
  1711.  
  1712. 'Methods:
  1713. '.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
  1714. '.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
  1715. '.Object - set to flipper reference. Optional.
  1716. '.StartPoint - set start point coord. Unnecessary, if .object is used.
  1717.  
  1718. 'Called with flipper -
  1719. 'ProcessBalls - catches ball data.
  1720. ' - OR -
  1721. '.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
  1722.  
  1723. Class FlipperPolarity
  1724. Public DebugOn, Enabled
  1725. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  1726. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  1727. private Flipper, FlipperStart, FlipperEnd, LR, PartialFlipCoef
  1728. Private Balls(20), balldata(20)
  1729.  
  1730. dim PolarityIn, PolarityOut
  1731. dim VelocityIn, VelocityOut
  1732. dim YcoefIn, YcoefOut
  1733. Public Sub Class_Initialize
  1734. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  1735. Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
  1736. End Sub
  1737.  
  1738. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  1739. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  1740. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  1741. Public Property Let EndPoint(aInput) : if IsObject(aInput) then FlipperEnd = aInput.x else FlipperEnd = aInput : end if : End Property
  1742. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  1743.  
  1744. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  1745. Select Case aChooseArray
  1746. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  1747. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  1748. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  1749. End Select
  1750. if gametime > 100 then Report aChooseArray
  1751. End Sub
  1752.  
  1753. Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
  1754. if not DebugOn then exit sub
  1755. dim a1, a2 : Select Case aChooseArray
  1756. case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
  1757. Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
  1758. Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
  1759. case else :tbpl.text = "wrong string" : exit sub
  1760. End Select
  1761. dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1762. tbpl.text = str
  1763. End Sub
  1764.  
  1765. Public Sub AddBall(aBall) : dim x : for x = 0 to uBound(balls) : if IsEmpty(balls(x)) then set balls(x) = aBall : exit sub :end if : Next : End Sub
  1766.  
  1767. Private Sub RemoveBall(aBall)
  1768. dim x : for x = 0 to uBound(balls)
  1769. if TypeName(balls(x) ) = "IBall" then
  1770. if aBall.ID = Balls(x).ID Then
  1771. balls(x) = Empty
  1772. Balldata(x).Reset
  1773. End If
  1774. End If
  1775. Next
  1776. End Sub
  1777.  
  1778. Public Sub Fire()
  1779. Flipper.RotateToEnd
  1780. processballs
  1781. End Sub
  1782.  
  1783. Public Property Get Pos 'returns % position a ball. For debug stuff.
  1784. dim x : for x = 0 to uBound(balls)
  1785. if not IsEmpty(balls(x) ) then
  1786. pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
  1787. End If
  1788. Next
  1789. End Property
  1790.  
  1791. Public Sub ProcessBalls() 'save data of balls in flipper range
  1792. FlipAt = GameTime
  1793. dim x : for x = 0 to uBound(balls)
  1794. if not IsEmpty(balls(x) ) then
  1795. balldata(x).Data = balls(x)
  1796. if DebugOn then StickL.visible = True : StickL.x = balldata(x).x 'debug TODO
  1797. End If
  1798. Next
  1799. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
  1800. PartialFlipCoef = abs(PartialFlipCoef-1)
  1801. if abs(Flipper.currentAngle - Flipper.EndAngle) < 30 Then
  1802. PartialFlipCoef = 0
  1803. End If
  1804. End Sub
  1805. Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
  1806.  
  1807. Public Sub PolarityCorrect(aBall)
  1808. if FlipperOn() then
  1809. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  1810. dim teststr : teststr = "Cutoff"
  1811. tmp = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  1812. if tmp < 0.1 then 'if real ball position is behind flipper, exit Sub to prevent stucks 'Disabled 1.03, I think it's the Mesh that's causing stucks, not this
  1813. if DebugOn then TestStr = "real pos < 0.1 ( " & round(tmp,2) & ")" : tbpl.text = Teststr
  1814. 'RemoveBall aBall
  1815. 'Exit Sub
  1816. end if
  1817.  
  1818. 'y safety Exit
  1819. if aBall.VelY > -8 then 'ball going down
  1820. if DebugOn then teststr = "y velocity: " & round(aBall.vely, 3) & "exit sub" : tbpl.text = teststr
  1821. RemoveBall aBall
  1822. exit Sub
  1823. end if
  1824. 'Find balldata. BallPos = % on Flipper
  1825. for x = 0 to uBound(Balls)
  1826. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  1827. idx = x
  1828. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  1829. 'TB.TEXT = balldata(x).id & " " & BALLDATA(X).X & VBNEWLINE & FLIPPERSTART & " " & FLIPPEREND
  1830. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1831. end if
  1832. Next
  1833.  
  1834. if not IsEmpty(VelocityIn(0) ) then
  1835. Dim VelCoef
  1836. if DebugOn then set tmp = new spoofball : tmp.data = aBall : End If
  1837. if IsEmpty(BallData(idx).id) and aBall.VelY < -12 then 'if tip hit with no collected data, do vel correction anyway
  1838. if PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1) > 1.1 then 'adjust plz
  1839. VelCoef = LinearEnvelope(5, VelocityIn, VelocityOut)
  1840. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  1841. if Enabled then aBall.Velx = aBall.Velx*VelCoef'VelCoef
  1842. if Enabled then aBall.Vely = aBall.Vely*VelCoef'VelCoef
  1843. if DebugOn then teststr = "tip protection" & vbnewline & "velcoef: " & round(velcoef,3) & vbnewline & round(PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1),3) & vbnewline
  1844. 'debug.print teststr
  1845. end if
  1846. Else
  1847. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  1848. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  1849. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  1850. end if
  1851. End If
  1852.  
  1853. 'Polarity Correction (optional now)
  1854. if not IsEmpty(PolarityIn(0) ) then
  1855. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  1856. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  1857. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  1858. End If
  1859. 'debug
  1860. if DebugOn then
  1861. TestStr = teststr & "%pos:" & round(BallPos,2)
  1862. if IsEmpty(PolarityOut(0) ) then
  1863. teststr = teststr & vbnewline & "(Polarity Disabled)" & vbnewline
  1864. else
  1865. teststr = teststr & "+" & round(1 *(AddX*ycoef*PartialFlipcoef),3)
  1866. if BallPos >= PolarityOut(uBound(PolarityOut) ) then teststr = teststr & "(MAX)" & vbnewline else teststr = teststr & vbnewline end if
  1867. if Ycoef < 1 then teststr = teststr & "ycoef: " & ycoef & vbnewline
  1868. if PartialFlipcoef < 1 then teststr = teststr & "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline
  1869. end if
  1870.  
  1871. teststr = teststr & vbnewline & "Vel: " & round(BallSpeed(tmp),2) & " -> " & round(ballspeed(aBall),2) & vbnewline
  1872. teststr = teststr & "%" & round(ballspeed(aBall) / BallSpeed(tmp),2)
  1873. tbpl.text = TestSTR
  1874. end if
  1875. Else
  1876. 'if DebugOn then tbpl.text = "td" & timedelay
  1877. End If
  1878. RemoveBall aBall
  1879. End Sub
  1880. End Class
  1881.  
  1882. '================================
  1883. 'Helper Functions
  1884.  
  1885. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  1886. dim x, aCount : aCount = 0
  1887. redim a(uBound(aArray) )
  1888. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  1889. if not IsEmpty(aArray(x) ) Then
  1890. if IsObject(aArray(x)) then
  1891. Set a(aCount) = aArray(x)
  1892. Else
  1893. a(aCount) = aArray(x)
  1894. End If
  1895. aCount = aCount + 1
  1896. End If
  1897. Next
  1898. if offset < 0 then offset = 0
  1899. redim aArray(aCount-1+offset) 'Resize original array
  1900. for x = 0 to aCount-1 'set objects back into original array
  1901. if IsObject(a(x)) then
  1902. Set aArray(x) = a(x)
  1903. Else
  1904. aArray(x) = a(x)
  1905. End If
  1906. Next
  1907. End Sub
  1908.  
  1909. Sub ShuffleArrays(aArray1, aArray2, offset)
  1910. ShuffleArray aArray1, offset
  1911. ShuffleArray aArray2, offset
  1912. End Sub
  1913.  
  1914.  
  1915. Function BallSpeed(ball) 'Calculates the ball speed
  1916. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  1917. End Function
  1918.  
  1919. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  1920. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  1921. Y = M*x+b
  1922. PSlope = Y
  1923. End Function
  1924.  
  1925. Function NullFunctionZ(aEnabled):End Function '1 argument null function placeholder TODO move me or replac eme
  1926.  
  1927. Class spoofball
  1928. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  1929. Public Property Let Data(aBall)
  1930. With aBall
  1931. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  1932. id = .ID : mass = .mass : radius = .radius
  1933. end with
  1934. End Property
  1935. Public Sub Reset()
  1936. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  1937. id = Empty : mass = Empty : radius = Empty
  1938. End Sub
  1939. End Class
  1940.  
  1941.  
  1942. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  1943. dim y 'Y output
  1944. dim L 'Line
  1945. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  1946. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  1947. Next
  1948. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  1949. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  1950.  
  1951. 'Clamp if on the boundry lines
  1952. 'if L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
  1953. 'if L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
  1954. 'clamp 2.0
  1955. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  1956. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  1957.  
  1958. LinearEnvelope = Y
  1959. End Function
Advertisement
Add Comment
Please, Sign In to add comment