Guest User

Untitled

a guest
Jul 4th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.63 KB | None | 0 0
  1. Option Explicit
  2. Randomize
  3.  
  4. ' Thalamus 2018-07-20
  5. ' Added/Updated "Positional Sound Playback Functions" and "Supporting Ball & Sound Functions"
  6.  
  7. Const VolDiv = 8000 ' Lower numper louder ballrolling sound
  8. Const VolCol = 3 ' Ball collision divider ( voldiv/volcol )
  9.  
  10. ' The rest of the values are multipliers
  11. '
  12. ' .5 = lower volume
  13. ' 1.5 = higher volume
  14.  
  15. Const VolBump = 8 ' Bumpers volume.
  16. Const VolRol = 5 ' Rollovers volume.
  17. Const VolGates = 5 ' Gates volume.
  18. Const VolMetal = 5 ' Metals volume.
  19. Const VolRB = 5 ' Rubber bands volume.
  20. Const VolRH = 5 ' Rubber hits volume.
  21. Const VolPo = 5 ' Rubber posts volume.
  22. Const VolPi = 5 ' Rubber pins volume.
  23. Const VolPlast = 5 ' Plastics volume.
  24. Const VolTarg = 5 ' Targets volume.
  25. Const VolWood = 5 ' Woods volume.
  26. Const VolKick = 1 ' Kicker volume.
  27. Const VolSpin = .1 ' Spinners volume.
  28. Const VolFlip = 5 ' Flipper volume.
  29.  
  30. On Error Resume Next
  31. ExecuteGlobal GetTextFile("controller.vbs")
  32. If Err Then MsgBox "Can't open controller.vbs"
  33. On Error Goto 0
  34.  
  35. Const cGameName="stingray"
  36.  
  37. LoadVPM "01530000","BALLY.VBS",3.2
  38. 'LoadVPM "01530000","STERN.VBS",3.2
  39.  
  40. Const UseSolenoids=2
  41. Const UseLamps=1
  42. Const UseGI=0
  43.  
  44. ' Standard Sounds
  45. Const SSolenoidOn="fx_solenoid",SSolenoidOff="fx_solenoidoff",SCoin="fx_coin",SFlipperOn="",SFlipperOff=""
  46.  
  47. Dim bsTrough,bsSaucer,dtL,HiddenValue
  48.  
  49. '*********** Desktop/Cabinet settings ************************
  50.  
  51. If Table1.ShowDT = true Then
  52. HiddenValue = 0
  53. rails.visible=1
  54. Else
  55. HiddenValue = 1
  56. rails.visible=0
  57. End If
  58.  
  59. '******************************************************
  60. ' FLIPPERS
  61. '******************************************************
  62.  
  63. Sub SolLFlipper(Enabled)
  64. If Enabled Then
  65. PlaySound SoundFX("fx_Flipperup",DOFContactors), VolFlip
  66. lf.fire
  67. Else
  68. if leftflipper.currentangle < leftflipper.startangle - 5 then
  69. PlaySound SoundFX("fx_flipperdown",DOFContactors), VolFlip
  70. end if
  71. LeftFlipper.RotateToStart
  72. End If
  73. End Sub
  74.  
  75. Sub SolRFlipper(Enabled)
  76. If Enabled Then
  77. PlaySound SoundFX("fx_Flipperup1",DOFContactors), VolFlip
  78. RF.fire
  79. Else
  80. if RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
  81. PlaySound SoundFX("fx_Flipperdown1",DOFContactors), VolFlip
  82. End If
  83. RightFlipper.RotateToStart
  84. End If
  85. End Sub
  86.  
  87. RightFlipper.timerinterval=1
  88. Rightflipper.timerenabled=True
  89.  
  90. sub RightFlipper_timer()
  91.  
  92. If leftflipper.currentangle = leftflipper.endangle and LFPress = 1 then
  93. leftflipper.eostorqueangle = EOSAnew
  94. leftflipper.eostorque = EOSTnew
  95. LeftFlipper.rampup = EOSRampup
  96. if LFCount = 0 Then LFCount = GameTime
  97. if GameTime - LFCount < LiveCatch Then
  98. leftflipper.Elasticity = 0.1
  99. If LeftFlipper.endangle <> LFEndAngle Then leftflipper.endangle = LFEndAngle
  100. Else
  101. leftflipper.Elasticity = FElasticity
  102. end if
  103. elseif leftflipper.currentangle > leftflipper.startangle - 0.05 Then
  104. leftflipper.rampup = SOSRampup
  105. leftflipper.endangle = LFEndAngle - 3
  106. leftflipper.Elasticity = FElasticity
  107. LFCount = 0
  108. elseif leftflipper.currentangle > leftflipper.endangle + 0.01 Then
  109. leftflipper.eostorque = EOST
  110. leftflipper.eostorqueangle = EOSA
  111. LeftFlipper.rampup = Frampup
  112. leftflipper.Elasticity = FElasticity
  113. end if
  114.  
  115. If rightflipper.currentangle = rightflipper.endangle and RFPress = 1 then
  116. rightflipper.eostorqueangle = EOSAnew
  117. rightflipper.eostorque = EOSTnew
  118. RightFlipper.rampup = EOSRampup
  119. if RFCount = 0 Then RFCount = GameTime
  120. if GameTime - RFCount < LiveCatch Then
  121. rightflipper.Elasticity = 0.1
  122. If RightFlipper.endangle <> RFEndAngle Then rightflipper.endangle = RFEndAngle
  123. Else
  124. rightflipper.Elasticity = FElasticity
  125. end if
  126. elseif rightflipper.currentangle < rightflipper.startangle + 0.05 Then
  127. rightflipper.rampup = SOSRampup
  128. rightflipper.endangle = RFEndAngle + 3
  129. rightflipper.Elasticity = FElasticity
  130. RFCount = 0
  131. elseif rightflipper.currentangle < rightflipper.endangle - 0.01 Then
  132. rightflipper.eostorque = EOST
  133. rightflipper.eostorqueangle = EOSA
  134. RightFlipper.rampup = Frampup
  135. rightflipper.Elasticity = FElasticity
  136. end if
  137.  
  138. end sub
  139.  
  140. dim LFPress, RFPress, EOST, EOSA, EOSTnew, EOSAnew
  141. dim FStrength, Frampup, FElasticity, EOSRampup, SOSRampup
  142. dim RFEndAngle, LFEndAngle, LFCount, RFCount, LiveCatch
  143.  
  144. EOST = leftflipper.eostorque
  145. EOSA = leftflipper.eostorqueangle
  146. FStrength = LeftFlipper.strength
  147. Frampup = LeftFlipper.rampup
  148. FElasticity = LeftFlipper.elasticity
  149. EOSTnew = 1.5 'FEOST
  150. EOSAnew = 0.2
  151. EOSRampup = 1.5
  152. SOSRampup = 8.5
  153. LiveCatch = 12
  154.  
  155. LFEndAngle = Leftflipper.endangle
  156. RFEndAngle = RightFlipper.endangle
  157.  
  158.  
  159. 'Solenoids
  160. 'SolCallback(1)="vpmSolSound SoundFX(""bell10"",DOFChimes),"
  161. 'SolCallback(2)="vpmSolSound SoundFX(""sj_chime_10a"",DOFChimes),"
  162. 'SolCallback(3)="vpmSolSound SoundFX(""sj_chime_100a"",DOFChimes),"
  163. 'SolCallBack(4)="vpmSolSound SoundFX(""sj_chime_1000a"",DOFChimes),"
  164. SolCallback(1)="SolChime1"
  165. SolCallback(2)="SolChime10"
  166. SolCallback(3)="SolChime100"
  167. SolCallBack(4)="SolChime1000"
  168. SolCallback(6)="Solknocker"
  169. SolCallback(7)="bsTrough.SolOut"
  170. SolCallback(9)="solsaucer"
  171. SolCallback(10)="SolLeftTargetReset"
  172. 'SolCallback(11)="vpmSolSound ""jet3""," 'bumper1
  173. 'SolCallback(12)="vpmSolSound ""jet3""," 'bumper2
  174. 'SolCallback(13)="vpmSolSound ""jet3""," 'bumper3
  175. 'SolCallback(14)="vpmSolSound ""sling""," 'right sling
  176. 'SolCallback(15)="vpmSolSound ""sling""," 'left sling
  177. SolCallback(19)="vpmNudge.SolGameOn"
  178.  
  179. SolCallback(sLLFlipper)="SolLFlipper"
  180. SolCallback(sLRFlipper)="SolRFlipper"
  181.  
  182. Sub Table1_Init
  183. vpmInit Me
  184. On Error Resume Next
  185. With Controller
  186. .GameName = cGameName
  187. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  188. .SplashInfoLine = "Dracula"&chr(13)&"(Stern 1979)"
  189. .HandleMechanics=0
  190. .HandleKeyboard=0
  191. .ShowDMDOnly=1
  192. .ShowFrame=0
  193. .ShowTitle=0
  194. .Hidden = HiddenValue
  195. .Run
  196. If Err Then MsgBox Err.Description
  197. On Error Goto 0
  198. End With
  199.  
  200. PinmameTimer.Interval=PinMameInterval
  201. PinmameTimer.Enabled=1
  202.  
  203. Set bsTrough=New cvpmBallstack
  204. with bsTrough
  205. .InitSw 0,8,0,0,0,0,0,0
  206. ' .InitNoTrough BallRelease,8,125,5
  207. .InitKick BallRelease,90,7
  208. .InitExitSnd Soundfx("fx2_ballrel",DOFContactors), Soundfx("fx2_solenoid",DOFContactors)
  209. .Balls=1
  210. end with
  211.  
  212. ' Set bsSaucer=New cvpmBallStack
  213. ' with bsSaucer
  214. ' .InitSaucer sw40,40,108,14
  215. ' .InitExitSnd Soundfx("fx2_ballrel",DOFContactors), Soundfx("fx2_solenoid",DOFContactors)
  216. ' .CreateEvents "bsSaucer", sw40
  217. ' end with
  218. '
  219. Set dtL=New cvpmDropTarget
  220. dtL.InitDrop Array(sw25,sw26,sw27,sw28,sw29),Array(25,26,27,28,29)
  221. dtL.InitSnd SoundFX("fx_droptarget",DOFContactors),SoundFX("fx2_DTReset",DOFContactors)
  222.  
  223. vpmNudge.TiltSwitch=7
  224. vpmNudge.Sensitivity=5
  225. vpmNudge.TiltObj=Array(sw25,sw26,sw27,sw28,sw29,LeftSlingshot,RightSlingshot)
  226. End Sub
  227.  
  228. Sub Table1_KeyDown(ByVal keycode)
  229. If keycode = LeftTiltKey Then Nudge 90, 2
  230. If keycode = RightTiltKey Then Nudge 270, 2
  231. If keycode = CenterTiltKey Then Nudge 0, 2
  232.  
  233. If keycode = LeftFlipperKey Then LFPress = 1
  234. If keycode = RightFlipperKey Then rfpress = 1
  235.  
  236. If vpmKeyDown(keycode) Then Exit Sub
  237. If keycode = PlungerKey Then Plunger.PullBack: PlaySoundAt "fx_plungerpull", Plunger: End If
  238. End Sub
  239.  
  240. Sub Table1_KeyUp(ByVal keycode)
  241. If keycode = PlungerKey Then Plunger.Fire: PlaySoundAt "fx_plunger", Plunger
  242.  
  243. If keycode = LeftFlipperKey Then
  244. lfpress = 0
  245. leftflipper.eostorqueangle = EOSA
  246. leftflipper.eostorque = EOST
  247. End If
  248. If keycode = RightFlipperKey Then
  249. rfpress = 0
  250. rightflipper.eostorqueangle = EOSA
  251. rightflipper.eostorque = EOST
  252. End If
  253.  
  254. If vpmKeyUp(keycode) Then Exit Sub
  255.  
  256. End Sub
  257.  
  258. Sub Drain_Hit()
  259. PlaySoundAt "fx_drain", Drain
  260. RF.PolarityCorrect Activeball
  261. LF.PolarityCorrect Activeball
  262. bstrough.addball me
  263. End Sub
  264.  
  265. '******************************************************
  266. ' Saucer
  267. '******************************************************
  268.  
  269. '*** PI returns the value for PI
  270. Function PI()
  271. PI = 4*Atn(1)
  272. End Function
  273.  
  274. Sub KickBall(kball, kangle, kvel, kvelz, kzlift)
  275. dim rangle
  276. rangle = PI * (kangle - 90) / 180
  277.  
  278. kball.z = kball.z + kzlift
  279. kball.velz = kvelz
  280. kball.velx = cos(rangle)*kvel
  281. kball.vely = sin(rangle)*kvel
  282. End Sub
  283.  
  284.  
  285. Dim KickerBall
  286.  
  287. '
  288. Sub sw12b_Hit
  289. set KickerBall = activeball
  290. Controller.Switch(12) = 1
  291. End Sub
  292.  
  293. Sub sw12b_unHit
  294. Controller.Switch(12) = 0
  295. End Sub
  296.  
  297. Sub sw12a_Hit
  298. set KickerBall = activeball
  299. Controller.Switch(12) = 1
  300. End Sub
  301.  
  302. Sub sw12a_unHit
  303. Controller.Switch(12) = 0
  304. End Sub
  305.  
  306. dim kickstep1
  307.  
  308. Sub SolSaucer(Enable)
  309. If Enable then
  310. PlaySoundAtVol "saucerin", sw12a, 3
  311. ' bsSaucer.ExitSol_On
  312. kickstep1 = 0
  313. pkickarm.objrotz=15:pkickarm001.objrotz=15
  314. If sw12a.ballcntover > 0 then
  315. PlaySoundAtVol "saucerkick",sw12a, 3
  316. KickBall KickerBall, 200, 14, 5, 30
  317. End If
  318. If sw12b.ballcntover > 0 then
  319. PlaySoundAtVol "saucerkick",sw12b, 3
  320. KickBall KickerBall, 190, 14, 5, 30
  321. End If
  322. sw12b.timerenabled = 1
  323. End If
  324. End Sub
  325.  
  326. Sub sw12b_timer
  327. Select Case kickstep1
  328. Case 3:pkickarm.objrotz=15:pkickarm001.objrotz=15
  329. Case 4:pkickarm.objrotz=15:pkickarm001.objrotz=15
  330. Case 5:pkickarm.objrotz=15:pkickarm001.objrotz=15
  331. Case 6:pkickarm.objrotz=15:pkickarm001.objrotz=15
  332. Case 7:pkickarm.objrotz=8:pkickarm001.objrotz=8
  333. Case 8:pkickarm.objrotz=3:pkickarm001.objrotz=3
  334. Case 9:pkickarm.objrotz=0:pkickarm001.objrotz=0:sw12b.TimerEnabled = 0: if sw12b.ballcntover > 0 then SolSaucer -1
  335. End Select
  336. kickstep1 = kickstep1 + 1
  337. End Sub
  338.  
  339. dim d25step, d26step, d27step, d28step, d29step
  340.  
  341. 'Drop Targets
  342. Sub sw25_Hit: dtl.Hit 1:playsoundat SoundFX("fx2_droptarget",DOFContactors),sw25
  343. drop25.transz=-25
  344. d25step = 0
  345. ' f25.visible=0
  346. sw25.timerenabled=1
  347. sw25.collidable=0
  348. End Sub
  349.  
  350. Sub sw25_timer
  351. Select Case d25step
  352. Case 3:drop25.transz=-24
  353. Case 4:drop25.transz=-36
  354. Case 5:drop25.transz=-43:sw25.TimerEnabled = 0
  355. End Select
  356. d25Step = d25Step + 1
  357. End Sub
  358.  
  359. Sub sw26_Hit: dtl.Hit 2:playsoundat SoundFX("fx2_droptarget",DOFContactors),sw26
  360. drop26.transz=-12
  361. d26step = 0
  362. ' f26.visible=0
  363. sw26.timerenabled=1
  364. sw26.collidable=0
  365. End Sub
  366.  
  367. Sub sw26_timer
  368. Select Case d26step
  369. Case 3:drop26.transz=-24
  370. Case 4:drop26.transz=-36
  371. Case 5:drop26.transz=-43:sw26.TimerEnabled = 0
  372. End Select
  373. d26Step = d26Step + 1
  374. End Sub
  375.  
  376. Sub sw27_Hit: dtL.Hit 3:playsoundat SoundFX("fx2_droptarget2",DOFContactors),sw27
  377. drop27.transz=-12
  378. d27step = 0
  379. ' f27.visible=0
  380. sw27.timerenabled=1
  381. sw27.collidable=0
  382. End Sub
  383.  
  384. Sub sw27_timer
  385. Select Case d27step
  386. Case 3:drop27.transz=-24
  387. Case 4:drop27.transz=-36
  388. Case 5:drop27.transz=-43:sw27.TimerEnabled = 0
  389. End Select
  390. d27Step = d27Step + 1
  391. End Sub
  392.  
  393. Sub sw28_Hit: dtl.Hit 4:playsoundat SoundFX("fx2_droptarget",DOFContactors),sw28
  394. drop28.transz=-12
  395. d28step = 0
  396. ' f28.visible=0
  397. sw28.timerenabled=1
  398. sw28.collidable=0
  399. End Sub
  400.  
  401. Sub sw28_timer
  402. Select Case d28step
  403. Case 3:drop28.transz=-24
  404. Case 4:drop28.transz=-36
  405. Case 5:drop28.transz=-43:sw28.TimerEnabled = 0
  406. End Select
  407. d28Step = d28Step + 1
  408. End Sub
  409.  
  410. Sub sw29_Hit: dtL.Hit 5:playsoundat SoundFX("fx2_droptarget",DOFContactors),sw29
  411. drop29.transz=-12
  412. d29step = 0
  413. ' f29.visible=0
  414. sw29.timerenabled=1
  415. sw29.collidable=0
  416. End Sub
  417.  
  418. Sub sw29_timer
  419. Select Case d29step
  420. Case 3:drop29.transz=-24
  421. Case 4:drop29.transz=-36
  422. Case 5:drop29.transz=-43:sw29.TimerEnabled = 0
  423. End Select
  424. d29Step = d29Step + 1
  425. End Sub
  426.  
  427. Sub SolLeftTargetReset(enabled)
  428. if enabled then
  429. dtL.SolDropUp enabled
  430. LDrop.enabled = True
  431. end if
  432. End Sub
  433.  
  434. Sub LDrop_timer()
  435. dim xx
  436. For each xx in DTLeftLights: xx.visible=1:Next
  437. sw25.collidable=1:sw26.collidable=1:sw27.collidable=1:sw28.collidable=1:sw29.collidable=1
  438. drop25.transz=0:drop26.transz=0:drop27.transz=0:drop28.transz=0:drop29.transz=0
  439. me.enabled = false
  440. End Sub
  441.  
  442. '***********************************
  443. ' Bumpers
  444. '***********************************
  445.  
  446. dim bump1step, bump2step, bump3step
  447.  
  448. Sub sw38_Hit
  449. vpmTimer.PulseSw 38
  450. playsoundAtVol SoundFX("fx2_bumper1",DOFContactors), sw38, VolBump
  451. layer1bumpskirt1.RotY=-3
  452. Bump1Step = 0
  453. sw38.timerenabled = 1
  454. End Sub
  455.  
  456. Sub sw38_timer
  457. Select Case Bump1Step
  458. Case 3: layer1bumpskirt1.RotY=-1
  459. Case 4: layer1bumpskirt1.RotY=1
  460. Case 5: layer1bumpskirt1.RotY=-1
  461. Case 6: layer1bumpskirt1.RotY=1
  462. Case 7: layer1bumpskirt1.RotY=0:sw38.timerenabled = 0
  463. End Select
  464. Bump1Step=Bump1Step + 1
  465. End Sub
  466.  
  467. Sub sw39_Hit
  468. vpmTimer.PulseSw 39
  469. playsoundAtVol SoundFX("fx2_bumper2",DOFContactors), sw39, VolBump
  470. layer1bumpskirt2.RotY=-5
  471. bump2step = 0
  472. sw39.timerenabled = 1
  473. End Sub
  474.  
  475. Sub sw39_timer
  476. Select Case bump2step
  477. Case 3: layer1bumpskirt2.RotY=-3
  478. Case 4: layer1bumpskirt2.RotY=2
  479. Case 5: layer1bumpskirt2.RotY=-1
  480. Case 6: layer1bumpskirt2.RotY=1
  481. Case 7: layer1bumpskirt2.RotY=0:sw39.timerenabled = 0
  482. End Select
  483. bump2step=bump2step + 1
  484. End Sub
  485.  
  486. Sub sw40_Hit
  487. vpmTimer.PulseSw 40
  488. playsoundAtVol SoundFX("fx2_bumper1",DOFContactors), sw40, VolBump
  489. layer1bumpskirt3.RotY=-5
  490. bump3step = 0
  491. sw40.timerenabled = 1
  492. End Sub
  493.  
  494. Sub sw40_timer
  495. Select Case bump3step
  496. Case 3: layer1bumpskirt3.RotY=-3
  497. Case 4: layer1bumpskirt3.RotY=2
  498. Case 5: layer1bumpskirt3.RotY=-1
  499. Case 6: layer1bumpskirt3.RotY=1
  500. Case 7: layer1bumpskirt3.RotY=0:sw40.timerenabled = 0
  501. End Select
  502. bump3step=bump3step + 1
  503. End Sub
  504.  
  505. 'Rollovers
  506. Sub SW14_Hit:Controller.Switch(14)=1:b14.transz=-12: End Sub
  507. Sub SW14_unHit:Controller.Switch(14)=0:b14.transz=0:End Sub
  508. Sub SW23_Hit:Controller.Switch(23)=1:w23.transz=-12: End Sub
  509. Sub SW23_unHit:Controller.Switch(23)=0:w23.transz=0:End Sub
  510. Sub SW24_Hit:Controller.Switch(24)=1:w24.transz=-12: End Sub
  511. Sub SW24_unHit:Controller.Switch(24)=0:w24.transz=0:End Sub
  512. Sub SW30a_Hit:Controller.Switch(30)=1:b30a.transz=-12: End Sub
  513. Sub SW30a_unHit:Controller.Switch(30)=0:b30a.transz=0:End Sub
  514. Sub SW30b_Hit:Controller.Switch(30)=1:b30b.transz=-12: End Sub
  515. Sub SW30b_unHit:Controller.Switch(30)=0:b30b.transz=0:End Sub
  516. Sub SW30c_Hit:Controller.Switch(30)=1:b30c.transz=-12: End Sub
  517. Sub SW30c_unHit:Controller.Switch(30)=0:b30c.transz=0:End Sub
  518. Sub SW30d_Hit:Controller.Switch(30)=1:b30d.transz=-12: End Sub
  519. Sub SW30d_unHit:Controller.Switch(30)=0:b30d.transz=0:End Sub
  520. Sub SW30e_Hit:Controller.Switch(30)=1:b30e.transz=-12: End Sub
  521. Sub SW30e_unHit:Controller.Switch(30)=0:b30e.transz=0:End Sub
  522. Sub SW31_Hit:Controller.Switch(31)=1:w31.transz=-12: End Sub
  523. Sub SW31_unHit:Controller.Switch(31)=0:w31.transz=0:End Sub
  524. Sub SW32_Hit:Controller.Switch(32)=1:w32.transz=-12:DOF 105, DOFOn:End Sub
  525. Sub SW32_unHit:Controller.Switch(32)=0:w32.transz=0:DOF 105, DOFOff:End Sub
  526.  
  527. 'Wire Triggers
  528. Sub SW1_Hit:Controller.Switch(1)=1 : End Sub
  529. Sub SW1_unHit:Controller.Switch(1)=0:End Sub
  530. Sub SW2_Hit:Controller.Switch(2)=1 : End Sub
  531. Sub SW2_unHit:Controller.Switch(2)=0:End Sub
  532. Sub SW3_Hit:Controller.Switch(3)=1 : End Sub
  533. Sub SW3_unHit:Controller.Switch(3)=0:End Sub
  534. Sub SW4_Hit:Controller.Switch(4)=1 : End Sub
  535. Sub SW4_unHit:Controller.Switch(4)=0:End Sub
  536.  
  537. 'Leaf Switches
  538. Sub SW21_Hit:vpmTimer.PulseSw (21) : End Sub
  539. Sub SW22b_Hit:vpmTimer.PulseSw (22) : End Sub
  540.  
  541. 'Spinners
  542. Sub sw30s_Spin : vpmTimer.PulseSw (30) :PlaySoundAtVol "fx2_spinner", sw30s, VolSpin:DOF 103, DOFPulse:End Sub
  543.  
  544. '***********Rotate Spinner
  545. Dim Angle
  546.  
  547. Sub SpinnerTimer_Timer
  548. Angle = (sin (sw30s.CurrentAngle-180))
  549. SpinnerRod.TransZ = -sin( (sw30s.CurrentAngle+180) * (2*3.14/360)) * 5
  550. SpinnerRod.TransX = (sin( (sw30s.CurrentAngle- 90) * (2*3.14/360)) * -5)
  551. End Sub
  552.  
  553. 'Targets
  554. Dim Step5, Step18, Step22, Step23, Step32
  555.  
  556. Sub sw5_Hit
  557. vpmTimer.PulseSw (5)
  558. sw5target.TransX=-5
  559. Timer5.enabled = 1
  560. Step5 = 0
  561. end sub
  562.  
  563. Sub Timer5_timer
  564. Select Case Step5
  565. Case 3: sw5target.TransX=3
  566. Case 4: sw5target.TransX=-4
  567. Case 5: sw5target.TransX=2
  568. Case 6: sw5target.TransX=-3
  569. Case 7: sw5target.TransX=1
  570. Case 8: sw5target.TransX=-2
  571. Case 9: sw5target.TransX=0
  572. Case 10: sw5target.TransX=-1: Timer5.enabled = 0
  573. End Select
  574. Step5=Step5 + 1
  575. End Sub
  576.  
  577. Sub sw18_Hit
  578. vpmTimer.PulseSw (18)
  579. sw18target.TransX=-5
  580. Timer18.enabled = 1
  581. Step18 = 0
  582. end sub
  583.  
  584. Sub Timer18_timer
  585. Select Case Step18
  586. Case 3: sw18target.TransX=3
  587. Case 4: sw18target.TransX=-4
  588. Case 5: sw18target.TransX=2
  589. Case 6: sw18target.TransX=-3
  590. Case 7: sw18target.TransX=1
  591. Case 8: sw18target.TransX=-2
  592. Case 9: sw18target.TransX=0
  593. Case 10: sw18target.TransX=-1: Timer18.enabled = 0
  594. End Select
  595. Step18=Step18 + 1
  596. End Sub
  597.  
  598. Sub sw30ta_Hit
  599. DODF 101, DOFPulse
  600. vpmTimer.PulseSw (30)
  601. t30ta.Transy=-5
  602. Timer22.enabled = 1
  603. Step22 = 0
  604. end sub
  605.  
  606. Sub Timer22_timer
  607. Select Case Step22
  608. Case 3: t30ta.transy=3
  609. Case 4: t30ta.transy=-4
  610. Case 5: t30ta.transy=2
  611. Case 6: t30ta.transy=-3
  612. Case 7: t30ta.transy=1
  613. Case 8: t30ta.transy=-2
  614. Case 9: t30ta.transy=0
  615. Case 10: t30ta.transy=-1: Timer22.enabled = 0
  616. End Select
  617. Step22=Step22 + 1
  618. End Sub
  619.  
  620. Sub sw30tb_Hit
  621. DOF 102, DOFPulse
  622. vpmTimer.PulseSw (30)
  623. t30tb.transy=-5
  624. Timer23.enabled = 1
  625. Step23 = 0
  626. end sub
  627.  
  628. Sub Timer23_timer
  629. Select Case Step23
  630. Case 3: t30tb.transy=3
  631. Case 4: t30tb.transy=-4
  632. Case 5: t30tb.transy=2
  633. Case 6: t30tb.transy=-3
  634. Case 7: t30tb.transy=1
  635. Case 8: t30tb.transy=-2
  636. Case 9: t30tb.transy=0
  637. Case 10: t30tb.transy=-1: Timer23.enabled = 0
  638. End Select
  639. Step23=Step23 + 1
  640. End Sub
  641.  
  642. Sub sw32a_Hit
  643. DOF 104, DOFPulse
  644. vpmTimer.PulseSw (32)
  645. t32a.transy=-5
  646. Timer32.enabled = 1
  647. Step32 = 0
  648. end sub
  649.  
  650. Sub Timer32_timer
  651. Select Case Step32
  652. Case 3: t32a.transy=3
  653. Case 4: t32a.transy=-4
  654. Case 5: t32a.transy=2
  655. Case 6: t32a.transy=-3
  656. Case 7: t32a.transy=1
  657. Case 8: t32a.transy=-2
  658. Case 9: t32a.transy=0
  659. Case 10: t32a.transy=-1: Timer32.enabled = 0
  660. End Select
  661. Step32=Step32 + 1
  662. End Sub
  663.  
  664. Sub SolKnocker(Enabled)
  665. If Enabled Then PlaySound SoundFX("Fx2_Knocker",DOFKnocker)
  666. End Sub
  667.  
  668. '**********Sling Shot Animations
  669. ' Rstep and Lstep are the variables that increment the animation
  670. '****************
  671. Dim RStep, Lstep, AStep, BStep, LWall1Step, RWall1Step, LWall2Step
  672.  
  673. Sub RightSlingShot_Slingshot
  674. PlaySoundAt SoundFX("fx2_slingshot1",DOFContactors), sling1
  675. vpmtimer.PulseSw(36)
  676. RSling.Visible = 0
  677. RSling1.Visible = 1
  678. sling1.TransZ = -31
  679. RStep = 0
  680. RightSlingShot.TimerEnabled = 1
  681. End Sub
  682.  
  683. Sub RightSlingShot_Timer
  684. Select Case RStep
  685. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  686. Case 4:RSLing2.Visible = 0:RSLing3.Visible = 1:sling1.TransZ = 0
  687. Case 5:RSLing3.Visible = 0:RSLing.Visible = 1:RightSlingShot.TimerEnabled = 0
  688. End Select
  689. RStep = RStep + 1
  690. End Sub
  691.  
  692. Sub LeftSlingShot_Slingshot
  693. PlaySoundAt SoundFX("fx2_slingshot2",DOFContactors),sling2
  694. vpmtimer.pulsesw(37)
  695. LSling.Visible = 0
  696. LSling1.Visible = 1
  697. sling2.TransZ = -32
  698. LStep = 0
  699. LeftSlingShot.TimerEnabled = 1
  700. End Sub
  701.  
  702. Sub LeftSlingShot_Timer
  703. Select Case LStep
  704. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  705. Case 4:LSLing2.Visible = 0:LSLing3.Visible = 1:sling2.TransZ = 0
  706. Case 5:LSLing3.Visible = 0:LSLing.Visible = 1:LeftSlingShot.TimerEnabled = 0
  707. End Select
  708. LStep = LStep + 1
  709. End Sub
  710.  
  711. Sub sw21a_hit
  712. vpmTimer.PulseSw (21)
  713. larubber.Visible = 0
  714. larubber1.Visible = 1
  715. lWall1Step = 0
  716. lWall1.enabled=true
  717. End Sub
  718.  
  719. Sub lWall1_Timer
  720. Select Case lWall1Step
  721. Case 3:larubber1.Visible = 0:larubber2.Visible = 1
  722. Case 4:larubber2.Visible = 0:larubber3.Visible = 1
  723. Case 5:larubber3.Visible = 0:larubber.Visible = 1:lWall1.enabled=false
  724. End Select
  725. lWall1Step = lWall1Step + 1
  726. End Sub
  727.  
  728. Sub sw21b_hit
  729. vpmTimer.PulseSw (21)
  730. rarubber.Visible = 0
  731. rarubber1.Visible = 1
  732. rWall1Step = 0
  733. rWall1.enabled=true
  734. End Sub
  735.  
  736. Sub rWall1_Timer
  737. Select Case RWall1Step
  738. Case 3:rarubber1.Visible = 0:rarubber2.Visible = 1
  739. Case 4:rarubber2.Visible = 0:rarubber3.Visible = 1
  740. Case 5:rarubber3.Visible = 0:rarubber.Visible = 1:RWall1.enabled=false
  741. End Select
  742. rWall1Step = rWall1Step + 1
  743. End Sub
  744.  
  745. Sub sw22a_hit
  746. vpmTimer.PulseSw (22)
  747. lbrubber.Visible = 0
  748. lbrubber1.Visible = 1
  749. lWall2Step = 0
  750. lWall2.enabled=true
  751. End Sub
  752.  
  753. Sub lWall2_Timer
  754. Select Case lWall2Step
  755. Case 3:lbrubber1.Visible = 0:lbrubber2.Visible = 1
  756. Case 4:lbrubber2.Visible = 0:lbrubber3.Visible = 1
  757. Case 5:lbrubber3.Visible = 0:lbrubber.Visible = 1:lWall2.enabled=false
  758. End Select
  759. lWall2Step = lWall2Step + 1
  760. End Sub
  761.  
  762. 'Chimes
  763.  
  764. Sub solchime1(Enable)
  765. If Enable then
  766. PlaySound SoundFX("bell10",DOFChimes), 1, 1
  767. End If
  768. End Sub
  769.  
  770. Sub solchime10(Enable)
  771. If Enable then
  772. PlaySound SoundFX("sj_chime_10a",DOFChimes), 1, 1
  773. End If
  774. End Sub
  775.  
  776. Sub solchime100(Enable)
  777. If Enable then
  778. PlaySound SoundFX("sj_chime_100a",DOFChimes), 1, 1
  779. End If
  780. End Sub
  781.  
  782. Sub solchime1000(Enable)
  783. If Enable then
  784. PlaySound SoundFX("sj_chime_1000a",DOFChimes), 1, 1
  785. End If
  786. End Sub
  787.  
  788. '-------------------------------------
  789. ' Map lights into array
  790. ' Set unmapped lamps to Nothing
  791. '-------------------------------------
  792.  
  793. Set Lights(1)=L001
  794. Set Lights(2)=L002
  795. Set Lights(3)=L003
  796. Set Lights(4)=L004
  797. Lights(5)=Array(L005,L005a)
  798. Lights(9)=Array(L009,L009a)
  799. Lights(10)=Array(L010,L010a)
  800. Lights(11)=Array(L011,L011a)
  801. Lights(12)=Array(l012,l012a,l012b,L012c,L012d,L012e)
  802. Set Lights(16)=L016
  803. Set Lights(17)=L017
  804. Set Lights(18)=L018
  805. Set Lights(19)=L019
  806. Lights(20)=Array(L020,L020a)
  807. Lights(21)=Array(L021,L021a)
  808. Lights(25)=Array(L025,L025a)
  809. Set Lights(33)=L033
  810. Set Lights(34)=L034
  811. Set Lights(36)=L036
  812. Set Lights(37)=L037
  813. Lights(38)=Array(L038,L038a)
  814. Lights(41)=Array(L041,L041a)
  815. Set Lights(44)=L044
  816. Set Lights(48)=L048
  817. Set Lights(49)=L049
  818. Set Lights(50)=L050
  819. Lights(52)=Array(L052,L052a,L052b,L052c)
  820. Lights(53)=Array(L053,L053a)
  821. Set Lights(55)=L055
  822. Lights(57)=Array(L057,L057a)
  823. Set Lights(58)=L058
  824. Set Lights(64)=L064
  825.  
  826. Set vpmShowDips = GetRef("editDips")
  827.  
  828. '*****************************************
  829. ' FLIPPER SHADOWS
  830. '*****************************************
  831.  
  832. sub FlipperTimer_Timer()
  833. FlipperLSh.RotZ = LeftFlipper.currentangle
  834. ' FlipperLSh1.RotZ = LeftFlipper1.currentangle
  835. FlipperRSh.RotZ = RightFlipper.currentangle
  836. If l005.state=1 Then
  837. b14.image="b14on"
  838. Else
  839. b14.image="b14off"
  840. End If
  841. If l036.state=1 Then
  842. bumpbase12.image="bumpbase"
  843. bumpbase3.image="bumpbaseoff"
  844. bumpcap12.image="bumpcap"
  845. bumpcap3.image="bumpcapoff"
  846. layer1bumpskirt1.image="bumpskirts"
  847. layer1bumpskirt2.image="bumpskirts"
  848. layer1bumpskirt3.image="bumpskirtsoff"
  849. Else
  850. bumpbase12.image="bumpbaseoff"
  851. bumpbase3.image="bumpbase"
  852. bumpcap12.image="bumpcapoff"
  853. bumpcap3.image="bumpcap"
  854. layer1bumpskirt1.image="bumpskirtsoff"
  855. layer1bumpskirt2.image="bumpskirtsoff"
  856. layer1bumpskirt3.image="bumpskirts"
  857. End If
  858. End Sub
  859.  
  860. '*****************************************
  861. ' BALL SHADOW
  862. '*****************************************
  863. Dim BallShadow
  864. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  865.  
  866. Sub BallShadowUpdate_timer()
  867. Dim BOT, b
  868. BOT = GetBalls
  869. ' hide shadow of deleted balls
  870. If UBound(BOT)<(tnob-1) Then
  871. For b = (UBound(BOT) + 1) to (tnob-1)
  872. BallShadow(b).visible = 0
  873. Next
  874. End If
  875. ' exit the Sub if no balls on the table
  876. If UBound(BOT) = -1 Then Exit Sub
  877. ' render the shadow for each ball
  878. For b = 0 to UBound(BOT)
  879. If BOT(b).X < Table1.Width/2 Then
  880. BallShadow(b).X = ((BOT(b).X) + ((BOT(b).X - (Table1.Width/2))/7))
  881. Else
  882. BallShadow(b).X = ((BOT(b).X) + ((BOT(b).X - (Table1.Width/2))/7))
  883. End If
  884. ballShadow(b).Y = BOT(b).Y + 10
  885. If BOT(b).Z > 20 Then
  886. BallShadow(b).visible = 1
  887. Else
  888. BallShadow(b).visible = 0
  889. End If
  890. Next
  891. End Sub
  892.  
  893. '******************************
  894. ' Diverse Collection Hit Sounds
  895. '******************************
  896.  
  897. 'Sub aBumpers_Hit (idx): PlaySound SoundFX("fx_bumper", DOFContactors), 0, 1, pan(ActiveBall): End Sub
  898. Sub aRollovers_Hit(idx):PlaySound "fx2_sensor", 0, Vol(ActiveBall)*VolRol, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  899. Sub aGates_Hit(idx):PlaySound "fx_Gate", 0, Vol(ActiveBall)*VolGates, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  900. Sub aMetals_Hit(idx):PlaySound "fx2_MetalHit2", 0, Vol(ActiveBall)*VolMetal, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  901. Sub aRubber_Bands_Hit(idx):PlaySound "fx2_rubber", 0, Vol(ActiveBall)*VolRB, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  902. Sub aRubbers_Hit(idx):PlaySound "fx_postrubber", 0, Vol(ActiveBall)*VolRH, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  903. Sub aRubber_Posts_Hit(idx):PlaySound "fx_postrubber", 0, Vol(ActiveBall)*VolPo, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  904. Sub aRubber_Pins_Hit(idx):PlaySound "fx_postrubber", 0, Vol(ActiveBall)*VolPi, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  905. Sub aPlastics_Hit(idx):PlaySound "fx_PlasticHit", 0, Vol(ActiveBall)*VolPlast, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  906. Sub aTargets_Hit(idx):PlaySound "fx2_target", 0, Vol(ActiveBall)*VolTarg, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  907. Sub aWoods_Hit(idx):PlaySound "fx2_Woodhit3", 0, Vol(ActiveBall)*VolWood, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
  908.  
  909. '**********************************************************************************************************
  910. 'Stern Stingray
  911. 'added by Inkochnito
  912.  
  913. Sub editDips
  914. Dim vpmDips : Set vpmDips = New cvpmDips
  915. With vpmDips
  916. .AddForm 700,400,"Stingray - DIP switches"
  917. .AddFrame 2,0,190,"Maximum credits",&H00070000,Array("10 credits",&H00010000,"20 credits",&H00030000,"30 credits",&H00050000,"40 credits",&H00070000)'dip 17&18&19
  918. .AddFrame 2,76,190,"High game to date award",&H00004000,Array("3 balls - 500K, 5 balls - 840K",0,"3 free games",&H00004000)'dip 15
  919. .AddFrame 2,122,190,"High score award",&H00000020,Array("extra ball",0,"replay",&H00000020)'dip 6
  920. .AddFrame 2,168,190,"Balls per game",&H00000040,Array("3 balls",0,"5 balls",&H00000040)'dip 7
  921. .AddChk 2,220,140,Array("Credits displayed",&H00080000)'dip 20
  922. .AddChk 2,235,120,Array("Match feature",&H00100000)'dip 21
  923. .AddChk 2,250,120,Array("4 player games",&H01000000)'dip 25
  924. .AddChk 2,265,200,Array("Extra Balls (custom ROM only)",&H02000000)'dip 26
  925. .AddFrame 205,0,190,"Special award",&HC0000000,Array("100.000 points",0,"free ball",&H40000000,"free game",&H80000000,"free ball and free game",&HC0000000)'dip 31&32
  926. .AddFrame 205,76,190,"Feature lites adjustment",32768,Array("all lites on",0,"lites alternating",32768)'dip 16
  927. .AddFrame 205,122,190,"Drop target special",&H00800000,Array("special lite on only",0,"special lite on and 1 replay",&H00800000)'dip 24
  928. .AddFrame 205,168,190,"Melody option",&H00000080,Array("2 tones only",0,"full melody",&H00000080)'dip 8
  929. .AddLabel 50,280,340,20,"After hitting OK, press F3 to reset game with new settings."
  930. .ViewDips
  931. End With
  932. End Sub
  933.  
  934. Set vpmShowDips = GetRef("editDips")
  935.  
  936. Sub table1_Paused:Controller.Pause = 1:End Sub
  937. Sub table1_unPaused:Controller.Pause = 0:End Sub
  938. Sub table1_Exit:Controller.Stop:End Sub
  939.  
  940. ' *******************************************************************************************************
  941. ' Positional Sound Playback Functions by DJRobX
  942. ' PlaySound sound, 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  943. ' *******************************************************************************************************
  944.  
  945. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  946. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  947. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  948.  
  949. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  950. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  951. End Sub
  952.  
  953. ' Set position as table object (Use object or light but NOT wall) and Vol to 1
  954.  
  955. Sub PlaySoundAt(soundname, tableobj)
  956. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  957. End Sub
  958.  
  959. 'Set all as per ball position & speed.
  960.  
  961. Sub PlaySoundAtBall(soundname)
  962. PlaySoundAt soundname, ActiveBall
  963. End Sub
  964.  
  965. 'Set position as table object and Vol manually.
  966.  
  967. Sub PlaySoundAtVol(sound, tableobj, Vol)
  968. PlaySound sound, 1, Vol, Pan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  969. End Sub
  970.  
  971. 'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
  972.  
  973. Sub PlaySoundAtBallVol(sound, VolMult)
  974. PlaySound sound, 0, Vol(ActiveBall) * VolMult, Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
  975. End Sub
  976.  
  977. 'Set position as bumperX and Vol manually.
  978.  
  979. Sub PlaySoundAtBumperVol(sound, tableobj, Vol)
  980. PlaySound sound, 1, Vol, Pan(tableobj), 0,0,1, 1, AudioFade(tableobj)
  981. End Sub
  982.  
  983. '*********************************************************************
  984. ' Supporting Ball & Sound Functions
  985. '*********************************************************************
  986.  
  987. 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
  988. Dim tmp
  989. tmp = tableobj.y * 2 / table1.height-1
  990. If tmp > 0 Then
  991. AudioFade = Csng(tmp ^10)
  992. Else
  993. AudioFade = Csng(-((- tmp) ^10) )
  994. End If
  995. End Function
  996.  
  997. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  998. Dim tmp
  999. tmp = tableobj.x * 2 / table1.width-1
  1000. If tmp > 0 Then
  1001. AudioPan = Csng(tmp ^10)
  1002. Else
  1003. AudioPan = Csng(-((- tmp) ^10) )
  1004. End If
  1005. End Function
  1006.  
  1007. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  1008. Dim tmp
  1009. tmp = ball.x * 2 / table1.width-1
  1010. If tmp > 0 Then
  1011. Pan = Csng(tmp ^10)
  1012. Else
  1013. Pan = Csng(-((- tmp) ^10) )
  1014. End If
  1015. End Function
  1016.  
  1017. Function AudioFade(ball) ' Can this be together with the above function ?
  1018. Dim tmp
  1019. tmp = ball.y * 2 / Table1.height-1
  1020. If tmp > 0 Then
  1021. AudioFade = Csng(tmp ^10)
  1022. Else
  1023. AudioFade = Csng(-((- tmp) ^10) )
  1024. End If
  1025. End Function
  1026.  
  1027. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  1028. Vol = Csng(BallVel(ball) ^2 / VolDiv)
  1029. End Function
  1030.  
  1031. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  1032. Pitch = BallVel(ball) * 20
  1033. End Function
  1034.  
  1035. Function BallVel(ball) 'Calculates the ball speed
  1036. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  1037. End Function
  1038.  
  1039. '*****************************************
  1040. ' JP's VP10 Rolling Sounds
  1041. '*****************************************
  1042.  
  1043. Const tnob = 5 ' total number of balls
  1044. ReDim rolling(tnob)
  1045. InitRolling
  1046.  
  1047. ReDim ArchRolling(tnob)
  1048. InitArchRolling
  1049.  
  1050. Dim ArchHit
  1051.  
  1052. Sub phys_metals001_Hit
  1053. Archhit = 1
  1054. End Sub
  1055.  
  1056. Sub NotOnArch_Hit
  1057. ArchHit = 0
  1058. End Sub
  1059.  
  1060. Sub NotOnArch_unHit
  1061. ArchHit = 0
  1062. End Sub
  1063.  
  1064. Sub InitRolling
  1065. Dim i
  1066. For i = 0 to tnob
  1067. rolling(i) = False
  1068. Next
  1069. End Sub
  1070.  
  1071. Sub InitArchRolling
  1072. Dim i
  1073. For i = 0 to tnob
  1074. ArchRolling(i) = False
  1075. Next
  1076. End Sub
  1077.  
  1078. Sub RollingTimer_Timer()
  1079. Dim BOT, b
  1080. BOT = GetBalls
  1081.  
  1082. ' stop the sound of deleted balls
  1083. For b = UBound(BOT) + 1 to tnob
  1084. rolling(b) = False
  1085. StopSound("fx_Rolling_Wood" & b)
  1086. StopSound("fx_Rolling_Plastic" & b)
  1087. StopSound("fx_Rolling_Metal" & b)
  1088. Next
  1089.  
  1090. ' exit the sub if no balls on the table
  1091. If UBound(BOT) = -1 Then Exit Sub
  1092.  
  1093. ' play the rolling sound for each ball
  1094. For b = 0 to UBound(BOT)
  1095. If BallVel(BOT(b) ) > 1 Then
  1096.  
  1097. ' ***Ball on WOOD playfield***
  1098. if BOT(b).z < 27 Then
  1099. PlaySound("fx_Rolling_Wood" & b), -1, Vol(BOT(b) )/2, AudioPan(BOT(b) )/5, 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
  1100. rolling(b) = True
  1101. StopSound("fx_Rolling_Plastic" & b)
  1102. StopSound("fx_Rolling_Metal" & b)
  1103. ' ***Ball on PLASTIC ramp***
  1104. Elseif BOT(b).z > 28 Then
  1105. PlaySound("fx_Rolling_Plastic" & b), -1, Vol(BOT(b) ), AudioPan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
  1106. rolling(b) = True
  1107. StopSound("fx_Rolling_Wood" & b)
  1108. StopSound("fx_Rolling_Metal" & b)
  1109. Else
  1110. if rolling(b) = true Then
  1111. rolling(b) = False
  1112. StopSound("fx_Rolling_Wood" & b)
  1113. StopSound("fx_Rolling_Plastic" & b)
  1114. StopSound("fx_Rolling_Metal" & b)
  1115. end if
  1116. End If
  1117. Else
  1118. If rolling(b) = True Then
  1119. StopSound("fx_Rolling_Wood" & b)
  1120. StopSound("fx_Rolling_Plastic" & b)
  1121. StopSound("fx_Rolling_Metal" & b)
  1122. rolling(b) = False
  1123. End If
  1124.  
  1125. End If
  1126.  
  1127. '***Ball Drop Sounds***
  1128.  
  1129. If BOT(b).VelZ < -1 and BOT(b).z < 50 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  1130. PlaySoundAtBOTBallZ "fx_ball_drop" & b, BOT(b)
  1131. End If
  1132.  
  1133. If BallVel(BOT(b) ) > 1 AND ArchHit =1 Then
  1134. ArchRolling(b) = True
  1135. PlaySound("ArchHitA" & b), 0, (BallVel(BOT(b))/15)^5 * 1, AudioPan(BOT(b)), 0, (BallVel(BOT(b))/40)^7, 1, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  1136. PlaySound("ArchRollA" & b), -1, (BallVel(BOT(b))/30)^5 * 1, AudioPan(BOT(b)), 0, (BallVel(BOT(b))/40)^7, 1, 0, 0 'Left & Right stereo or Top & Bottom stereo PF Speakers.
  1137. Else
  1138. If ArchRolling(b) = True Then
  1139. StopSound("ArchRollA" & b)
  1140. ArchRolling(b) = False
  1141. End If
  1142. End If
  1143. Next
  1144. End Sub
  1145.  
  1146. Sub PlaySoundAtBOTBall(sound, BOT)
  1147. PlaySound sound, 0, Vol(BOT), AudioPan(BOT), 0, Pitch(BOT), 0, 1, AudioFade(BOT)
  1148. End Sub
  1149.  
  1150. Sub PlaySoundAtBOTBallZ(sound, BOT)
  1151. PlaySound sound, 0, ABS(BOT.velz)/17, AudioPan(BOT), 0, Pitch(BOT), 1, 0, AudioFade(BOT)
  1152. End Sub
  1153.  
  1154. '*** Determines if a Points (px,py) is inside a 4 point polygon A-D in Clockwise/CCW order
  1155. Function InRect(px,py,ax,ay,bx,by,cx,cy,dx,dy)
  1156. Dim AB, BC, CD, DA
  1157. AB = (bx*py) - (by*px) - (ax*py) + (ay*px) + (ax*by) - (ay*bx)
  1158. BC = (cx*py) - (cy*px) - (bx*py) + (by*px) + (bx*cy) - (by*cx)
  1159. CD = (dx*py) - (dy*px) - (cx*py) + (cy*px) + (cx*dy) - (cy*dx)
  1160. DA = (ax*py) - (ay*px) - (dx*py) + (dy*px) + (dx*ay) - (dy*ax)
  1161.  
  1162. 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
  1163. InRect = True
  1164. Else
  1165. InRect = False
  1166. End If
  1167. End Function
  1168.  
  1169. '**********************
  1170. ' Ball Collision Sound
  1171. '**********************
  1172.  
  1173. Sub OnBallBallCollision(ball1, ball2, velocity)
  1174. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  1175. End Sub
  1176.  
  1177. '******************************************************
  1178. ' FLIPPER CORRECTION SUPPORTING FUNCTIONS
  1179. '******************************************************
  1180.  
  1181. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  1182. dim a : a = Array(LF, RF)
  1183. dim x : for each x in a
  1184. x.addpoint aStr, idx, aX, aY
  1185. Next
  1186. End Sub
  1187.  
  1188. 'Methods:
  1189. '.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
  1190. '.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
  1191. '.Object - set to flipper reference. Optional.
  1192. '.StartPoint - set start point coord. Unnecessary, if .object is used.
  1193.  
  1194. 'Called with flipper -
  1195. 'ProcessBalls - catches ball data.
  1196. ' - OR -
  1197. '.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
  1198.  
  1199. Class FlipperPolarity
  1200. Public DebugOn, Enabled
  1201. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  1202. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  1203. private Flipper, FlipperStart, FlipperEnd, LR, PartialFlipCoef
  1204. Private Balls(20), balldata(20)
  1205.  
  1206. dim PolarityIn, PolarityOut
  1207. dim VelocityIn, VelocityOut
  1208. dim YcoefIn, YcoefOut
  1209. Public Sub Class_Initialize
  1210. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  1211. Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
  1212. End Sub
  1213.  
  1214. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  1215. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  1216. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  1217. Public Property Let EndPoint(aInput) : if IsObject(aInput) then FlipperEnd = aInput.x else FlipperEnd = aInput : end if : End Property
  1218. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  1219.  
  1220. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  1221. Select Case aChooseArray
  1222. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  1223. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  1224. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  1225. End Select
  1226. if gametime > 100 then Report aChooseArray
  1227. End Sub
  1228.  
  1229. Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
  1230. if not DebugOn then exit sub
  1231. dim a1, a2 : Select Case aChooseArray
  1232. case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
  1233. Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
  1234. Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
  1235. case else :tbpl.text = "wrong string" : exit sub
  1236. End Select
  1237. dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1238. tbpl.text = str
  1239. End Sub
  1240.  
  1241. 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
  1242.  
  1243. Private Sub RemoveBall(aBall)
  1244. dim x : for x = 0 to uBound(balls)
  1245. if TypeName(balls(x) ) = "IBall" then
  1246. if aBall.ID = Balls(x).ID Then
  1247. balls(x) = Empty
  1248. Balldata(x).Reset
  1249. End If
  1250. End If
  1251. Next
  1252. End Sub
  1253.  
  1254. Public Sub Fire()
  1255. Flipper.RotateToEnd
  1256. processballs
  1257. End Sub
  1258.  
  1259. Public Property Get Pos 'returns % position a ball. For debug stuff.
  1260. dim x : for x = 0 to uBound(balls)
  1261. if not IsEmpty(balls(x) ) then
  1262. pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
  1263. End If
  1264. Next
  1265. End Property
  1266.  
  1267. Public Sub ProcessBalls() 'save data of balls in flipper range
  1268. FlipAt = GameTime
  1269. dim x : for x = 0 to uBound(balls)
  1270. if not IsEmpty(balls(x) ) then
  1271. balldata(x).Data = balls(x)
  1272. if DebugOn then StickL.visible = True : StickL.x = balldata(x).x 'debug TODO
  1273. End If
  1274. Next
  1275. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
  1276. PartialFlipCoef = abs(PartialFlipCoef-1)
  1277. if abs(Flipper.currentAngle - Flipper.EndAngle) < 30 Then
  1278. PartialFlipCoef = 0
  1279. End If
  1280. End Sub
  1281. Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
  1282.  
  1283. Public Sub PolarityCorrect(aBall)
  1284. if FlipperOn() then
  1285. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  1286. dim teststr : teststr = "Cutoff"
  1287. tmp = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  1288. 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
  1289. if DebugOn then TestStr = "real pos < 0.1 ( " & round(tmp,2) & ")" : tbpl.text = Teststr
  1290. 'RemoveBall aBall
  1291. 'Exit Sub
  1292. end if
  1293.  
  1294. 'y safety Exit
  1295. if aBall.VelY > -8 then 'ball going down
  1296. if DebugOn then teststr = "y velocity: " & round(aBall.vely, 3) & "exit sub" : tbpl.text = teststr
  1297. RemoveBall aBall
  1298. exit Sub
  1299. end if
  1300. 'Find balldata. BallPos = % on Flipper
  1301. for x = 0 to uBound(Balls)
  1302. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  1303. idx = x
  1304. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  1305. 'TB.TEXT = balldata(x).id & " " & BALLDATA(X).X & VBNEWLINE & FLIPPERSTART & " " & FLIPPEREND
  1306. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1307. end if
  1308. Next
  1309.  
  1310. 'Velocity correction
  1311. if not IsEmpty(VelocityIn(0) ) then
  1312. Dim VelCoef
  1313. if DebugOn then set tmp = new spoofball : tmp.data = aBall : End If
  1314. if IsEmpty(BallData(idx).id) and aBall.VelY < -12 then 'if tip hit with no collected data, do vel correction anyway
  1315. if PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1) > 1.1 then 'adjust plz
  1316. VelCoef = LinearEnvelope(5, VelocityIn, VelocityOut)
  1317. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  1318. if Enabled then aBall.Velx = aBall.Velx*VelCoef'VelCoef
  1319. if Enabled then aBall.Vely = aBall.Vely*VelCoef'VelCoef
  1320. if DebugOn then teststr = "tip protection" & vbnewline & "velcoef: " & round(velcoef,3) & vbnewline & round(PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1),3) & vbnewline
  1321. 'debug.print teststr
  1322. end if
  1323. Else
  1324. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  1325. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  1326. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  1327. end if
  1328. End If
  1329.  
  1330. 'Polarity Correction (optional now)
  1331. if not IsEmpty(PolarityIn(0) ) then
  1332. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  1333. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  1334. 'playsound "fx_knocker"
  1335. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  1336. End If
  1337. 'debug
  1338. if DebugOn then
  1339. TestStr = teststr & "%pos:" & round(BallPos,2)
  1340. if IsEmpty(PolarityOut(0) ) then
  1341. teststr = teststr & vbnewline & "(Polarity Disabled)" & vbnewline
  1342. else
  1343. teststr = teststr & "+" & round(1 *(AddX*ycoef*PartialFlipcoef),3)
  1344. if BallPos >= PolarityOut(uBound(PolarityOut) ) then teststr = teststr & "(MAX)" & vbnewline else teststr = teststr & vbnewline end if
  1345. if Ycoef < 1 then teststr = teststr & "ycoef: " & ycoef & vbnewline
  1346. if PartialFlipcoef < 1 then teststr = teststr & "PartialFlipcoef: " & round(PartialFlipcoef,4) & vbnewline
  1347. end if
  1348.  
  1349. teststr = teststr & vbnewline & "Vel: " & round(BallSpeed(tmp),2) & " -> " & round(ballspeed(aBall),2) & vbnewline
  1350. teststr = teststr & "%" & round(ballspeed(aBall) / BallSpeed(tmp),2)
  1351. tbpl.text = TestSTR
  1352. end if
  1353. Else
  1354. 'if DebugOn then tbpl.text = "td" & timedelay
  1355. End If
  1356. RemoveBall aBall
  1357. End Sub
  1358. End Class
  1359.  
  1360. '================================
  1361. 'Helper Functions
  1362.  
  1363.  
  1364. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  1365. dim x, aCount : aCount = 0
  1366. redim a(uBound(aArray) )
  1367. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  1368. if not IsEmpty(aArray(x) ) Then
  1369. if IsObject(aArray(x)) then
  1370. Set a(aCount) = aArray(x)
  1371. Else
  1372. a(aCount) = aArray(x)
  1373. End If
  1374. aCount = aCount + 1
  1375. End If
  1376. Next
  1377. if offset < 0 then offset = 0
  1378. redim aArray(aCount-1+offset) 'Resize original array
  1379. for x = 0 to aCount-1 'set objects back into original array
  1380. if IsObject(a(x)) then
  1381. Set aArray(x) = a(x)
  1382. Else
  1383. aArray(x) = a(x)
  1384. End If
  1385. Next
  1386. End Sub
  1387.  
  1388. Sub ShuffleArrays(aArray1, aArray2, offset)
  1389. ShuffleArray aArray1, offset
  1390. ShuffleArray aArray2, offset
  1391. End Sub
  1392.  
  1393.  
  1394. Function BallSpeed(ball) 'Calculates the ball speed
  1395. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  1396. End Function
  1397.  
  1398. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  1399. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  1400. Y = M*x+b
  1401. PSlope = Y
  1402. End Function
  1403.  
  1404. Function NullFunctionZ(aEnabled):End Function '1 argument null function placeholder TODO move me or replac eme
  1405.  
  1406. Class spoofball
  1407. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  1408. Public Property Let Data(aBall)
  1409. With aBall
  1410. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  1411. id = .ID : mass = .mass : radius = .radius
  1412. end with
  1413. End Property
  1414. Public Sub Reset()
  1415. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  1416. id = Empty : mass = Empty : radius = Empty
  1417. End Sub
  1418. End Class
  1419.  
  1420.  
  1421. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  1422. dim y 'Y output
  1423. dim L 'Line
  1424. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  1425. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  1426. Next
  1427. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  1428. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  1429.  
  1430. 'Clamp if on the boundry lines
  1431. 'if L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
  1432. 'if L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
  1433. 'clamp 2.0
  1434. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  1435. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  1436.  
  1437. LinearEnvelope = Y
  1438. End Function
  1439.  
  1440. dim LF : Set LF = New FlipperPolarity
  1441. dim RF : Set RF = New FlipperPolarity
  1442.  
  1443. InitPolarity
  1444.  
  1445. Sub InitPolarity()
  1446. dim x, a : a = Array(LF, RF)
  1447. for each x in a
  1448. 'safety coefficient (diminishes polarity correction only)
  1449. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  1450. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  1451.  
  1452. x.enabled = True
  1453. x.TimeDelay = 80
  1454. Next
  1455.  
  1456. 'rf.report "Polarity"
  1457. AddPt "Polarity", 0, 0, -2.7
  1458. AddPt "Polarity", 1, 0.16, -2.7
  1459. AddPt "Polarity", 2, 0.33, -2.7
  1460. AddPt "Polarity", 3, 0.37, -2.7 '4.2
  1461. AddPt "Polarity", 4, 0.41, -2.7
  1462. AddPt "Polarity", 5, 0.45, -2.7 '4.2
  1463. AddPt "Polarity", 6, 0.576,-2.7
  1464. AddPt "Polarity", 7, 0.66, -1.8'-2.1896
  1465. AddPt "Polarity", 8, 0.743, -0.5
  1466. AddPt "Polarity", 9, 0.81, -0.5
  1467. AddPt "Polarity", 10, 0.88, 0
  1468.  
  1469. '"Velocity" Profile
  1470. addpt "Velocity", 0, 0, 1
  1471. addpt "Velocity", 1, 0.16, 1.06
  1472. addpt "Velocity", 2, 0.41, 1.05
  1473. addpt "Velocity", 3, 0.53, 1'0.982
  1474. addpt "Velocity", 4, 0.702, 0.968
  1475. addpt "Velocity", 5, 0.95, 0.968
  1476. addpt "Velocity", 6, 1.03, 0.945
  1477.  
  1478. LF.Object = LeftFlipper
  1479. LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
  1480. RF.Object = RightFlipper
  1481. RF.EndPoint = EndPointRp
  1482. End Sub
  1483.  
  1484. 'Trigger Hit - .AddBall activeball
  1485. 'Trigger UnHit - .PolarityCorrect activeball
  1486.  
  1487. Sub TriggerLF_Hit() : LF.Addball activeball : End Sub
  1488. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball: End Sub
  1489. Sub TriggerRF_Hit() : RF.Addball activeball : End Sub
  1490. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : End Sub
  1491.  
  1492. Sub RDampen_Timer()
  1493. Cor.Update
  1494. End Sub
  1495.  
  1496. '****************************************************************************
  1497. 'PHYSICS DAMPENERS
  1498.  
  1499. 'These are data mined bounce curves,
  1500. 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
  1501. 'Requires tracking ballspeed to calculate COR
  1502.  
  1503.  
  1504. Sub dPosts_Hit(idx)
  1505. RubbersD.dampen Activeball
  1506. End Sub
  1507.  
  1508. Sub dSleeves_Hit(idx)
  1509. SleevesD.Dampen Activeball
  1510. End Sub
  1511.  
  1512.  
  1513. dim RubbersD : Set RubbersD = new Dampener 'frubber
  1514. RubbersD.name = "Rubbers"
  1515. RubbersD.debugOn = False 'shows info in textbox "TBPout"
  1516. RubbersD.Print = False 'debug, reports in debugger (in vel, out cor)
  1517. 'cor bounce curve (linear)
  1518. 'for best results, try to match in-game velocity as closely as possible to the desired curve
  1519. 'RubbersD.addpoint 0, 0, 0.935 'point# (keep sequential), ballspeed, CoR (elasticity)
  1520. RubbersD.addpoint 0, 0, 0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
  1521. RubbersD.addpoint 1, 3.77, 0.96
  1522. RubbersD.addpoint 2, 5.76, 0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
  1523. RubbersD.addpoint 3, 15.84, 0.874
  1524. RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
  1525.  
  1526. dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
  1527. SleevesD.name = "Sleeves"
  1528. SleevesD.debugOn = False 'shows info in textbox "TBPout"
  1529. SleevesD.Print = False 'debug, reports in debugger (in vel, out cor)
  1530. SleevesD.CopyCoef RubbersD, 0.85
  1531.  
  1532. Class Dampener
  1533. Public Print, debugOn 'tbpOut.text
  1534. public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
  1535. Public ModIn, ModOut
  1536. Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
  1537.  
  1538. Public Sub AddPoint(aIdx, aX, aY)
  1539. ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
  1540. if gametime > 100 then Report
  1541. End Sub
  1542.  
  1543. public sub Dampen(aBall)
  1544. if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
  1545. dim RealCOR, DesiredCOR, str, coef
  1546. DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
  1547. RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
  1548. coef = desiredcor / realcor
  1549. if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
  1550. "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
  1551. if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)
  1552.  
  1553. aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
  1554. if debugOn then TBPout.text = str
  1555. End Sub
  1556.  
  1557. Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
  1558. dim x : for x = 0 to uBound(aObj.ModIn)
  1559. addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
  1560. Next
  1561. End Sub
  1562.  
  1563.  
  1564. Public Sub Report() 'debug, reports all coords in tbPL.text
  1565. if not debugOn then exit sub
  1566. dim a1, a2 : a1 = ModIn : a2 = ModOut
  1567. dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1568. TBPout.text = str
  1569. End Sub
  1570.  
  1571.  
  1572. End Class
  1573.  
  1574. 'Tracks ball velocity for judging bounce calculations & angle
  1575. 'apologies to JimmyFingers is this is what his script does. I know his tracks ball velocity too but idk how it works in particular
  1576. dim cor : set cor = New CoRTracker
  1577. cor.debugOn = False
  1578. 'cor.update() - put this on a low interval timer
  1579. Class CoRTracker
  1580. public DebugOn 'tbpIn.text
  1581. public ballvel
  1582.  
  1583. Private Sub Class_Initialize : redim ballvel(0) : End Sub
  1584. 'TODO this would be better if it didn't do the sorting every ms, but instead every time it's pulled for COR stuff
  1585. Public Sub Update() 'tracks in-ball-velocity
  1586. dim str, b, AllBalls, highestID : allBalls = getballs
  1587. if uBound(allballs) < 0 then if DebugOn then str = "no balls" : TBPin.text = str : exit Sub else exit sub end if: end if
  1588. for each b in allballs
  1589. if b.id >= HighestID then highestID = b.id
  1590. Next
  1591.  
  1592. if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
  1593.  
  1594. for each b in allballs
  1595. ballvel(b.id) = BallSpeed(b)
  1596. if DebugOn then
  1597. dim s, bs 'debug spacer, ballspeed
  1598. bs = round(BallSpeed(b),1)
  1599. if bs < 10 then s = " " else s = "" end if
  1600. str = str & b.id & ": " & s & bs & vbnewline
  1601. 'str = str & b.id & ": " & s & bs & "z:" & b.z & vbnewline
  1602. end if
  1603. Next
  1604. if DebugOn then str = "ubound ballvels: " & ubound(ballvel) & vbnewline & str : if TBPin.text <> str then TBPin.text = str : end if
  1605. End Sub
  1606. End Class
Add Comment
Please, Sign In to add comment