Arngrim

Mystic

Jul 25th, 2021
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.49 KB | None | 0 0
  1. Option Explicit
  2. Randomize
  3.  
  4. On Error Resume Next
  5. ExecuteGlobal GetTextFile("controller.vbs")
  6. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  7. On Error Goto 0
  8.  
  9. Const cGameName="mysticb",UseSolenoids=1,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  10.  
  11.  
  12. LoadVPM "01550000", "Bally.vbs", 3.26
  13.  
  14. 'Flipper Rampup mode: 0 = fast, 1 = medium, 2 = slow (tap passes should work)
  15. dim FlipperCoilRampupMode : FlipperCoilRampupMode = 1
  16.  
  17. Dim DesktopMode: DesktopMode = Table1.ShowDT
  18.  
  19. If DesktopMode = True Then 'Show Desktop components
  20. Ramp16.visible=1
  21. Ramp15.visible=1
  22. Primitive13.visible=1
  23. Else
  24. Ramp16.visible=0
  25. Ramp15.visible=0
  26. 'Primitive13.visible=0
  27. Primitive13.size_y=250
  28. End if
  29.  
  30. '*************************************************************
  31. 'Solenoid Call backs
  32. '**********************************************************************************************************
  33. SolCallback(6) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  34. SolCallback(7) = "bsTrough.SolOut"
  35. SolCallBack(8) = "bsSaucer.SolOut"
  36. SolCallback(13) = "dtBank1.SolDropUp"
  37. SolCallback(14) = "dtBank2.SolDropUp"
  38. SolCallback(15) = "dtBank3.SolDropUp"
  39. SolCallback(19) = "vpmNudge.SolGameOn"
  40.  
  41. SolCallback(sLRFlipper) = "SolRFlipper"
  42. SolCallback(sLLFlipper) = "SolLFlipper"
  43.  
  44. Sub SolLFlipper(Enabled)
  45. If Enabled Then
  46. PlaySound SoundFX("fx_Flipperup",DOFFlippers):LeftFlipper.RotateToEnd
  47. LF.FIRE
  48. Else
  49. PlaySound SoundFX("fx_Flipperdown",DOFFlippers):LeftFlipper.RotateToStart
  50. End If
  51. End Sub
  52.  
  53. Sub SolRFlipper(Enabled)
  54. If Enabled Then
  55. PlaySound SoundFX("fx_Flipperup",DOFFlippers):RightFlipper.RotateToEnd
  56. RF.FIRE
  57. Else
  58. PlaySound SoundFX("fx_Flipperdown",DOFFlippers):RightFlipper.RotateToStart
  59. End If
  60. End Sub
  61. '**********************************************************************************************************
  62.  
  63. 'Solenoid Controlled toys
  64. '**********************************************************************************************************
  65. '*****GI Lights On
  66. dim xx
  67. For each xx in GI:xx.State = 1: Next
  68.  
  69. '**********************************************************************************************************
  70.  
  71. 'Initiate Table
  72. '**********************************************************************************************************
  73. Dim bsTrough, BsSaucer, dtBank1, dtBank2, dtBank3
  74.  
  75. Sub Table1_Init
  76. vpmInit Me
  77. On Error Resume Next
  78. With Controller
  79. .GameName = cGameName
  80. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  81. .SplashInfoLine = "Mystic - Bally 1979"&chr(13)&"You Suck"
  82. .HandleMechanics=0
  83. .HandleKeyboard=0
  84. .ShowDMDOnly=1
  85. .ShowFrame=0
  86. .ShowTitle=0
  87. .hidden = 1
  88. On Error Resume Next
  89. .Run GetPlayerHWnd
  90. If Err Then MsgBox Err.Description
  91. On Error Goto 0
  92. End With
  93. On Error Goto 0
  94.  
  95. PinMAMETimer.Interval = PinMAMEInterval
  96. PinMAMETimer.Enabled = 1
  97.  
  98. vpmNudge.TiltSwitch = 7
  99. vpmNudge.Sensitivity = 5
  100. vpmNudge.TiltObj = Array(Bumper1, Bumper2, Bumper3, LeftSlingshot, RightSlingshot)
  101.  
  102. ' Trough
  103. Set bsTrough = New cvpmBallStack
  104. bsTrough.InitSw 0, 8, 0, 0, 0, 0, 0, 0
  105. bsTrough.InitKick BallRelease, 50, 13
  106. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  107. bsTrough.Balls = 1
  108.  
  109. Set bsSaucer = New cvpmBallStack
  110. bsSaucer.InitSaucer sw24, 24, 210, 20
  111. bsSaucer.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  112. bsSaucer.KickAngleVar = 1.5
  113. bsSaucer.KickForceVar = 4
  114.  
  115. ' Drop targets
  116. set dtBank1 = new cvpmdroptarget
  117. dtBank1.initdrop array(sw29,sw30,sw31),array(29,30,31)
  118. dtBank1.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  119.  
  120. set dtBank2 = new cvpmdroptarget
  121. dtBank2.initdrop array(sw21,sw22,sw23),array(21,22,23)
  122. dtBank2.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  123.  
  124. set dtBank3 = new cvpmdroptarget
  125. dtBank3.initdrop array(sw13,sw14,sw15),array(13,14,15)
  126. dtBank3.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  127.  
  128. captivekick.CreateBall
  129. captivekick.Kick 180, 2
  130. End Sub
  131.  
  132. '**********************************************************************************************************
  133. 'Plunger code
  134. '**********************************************************************************************************
  135.  
  136. Sub Table1_KeyDown(ByVal KeyCode)
  137. If KeyDownHandler(keycode) Then Exit Sub
  138.  
  139. If keycode = LeftFlipperKey Then lfpress = 1
  140. If keycode = RightFlipperKey Then rfpress = 1
  141.  
  142. If keycode = LeftMagnaSave Then bLutActive = True
  143. If keycode = RightMagnaSave Then
  144. If bLutActive Then NextLUT: End If
  145. End If
  146. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  147. End Sub
  148.  
  149. Sub Table1_KeyUp(ByVal KeyCode)
  150.  
  151. If keycode = LeftFlipperKey Then
  152. lfpress = 0
  153. leftflipper.eostorqueangle = EOSA
  154. leftflipper.eostorque = EOST
  155. End If
  156. If keycode = RightFlipperKey Then
  157. rfpress = 0
  158. rightflipper.eostorqueangle = EOSA
  159. rightflipper.eostorque = EOST
  160. End If
  161.  
  162. If keycode = LeftMagnaSave Then bLutActive = False
  163. If KeyUpHandler(keycode) Then Exit Sub
  164. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  165. End Sub
  166.  
  167. '**********************************************************************************************************
  168. ' Drain hole and kickers
  169. Sub Drain_Hit:bsTrough.addball me : playsound"drain" : End Sub
  170. Sub sw24_Hit:bsSaucer.AddBall 0 : playsound "popper_ball": End Sub
  171.  
  172. 'Rollovers
  173. Sub sw3_Hit:Controller.Switch(3) = 1 : playsound"rollover" : End Sub
  174. Sub sw3_UnHit:Controller.Switch(3) = 0:End Sub
  175. Sub sw2_Hit:Controller.Switch(2) = 1 : playsound"rollover" : End Sub
  176. Sub sw2_UnHit:Controller.Switch(2) = 0:End Sub
  177. Sub sw17_Hit:Controller.Switch(17) = 1 : playsound"rollover" : End Sub
  178. Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
  179. Sub sw18_Hit:Controller.Switch(18) = 1 : playsound"rollover" : End Sub
  180. Sub sw18_UnHit:Controller.Switch(18) = 0:End Sub
  181. Sub sw19_Hit:Controller.Switch(19) = 1 : playsound"rollover" : End Sub
  182. Sub sw19_UnHit:Controller.Switch(19) = 0:End Sub
  183. Sub sw20_Hit:Controller.Switch(20) = 1 : playsound"rollover" : End Sub
  184. Sub sw20_UnHit:Controller.Switch(20) = 0:End Sub
  185.  
  186. 'Spinners
  187. Sub sw5_Spin():vpmTimer.PulseSw 5 : playsound"fx_spinner" : End Sub
  188. Sub sw4_Spin():vpmTimer.PulseSw 4 : playsound"fx_spinner" : End Sub
  189.  
  190. 'Leaf Switches
  191. Sub sw12_Hit:vpmTimer.PulseSw 12 : playsound"flip_hit_3" : End Sub
  192. Sub sw12b_Hit:vpmTimer.PulseSw 12 : playsound"flip_hit_3" : End Sub
  193.  
  194. 'Drop Targets
  195. Sub Sw13_Dropped:dtBank3.Hit 1 :End Sub
  196. Sub Sw14_Dropped:dtBank3.Hit 2 :End Sub
  197. Sub Sw15_Dropped:dtBank3.Hit 3 :End Sub
  198.  
  199. 'Drop Targets
  200. Sub Sw21_Dropped:dtBank2.Hit 1 :End Sub
  201. Sub Sw22_Dropped:dtBank2.Hit 2 :End Sub
  202. Sub Sw23_Dropped:dtBank2.Hit 3 :End Sub
  203.  
  204. 'Drop Targets
  205. Sub Sw29_Dropped:dtBank1.Hit 1 :End Sub
  206. Sub Sw30_Dropped:dtBank1.Hit 2 :End Sub
  207. Sub Sw31_Dropped:dtBank1.Hit 3 :End Sub
  208.  
  209. 'Targets
  210. Sub sw32_Hit:vpmTimer.PulseSw 32:PlaySound SoundFX("Target",DOFTargets),0,1,-0.15,0.1:End Sub
  211.  
  212. 'Bumpers
  213. Sub Bumper1_Hit : vpmTimer.PulseSw(40) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  214. Sub Bumper2_Hit : vpmTimer.PulseSw(39) : playsound SoundFX("fx_bumper2",DOFContactors): End Sub
  215. Sub Bumper3_Hit : vpmTimer.PulseSw(38) : playsound SoundFX("fx_bumper3",DOFContactors): End Sub
  216.  
  217. 'Gates
  218.  
  219. Sub BallReleaseGate_Hit():PlaySound "Gate5":End Sub
  220. Sub GateP_Hit():PlaySound "Gate5":End Sub
  221. Sub GateR_Hit():PlaySound "Gate5":End Sub
  222. Sub GateL_Hit():PlaySound "Gate5":End Sub
  223.  
  224. '**********Sling Shot Animations
  225. ' Rstep and Lstep are the variables that increment the animation
  226. '****************
  227. Dim RStep, Lstep
  228.  
  229. Sub RightSlingShot_Slingshot
  230. vpmTimer.PulseSw 36
  231. PlaySound SoundFX("right_slingshot",DOFContactors), 0, 1, 0.05, 0.05
  232. RSling.Visible = 0
  233. RSling1.Visible = 1
  234. sling1.TransZ = -20
  235. RStep = 0
  236. RightSlingShot.TimerEnabled = 1
  237. End Sub
  238.  
  239. Sub RightSlingShot_Timer
  240. Select Case RStep
  241. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  242. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
  243. End Select
  244. RStep = RStep + 1
  245. End Sub
  246.  
  247. Sub LeftSlingShot_Slingshot
  248. vpmTimer.PulseSw 37
  249. PlaySound SoundFX("left_slingshot",DOFContactors),0,1,-0.05,0.05
  250. LSling.Visible = 0
  251. LSling1.Visible = 1
  252. sling2.TransZ = -20
  253. LStep = 0
  254. LeftSlingShot.TimerEnabled = 1
  255. End Sub
  256.  
  257. Sub LeftSlingShot_Timer
  258. Select Case LStep
  259. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  260. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0:
  261. End Select
  262. LStep = LStep + 1
  263. End Sub
  264.  
  265.  
  266. '***************************************************
  267. ' JP's VP10 Fading Lamps & Flashers
  268. ' Based on PD's Fading Light System
  269. ' SetLamp 0 is Off
  270. ' SetLamp 1 is On
  271. ' fading for non opacity objects is 4 steps
  272. '***************************************************
  273.  
  274. Dim LampState(200), FadingLevel(200)
  275. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  276.  
  277. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  278. LampTimer.Interval = 5 'lamp fading speed
  279. LampTimer.Enabled = 1
  280.  
  281. ' Lamp & Flasher Timers
  282.  
  283. Sub LampTimer_Timer()
  284. Dim chgLamp, num, chg, ii
  285. chgLamp = Controller.ChangedLamps
  286. If Not IsEmpty(chgLamp) Then
  287. For ii = 0 To UBound(chgLamp)
  288. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  289. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  290. Next
  291. End If
  292. UpdateLamps
  293. End Sub
  294.  
  295. Sub UpdateLamps
  296. NFadeL 1, l1
  297. NFadeL 2, l2
  298. NFadeL 3, l3
  299. NFadeL 4, l4
  300. NFadeL 5, l5
  301. NFadeL 6, l6
  302. NFadeL 7, l7
  303. NFadeL 8, l8
  304. NFadeL 9, l9
  305. NFadeL 10, l10
  306. NFadeL 11, l11
  307. NFadeL 12, l12
  308. NFadeL 14, l14
  309. NFadeL 15, l15
  310. NFadeL 17, l17
  311. NFadeL 18, l18
  312. NFadeL 19, l19
  313. NFadeL 20, l20
  314. NFadeL 21, l21
  315. NFadeL 22, l22
  316. NFadeL 23, l23
  317. NFadeL 24, l24
  318. NFadeL 25, l25
  319. NFadeL 26, l26
  320. NFadeL 28, l28
  321. NFadeL 30, l30
  322. NFadeL 31, l31
  323. NFadeL 33, l33
  324. NFadeL 34, l34
  325. NFadeL 35, l35
  326. NFadeL 36, l36
  327. NFadeL 37, l37
  328. NFadeL 38, l38
  329. NFadeL 39, l39
  330. NFadeL 40, l40
  331. NFadeL 42, l42
  332. NFadeL 44, l44
  333. NFadeL 46, l46
  334. NFadeL 47, l47
  335. NFadeL 49, l49
  336. NFadeL 50, l50
  337. NFadeL 51, l51
  338. NFadeL 52, l52
  339. NFadeL 53, l53
  340. NFadeL 54, l54
  341. NFadeL 55, l55
  342. NFadeL 56, l56
  343. NFadeLm 57, l57b
  344. NFadeL 57, l57
  345. NFadeL 58, l58
  346. NFadeL 59, l59 'apron credit
  347. NFadeL 60, l60
  348. NFadeL 62, l62
  349. NFadeL 63, l63
  350.  
  351. 'BackGlass lights
  352. 'FadeReelm 11, l11b ' SAME PLAYER SHOOT AGAIN
  353. 'FadeReel 13, l13 ' BALL IN PLAY
  354. 'FadeReel 16, l16 ' 1 player
  355. 'FadeReel 27, l27 ' MATCH
  356. 'FadeReel 29, l29 ' HIGH SCORE TO DATE
  357. 'FadeReel 32, l32 ' 2 player
  358. 'FadeReel 41, l41 ' pyramid
  359. 'FadeReel 43, l43 ' eye
  360. 'FadeReel 45, l45 ' GAME OVER
  361. 'FadeReel 48, l48 ' 3 player
  362. 'FadeReel 61, l61 ' TILT
  363. 'FadeReel 64, l64 ' 4 player
  364.  
  365. End Sub
  366.  
  367.  
  368. ' div lamp subs
  369.  
  370. Sub InitLamps()
  371. Dim x
  372. For x = 0 to 200
  373. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  374. FadingLevel(x) = 4 ' used to track the fading state
  375. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  376. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  377. FlashMax(x) = 1 ' the maximum value when on, usually 1
  378. FlashMin(x) = 0 ' the minimum value when off, usually 0
  379. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  380. Next
  381. End Sub
  382.  
  383. Sub AllLampsOff
  384. Dim x
  385. For x = 0 to 200
  386. SetLamp x, 0
  387. Next
  388. End Sub
  389.  
  390. Sub SetLamp(nr, value)
  391. If value <> LampState(nr) Then
  392. LampState(nr) = abs(value)
  393. FadingLevel(nr) = abs(value) + 4
  394. End If
  395. End Sub
  396.  
  397. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  398.  
  399. Sub NFadeL(nr, object)
  400. Select Case FadingLevel(nr)
  401. Case 4:object.state = 0:FadingLevel(nr) = 0
  402. Case 5:object.state = 1:FadingLevel(nr) = 1
  403. End Select
  404. End Sub
  405.  
  406. Sub NFadeLm(nr, object) ' used for multiple lights
  407. Select Case FadingLevel(nr)
  408. Case 4:object.state = 0
  409. Case 5:object.state = 1
  410. End Select
  411. End Sub
  412.  
  413. 'Lights, Ramps & Primitives used as 4 step fading lights
  414. 'a,b,c,d are the images used from on to off
  415.  
  416. Sub FadeObj(nr, object, a, b, c, d)
  417. Select Case FadingLevel(nr)
  418. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  419. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  420. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  421. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  422. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  423. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  424. End Select
  425. End Sub
  426.  
  427. Sub FadeObjm(nr, object, a, b, c, d)
  428. Select Case FadingLevel(nr)
  429. Case 4:object.image = b
  430. Case 5:object.image = a
  431. Case 9:object.image = c
  432. Case 13:object.image = d
  433. End Select
  434. End Sub
  435.  
  436. Sub NFadeObj(nr, object, a, b)
  437. Select Case FadingLevel(nr)
  438. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  439. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  440. End Select
  441. End Sub
  442.  
  443. Sub NFadeObjm(nr, object, a, b)
  444. Select Case FadingLevel(nr)
  445. Case 4:object.image = b
  446. Case 5:object.image = a
  447. End Select
  448. End Sub
  449.  
  450. ' Flasher objects
  451.  
  452. Sub Flash(nr, object)
  453. Select Case FadingLevel(nr)
  454. Case 4 'off
  455. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  456. If FlashLevel(nr) < FlashMin(nr) Then
  457. FlashLevel(nr) = FlashMin(nr)
  458. FadingLevel(nr) = 0 'completely off
  459. End if
  460. Object.IntensityScale = FlashLevel(nr)
  461. Case 5 ' on
  462. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  463. If FlashLevel(nr) > FlashMax(nr) Then
  464. FlashLevel(nr) = FlashMax(nr)
  465. FadingLevel(nr) = 1 'completely on
  466. End if
  467. Object.IntensityScale = FlashLevel(nr)
  468. End Select
  469. End Sub
  470.  
  471. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  472. Object.IntensityScale = FlashLevel(nr)
  473. End Sub
  474.  
  475. 'Reels
  476. Sub FadeReel(nr, reel)
  477. Select Case FadingLevel(nr)
  478. Case 2:FadingLevel(nr) = 0
  479. Case 3:FadingLevel(nr) = 2
  480. Case 4:reel.Visible = 0:FadingLevel(nr) = 3
  481. Case 5:reel.Visible = 1:FadingLevel(nr) = 1
  482. End Select
  483. End Sub
  484.  
  485. 'Inverted Reels
  486. Sub FadeIReel(nr, reel)
  487. Select Case FadingLevel(nr)
  488. Case 2:FadingLevel(nr) = 0
  489. Case 3:FadingLevel(nr) = 2
  490. Case 4:reel.Visible = 1:FadingLevel(nr) = 3
  491. Case 5:reel.Visible = 0:FadingLevel(nr) = 1
  492. End Select
  493. End Sub
  494.  
  495.  
  496. '**********************************************************************************************************
  497. 'Digital Display
  498. '**********************************************************************************************************
  499.  
  500. Dim Digits(32)
  501. ' 1st Player
  502. Digits(0) = Array(LED10,LED11,LED12,LED13,LED14,LED15,LED16)
  503. Digits(1) = Array(LED20,LED21,LED22,LED23,LED24,LED25,LED26)
  504. Digits(2) = Array(LED30,LED31,LED32,LED33,LED34,LED35,LED36)
  505. Digits(3) = Array(LED40,LED41,LED42,LED43,LED44,LED45,LED46)
  506. Digits(4) = Array(LED50,LED51,LED52,LED53,LED54,LED55,LED56)
  507. Digits(5) = Array(LED60,LED61,LED62,LED63,LED64,LED65,LED66)
  508. Digits(6) = Array(LED70,LED71,LED72,LED73,LED74,LED75,LED76)
  509.  
  510. ' 2nd Player
  511. Digits(7) = Array(LED80,LED81,LED82,LED83,LED84,LED85,LED86)
  512. Digits(8) = Array(LED90,LED91,LED92,LED93,LED94,LED95,LED96)
  513. Digits(9) = Array(LED100,LED101,LED102,LED103,LED104,LED105,LED106)
  514. Digits(10) = Array(LED110,LED111,LED112,LED113,LED114,LED115,LED116)
  515. Digits(11) = Array(LED120,LED121,LED122,LED123,LED124,LED125,LED126)
  516. Digits(12) = Array(LED130,LED131,LED132,LED133,LED134,LED135,LED136)
  517. Digits(13) = Array(LED140,LED141,LED142,LED143,LED144,LED145,LED146)
  518.  
  519. ' 3rd Player
  520. Digits(14) = Array(LED150,LED151,LED152,LED153,LED154,LED155,LED156)
  521. Digits(15) = Array(LED160,LED161,LED162,LED163,LED164,LED165,LED166)
  522. Digits(16) = Array(LED170,LED171,LED172,LED173,LED174,LED175,LED176)
  523. Digits(17) = Array(LED180,LED181,LED182,LED183,LED184,LED185,LED186)
  524. Digits(18) = Array(LED190,LED191,LED192,LED193,LED194,LED195,LED196)
  525. Digits(19) = Array(LED200,LED201,LED202,LED203,LED204,LED205,LED206)
  526. Digits(20) = Array(LED210,LED211,LED212,LED213,LED214,LED215,LED216)
  527.  
  528. ' 4th Player
  529. Digits(21) = Array(LED220,LED221,LED222,LED223,LED224,LED225,LED226)
  530. Digits(22) = Array(LED230,LED231,LED232,LED233,LED234,LED235,LED236)
  531. Digits(23) = Array(LED240,LED241,LED242,LED243,LED244,LED245,LED246)
  532. Digits(24) = Array(LED250,LED251,LED252,LED253,LED254,LED255,LED256)
  533. Digits(25) = Array(LED260,LED261,LED262,LED263,LED264,LED265,LED266)
  534. Digits(26) = Array(LED270,LED271,LED272,LED273,LED274,LED275,LED276)
  535. Digits(27) = Array(LED280,LED281,LED282,LED283,LED284,LED285,LED286)
  536.  
  537. ' Credits
  538. Digits(28) = Array(LED4,LED2,LED6,LED7,LED5,LED1,LED3)
  539. Digits(29) = Array(LED18,LED9,LED27,LED28,LED19,LED8,LED17)
  540. ' Balls
  541. Digits(30) = Array(LED39,LED37,LED48,LED49,LED47,LED29,LED38)
  542. Digits(31) = Array(LED67,LED58,LED69,LED77,LED68,LED57,LED59)
  543.  
  544. Sub DisplayTimer_Timer
  545. Dim ChgLED,ii,num,chg,stat,obj
  546. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  547. If Not IsEmpty(ChgLED) Then
  548. If DesktopMode = True Then
  549. For ii = 0 To UBound(chgLED)
  550. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  551. if (num < 32) then
  552. For Each obj In Digits(num)
  553. If chg And 1 Then obj.State = stat And 1
  554. chg = chg\2 : stat = stat\2
  555. Next
  556. else
  557. end if
  558. next
  559. end if
  560. end if
  561. End Sub
  562.  
  563.  
  564. '**********************************************************************************************************
  565. '**********************************************************************************************************
  566.  
  567. 'Bally Mystic 7 digits
  568. 'Added by Inkochnito
  569. Sub editDips
  570. Dim vpmDips:Set vpmDips=New cvpmDips
  571. With vpmDips
  572. .AddForm 350,400,"Mystic 7 digits - DIP switches"
  573. .AddFrame 2,0,190,"Maximum credits",&H03000000,Array("10 credits",0,"15 credits",&H01000000,"25 credits",&H02000000,"free play (40 credits)",&H03000000)'dip 25&26
  574. .AddFrame 2,76,190,"Sound features",&H30000000,Array("chime effects",0,"no background noises",&H10000000,"noise effects",&H20000000,"background && noises",&H30000000)'dip 29&30
  575. .AddFrame 2,154,190,"Game Mode",&H00000060,Array("novelty",&H00000020,"extra ball",&H00000040,"replay",&H00000060)'dip 6&7
  576. .AddFrame 2,215,190,"Multiplier memory",32768,Array("no memory",0,"Mystical lane",32768,"bonus X && Mystical lane",49152)'dip 15&16
  577. .AddFrame 205,0,190,"High game to date",&H00200000,Array("no award",0,"3 credits",&H00200000)'dip 22
  578. .AddFrame 205,46,190,"Score version",&H00100000,Array("6 digit scoring",0,"7 digit scoring",&H00100000)'dip 21
  579. .AddFrame 205,92,190,"Balls per game",&H40000000,Array("3 balls",0,"5 balls",&H40000000)'dip 31
  580. .AddFrame 205,138,190,"Pyramids/Eyes special",&H00000080,Array("2 credits",0,"3 credits",&H00000080)'dip 8
  581. .AddFrame 205,184,190,"Mystical lane adjust",0,Array("5K lite on",0,"5K && 2X lite on (3 Ball)",&H80000000)'dip 32
  582. .AddChk 205,235,150,Array("Pyramids/Eyes memory",&H00400000)'dip 23
  583. .AddChk 205,250,150,Array("Star lane memory",&H00800000)'dip 24
  584. .AddChk 205,265,150,Array("Spinner Setting (3 Ball)",&H00002000)'dip 14
  585. .AddChk 205,280,150,Array("Match feature",&H08000000)'dip 28
  586. .AddChk 205,295,150,Array("Credits displayed",&H04000000)'dip 27
  587. .AddLabel 50,315,300,20,"After hitting OK, press F3 to reset game with new settings."
  588. .ViewDips
  589. End With
  590. End Sub
  591. Set vpmShowDips=GetRef("editDips")
  592.  
  593.  
  594. '*********************************************************************
  595. ' Positional Sound Playback Functions
  596. '*********************************************************************
  597.  
  598. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  599. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  600. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  601. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  602. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  603. End Sub
  604.  
  605. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  606. Sub PlaySoundAt(soundname, tableobj)
  607. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  608. End Sub
  609.  
  610. Sub PlaySoundAtBall(soundname)
  611. PlaySoundAt soundname, ActiveBall
  612. End Sub
  613.  
  614.  
  615. '*********************************************************************
  616. ' Supporting Ball & Sound Functions
  617. '*********************************************************************
  618.  
  619. 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
  620. Dim tmp
  621. tmp = tableobj.y * 2 / table1.height-1
  622. If tmp > 0 Then
  623. AudioFade = Csng(tmp ^10)
  624. Else
  625. AudioFade = Csng(-((- tmp) ^10) )
  626. End If
  627. End Function
  628.  
  629. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  630. Dim tmp
  631. tmp = tableobj.x * 2 / table1.width-1
  632. If tmp > 0 Then
  633. AudioPan = Csng(tmp ^10)
  634. Else
  635. AudioPan = Csng(-((- tmp) ^10) )
  636. End If
  637. End Function
  638.  
  639. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  640. Vol = Csng(BallVel(ball) ^2 / 2000)
  641. End Function
  642.  
  643. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  644. Pitch = BallVel(ball) * 20
  645. End Function
  646.  
  647. Function BallVel(ball) 'Calculates the ball speed
  648. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  649. End Function
  650.  
  651.  
  652. '********************************************************************
  653. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  654. '********************************************************************
  655.  
  656. Const tnob = 5 ' total number of balls
  657. ReDim rolling(tnob)
  658. InitRolling
  659.  
  660. Sub InitRolling
  661. Dim i
  662. For i = 0 to tnob
  663. rolling(i) = False
  664. Next
  665. End Sub
  666.  
  667. Sub RollingTimer_Timer()
  668. Dim BOT, b
  669. BOT = GetBalls
  670.  
  671. ' stop the sound of deleted balls
  672. For b = UBound(BOT) + 1 to tnob
  673. rolling(b) = False
  674. StopSound("fx_ballrolling" & b)
  675. Next
  676.  
  677. ' exit the sub if no balls on the table
  678. If UBound(BOT) = -1 Then Exit Sub
  679.  
  680. For b = 0 to UBound(BOT)
  681. ' play the rolling sound for each ball
  682. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  683. rolling(b) = True
  684. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  685. Else
  686. If rolling(b) = True Then
  687. StopSound("fx_ballrolling" & b)
  688. rolling(b) = False
  689. End If
  690. End If
  691.  
  692. ' play ball drop sounds
  693. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  694. PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  695. End If
  696. Next
  697. End Sub
  698.  
  699. '**********************
  700. ' Ball Collision Sound
  701. '**********************
  702.  
  703. Sub OnBallBallCollision(ball1, ball2, velocity)
  704. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  705. End Sub
  706.  
  707.  
  708. '*************
  709. ' JP'S LUT
  710. '*************
  711.  
  712. Dim bLutActive, LUTImage
  713. Sub LoadLUT
  714. Dim x
  715. x = LoadValue(cGameName, "LUTImage")
  716. If(x <> "") Then LUTImage = x Else LUTImage = 0
  717. UpdateLUT
  718. End Sub
  719.  
  720. Sub SaveLUT
  721. SaveValue cGameName, "LUTImage", LUTImage
  722. End Sub
  723.  
  724. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  725.  
  726. Sub UpdateLUT
  727. Select Case LutImage
  728. Case 0: table1.ColorGradeImage = "LUT0"
  729. Case 1: table1.ColorGradeImage = "LUT1"
  730. Case 2: table1.ColorGradeImage = "LUT2"
  731. Case 3: table1.ColorGradeImage = "LUT3"
  732. Case 4: table1.ColorGradeImage = "LUT4"
  733. Case 5: table1.ColorGradeImage = "LUT5"
  734. Case 6: table1.ColorGradeImage = "LUT6"
  735. Case 7: table1.ColorGradeImage = "LUT7"
  736. Case 8: table1.ColorGradeImage = "LUT8"
  737. Case 9: table1.ColorGradeImage = "LUT9"
  738.  
  739. End Select
  740. End Sub
  741.  
  742.  
  743. '*****************************************
  744. ' ninuzzu's FLIPPER SHADOWS
  745. '*****************************************
  746.  
  747. sub FlipperTimer_Timer()
  748. FlipperLSh.RotZ = LeftFlipper.currentangle
  749. FlipperRSh.RotZ = RightFlipper.currentangle
  750. End Sub
  751.  
  752. '*****************************************
  753. ' ninuzzu's BALL SHADOW
  754. '*****************************************
  755.  
  756. Dim BallShadow
  757. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  758.  
  759. Sub BallShadowUpdate_timer()
  760. Dim BOT, b
  761. BOT = GetBalls
  762. ' hide shadow of deleted balls
  763. If UBound(BOT)<(tnob-1) Then
  764. For b = (UBound(BOT) + 1) to (tnob-1)
  765. BallShadow(b).visible = 0
  766. Next
  767. End If
  768. ' exit the Sub if no balls on the table
  769. If UBound(BOT) = -1 Then Exit Sub
  770. ' render the shadow for each ball
  771. For b = 0 to UBound(BOT)
  772. If BOT(b).X < Table1.Width/2 Then
  773. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) + 6
  774. Else
  775. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) - 6
  776. End If
  777. ballShadow(b).Y = BOT(b).Y + 4
  778. If BOT(b).Z > 20 Then
  779. BallShadow(b).visible = 1
  780. Else
  781. BallShadow(b).visible = 0
  782. End If
  783. Next
  784. End Sub
  785.  
  786.  
  787. '************************************
  788. ' What you need to add to your table
  789. '************************************
  790.  
  791. ' a timer called RollingTimer. With a fast interval, like 10
  792. ' one collision sound, in this script is called fx_collide
  793. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  794. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  795.  
  796.  
  797. '******************************************
  798. ' Explanation of the rolling sound routine
  799. '******************************************
  800.  
  801. ' sounds are played based on the ball speed and position
  802.  
  803. ' the routine checks first for deleted balls and stops the rolling sound.
  804.  
  805. ' The For loop goes through all the balls on the table and checks for the ball speed and
  806. ' if the ball is on the table (height lower than 30) then then it plays the sound
  807. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  808.  
  809. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  810. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  811. ' according to the position of the ball on the table.
  812.  
  813.  
  814. '**************************************
  815. ' Explanation of the collision routine
  816. '**************************************
  817.  
  818. ' The collision is built in VP.
  819. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  820. ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning
  821. ' depending of the speed of the collision.
  822.  
  823.  
  824. Sub Pins_Hit (idx)
  825. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  826. End Sub
  827.  
  828. Sub Targets_Hit (idx)
  829. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  830. End Sub
  831.  
  832. Sub Metals_Thin_Hit (idx)
  833. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  834. End Sub
  835.  
  836. Sub Metals_Medium_Hit (idx)
  837. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  838. End Sub
  839.  
  840. Sub Metals2_Hit (idx)
  841. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  842. End Sub
  843.  
  844. Sub Gates_Hit (idx)
  845. PlaySound "Gate5", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  846. End Sub
  847.  
  848. Sub Spinner_Spin
  849. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  850. End Sub
  851.  
  852. Sub Rubbers_Hit(idx)
  853. dim finalspeed
  854. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  855. If finalspeed > 20 then
  856. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  857. End if
  858. If finalspeed >= 6 AND finalspeed <= 20 then
  859. RandomSoundRubber()
  860. End If
  861. End Sub
  862.  
  863. Sub Posts_Hit(idx)
  864. dim finalspeed
  865. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  866. If finalspeed > 16 then
  867. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  868. End if
  869. If finalspeed >= 6 AND finalspeed <= 16 then
  870. RandomSoundRubber()
  871. End If
  872. End Sub
  873.  
  874. Sub RandomSoundRubber()
  875. Select Case Int(Rnd*3)+1
  876. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  877. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  878. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  879. End Select
  880. End Sub
  881.  
  882. Sub LeftFlipper_Collide(parm)
  883. RandomSoundFlipper()
  884. End Sub
  885.  
  886. Sub RightFlipper_Collide(parm)
  887. RandomSoundFlipper()
  888. End Sub
  889.  
  890. Sub RandomSoundFlipper()
  891. Select Case Int(Rnd*3)+1
  892. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  893. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  894. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  895. End Select
  896. End Sub
  897.  
  898.  
  899.  
  900. '******************************************************
  901. ' FLIPPER CORRECTION INITIALIZATION
  902. ' Start nFOZZY FLIPPERS'
  903. '******************************************************
  904.  
  905. 'Flipper Correction Initialization late 80’s to early 90’s
  906. dim LF : Set LF = New FlipperPolarity
  907. dim RF : Set RF = New FlipperPolarity
  908.  
  909. InitPolarity
  910.  
  911. Sub InitPolarity()
  912. dim x, a : a = Array(LF, RF)
  913. for each x in a
  914. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  915. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  916. x.enabled = True
  917. x.TimeDelay = 60
  918. Next
  919.  
  920. AddPt "Polarity", 0, 0, 0
  921. AddPt "Polarity", 1, 0.05, -5
  922. AddPt "Polarity", 2, 0.4, -5
  923. AddPt "Polarity", 3, 0.6, -4.5
  924. AddPt "Polarity", 4, 0.65, -4.0
  925. AddPt "Polarity", 5, 0.7, -3.5
  926. AddPt "Polarity", 6, 0.75, -3.0
  927. AddPt "Polarity", 7, 0.8, -2.5
  928. AddPt "Polarity", 8, 0.85, -2.0
  929. AddPt "Polarity", 9, 0.9,-1.5
  930. AddPt "Polarity", 10, 0.95, -1.0
  931. AddPt "Polarity", 11, 1, -0.5
  932. AddPt "Polarity", 12, 1.1, 0
  933. AddPt "Polarity", 13, 1.3, 0
  934.  
  935. addpt "Velocity", 0, 0, 1
  936. addpt "Velocity", 1, 0.16, 1.06
  937. addpt "Velocity", 2, 0.41, 1.05
  938. addpt "Velocity", 3, 0.53, 1'0.982
  939. addpt "Velocity", 4, 0.702, 0.968
  940. addpt "Velocity", 5, 0.95, 0.968
  941. addpt "Velocity", 6, 1.03, 0.945
  942.  
  943. LF.Object = LeftFlipper
  944. LF.EndPoint = EndPointLp
  945. RF.Object = RightFlipper
  946. RF.EndPoint = EndPointRp
  947. End Sub
  948.  
  949. Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
  950. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : End Sub
  951. Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
  952. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub
  953.  
  954. '******************************************************
  955. ' FLIPPER CORRECTION FUNCTIONS
  956. '******************************************************
  957.  
  958. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  959. dim a : a = Array(LF, RF)
  960. dim x : for each x in a
  961. x.addpoint aStr, idx, aX, aY
  962. Next
  963. End Sub
  964.  
  965. Class FlipperPolarity
  966. Public DebugOn, Enabled
  967. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  968. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  969. private Flipper, FlipperStart,FlipperEnd, FlipperEndY, LR, PartialFlipCoef
  970. Private Balls(20), balldata(20)
  971.  
  972. dim PolarityIn, PolarityOut
  973. dim VelocityIn, VelocityOut
  974. dim YcoefIn, YcoefOut
  975. Public Sub Class_Initialize
  976. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  977. Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
  978. End Sub
  979.  
  980. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  981. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  982. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  983. Public Property Let EndPoint(aInput) : FlipperEnd = aInput.x: FlipperEndY = aInput.y: End Property
  984. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  985. Public Property Get EndPointY: EndPointY = FlipperEndY : End Property
  986.  
  987. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  988. Select Case aChooseArray
  989. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  990. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  991. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  992. End Select
  993. if gametime > 100 then Report aChooseArray
  994. End Sub
  995.  
  996. Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
  997. if not DebugOn then exit sub
  998. dim a1, a2 : Select Case aChooseArray
  999. case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
  1000. Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
  1001. Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
  1002. case else :tbpl.text = "wrong string" : exit sub
  1003. End Select
  1004. dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1005. tbpl.text = str
  1006. End Sub
  1007.  
  1008. 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
  1009.  
  1010. Private Sub RemoveBall(aBall)
  1011. dim x : for x = 0 to uBound(balls)
  1012. if TypeName(balls(x) ) = "IBall" then
  1013. if aBall.ID = Balls(x).ID Then
  1014. balls(x) = Empty
  1015. Balldata(x).Reset
  1016. End If
  1017. End If
  1018. Next
  1019. End Sub
  1020.  
  1021. Public Sub Fire()
  1022. Flipper.RotateToEnd
  1023. processballs
  1024. End Sub
  1025.  
  1026. Public Property Get Pos 'returns % position a ball. For debug stuff.
  1027. dim x : for x = 0 to uBound(balls)
  1028. if not IsEmpty(balls(x) ) then
  1029. pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
  1030. End If
  1031. Next
  1032. End Property
  1033.  
  1034. Public Sub ProcessBalls() 'save data of balls in flipper range
  1035. FlipAt = GameTime
  1036. dim x : for x = 0 to uBound(balls)
  1037. if not IsEmpty(balls(x) ) then
  1038. balldata(x).Data = balls(x)
  1039. End If
  1040. Next
  1041. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
  1042. PartialFlipCoef = abs(PartialFlipCoef-1)
  1043. End Sub
  1044. Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
  1045.  
  1046. Public Sub PolarityCorrect(aBall)
  1047. if FlipperOn() then
  1048. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  1049.  
  1050. 'y safety Exit
  1051. if aBall.VelY > -8 then 'ball going down
  1052. RemoveBall aBall
  1053. exit Sub
  1054. end if
  1055.  
  1056. 'Find balldata. BallPos = % on Flipper
  1057. for x = 0 to uBound(Balls)
  1058. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  1059. idx = x
  1060. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  1061. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1062. end if
  1063. Next
  1064.  
  1065. If BallPos = 0 Then 'no ball data meaning the ball is entering and exiting pretty close to the same position, use current values.
  1066. BallPos = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  1067. if ballpos > 0.65 then Ycoef = LinearEnvelope(aBall.Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1068. End If
  1069.  
  1070. 'Velocity correction
  1071. if not IsEmpty(VelocityIn(0) ) then
  1072. Dim VelCoef
  1073. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  1074.  
  1075. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  1076.  
  1077. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  1078. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  1079. End If
  1080.  
  1081. 'Polarity Correction (optional now)
  1082. if not IsEmpty(PolarityIn(0) ) then
  1083. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  1084. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  1085.  
  1086. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  1087. 'playsound "fx_knocker"
  1088. End If
  1089. End If
  1090. RemoveBall aBall
  1091. End Sub
  1092. End Class
  1093.  
  1094. '******************************************************
  1095. ' FLIPPER POLARITY AND RUBBER DAMPENER
  1096. ' SUPPORTING FUNCTIONS
  1097. '******************************************************
  1098.  
  1099. ' Used for flipper correction and rubber dampeners
  1100. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  1101. dim x, aCount : aCount = 0
  1102. redim a(uBound(aArray) )
  1103. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  1104. if not IsEmpty(aArray(x) ) Then
  1105. if IsObject(aArray(x)) then
  1106. Set a(aCount) = aArray(x)
  1107. Else
  1108. a(aCount) = aArray(x)
  1109. End If
  1110. aCount = aCount + 1
  1111. End If
  1112. Next
  1113. if offset < 0 then offset = 0
  1114. redim aArray(aCount-1+offset) 'Resize original array
  1115. for x = 0 to aCount-1 'set objects back into original array
  1116. if IsObject(a(x)) then
  1117. Set aArray(x) = a(x)
  1118. Else
  1119. aArray(x) = a(x)
  1120. End If
  1121. Next
  1122. End Sub
  1123.  
  1124. ' Used for flipper correction and rubber dampeners
  1125. Sub ShuffleArrays(aArray1, aArray2, offset)
  1126. ShuffleArray aArray1, offset
  1127. ShuffleArray aArray2, offset
  1128. End Sub
  1129.  
  1130. ' Used for flipper correction, rubber dampeners, and drop targets
  1131. Function BallSpeed(ball) 'Calculates the ball speed
  1132. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  1133. End Function
  1134.  
  1135. ' Used for flipper correction and rubber dampeners
  1136. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  1137. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  1138. Y = M*x+b
  1139. PSlope = Y
  1140. End Function
  1141.  
  1142. ' Used for flipper correction
  1143. Class spoofball
  1144. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  1145. Public Property Let Data(aBall)
  1146. With aBall
  1147. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  1148. id = .ID : mass = .mass : radius = .radius
  1149. end with
  1150. End Property
  1151. Public Sub Reset()
  1152. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  1153. id = Empty : mass = Empty : radius = Empty
  1154. End Sub
  1155. End Class
  1156.  
  1157. ' Used for flipper correction and rubber dampeners
  1158. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  1159. dim y 'Y output
  1160. dim L 'Line
  1161. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  1162. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  1163. Next
  1164. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  1165. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  1166.  
  1167. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  1168. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  1169.  
  1170. LinearEnvelope = Y
  1171. End Function
  1172.  
  1173. ' Used for drop targets and stand up targets
  1174. Function Atn2(dy, dx)
  1175. dim pi
  1176. pi = 4*Atn(1)
  1177.  
  1178. If dx > 0 Then
  1179. Atn2 = Atn(dy / dx)
  1180. ElseIf dx < 0 Then
  1181. If dy = 0 Then
  1182. Atn2 = pi
  1183. Else
  1184. Atn2 = Sgn(dy) * (pi - Atn(Abs(dy / dx)))
  1185. end if
  1186. ElseIf dx = 0 Then
  1187. if dy = 0 Then
  1188. Atn2 = 0
  1189. else
  1190. Atn2 = Sgn(dy) * pi / 2
  1191. end if
  1192. End If
  1193. End Function
  1194.  
  1195. ' Used for drop targets and flipper tricks
  1196. Function Distance(ax,ay,bx,by)
  1197. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1198. End Function
  1199.  
  1200. '******************************************************
  1201. ' FLIPPER TRICKS
  1202. '******************************************************
  1203.  
  1204. RightFlipper.timerinterval=1
  1205. Rightflipper.timerenabled=True
  1206.  
  1207. sub RightFlipper_timer()
  1208. FlipperTricks LeftFlipper, LFPress, LFCount, LFEndAngle, LFState
  1209. FlipperTricks RightFlipper, RFPress, RFCount, RFEndAngle, RFState
  1210. FlipperNudge RightFlipper, RFEndAngle, RFEOSNudge, LeftFlipper, LFEndAngle
  1211. FlipperNudge LeftFlipper, LFEndAngle, LFEOSNudge, RightFlipper, RFEndAngle
  1212. end sub
  1213.  
  1214. Dim LFEOSNudge, RFEOSNudge
  1215.  
  1216. Sub FlipperNudge(Flipper1, Endangle1, EOSNudge1, Flipper2, EndAngle2)
  1217. Dim BOT, b
  1218.  
  1219. If abs(Flipper1.currentangle) < abs(Endangle1) + 3 and EOSNudge1 <> 1 Then
  1220. EOSNudge1 = 1
  1221. If Flipper2.currentangle = EndAngle2 Then
  1222. BOT = GetBalls
  1223. For b = 0 to Ubound(BOT)
  1224. If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper1) Then
  1225. 'Debug.Print "ball in flip1. exit"
  1226. exit Sub
  1227. end If
  1228. Next
  1229. For b = 0 to Ubound(BOT)
  1230. If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper2) Then
  1231. 'debug.print "flippernudge!!"
  1232. BOT(b).velx = BOT(b).velx /1.5
  1233. BOT(b).vely = BOT(b).vely - 1
  1234. end If
  1235. Next
  1236. End If
  1237. Else
  1238. If abs(Flipper1.currentangle) > abs(Endangle1) + 30 then EOSNudge1 = 0
  1239. End If
  1240. End Sub
  1241.  
  1242. '*****************
  1243. ' Maths
  1244. '*****************
  1245. Const Pi = 3.1415927
  1246.  
  1247. Function dSin(degrees)
  1248. dsin = sin(degrees * Pi/180)
  1249. End Function
  1250.  
  1251. Function dCos(degrees)
  1252. dcos = cos(degrees * Pi/180)
  1253. End Function
  1254.  
  1255.  
  1256. '*************************************************
  1257. ' Check ball distance from Flipper for Rem
  1258. '*************************************************
  1259.  
  1260. Function Distance(ax,ay,bx,by)
  1261. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1262. End Function
  1263.  
  1264. Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
  1265. DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
  1266. End Function
  1267.  
  1268. Function Radians(Degrees)
  1269. Radians = Degrees * PI /180
  1270. End Function
  1271.  
  1272. Function AnglePP(ax,ay,bx,by)
  1273. AnglePP = Atn2((by - ay),(bx - ax))*180/PI
  1274. End Function
  1275.  
  1276. Function DistanceFromFlipper(ballx, bally, Flipper)
  1277. DistanceFromFlipper = DistancePL(ballx, bally, Flipper.x, Flipper.y, Cos(Radians(Flipper.currentangle+90))+Flipper.x, Sin(Radians(Flipper.currentangle+90))+Flipper.y)
  1278. End Function
  1279.  
  1280. Function FlipperTrigger(ballx, bally, Flipper)
  1281. Dim DiffAngle
  1282. DiffAngle = ABS(Flipper.currentangle - AnglePP(Flipper.x, Flipper.y, ballx, bally) - 90)
  1283. If DiffAngle > 180 Then DiffAngle = DiffAngle - 360
  1284.  
  1285. If DistanceFromFlipper(ballx,bally,Flipper) < 48 and DiffAngle <= 90 and Distance(ballx,bally,Flipper.x,Flipper.y) < Flipper.Length Then
  1286. FlipperTrigger = True
  1287. Else
  1288. FlipperTrigger = False
  1289. End If
  1290. End Function
  1291.  
  1292. '*************************************************
  1293. ' End - Check ball distance from Flipper for Rem
  1294. '*************************************************
  1295.  
  1296.  
  1297.  
  1298. dim LFPress, RFPress, LFCount, RFCount
  1299. dim LFState, RFState
  1300. dim EOST, EOSA,Frampup, FElasticity,FReturn
  1301. dim RFEndAngle, LFEndAngle
  1302.  
  1303. EOST = leftflipper.eostorque
  1304. EOSA = leftflipper.eostorqueangle
  1305. Frampup = LeftFlipper.rampup
  1306. FElasticity = LeftFlipper.elasticity
  1307. FReturn = LeftFlipper.return
  1308. Const EOSTnew = 1 '0.8
  1309. Const EOSAnew = 1
  1310. Const EOSRampup = 0
  1311. Dim SOSRampup
  1312. Select Case FlipperCoilRampupMode
  1313. Case 0:
  1314. SOSRampup = 2.5
  1315. Case 1:
  1316. SOSRampup = 4.5
  1317. Case 2:
  1318. SOSRampup = 8.5
  1319. End Select
  1320. Const LiveCatch = 16
  1321. Const LiveElasticity = 0.45
  1322. Const SOSEM = 0.815
  1323. Const EOSReturn = 0.035 '0.025
  1324.  
  1325.  
  1326. LFEndAngle = Leftflipper.endangle
  1327. RFEndAngle = RightFlipper.endangle
  1328.  
  1329. Sub FlipperActivate(Flipper, FlipperPress)
  1330. FlipperPress = 1
  1331. Flipper.Elasticity = FElasticity
  1332.  
  1333. Flipper.eostorque = EOST
  1334. Flipper.eostorqueangle = EOSA
  1335. End Sub
  1336.  
  1337. Sub FlipperDeactivate(Flipper, FlipperPress)
  1338. FlipperPress = 0
  1339. Flipper.eostorqueangle = EOSA
  1340. Flipper.eostorque = EOST*EOSReturn/FReturn
  1341.  
  1342.  
  1343. If Abs(Flipper.currentangle) <= Abs(Flipper.endangle) + 0.1 Then
  1344. Dim BOT, b
  1345. BOT = GetBalls
  1346.  
  1347. For b = 0 to UBound(BOT)
  1348. If Distance(BOT(b).x, BOT(b).y, Flipper.x, Flipper.y) < 55 Then 'check for cradle
  1349. If BOT(b).vely >= -0.4 Then BOT(b).vely = -0.4
  1350. End If
  1351. Next
  1352. End If
  1353. End Sub
  1354.  
  1355. Sub FlipperTricks (Flipper, FlipperPress, FCount, FEndAngle, FState)
  1356. Dim Dir
  1357. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1358.  
  1359. If Abs(Flipper.currentangle) > Abs(Flipper.startangle) - 0.05 Then
  1360. If FState <> 1 Then
  1361. Flipper.rampup = SOSRampup
  1362. Flipper.endangle = FEndAngle - 3*Dir
  1363. Flipper.Elasticity = FElasticity * SOSEM
  1364. FCount = 0
  1365. FState = 1
  1366. End If
  1367. ElseIf Abs(Flipper.currentangle) <= Abs(Flipper.endangle) and FlipperPress = 1 then
  1368. if FCount = 0 Then FCount = GameTime
  1369.  
  1370. If FState <> 2 Then
  1371. Flipper.eostorqueangle = EOSAnew
  1372. Flipper.eostorque = EOSTnew
  1373. Flipper.rampup = EOSRampup
  1374. Flipper.endangle = FEndAngle
  1375. FState = 2
  1376. End If
  1377. Elseif Abs(Flipper.currentangle) > Abs(Flipper.endangle) + 0.01 and FlipperPress = 1 Then
  1378. If FState <> 3 Then
  1379. Flipper.eostorque = EOST
  1380. Flipper.eostorqueangle = EOSA
  1381. Flipper.rampup = Frampup
  1382. Flipper.Elasticity = FElasticity
  1383. FState = 3
  1384. End If
  1385.  
  1386. End If
  1387. End Sub
  1388.  
  1389. Const LiveDistanceMin = 30 'minimum distance in vp units from flipper base live catch dampening will occur
  1390. Const LiveDistanceMax = 117 'maximum distance in vp units from flipper base live catch dampening will occur (tip protection)
  1391.  
  1392. Sub CheckLiveCatch(ball, Flipper, FCount, parm) 'Experimental new live catch
  1393. Dim Dir
  1394. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1395. Dim LiveCatchBounce 'If live catch is not perfect, it won't freeze ball totally
  1396. Dim CatchTime : CatchTime = GameTime - FCount
  1397.  
  1398. if CatchTime <= LiveCatch and parm > 6 and ABS(Flipper.x - ball.x) > LiveDistanceMin and ABS(Flipper.x - ball.x) < LiveDistanceMax Then
  1399. if CatchTime <= LiveCatch*0.8 Then 'Perfect catch only when catch time happens in the beginning of the window
  1400. LiveCatchBounce = 0
  1401. else
  1402. LiveCatchBounce = Abs((LiveCatch/2) - CatchTime) 'Partial catch when catch happens a bit late
  1403. end If
  1404.  
  1405. 'debug.print "Live catch! Bounce: " & LiveCatchBounce
  1406.  
  1407. If LiveCatchBounce = 0 and ball.velx * Dir > 0 Then ball.velx = 0
  1408. ball.vely = LiveCatchBounce * (16 / LiveCatch) ' Multiplier for inaccuracy bounce
  1409. ball.angmomx= 0
  1410. ball.angmomy= 0
  1411. ball.angmomz= 0
  1412. End If
  1413. End Sub
  1414.  
  1415. '*****************************************************************************************************
  1416. 'END nFOZZY FLIPPERS'
  1417.  
  1418.  
  1419.  
  1420.  
  1421. 'PHYSICS DAMPENERS
  1422.  
  1423. 'These are data mined bounce curves,
  1424. 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
  1425. 'Requires tracking ballspeed to calculate COR
  1426.  
  1427. Sub dPosts_Hit(idx)
  1428. RubbersD.dampen Activeball
  1429. End Sub
  1430.  
  1431. Sub dSleeves_Hit(idx)
  1432. SleevesD.Dampen Activeball
  1433. End Sub
  1434.  
  1435.  
  1436. dim RubbersD : Set RubbersD = new Dampener 'frubber
  1437. RubbersD.name = "Rubbers"
  1438. RubbersD.debugOn = False 'shows info in textbox "TBPout"
  1439. RubbersD.Print = False 'debug, reports in debugger (in vel, out cor)
  1440. 'cor bounce curve (linear)
  1441. 'for best results, try to match in-game velocity as closely as possible to the desired curve
  1442. 'RubbersD.addpoint 0, 0, 0.935 'point# (keep sequential), ballspeed, CoR (elasticity)
  1443. RubbersD.addpoint 0, 0, 0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
  1444. RubbersD.addpoint 1, 3.77, 0.96
  1445. RubbersD.addpoint 2, 5.76, 0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
  1446. RubbersD.addpoint 3, 15.84, 0.874
  1447. RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
  1448.  
  1449. dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
  1450. SleevesD.name = "Sleeves"
  1451. SleevesD.debugOn = False 'shows info in textbox "TBPout"
  1452. SleevesD.Print = False 'debug, reports in debugger (in vel, out cor)
  1453. SleevesD.CopyCoef RubbersD, 0.85
  1454.  
  1455. Class Dampener
  1456. Public Print, debugOn 'tbpOut.text
  1457. public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
  1458. Public ModIn, ModOut
  1459. Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
  1460.  
  1461. Public Sub AddPoint(aIdx, aX, aY)
  1462. ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
  1463. if gametime > 100 then Report
  1464. End Sub
  1465.  
  1466. public sub Dampen(aBall)
  1467. if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
  1468. dim RealCOR, DesiredCOR, str, coef
  1469. DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
  1470. RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
  1471. coef = desiredcor / realcor
  1472. if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
  1473. "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
  1474. if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)
  1475.  
  1476. aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
  1477. if debugOn then TBPout.text = str
  1478. End Sub
  1479.  
  1480. Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
  1481. dim x : for x = 0 to uBound(aObj.ModIn)
  1482. addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
  1483. Next
  1484. End Sub
  1485.  
  1486.  
  1487. Public Sub Report() 'debug, reports all coords in tbPL.text
  1488. if not debugOn then exit sub
  1489. dim a1, a2 : a1 = ModIn : a2 = ModOut
  1490. dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1491. TBPout.text = str
  1492. End Sub
  1493.  
  1494.  
  1495. End Class
  1496.  
  1497. 'Tracks ball velocity for judging bounce calculations & angle
  1498. 'apologies to JimmyFingers is this is what his script does. I know his tracks ball velocity too but idk how it works in particular
  1499. dim cor : set cor = New CoRTracker
  1500. cor.debugOn = False
  1501. 'cor.update() - put this on a low interval timer
  1502. Class CoRTracker
  1503. public DebugOn 'tbpIn.text
  1504. public ballvel
  1505.  
  1506. Private Sub Class_Initialize : redim ballvel(0) : End Sub
  1507. 'TODO this would be better if it didn't do the sorting every ms, but instead every time it's pulled for COR stuff
  1508. Public Sub Update() 'tracks in-ball-velocity
  1509. dim str, b, AllBalls, highestID : allBalls = getballs
  1510. if uBound(allballs) < 0 then if DebugOn then str = "no balls" : TBPin.text = str : exit Sub else exit sub end if: end if
  1511. for each b in allballs
  1512. if b.id >= HighestID then highestID = b.id
  1513. Next
  1514.  
  1515. if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
  1516.  
  1517. for each b in allballs
  1518. ballvel(b.id) = BallSpeed(b)
  1519. if DebugOn then
  1520. dim s, bs 'debug spacer, ballspeed
  1521. bs = round(BallSpeed(b),1)
  1522. if bs < 10 then s = " " else s = "" end if
  1523. str = str & b.id & ": " & s & bs & vbnewline
  1524. 'str = str & b.id & ": " & s & bs & "z:" & b.z & vbnewline
  1525. end if
  1526. Next
  1527. if DebugOn then str = "ubound ballvels: " & ubound(ballvel) & vbnewline & str : if TBPin.text <> str then TBPin.text = str : end if
  1528. End Sub
  1529. End Class
  1530.  
  1531. Sub RDampen_Timer()
  1532. Cor.Update
  1533. End Sub
  1534.  
  1535.  
  1536.  
  1537. ' Thalamus : Exit in a clean and proper way
  1538. Sub Table1_exit()
  1539. If B2SOn Then
  1540. Controller.Pause = False
  1541. Controller.Stop
  1542. End If
  1543. End Sub
  1544.  
  1545.  
Advertisement
Add Comment
Please, Sign In to add comment