Arngrim

NBA Fastbreak

Jan 3rd, 2021
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 123.31 KB | None | 0 0
  1. ' NBA Fastbreak / IPD No. 4023 / March, 1997 / 4 Players
  2. ' http://www.ipdb.org/machine.cgi?id=4023
  3. ' VP915 v1.0 by JPSalas 2013
  4. ' VPX v1.0 by MaX 2016
  5. ' based on the tables by Aurich and bmiki75
  6. ' 2018 Mod by Darth Marino. Extra special thanks to DJROBX for helping implement the Shot Clock
  7. ' Fast Flips implemented by DJRobX and CarnyPriest
  8. ' VPin Workshop Mod 12/2020
  9.  
  10. '**CHANGE LOG **
  11. ' 005 - iaakki - PF and insert images, first inserts added. All lights moved to different layers
  12. ' 006 - iaakki - PF material fixed. Adding more inserts, right ramp invisible for now
  13. ' 007 - tomate - All the new geometry inside. Layer 1:Non-colidables primitives Layer 2:Colidables LowPoly primitives Layer 3:original VPX objetcs aligned. Added new rubber stuff.
  14. ' 008 - iaakki - fixed missing wall diverters
  15. ' 009 - tomate - Fixed issue with bumpers, remove collidable wall in position of diverter1, fixed plastics texture problems, added a collidable wall on shot clock, fixed geometry of the RRamp
  16. ' 010 - tomate - Added some new geometries, aligned rubbers and addded new POV
  17. ' 011 - iaakki - combined inserts and graphics from separate version
  18. ' 012 - tomate - New textures
  19. ' 013 - tomate - Improve plastic textures, shadows on PF, new apron
  20. ' 014 - tomate - More work on textures
  21. ' 015 - tomate - Work on file weight, fixed wall problem in player #3, new apron texture, some additional fixes
  22. ' 016 - Benji - Added nfozzy physics to flippers, rubber dampening is in script but not assigned to any objects yet.Physics material assigned to collidable ramp primitives
  23. ' 017 - Benji - Added darkening/contrast LUT and DL to ramps_laterl primitive (can be disabled in options below). Added collidable rubber sleeves primitives on layer 10 and assigned physics material and nfozzy dampening event
  24. ' 018 - tomate - New lighting and color correction with LUTs, new PF with color correction, shadow layer added
  25. ' 019 - tomate - Diverter added, fix on collideable walls to prevent ball from getting stuck, new flippers added, triggers fixed, some minor adjustments in textures, clock numbers fixed
  26. ' 020 - Benji - Added physics to rubber bands
  27. ' 021 - iaakki - flupper domes partially done
  28. ' 022 - tomate - Added PF mesh, values of sides passes fixed, force value for sw25 fixed, color correction to PF
  29. ' 023 - iaakki - flasher domes done
  30. ' 024 - iaakki - GI redone and connected, PF GI missing from strings 2 and 3, gInsertLevel const added to reduce insert brightness globally
  31. ' 025 - tomate - Clean script flippers williams logo, blenddisablelighting to Ramp_central added, new water level added, new transparent textures for plastic ramps added
  32. ' 026 - tomate - fix the height of the bulbs under Jam & Slam ramps, new siderails and sidewalls added, GlobalFlasher added on PF at layer10
  33. ' 027 - Benji - Added Fleep sound package and DJRobX wire/plastic/metal ramp bumps.
  34. ' 030 - iaakki - included flipper logos. Flipnudge is having some issues still
  35. ' 031 - Sixtoe - Added VR Room, fixed flipper shadows, trimmed lights, unified timmers (including removing redundant timers), removed legacy nudging system, fixed numerous VR depth bias issues, replaced flasher for red left turbo bumper flasher and hooked it up to the flasher system
  36. ' 032 - Benji - Removed extra glosiness from new flippers by creating new material for flippers. Got new Flipper Nudge functionality working
  37. ' 033 - iaakki - Diverter2, Flipper_collide sub, FlipperSlack&Checklivecatch calls fixed and slackyFlips const added -> Flip tricks works
  38. ' 034 - tomate - fixed kicker sw66 (player # 3) shooting power, adjustments on collideable walls to prevent ball jamming, adjust DL of new bats
  39. ' 035 - tomate - Primitives of collidable Ramps fixed, usless old collidable objects removed
  40. ' 036 - sixtoe/tomate - Shadow ball added, gamma correction to ramps decals
  41. ' 037.1 - Sixtoe - Updated VR cabinet, corrected ramp materials for VR, added left ramp lid, aligned 3rd basket flasher, corrected blooms for all basket flashers, added new bloom for flasher10
  42. ' 037.2 - Sixtoe - removed LowPoly_Ramps001 collision primitive as was a duplicate, hid everything visible outside of table limits, created apron "shoot" button and light, corrected apron prim so UV isn't broken, repositioned all slings and sling rubbers, fixed right sling
  43. ' 037.3 - Sixtoe - added cabinet start light, hooked up existing off cabninet start and shoot lights for desktop mode?, hooked GlobalFlasher to GI system, created sidewall "off" images and hooked up the sidewalls to the GI system for both the normal and VR version (crowd currently not implemented)
  44. ' 038 - iaakki - fixed POV and some insert light bulb values
  45. ' 039 - tomate - fixed upper right rubber, new texture for the ball, POV adjusted to show the full apron
  46. ' 040 - tomate - adjustments to apron and metals textures, tweaks DL on some objects, change ramp materials to look brighter
  47. ' 041 - iaakki - top area pf gi redone
  48. ' 042 - iaakki - Some plastic GI light heights retuned
  49. ' 043 - Sixtoe - changed lamp decal materials so that they work properly, set back to active so they're still see through, fixed some lights, fixed the start button to not show in vr, changed and adjusted the apron walls to show in VR, changed the material of the defender as it was broken in vr, hooked up rollvers to new sound code, removed old sound code and la1-6 walls, droppped playfield hole surrounds, tidied up playfield holes and made a new one for a sw43 target,
  50. ' 044 - tomate/iaakki - low res for some textures, StandUp targets separation into 3 prims and animation done, modify backwall texture
  51. ' 045 - tomate/oqq - correct apron wall height plastic under central ramp texture, add movments to bumperRings and separate prims
  52. ' 046 - tomate - add cabinet mode (working half), removed white things under the ramps, added subtle transparency to the ramp decals, so the lights below can be seen a bit, new yellow targets prims and textures
  53. ' 046.1 - tomate - yellow targets working
  54. ' 047 - Sixtoe - VR room settings fixed and tweaked, ultra minimal vr added, fixed desktop mode, fixed ball jumping into plunger lane by adding new cover wall, fixed ramp primitive have a hole in it, removed crowd sides for now, fixed desktop pov, turned flipper strength way down
  55. ' 048 - iaakki - Desktop POV adjusted, standup target bounces reduced, pf friction increased, Flasherbase1 height fixed
  56. ' 049 - Sixtoe - Fixed low poly ramp stopping ball going up left ramp, then fixed it getting stuck there!, adjusted right ramp roof again, added new wall on left by food kicker to stop ball trap, repositioned basket loop to fix POV and make sounds appear near top of table, added missing rubbers to outlane pegs, fixed blade/sidewall texture collision in cabinetmode, added wall on slam ramp to stop ball falling off wire ramp back onto slam ramp
  57. ' 050 - iaakki - Standup targets elasticity reduced. Sw64 surface fixed to 55h, l57 brightness reduced, insert paint layer color adjustment
  58. ' 051 - tomate - fix Pincab_rails mesh, change material settings and mapped. Fix POV's, now is working in FS and DT mode.
  59. ' 052 - iaakki - fine tuned flip positions, fixed lamp update functions to reset properly for all lamps.
  60. ' 053 - iaakki - sw46 and sw63 surface fixed, diverter sounds added
  61. ' 054 - tomate - Change size and textures of SideBlades, add roof to left plastic, raised the top of the LeftRamp roof to prevent ball hitting, add thickness to PF and mapping
  62. ' 054.1 - tomate - Restored the old roof of the left ramp as the new one didn´t work
  63. ' 055 - iaakki- ScSp reflections on by default, cabinetmode raises flasherblooms to 500, flasherlights adjusted and lifted to same level as the plastic.
  64. ' 056 - Sixtoe - extended collidable wall around the orbit loop to remove ball traps on the top corners, added code to adjust flashbloom height and Y position to cabinet mode, adjusted wire ramp disable lighting to stop lights coming through it in VR, removed rundant ring1/2/3 walls, switched metal post to plastic post under white flasher, adjusted switch 64 height, added bumper1 top wall,
  65. ' RC1 - tomate - make not visible wall over main bumper, set 100% sound effect Volume, set CabinetMode = 0
  66. ' RC2 - Sixtoe - Adjusted slam ramp, added kicker primitives to basket shots, added additional wall on slingshot back, tweaked a handful of other things
  67. ' RC3 - Sixtoe - Adjusted flippers, removed sling added in error, changed height of wireexit1
  68. ' RC4 - iaakki - Round standup target fixed to feel more natural, redclock script error fixed
  69. ' RC5 - tomate - red clock numbers added
  70. ' RC6 - tomate - redclocktimer enabled, add kicker primitive to middle-left hole, some tweaks in decal_ramps textures and Left ramp texture, new textures for laneguides
  71. ' RC7 - tomate - increase Cabflash.height value to 520, change POV to match cabinet view, add a wall under cnetral ramp to prevent ball jams, separate the primitives from the laneguides and made them non-collideable, add wall on the laneguides to avoid sorcery
  72. ' 100 - iaakki - flasherbloom default heights checked, ball counts fixed, default options set
  73.  
  74. Option Explicit
  75. Randomize
  76.  
  77. '///////////////////////////////////////////////////
  78. '///////////////// Table Options ///////////////////
  79. '///////////////////////////////////////////////////
  80.  
  81. 'Make flipper solenoid to alter active ball behavior
  82. Const FlipSolNudge = 1
  83.  
  84. Const slackyFlips = 1
  85.  
  86. 'Live catch window size. Higher value will make live catching easier. 8-32
  87. Const LiveCatch = 16
  88.  
  89. '///////////////////////-----General Sound Options-----///////////////////////
  90. '// VolumeDial:
  91. '// VolumeDial is the actual global volume multiplier for the mechanical sounds.
  92. '// Values smaller than 1 will decrease mechanical sounds volume.
  93. '// Recommended values should be no greater than 1.
  94. Const VolumeDial = 0.8
  95.  
  96. '*************************************
  97. '***********CABINET MODE**************
  98. 'Cabinet mode - Will hide the rails and scale the side panels higher
  99. Const CabinetMode = 1
  100. '*************************************
  101.  
  102. '*************************************
  103. '**************VR ROOM****************
  104. '****Turns on VR Room and Cabinet****
  105. '0 - VR Room off, 1 - Minimal Room, 2 - Ultra Minimal
  106. VRRoom = 0
  107. '*************************************
  108.  
  109. '*************************************
  110. '*******FAST FLIPS OPTION*************
  111. '***REQUIRES PINMAME SAMupdate r4614 OR NEWER!!!!!!!!!!!!!!!!!!
  112. '*** http://vpuniverse.com/forums/topic/3651-sambuild32-beta-thread/
  113. '*************************************
  114. ' 1 = OFF 2 = ON
  115. Const UseSolenoids = 2
  116. '*************************************
  117.  
  118. '*************************************
  119. '*********RED SHOT CLOCK MOD**********
  120. ' 0 = OFF 1 = ON
  121. RedClock=0
  122. '*************************************
  123.  
  124.  
  125. Dim DesktopMode:DesktopMode = Table1.ShowDT
  126. Dim UseVPMDMD:UseVPMDMD = DesktopMode
  127.  
  128. On Error Resume Next
  129. ExecuteGlobal GetTextFile("controller.vbs")
  130. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  131. On Error Goto 0
  132.  
  133. Const BallSize = 50 'add this here to redefine the ball size, placed before LoadVPM.'
  134.  
  135. LoadVPM "01120100", "WPC.VBS", 3.49 'minimum core.vbs version
  136.  
  137. Dim bsTrough, bsEject, bsSaucer1, bsSaucer2, bsSaucer3, bsSaucer4, mBallCatch, mDefender, MagnetCatch, bgball
  138. Dim PlungerIM, x, bump1, bump2, bump3, ArenaMod, RedClock, FastFlips, ff
  139.  
  140. '************************************
  141. ramps_lateral.blenddisablelighting=2
  142. ramp_central.blenddisablelighting=2
  143. '************************************
  144.  
  145. '************Diverter2 animation*************************
  146. dim DiverterDir
  147. Sub SolDiverter2(Enabled)
  148. 'debug.print "diverter2 state: " & Enabled
  149. If Enabled Then
  150. Diverter2.IsDropped=1
  151. DiverterDir = 2
  152. Diverter2.timerinterval = 5:Diverter2.timerenabled = 1
  153. PlaySoundAt SoundFX("DiverterOn",DOFContactors),DiverterP2
  154. else
  155. Diverter2.IsDropped=0
  156. DiverterDir = -2
  157. Diverter2.timerinterval = 5:Diverter2.timerenabled = 1
  158. PlaySoundAt SoundFX("DiverterOff",DOFContactors),DiverterP2
  159. End If
  160. End Sub
  161.  
  162. Sub Diverter2_Timer()
  163. DiverterP2.transY=DiverterP2.transY+DiverterDir
  164. If DiverterP2.transY>30 AND DiverterDir=2 Then Me.timerenabled=0:DiverterP2.transY=30
  165. If DiverterP2.transY<0 AND DiverterDir=-2 Then Me.timerenabled=0:DiverterP2.transY=0
  166. End Sub
  167.  
  168. '**************StandUp targets****************************
  169.  
  170. 'Sub sw41_Hit:vpmTimer.PulseSw 41:End Sub
  171.  
  172. 'Const VolTarg = 1 ' Targets multiplier
  173. Dim zMultiplier
  174.  
  175. DIM target41step
  176. Sub sw41_Hit
  177. Select Case Int(Rnd * 4) + 1
  178. Case 1: zMultiplier = 1.15
  179. Case 2: zMultiplier = 0.8
  180. Case 3: zMultiplier = 0.5
  181. Case 4: zMultiplier = 0.2
  182. End Select
  183. 'msgbox "hit 41 zmult: " & zMultiplier
  184. activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 41:pSW41.TransY = -3:Target41Step = 1:sw41a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
  185. End Sub
  186.  
  187. Sub sw41a_timer()
  188. Select Case Target41Step
  189. Case 1:pSW41.TransY = -1
  190. Case 2:pSW41.TransY = 2
  191. Case 3:pSW41.TransY = 0:Me.Enabled = 0
  192. End Select
  193. Target41Step = Target41Step + 1
  194. End Sub
  195.  
  196.  
  197. DIM target42step
  198. Sub sw42_Hit
  199. Select Case Int(Rnd * 4) + 1
  200. Case 1: zMultiplier = 1.15
  201. Case 2: zMultiplier = 0.8
  202. Case 3: zMultiplier = 0.5
  203. Case 4: zMultiplier = 0.2
  204. End Select
  205. 'msgbox "hit 42 zmult: " & zMultiplier
  206. activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 42:pSW42.TransY = -3:Target42Step = 1:sw42a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
  207. End Sub
  208.  
  209. Sub sw42a_timer()
  210. Select Case Target42Step
  211. Case 1:pSW42.TransY = -1
  212. Case 2:pSW42.TransY = 2
  213. Case 3:pSW42.TransY = 0:Me.Enabled = 0
  214. End Select
  215. Target42Step = Target42Step + 1
  216. End Sub
  217.  
  218. DIM target43step
  219. Sub sw43_Hit
  220. Select Case Int(Rnd * 4) + 1
  221. Case 1: zMultiplier = 1.15
  222. Case 2: zMultiplier = 0.8
  223. Case 3: zMultiplier = 0.5
  224. Case 4: zMultiplier = 0.2
  225. End Select
  226. 'msgbox "hit 43 zmult: " & zMultiplier
  227. activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 43:pSW43.TransY = -3:Target43Step = 1:sw43a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
  228. End Sub
  229.  
  230. Sub sw43a_timer()
  231. Select Case Target43Step
  232. Case 1:pSW43.TransY = -1
  233. Case 2:pSW43.TransY = 2
  234. Case 3:pSW43.TransY = 0:Me.Enabled = 0
  235. End Select
  236. Target43Step = Target43Step + 1
  237. End Sub
  238.  
  239.  
  240. DIM target28step
  241. Sub sw28_Hit
  242. Select Case Int(Rnd * 4) + 1
  243. Case 1: zMultiplier = 1.15
  244. Case 2: zMultiplier = 0.8
  245. Case 3: zMultiplier = 0.5
  246. Case 4: zMultiplier = 0.2
  247. End Select
  248. 'msgbox "hit 28 zmult: " & zMultiplier
  249. activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 28:pSW28.TransY = -3:Target28Step = 1:sw28a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
  250. End Sub
  251.  
  252. Sub sw28a_timer()
  253. Select Case Target28Step
  254. Case 1:pSW28.TransY = -1
  255. Case 2:pSW28.TransY = 2
  256. Case 3:pSW28.TransY = 0:Me.Enabled = 0
  257. End Select
  258. Target28Step = Target28Step + 1
  259. End Sub
  260.  
  261. DIM target18step
  262. Sub sw18_Hit
  263. Select Case Int(Rnd * 4) + 1
  264. Case 1: zMultiplier = 1.15
  265. Case 2: zMultiplier = 0.8
  266. Case 3: zMultiplier = 0.5
  267. Case 4: zMultiplier = 0.2
  268. End Select
  269. 'msgbox "hit 18 zmult: " & zMultiplier
  270. activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 18:pSW18.TransY = -3:Target18Step = 1:sw18a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
  271. End Sub
  272.  
  273. Sub sw18a_timer()
  274. Select Case Target18Step
  275. Case 1:pSW18.TransY = -1
  276. Case 2:pSW18.TransY = 2
  277. Case 3:pSW18.TransY = 0:Me.Enabled = 0
  278. End Select
  279. Target18Step = Target18Step + 1
  280. End Sub
  281.  
  282.  
  283. '**************Bumpers animation*******************
  284.  
  285. Sub Bumper2_Hit:vpmTimer.PulseSw 23:PlaySound SoundFX("fx_bumper2",DOFContactors):bump2 = 1:Me.TimerEnabled = 1:End Sub
  286. Sub Bumper2_Timer()
  287. Select Case bump2
  288. Case 1:Ring2.HeightTop = 15:Ring2.HeightBottom = 15:bump2 = 2
  289. Case 2:Ring2.HeightTop = 25:Ring2.HeightBottom = 25:bump2 = 3
  290. Case 3:Ring2.HeightTop = 35:Ring2.HeightBottom = 35:bump2 = 4
  291. Case 4:Ring2.HeightTop = 45:Ring2.HeightBottom = 45:Me.TimerEnabled = 0
  292. End Select
  293.  
  294. Bumper2R.State = ABS(Bumper2R.State - 1) 'refresh light
  295. End Sub
  296.  
  297. '*************************************
  298.  
  299. Const UseLamps = 0
  300. 'Const UseGI = 0
  301. Const UseSync = 0 'set it to 1 if the table runs too fast
  302. Const HandleMech = 1
  303.  
  304. ' Standard Sounds
  305. Const SSolenoidOn = "fx_Solenoidon"
  306. Const SSolenoidOff = "fx_SolenoidOff"
  307. Const SFlipperOn = "fx_flipperup1"
  308. Const SFlipperoff = "fx_flipperdown"
  309. Const SCoin = "fx_coin"
  310. Const cGameName = "nbaf_31"
  311. Const cSingleLFlip=0
  312. Const cSingleRFlip=0
  313.  
  314. Set GiCallback2 = GetRef("UpdateGI")
  315.  
  316. 'sub updategi (no, aValue)
  317.  
  318. 'Eval("textbox"&no).text=enabled
  319. 'debug.print no & " nro and aValue: " & aValue
  320. 'iaakki: ok NBA gi has few areas
  321. '[4:35 PM] iaakki: 0 = "string 1"
  322. '[4:36 PM] iaakki: 1 = "string 2"
  323. '[4:36 PM] iaakki: 2 = "string 3"
  324.  
  325. 'end sub
  326.  
  327. Sub UpdateGi(nr,step)
  328. Dim ii
  329. Select Case nr
  330. Case 0 'Top Playfield
  331. 'string 1
  332. If step=0 Then
  333. For each ii in GI0:ii.state=0:Next
  334. ' For each ii in GIPOA:ii.visible=0:Next
  335. Else
  336. For each ii in GI0:ii.state=1:Next
  337. ' For each ii in GIPOA:ii.visible=1:Next
  338. End If
  339. For each ii in GI0:ii.IntensityScale = 0.125 * step:Next
  340. Case 1 'Bottom Playfield
  341. 'string 2
  342. If step=0 Then
  343. For each ii in GI1:ii.state=0:Next
  344. GlobalFlasher.visible=0
  345. PinCab_Blades.image = "PinCab_Blades_Off"
  346. SideWalls.image = "PinCab_Blades_Off"
  347. ' For each ii in GIBot:ii.state=0:Next
  348. ' For each ii in GIBotSides:ii.visible=0:Next
  349. Else
  350. For each ii in GI1:ii.state=1:Next
  351. GlobalFlasher.visible=1
  352. PinCab_Blades.image = "PinCab_Blades_On"
  353. SideWalls.image = "PinCab_Blades_On"
  354. ' For each ii in GIBot:ii.state=1:Next
  355. ' For each ii in GIBotSides:ii.visible=1:Next
  356. End If
  357. For each ii in GI1:ii.IntensityScale = 0.125 * step:Next
  358. ' For each ii in GIBot:ii.IntensityScale = 0.125 * step:Next
  359. ' For each ii in GIBotSides:ii.IntensityScale = 0.125 * step:Next
  360. ' If Step>=7 Then Table1.ColorGradeImage = "ColorGrade_8":Else Table1.ColorGradeImage = "ColorGrade_" & (step+1):End If
  361. Case 2 'Insert Top
  362. 'string 3
  363. If step=0 Then
  364. For each ii in GI2:ii.state=0:Next
  365. ' For each ii in GIPOA:ii.visible=0:Next
  366. Else
  367. For each ii in GI2:ii.state=1:Next
  368. ' For each ii in GIPOA:ii.visible=1:Next
  369. End If
  370. For each ii in GI2:ii.IntensityScale = 0.125 * step:Next
  371. End Select
  372. End Sub
  373.  
  374. Sub table1_Init
  375. vpmInit Me
  376. Dim ii
  377. With Controller
  378.  
  379. .GameName = cGameName
  380. .SplashInfoLine = "NBA Fastbreak, Bally 1997"
  381. ' .Games(cGameName).Settings.Value("rol") = 0 'rotated vpm display
  382. .HandleMechanics = 0
  383. .HandleKeyboard = 0
  384. .ShowDMDOnly = 1
  385. .ShowFrame = 0
  386. .ShowTitle = 0
  387. .Hidden = 0
  388. ' .Games(cGameName).Settings.Value("dmd_pos_x")=0
  389. ' .Games(cGameName).Settings.Value("dmd_pos_y")=0
  390. If Err Then MsgBox Err.Description
  391. End With
  392. On Error Goto 0
  393. Controller.SolMask(0) = 0
  394. vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the Timer to renable all the solenoids after 2 seconds
  395. Controller.DIP(0) = &H00
  396. ' Controller.Run GetPlayerHWnd
  397. controller.run
  398. Controller.Switch(22) = 1 'close coin door
  399. Controller.Switch(24) = 1 'and keep it close
  400.  
  401. If ArenaMod=1 then
  402. ' Wall80.isdropped=false
  403. ' Wall123.isdropped=false
  404.  
  405. else
  406. ' Wall80.isdropped=True
  407. ' Wall123.isdropped=True
  408. End If
  409.  
  410. ' Nudging
  411. vpmNudge.TiltSwitch = 14
  412. vpmNudge.Sensitivity = 1
  413. vpmNudge.TiltObj = Array(LeftSlingshot, RightSlingshot, bumper1, bumper2, bumper3)
  414.  
  415. ' Trough & Ball Release
  416. Set bsTrough = New cvpmBallStack
  417. With bsTrough
  418. .InitSw 0, 32, 33, 34, 35, 31, 0, 0
  419. .InitKick BallRelease, 180, 10
  420. .InitExitSnd SoundFX("fx_Ballrel",DOFContactors), SoundFX("fx_solenoid",DOFContactors)
  421. .InitEntrySnd "fx_solenoid", "fx_solenoid"
  422. .IsTrough = True
  423. .Balls = 4
  424. End With
  425.  
  426. ' Ball Catch Magnet
  427. Set MagnetCatch = New cvpmMagnet
  428. With MagnetCatch
  429. .InitMagnet BCMagnet, 7
  430. .Solenoid = 8
  431. .CreateEvents "MagnetCatch"
  432. End With
  433.  
  434. ' Eject
  435. Set bsEject = New cvpmBallStack
  436. With bsEject
  437. .InitSaucer sw25, 25, 165, 15
  438. .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  439. End With
  440.  
  441. ' Saucers (In the Paint)
  442. Set bsSaucer1 = New cvpmBallStack
  443. With bsSaucer1
  444. .InitSaucer sw68, 68, 65, 32
  445. .Kickz = 1.2
  446. .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  447. End With
  448.  
  449. Set bsSaucer2 = New cvpmBallStack
  450. With bsSaucer2
  451. .InitSaucer sw67, 67, 26, 28
  452. .Kickz = 1.15
  453. .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  454. End With
  455.  
  456. Set bsSaucer3 = New cvpmBallStack
  457. With bsSaucer3
  458. .InitSaucer sw66, 66, 337, 28
  459. .Kickz = 1.15
  460. .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  461. End With
  462.  
  463. Set bsSaucer4 = New cvpmBallStack
  464. With bsSaucer4
  465. .InitSaucer sw65, 65, 293, 31.5
  466. .Kickz = 1.2
  467. .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  468. End With
  469.  
  470. ' Defender
  471. Set mDefender = New cvpmMech
  472. With mDefender
  473. .MType = vpmMechOneDirSol + vpmMechStopEnd + vpmMechLinear
  474. .Sol1 = 37 'Enable
  475. .Sol2 = 38 'Direction
  476. .Length = 65
  477. .Steps = 65
  478. .AddSw 51, 0, 1
  479. .AddSw 52, 17, 18
  480. .AddSw 53, 31, 32
  481. .AddSw 54, 44, 45
  482. .AddSw 55, 64, 65
  483. .CallBack = GetRef("UpdateDefender")
  484. .Start
  485. End With
  486. UpdateDefender 32, 32, 32
  487.  
  488. 'Impulse Plunger
  489. Const IMPowerSetting = 38 ' Plunger Power
  490. Const IMTime = 1.1 ' Time in seconds for Full Plunge
  491. Set plungerIM = New cvpmImpulseP
  492. With plungerIM
  493. .InitImpulseP swPlunger, IMPowerSetting, IMTime
  494. .Switch 15
  495. .Random 0
  496. .InitExitSnd "fx_plunger2", "fx_plunger"
  497. .CreateEvents "plungerIM"
  498. End With
  499.  
  500. ' Misc. Initialisation
  501. LeftSLing.IsDropped = 1:LeftSLing2.IsDropped = 1:LeftSLing3.IsDropped = 1
  502. RightSLing.IsDropped = 1:RightSLing2.IsDropped = 1:RightSLing3.IsDropped = 1
  503. LeftSLingH.IsDropped = 1:LeftSLingH2.IsDropped = 1:LeftSLingH3.IsDropped = 1
  504. RightSLingH.IsDropped = 1:RightSLingH2.IsDropped = 1:RightSLingH3.IsDropped = 1
  505.  
  506.  
  507. For each ii in ADef1:ii.Isdropped = 1:Next
  508. For each ii in ADef2:ii.visible = 0:ii.Collidable = 0:Next
  509.  
  510. BackBall.CreateSizedBall(20).Image = "BasketBall"
  511.  
  512. ' Main Timer init
  513. PinMAMETimer.Interval = PinMAMEInterval
  514. PinMAMETimer.Enabled = 1
  515. 'StartShake
  516.  
  517. Dim DesktopMode: DesktopMode = Table1.ShowDT
  518.  
  519. If DesktopMode = True Then
  520. EMreel1.visible=true
  521. Else
  522. EMreel1.visible=false
  523. end If
  524. End Sub
  525.  
  526.  
  527. Sub Table_exit()
  528. Controller.Stop
  529. End Sub
  530.  
  531. '**********
  532. ' Keys
  533. '**********
  534.  
  535.  
  536.  
  537. Sub table1_KeyDown(ByVal Keycode)
  538. If KeyCode = PlungerKey Then Controller.Switch(11) = 1
  539. If keycode = LeftTiltKey Then Nudge 90, 5:SoundNudgeLeft()
  540. If keycode = RightTiltKey Then Nudge 270, 5:SoundNudgeRight()
  541. If keycode = CenterTiltKey Then Nudge 0, 3:SoundNudgeCenter()
  542. If keycode = keyInsertCoin1 or keycode = keyInsertCoin2 or keycode = keyInsertCoin3 or keycode = keyInsertCoin4 Then
  543. Select Case Int(rnd*3)
  544. Case 0: PlaySound ("Coin_In_1"), 0, CoinSoundLevel, 0, 0.25
  545. Case 1: PlaySound ("Coin_In_2"), 0, CoinSoundLevel, 0, 0.25
  546. Case 2: PlaySound ("Coin_In_3"), 0, CoinSoundLevel, 0, 0.25
  547.  
  548. End Select
  549. End If
  550.  
  551. if keycode=StartGameKey then soundStartButton()
  552.  
  553. 'nFozzy Begin'
  554. If keycode = LeftFlipperKey Then FlipperActivate LeftFlipper, LFPress
  555. If keycode = RightFlipperKey Then FlipperActivate RightFlipper, RFPress
  556. 'nFozzy End'
  557.  
  558. If vpmKeyDown(keycode) Then Exit Sub
  559. End Sub
  560.  
  561.  
  562. Sub table1_KeyUp(ByVal Keycode)
  563.  
  564. 'nFozzy Begin'
  565. If keycode = LeftFlipperKey Then FlipperDeActivate LeftFlipper, LFPress
  566. If keycode = RightFlipperKey Then FlipperDeActivate RightFlipper, RFPress
  567. ' If keycode = LeftFlipperKey Then
  568. ' lfpress = 0
  569. ' leftflipper.eostorqueangle = EOSA
  570. ' leftflipper.eostorque = EOST
  571. ' End If
  572. ' If keycode = RightFlipperKey Then
  573. ' rfpress = 0
  574. ' rightflipper.eostorqueangle = EOSA
  575. ' rightflipper.eostorque = EOST
  576. ' End If
  577. 'nFozzy End'
  578.  
  579. If vpmKeyUp(keycode) Then Exit Sub
  580. If keycode = PlungerKey Then Controller.Switch(11) = 0
  581. End Sub
  582.  
  583. '*********
  584. ' Switches
  585. '********* -20 -15 -7
  586.  
  587. Dim LStep, RStep
  588.  
  589. Sub LeftSlingShot_Slingshot:LeftSling.IsDropped = 0:PlaySound SoundFX("fx_slingshot1",DOFContactors):vpmTimer.PulseSw 57:LStep = 0:Me.TimerEnabled = 1:End Sub
  590.  
  591. Sub LeftSlingShot_Timer
  592. Select Case LStep
  593. Case 0:LeftSLing.IsDropped = 0:LeftSLingH.IsDropped = 0
  594. Case 1: 'pause
  595. Case 2:LeftSLing.IsDropped = 1:LeftSLing2.IsDropped = 0:LeftSLingH.IsDropped = 1:LeftSLingH2.IsDropped = 0
  596. Case 3:LeftSLing2.IsDropped = 1:LeftSLing3.IsDropped = 0:LeftSLingH2.IsDropped = 1:LeftSLingH3.IsDropped = 0
  597. Case 4:LeftSLing3.IsDropped = 1:LeftSLingH3.IsDropped = 1:Me.TimerEnabled = 0
  598. End Select
  599.  
  600. LStep = LStep + 1
  601. End Sub
  602.  
  603. Sub RightSlingShot_Slingshot:RightSling.IsDropped = 0:PlaySound SoundFX("fx_slingshot2",DOFContactors):vpmTimer.PulseSw 58:RStep = 0:Me.TimerEnabled = 1:End Sub
  604. Sub RightSlingShot_Timer
  605. Select Case RStep
  606. Case 0:RightSLing.IsDropped = 0:RightSLingH.IsDropped = 0
  607. Case 1: 'pause
  608. Case 2:RightSLing.IsDropped = 1:RightSLing2.IsDropped = 0:RightSLingH.IsDropped = 1:RightSLingH2.IsDropped = 0
  609. Case 3:RightSLing2.IsDropped = 1:RightSLing3.IsDropped = 0:RightSLingH2.IsDropped = 1:RightSLingH3.IsDropped = 0
  610. Case 4:RightSLing3.IsDropped = 1:RightSLingH3.IsDropped = 1:Me.TimerEnabled = 0
  611. End Select
  612.  
  613. RStep = RStep + 1
  614. End Sub
  615.  
  616. ' Bumpers
  617. Sub Bumper1_Hit:vpmTimer.PulseSw 61:RandomSoundBumperMiddle(Bumper1):bump1 = 1:Me.TimerEnabled = 1:End Sub
  618. Sub Bumper1_Timer()
  619. Select Case bump1
  620. Case 1:bump1 = 2: BumperRing1.Z = -30
  621. Case 2:bump1 = 3: BumperRing1.Z = -20
  622. Case 3:bump1 = 4: BumperRing1.Z = -10
  623. Case 4:Me.TimerEnabled = 0: BumperRing1.Z = 0
  624. End Select
  625.  
  626. 'Bumper1R.State = ABS(Bumper1R.State - 1) 'refresh light
  627. End Sub
  628.  
  629. Sub Bumper2_Hit:vpmTimer.PulseSw 23:RandomSoundBumperMiddle(Bumper2):bump2 = 1:Me.TimerEnabled = 1:End Sub
  630. Sub Bumper2_Timer()
  631. Select Case bump2
  632. Case 1:bump2 = 2 : BumperRing2.Z = -30
  633. Case 2:bump2 = 3 : BumperRing2.Z = -20
  634. Case 3:bump2 = 4 : BumperRing2.Z = -10
  635. Case 4:Me.TimerEnabled = 0 : : BumperRing2.Z = 0
  636. End Select
  637. ' Bumper2R.State = ABS(Bumper2R.State - 1) 'refresh light
  638. End Sub
  639.  
  640. Sub Bumper3_Hit:vpmTimer.PulseSw 62:PlaySound SoundFX("fx_bumper3",DOFContactors):bump3 = 1:Me.TimerEnabled = 1:End Sub
  641. Sub Bumper3_Timer()
  642. Select Case bump3
  643. Case 1:bump3 = 2: BumperRing3.Z = -30
  644. Case 2:bump3 = 3: BumperRing3.Z = -20
  645. Case 3:bump3 = 4: BumperRing3.Z = -10
  646. Case 4:Me.TimerEnabled = 0: BumperRing3.Z = 0
  647. End Select
  648. ' Bumper3R.State = ABS(Bumper3R.State - 1) 'refresh light
  649. End Sub
  650.  
  651. ' Eject holes
  652. Sub Drain_Hit:ClearBallID:Playsound "fx_drain":bsTrough.AddBall Me:End Sub
  653. Sub sw25_Hit:Playsound "fx_kicker_enter":bsEject.AddBall 0:End Sub
  654.  
  655. Sub sw65_Hit
  656. PlaySound "fx_kicker_enter"
  657. bsSaucer4.AddBall 0
  658. End Sub
  659.  
  660. Sub sw66_Hit
  661. PlaySound "fx_kicker_enter"
  662. bsSaucer3.AddBall 0
  663. End Sub
  664.  
  665. Sub sw67_Hit
  666. PlaySound "fx_kicker_enter"
  667. bsSaucer2.AddBall 0
  668. End Sub
  669.  
  670. Sub sw68_Hit
  671. PlaySound "fx_kicker_enter"
  672. bsSaucer1.AddBall 0
  673. End Sub
  674.  
  675. ' Rollovers
  676. Sub sw26_Hit:Controller.Switch(26) = 1:End Sub
  677. Sub sw26_UnHit:Controller.Switch(26) = 0:End Sub
  678.  
  679. Sub sw16_Hit:Controller.Switch(16) = 1:End Sub
  680. Sub sw16_UnHit:Controller.Switch(16) = 0:End Sub
  681.  
  682. Sub sw17_Hit:Controller.Switch(17) = 1:End Sub
  683. Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
  684.  
  685. Sub sw27_Hit:Controller.Switch(27) = 1:End Sub
  686. Sub sw27_UnHit:Controller.Switch(27) = 0:End Sub
  687.  
  688. Sub sw56_Hit:Controller.Switch(56) = 1:End Sub
  689. Sub sw56_UnHit:Controller.Switch(56) = 0:End Sub
  690.  
  691. Sub sw38_Hit:Controller.Switch(38) = 1:End Sub
  692. Sub sw38_UnHit:Controller.Switch(38) = 0:End Sub
  693.  
  694. Sub sw48_Hit:Controller.Switch(48) = 1:End Sub
  695. Sub sw48_UnHit:Controller.Switch(48) = 0:End Sub
  696.  
  697. 'Optos
  698. Sub sw36_Hit:Controller.Switch(36) = 1:End Sub
  699. Sub sw36_UnHit:Controller.Switch(36) = 0:End Sub
  700.  
  701. Sub sw47_Hit:Controller.Switch(47) = 1:End Sub
  702. Sub sw47_UnHit:Controller.Switch(47) = 0:End Sub
  703.  
  704. Sub sw45_Hit:Controller.Switch(45) = 1:End Sub
  705. Sub sw45_UnHit:Controller.Switch(45) = 0:End Sub
  706.  
  707. Sub sw46_Hit:Controller.Switch(46) = 1:PlaySound "fx_metalrolling":ActiveBall.VelY = 10:End Sub
  708. Sub sw46_UnHit:Controller.Switch(46) = 0:End Sub
  709.  
  710. Sub sw44_Hit:Controller.Switch(44) = 1:End Sub
  711. Sub sw44_UnHit:Controller.Switch(44) = 0:End Sub
  712.  
  713. Sub sw37_Hit:Controller.Switch(37) = 1:End Sub
  714. Sub sw37_UnHit:Controller.Switch(37) = 0:End Sub
  715.  
  716. Sub sw64_Hit:Controller.Switch(64) = 1:End Sub
  717. Sub sw64_UnHit:Controller.Switch(64) = 0:End Sub
  718.  
  719. Sub sw63_Hit:Controller.Switch(63) = 1:End Sub '75h
  720. Sub sw63_UnHit:Controller.Switch(63) = 0:End Sub
  721.  
  722. Sub sw115_Hit:Controller.Switch(115) = 1:End Sub
  723. Sub sw115_UnHit:Controller.Switch(115) = 0:End Sub
  724.  
  725. Sub sw117_Hit:Controller.Switch(117) = 1:End Sub
  726. Sub sw117_UnHit:Controller.Switch(117) = 0:End Sub
  727.  
  728. Sub sw12_Hit:Controller.Switch(12) = 1:End Sub
  729. Sub sw12_UnHit:Controller.Switch(12) = 0:End Sub
  730. Sub sw1_Hit:BasketFlipper.RotateToStart:End Sub
  731. Sub sw2_Hit:BasketFlipper.RotateToStart:End Sub
  732. Sub sw3_Hit:BasketFlipper.RotateToStart:End Sub
  733.  
  734. Sub bask0_hit:EMreel1.setvalue (1):End Sub
  735. Sub bask1_hit:EMreel1.setvalue (2):End Sub
  736. Sub bask2_hit:EMreel1.setvalue (1):End Sub
  737. Sub bask3_hit:EMreel1.setvalue (0):End Sub
  738.  
  739.  
  740. '***********
  741. ' Solenoids
  742. '***********
  743.  
  744. SolCallBack(1) = "Auto_Plunger"
  745. 'SolCallBack(2) = Not Used
  746. 'SolCallBack(3) = "vpmSolWall Diverter2,True,"
  747. SolCallBack(3) = "SolDiverter2"
  748. SolCallBack(4) = "vpmSolWall Diverter1,True,"
  749. SolCallBack(5) = "bsEject.SolOut"
  750. SolCallBack(6) = "RightGate.Open ="
  751. SolCallBack(7) = "SolBasket"
  752. 'SolCallBack(8) ' magnet - handled in the magnet definition
  753. SolCallBack(9) = "bsTrough.SolOut"
  754. 'SolCallBack(10) = "vpmSolSound ""lSling"","
  755. 'SolCallBack(11) = "vpmSolSound ""lSling"","
  756. 'SolCallBack(12) = "vpmSolSound ""Jet1"","
  757. 'SolCallBack(13) = "vpmSolSound ""Jet1"","
  758. 'SolCallBack(14) = "vpmSolSound ""Jet1"","
  759.  
  760. SolCallBack(15) = "PassRight2"
  761. SolCallBack(16) = "PassLeft2"
  762.  
  763. SolCallBack(17) = "FlashSol17" '"SetLamp 117," 'eject kickout flasher
  764. SolCallBack(18) = "FlashSol18" '"SetLamp 118," 'left jet bumper
  765. SolCallBack(19) = "FlashSol19" '"SetLamp 119," 'upper left
  766. SolCallBack(20) = "FlashSol20" '"SetLamp 120," 'upper right
  767. SolCallBack(22) = "SetLamp 122," 'trophy insert TODO
  768. SolCallBack(24) = "FlashSol24" '"SetLamp 124," 'lower right left
  769.  
  770. SolCallBack(25) = "PassRight1"
  771. SolCallBack(26) = "PassLeft3"
  772. SolCallBack(27) = "PassRight3"
  773. SolCallBack(28) = "PassLeft4"
  774.  
  775. SolCallBack(33) = "bsSaucer1.SolOut"
  776. SolCallBack(34) = "bsSaucer2.SolOut"
  777. SolCallBack(35) = "bsSaucer3.SolOut"
  778. SolCallBack(36) = "bsSaucer4.SolOut"
  779. 'SolCallBack(37) = Motor Enable (defender) - handled in the mech
  780. 'SolCallBack(38) = Motor Direction (defender) - handled in the mech
  781. 'SolCallBack(39) = "ClockEnable"
  782. 'SolCallBack(40) = "ClockCount"
  783.  
  784. Sub Auto_Plunger(Enabled)
  785. If Enabled Then
  786. PlungerIM.AutoFire
  787. End If
  788. End Sub
  789.  
  790. Sub SolBasket(Enabled)
  791. If Enabled Then
  792. BackBall.Kick 330, 75
  793. If bgball=1 then BasketFlipper.RotateToEnd
  794. bgball=0
  795. End If
  796. End Sub
  797.  
  798. Sub BackBall1_Hit
  799. BackBall1.Destroyball
  800. BallReturn1.CreateSizedBall(20).Image = "BasketBall"
  801. BallReturn1.Kick 100, 15
  802. End Sub
  803. Sub BallReturn2_Hit
  804. BallReturn2.Destroyball
  805. BackBall.CreateSizedBall(20).Image = "BasketBall"
  806. bgball=1
  807. End Sub
  808.  
  809. Sub UpdateDefender(aNewPos, aSpeed, aLastPos)
  810. ADef1(aLastPos).IsDropped = True
  811. ADef1(aNewPos).IsDropped = False
  812. ADef2(aLastPos).visible = 0:ADef2(aLastPos).collidable = 0
  813. ADef2(aNewPos).visible = 1:ADef2(aNewPos).collidable = 1
  814. 'DefR.State = ABS(DefR.State -1)
  815. End Sub
  816.  
  817. ' In The Paint
  818.  
  819. Sub PassRight1(Enabled)
  820. If Enabled then
  821. bsSaucer1.Kickz = 0
  822. bsSaucer1.InitAltKick 110, 10
  823. bsSaucer1.ExitAltSol_On
  824. bsSaucer1.Kickz = 1.2
  825. End If
  826. End Sub
  827.  
  828. Sub PassRight2(Enabled)
  829. If Enabled then
  830. bsSaucer2.Kickz = 0
  831. bsSaucer2.InitAltKick 70, 12
  832. bsSaucer2.ExitAltSol_On
  833. bsSaucer2.Kickz = 1.15
  834. End If
  835. End Sub
  836.  
  837. Sub PassRight3(Enabled)
  838. If Enabled then
  839. bsSaucer3.Kickz = 0
  840. bsSaucer3.InitAltKick 45, 13
  841. bsSaucer3.ExitAltSol_On
  842. bsSaucer3.Kickz = 1.15
  843. End If
  844. End Sub
  845.  
  846. Sub PassLeft2(Enabled)
  847. If Enabled then
  848. bsSaucer2.Kickz = 0
  849. bsSaucer2.InitAltKick 315, 13
  850. bsSaucer2.ExitAltSol_On
  851. bsSaucer2.Kickz = 1.15
  852. End If
  853. End Sub
  854.  
  855. Sub PassLeft3(Enabled)
  856. If Enabled then
  857. bsSaucer3.Kickz = 0
  858. bsSaucer3.InitAltKick 295, 14
  859. bsSaucer3.ExitAltSol_On
  860. bsSaucer3.Kickz = 1.15
  861. End If
  862. End Sub
  863.  
  864. Sub PassLeft4(Enabled)
  865. If Enabled then
  866. bsSaucer4.Kickz = 0
  867. bsSaucer4.InitAltKick 250, 10
  868. bsSaucer4.ExitAltSol_On
  869. bsSaucer4.Kickz = 1.2
  870. End If
  871. End Sub
  872.  
  873.  
  874.  
  875. '***************************************
  876. ' Special JP Flippers, including:
  877. ' - tap code by Jimmifingers
  878. ' - recoil fix to enable dropcatches
  879. ' - ball hit sound
  880. '**************************************
  881.  
  882. SolCallback(sLRFlipper) = "SolRFlipper"
  883. SolCallback(sLLFlipper) = "SolLFlipper"
  884.  
  885. Const ReflipAngle = 20
  886.  
  887. Sub SolLFlipper(Enabled)
  888. If Enabled Then
  889. LF.Fire 'leftflipper.rotatetoend
  890.  
  891. If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
  892. RandomSoundReflipUpLeft LeftFlipper
  893. Else
  894. SoundFlipperUpAttackLeft LeftFlipper
  895. RandomSoundFlipperUpLeft LeftFlipper
  896. End If
  897. Else
  898. LeftFlipper.RotateToStart
  899. If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
  900. RandomSoundFlipperDownLeft LeftFlipper
  901. End If
  902. FlipperLeftHitParm = FlipperUpSoundLevel
  903. End If
  904. End Sub
  905.  
  906. Sub SolRFlipper(Enabled)
  907. If Enabled Then
  908. RF.Fire 'rightflipper.rotatetoend
  909.  
  910. If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
  911. RandomSoundReflipUpRight RightFlipper
  912. Else
  913. SoundFlipperUpAttackRight RightFlipper
  914. RandomSoundFlipperUpRight RightFlipper
  915. End If
  916. Else
  917. RightFlipper.RotateToStart
  918. If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
  919. RandomSoundFlipperDownRight RightFlipper
  920. End If
  921. FlipperRightHitParm = FlipperUpSoundLevel
  922. End If
  923. End Sub
  924.  
  925.  
  926.  
  927. '******************************************************
  928. ' FLIPPER AND RUBBER CORRECTION
  929. '******************************************************
  930.  
  931. dim LF : Set LF = New FlipperPolarity
  932. dim RF : Set RF = New FlipperPolarity
  933.  
  934. InitPolarity
  935.  
  936. Sub InitPolarity()
  937. dim x, a : a = Array(LF, RF)
  938. for each x in a
  939. 'safety coefficient (diminishes polarity correction only)
  940. 'x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 0 'don't mess with these
  941. x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
  942. x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
  943.  
  944. x.enabled = True
  945. 'x.DebugOn = True : stickL.visible = True : tbpl.visible = True : vpmSolFlipsTEMP.DebugOn = True
  946. x.TimeDelay = 60
  947. Next
  948.  
  949. 'rf.report "Velocity"
  950. addpt "Velocity", 0, 0, 1
  951. addpt "Velocity", 1, 0.1, 1.07
  952. addpt "Velocity", 2, 0.2, 1.15
  953. addpt "Velocity", 3, 0.3, 1.25
  954. addpt "Velocity", 4, 0.41, 1.05
  955. addpt "Velocity", 5, 0.65, 1.0'0.982
  956. addpt "Velocity", 6, 0.702, 0.968
  957. addpt "Velocity", 7, 0.95, 0.968
  958. addpt "Velocity", 8, 1.03, 0.945
  959.  
  960. AddPt "Polarity", 0, 0, 0
  961. AddPt "Polarity", 1, 0.05, -5.5
  962. AddPt "Polarity", 2, 0.4, -5.5
  963. AddPt "Polarity", 3, 0.8, -5.5
  964. AddPt "Polarity", 4, 0.85, -5.25
  965. AddPt "Polarity", 5, 0.9, -4.25
  966. AddPt "Polarity", 6, 0.95, -3.75
  967. AddPt "Polarity", 7, 1, -3.25
  968. AddPt "Polarity", 8, 1.05, -2.25
  969. AddPt "Polarity", 9, 1.1, -1.5
  970. AddPt "Polarity", 10, 1.15, -1
  971. AddPt "Polarity", 11, 1.2, -0.5
  972. AddPt "Polarity", 12, 1.25, 0
  973. AddPt "Polarity", 13, 1.3, 0
  974.  
  975. LF.Object = LeftFlipper
  976. LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
  977. RF.Object = RightFlipper
  978. RF.EndPoint = EndPointRp
  979. End Sub
  980.  
  981. Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
  982. dim a : a = Array(LF, RF)
  983. dim x : for each x in a
  984. x.addpoint aStr, idx, aX, aY
  985. Next
  986. End Sub
  987.  
  988. 'Trigger Hit - .AddBall activeball
  989. 'Trigger UnHit - .PolarityCorrect activeball
  990. dim LFFlipBall, RFFlipBall : LFFlipBall = 0 : RFFlipBall = 0
  991.  
  992.  
  993. Sub TriggerLF_Hit() : LF.Addball activeball : LFFlipBall = 1 : End Sub
  994. Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : LFFlipBall = 0 : End Sub
  995. Sub TriggerRF_Hit() : RF.Addball activeball : RFFlipBall = 1 : End Sub
  996. Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : RFFlipBall = 0 : End Sub
  997.  
  998. 'Methods:
  999. '.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
  1000. '.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
  1001. '.Object - set to flipper reference. Optional.
  1002. '.StartPoint - set start point coord. Unnecessary, if .object is used.
  1003.  
  1004. 'Called with flipper -
  1005. 'ProcessBalls - catches ball data.
  1006. ' - OR -
  1007. '.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
  1008.  
  1009. Class FlipperPolarity
  1010. Public DebugOn, Enabled
  1011. Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
  1012. Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
  1013. private Flipper, FlipperStart,FlipperEnd, FlipperEndY, LR, PartialFlipCoef
  1014. Private Balls(20), balldata(20)
  1015.  
  1016. dim PolarityIn, PolarityOut
  1017. dim VelocityIn, VelocityOut
  1018. dim YcoefIn, YcoefOut
  1019. Public Sub Class_Initialize
  1020. redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
  1021. Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
  1022. End Sub
  1023.  
  1024. Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
  1025. Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
  1026. Public Property Get StartPoint : StartPoint = FlipperStart : End Property
  1027. Public Property Let EndPoint(aInput) : FlipperEnd = aInput.x: FlipperEndY = aInput.y: End Property
  1028. Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
  1029. Public Property Get EndPointY: EndPointY = FlipperEndY : End Property
  1030.  
  1031.  
  1032. Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
  1033. Select Case aChooseArray
  1034. case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
  1035. Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
  1036. Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
  1037. End Select
  1038. if gametime > 100 then Report aChooseArray
  1039. End Sub
  1040.  
  1041. Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
  1042. if not DebugOn then exit sub
  1043. dim a1, a2 : Select Case aChooseArray
  1044. case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
  1045. Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
  1046. Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
  1047. case else :tbpl.text = "wrong string" : exit sub
  1048. End Select
  1049. dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  1050. tbpl.text = str
  1051. End Sub
  1052.  
  1053. 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
  1054.  
  1055. Private Sub RemoveBall(aBall)
  1056. dim x : for x = 0 to uBound(balls)
  1057. if TypeName(balls(x) ) = "IBall" then
  1058. if aBall.ID = Balls(x).ID Then
  1059. balls(x) = Empty
  1060. Balldata(x).Reset
  1061. End If
  1062. End If
  1063. Next
  1064. End Sub
  1065.  
  1066. Public Sub Fire()
  1067. Flipper.RotateToEnd
  1068. processballs
  1069. End Sub
  1070.  
  1071. Public Property Get Pos 'returns % position a ball. For debug stuff.
  1072. dim x : for x = 0 to uBound(balls)
  1073. if not IsEmpty(balls(x) ) then
  1074. pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
  1075. End If
  1076. Next
  1077. End Property
  1078.  
  1079. Public Sub ProcessBalls() 'save data of balls in flipper range
  1080. FlipAt = GameTime
  1081. dim x : for x = 0 to uBound(balls)
  1082. if not IsEmpty(balls(x) ) then
  1083. balldata(x).Data = balls(x)
  1084. End If
  1085. Next
  1086. PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
  1087. PartialFlipCoef = abs(PartialFlipCoef-1)
  1088. End Sub
  1089. Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
  1090.  
  1091. Public Sub PolarityCorrect(aBall)
  1092. if FlipperOn() then
  1093. dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
  1094.  
  1095. 'y safety Exit
  1096. if aBall.VelY > -8 then 'ball going down
  1097. RemoveBall aBall
  1098. exit Sub
  1099. end if
  1100.  
  1101. 'Find balldata. BallPos = % on Flipper
  1102. for x = 0 to uBound(Balls)
  1103. if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
  1104. idx = x
  1105. BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
  1106. if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1107. end if
  1108. Next
  1109.  
  1110. If BallPos = 0 Then 'no ball data meaning the ball is entering and exiting pretty close to the same position, use current values.
  1111. BallPos = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
  1112. if ballpos > 0.65 then Ycoef = LinearEnvelope(aBall.Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
  1113. End If
  1114.  
  1115. 'Velocity correction
  1116. if not IsEmpty(VelocityIn(0) ) then
  1117. Dim VelCoef
  1118. : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
  1119.  
  1120. if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
  1121.  
  1122. if Enabled then aBall.Velx = aBall.Velx*VelCoef
  1123. if Enabled then aBall.Vely = aBall.Vely*VelCoef
  1124. End If
  1125.  
  1126. 'Polarity Correction (optional now)
  1127. if not IsEmpty(PolarityIn(0) ) then
  1128. If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
  1129. dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
  1130.  
  1131. if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
  1132. 'debug.print BallPos & " " & AddX & " " & Ycoef & " "& PartialFlipcoef & " "& VelCoef
  1133. 'playsound "fx_knocker"
  1134. End If
  1135. End If
  1136. RemoveBall aBall
  1137. End Sub
  1138. End Class
  1139.  
  1140.  
  1141. '================================
  1142. 'Helper Functions
  1143.  
  1144.  
  1145. Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
  1146. dim x, aCount : aCount = 0
  1147. redim a(uBound(aArray) )
  1148. for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
  1149. if not IsEmpty(aArray(x) ) Then
  1150. if IsObject(aArray(x)) then
  1151. Set a(aCount) = aArray(x)
  1152. Else
  1153. a(aCount) = aArray(x)
  1154. End If
  1155. aCount = aCount + 1
  1156. End If
  1157. Next
  1158. if offset < 0 then offset = 0
  1159. redim aArray(aCount-1+offset) 'Resize original array
  1160. for x = 0 to aCount-1 'set objects back into original array
  1161. if IsObject(a(x)) then
  1162. Set aArray(x) = a(x)
  1163. Else
  1164. aArray(x) = a(x)
  1165. End If
  1166. Next
  1167. End Sub
  1168.  
  1169. Sub ShuffleArrays(aArray1, aArray2, offset)
  1170. ShuffleArray aArray1, offset
  1171. ShuffleArray aArray2, offset
  1172. End Sub
  1173.  
  1174.  
  1175. Function BallSpeed(ball) 'Calculates the ball speed
  1176. BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
  1177. End Function
  1178.  
  1179. Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
  1180. dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
  1181. Y = M*x+b
  1182. PSlope = Y
  1183. End Function
  1184.  
  1185. Function NullFunctionZ(aEnabled):End Function '1 argument null function placeholder TODO move me or replac eme
  1186.  
  1187. Class spoofball
  1188. Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
  1189. Public Property Let Data(aBall)
  1190. With aBall
  1191. x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
  1192. id = .ID : mass = .mass : radius = .radius
  1193. end with
  1194. End Property
  1195. Public Sub Reset()
  1196. x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
  1197. id = Empty : mass = Empty : radius = Empty
  1198. End Sub
  1199. End Class
  1200.  
  1201. Function Distance(ax,ay,bx,by)
  1202. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1203. End Function
  1204.  
  1205. Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
  1206. DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
  1207. End Function
  1208.  
  1209. '******************** Slacky Flips **************************'
  1210. Dim FlipY
  1211. FlipY = rightflipper.y
  1212.  
  1213. Const Dislocation = 2 'Amount of minimum slack, affect to recovery speed too
  1214. Const SlackHitLimit = 10 '6-16 Lower value will make slack happen with lower collision force
  1215. Const HitForceDivider = 50 '10-100 Lower value will add slack. Set to roughly half of the max hit force(parm) you see when playing
  1216. Const MaxSlack = 4
  1217. Dim SlackAmount
  1218.  
  1219. Sub CheckFlipperSlack(ball, Flipper, Logo, parm)
  1220. If slackyFlips = 1 Then
  1221. SlackAmount = Dislocation + parm / HitForceDivider
  1222. if SlackAmount > MaxSlack then SlackAmount = MaxSlack
  1223. if parm > SlackHitLimit Then
  1224. Flipper.Y = FlipY + SlackAmount
  1225. Logo.Y = FlipY + SlackAmount
  1226. slacktimer.interval = 10
  1227. slacktimer.Enabled = 1
  1228. 'debug.print parm & " parm and SlackAmount " & SlackAmount
  1229. end If
  1230. end If
  1231. end Sub
  1232.  
  1233. Sub slacktimer_timer()
  1234. 'msgbox "location change" & RightFlipper.Y & " and " & LeftFlipper.Y
  1235. if RightFlipper.Y > FlipY + 2 Then
  1236. RightFlipper.Y = RightFlipper.Y - 2
  1237. RFLogo.Y = RFLogo.Y - 2
  1238. else
  1239. RightFlipper.Y = FlipY
  1240. RFLogo.Y = FlipY
  1241. End If
  1242. if LeftFlipper.Y > FlipY + 2 Then
  1243. LeftFlipper.Y = LeftFlipper.Y - 2
  1244. LFLogo.Y = LFLogo.Y - 2
  1245. else
  1246. LeftFlipper.Y = FlipY
  1247. LFLogo.Y = FlipY
  1248. End If
  1249.  
  1250. if LeftFlipper.Y = FlipY and RightFlipper.Y = FlipY Then slacktimer.Enabled = 0
  1251. end Sub
  1252. 'Then you need to add this to the flipper collide sub:
  1253. 'CheckFlipperSlack Activeball, LeftFlipper, LFLogo, parm
  1254.  
  1255. '******************************************************
  1256. ' FLIPPER TRICKS
  1257. '******************************************************
  1258.  
  1259. RightFlipper.timerinterval=-1
  1260. Rightflipper.timerenabled=True
  1261.  
  1262. sub RightFlipper_timer()
  1263. FlipperTricks LeftFlipper, LFPress, LFCount, LFEndAngle, LFState
  1264. FlipperTricks RightFlipper, RFPress, RFCount, RFEndAngle, RFState
  1265. If FlipSolNudge = 1 Then
  1266. FlipperNudge RightFlipper, RFEndAngle, RFEOSNudge, LeftFlipper, LFEndAngle
  1267. FlipperNudge LeftFlipper, LFEndAngle, LFEOSNudge, RightFlipper, RFEndAngle
  1268. End If
  1269. end sub
  1270.  
  1271. Dim LFEOSNudge, RFEOSNudge
  1272.  
  1273. Sub FlipperNudge(Flipper1, Endangle1, EOSNudge1, Flipper2, EndAngle2)
  1274. Dim BOT, b
  1275.  
  1276. If Flipper1.currentangle = Endangle1 and EOSNudge1 <> 1 Then
  1277. EOSNudge1 = 1
  1278. 'debug.print Flipper1.currentangle &" = "& Endangle1 &"--"& Flipper2.currentangle &" = "& EndAngle2
  1279. If Flipper2.currentangle = EndAngle2 Then
  1280. BOT = GetBalls
  1281. 'debug.print "nudge ball " & BOT(0).x
  1282. For b = 0 to Ubound(BOT)
  1283. If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper2) Then
  1284. BOT(b).velx = BOT(b).velx / 1.7
  1285. BOT(b).vely = BOT(b).vely - 1
  1286. end If
  1287. Next
  1288. End If
  1289. Else
  1290. If Flipper1.currentangle <> EndAngle1 then
  1291. EOSNudge1 = 0
  1292. end if
  1293. End If
  1294. End Sub
  1295.  
  1296. '*************************************************
  1297. ' Check ball distance from Flipper for Rem
  1298. '*************************************************
  1299.  
  1300. Function Distance(ax,ay,bx,by)
  1301. Distance = SQR((ax - bx)^2 + (ay - by)^2)
  1302. End Function
  1303.  
  1304. Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
  1305. DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
  1306. End Function
  1307.  
  1308. Function Radians(Degrees)
  1309. Radians = Degrees * PI /180
  1310. End Function
  1311.  
  1312. Function AnglePP(ax,ay,bx,by)
  1313. AnglePP = Atn2((by - ay),(bx - ax))*180/PI
  1314. End Function
  1315.  
  1316. Function Atn2(dy, dx)
  1317. If dx > 0 Then
  1318. Atn2 = Atn(dy / dx)
  1319. ElseIf dx < 0 Then
  1320. Atn2 = Sgn(dy) * (PI - Atn(Abs(dy / dx)))
  1321. ElseIf dy = 0 Then
  1322. Atn2 = 0
  1323. Else
  1324. Atn2 = Sgn(dy) * PI / 2
  1325. End If
  1326. End Function
  1327.  
  1328. Function DistanceFromFlipper(ballx, bally, Flipper)
  1329. DistanceFromFlipper = DistancePL(ballx, bally, Flipper.x, Flipper.y, Cos(Radians(Flipper.currentangle+90))+Flipper.x, Sin(Radians(Flipper.currentangle+90))+Flipper.y)
  1330. End Function
  1331.  
  1332. Function FlipperTrigger(ballx, bally, Flipper)
  1333. Dim DiffAngle
  1334. DiffAngle = ABS(Flipper.currentangle - AnglePP(Flipper.x, Flipper.y, ballx, bally) - 90)
  1335. If DiffAngle > 180 Then DiffAngle = DiffAngle - 360
  1336.  
  1337. If DistanceFromFlipper(ballx,bally,Flipper) < 48 and DiffAngle <= 90 and Distance(ballx,bally,Flipper.x,Flipper.y) < Flipper.Length Then
  1338. FlipperTrigger = True
  1339. Else
  1340. FlipperTrigger = False
  1341. End If
  1342. End Function
  1343.  
  1344. '*************************************************
  1345. ' End - Check ball distance from Flipper for Rem
  1346. '*************************************************
  1347.  
  1348.  
  1349.  
  1350. dim LFPress, RFPress, LFCount, RFCount
  1351. dim LFState, RFState
  1352. dim EOST, EOSA,Frampup, FElasticity,FReturn
  1353. dim RFEndAngle, LFEndAngle
  1354.  
  1355. EOST = leftflipper.eostorque
  1356. EOSA = leftflipper.eostorqueangle
  1357. Frampup = LeftFlipper.rampup
  1358. FElasticity = LeftFlipper.elasticity
  1359. FReturn = LeftFlipper.return
  1360. Const EOSTnew = 1
  1361. Const EOSAnew = 0.8
  1362. Const EOSRampup = 0
  1363. Dim SOSRampup
  1364. SOSRampup = 2.5
  1365. 'Const LiveCatch = 16
  1366. Const LiveElasticity = 0.45
  1367. Const SOSEM = 0.815
  1368. Const EOSReturn = 0.025
  1369.  
  1370. LFEndAngle = Leftflipper.endangle
  1371. RFEndAngle = RightFlipper.endangle
  1372.  
  1373. Sub FlipperActivate(Flipper, FlipperPress)
  1374. FlipperPress = 1
  1375. Flipper.Elasticity = FElasticity
  1376.  
  1377. Flipper.eostorque = EOST
  1378. Flipper.eostorqueangle = EOSA
  1379. End Sub
  1380.  
  1381. Sub FlipperDeactivate(Flipper, FlipperPress)
  1382. FlipperPress = 0
  1383. Flipper.eostorqueangle = EOSA
  1384. Flipper.eostorque = EOST*EOSReturn/FReturn
  1385.  
  1386.  
  1387. If Abs(Flipper.currentangle) <= Abs(Flipper.endangle) + 0.1 Then
  1388. Dim BOT, b
  1389. BOT = GetBalls
  1390.  
  1391. For b = 0 to UBound(BOT)
  1392. If Distance(BOT(b).x, BOT(b).y, Flipper.x, Flipper.y) < 55 Then 'check for cradle
  1393. If BOT(b).vely >= -0.4 Then BOT(b).vely = -0.4
  1394. End If
  1395. Next
  1396. End If
  1397. End Sub
  1398.  
  1399. Sub FlipperTricks (Flipper, FlipperPress, FCount, FEndAngle, FState)
  1400. Dim Dir
  1401. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1402.  
  1403. If Abs(Flipper.currentangle) > Abs(Flipper.startangle) - 0.05 Then
  1404. If FState <> 1 Then
  1405. Flipper.rampup = SOSRampup
  1406. Flipper.endangle = FEndAngle - 3*Dir
  1407. Flipper.Elasticity = FElasticity * SOSEM
  1408. FCount = 0
  1409. FState = 1
  1410. End If
  1411. ElseIf Abs(Flipper.currentangle) <= Abs(Flipper.endangle) and FlipperPress = 1 then
  1412. if FCount = 0 Then FCount = GameTime
  1413.  
  1414. If FState <> 2 Then
  1415. Flipper.eostorqueangle = EOSAnew
  1416. Flipper.eostorque = EOSTnew
  1417. Flipper.rampup = EOSRampup
  1418. Flipper.endangle = FEndAngle
  1419. FState = 2
  1420. End If
  1421. Elseif Abs(Flipper.currentangle) > Abs(Flipper.endangle) + 0.01 and FlipperPress = 1 Then
  1422. If FState <> 3 Then
  1423. Flipper.eostorque = EOST
  1424. Flipper.eostorqueangle = EOSA
  1425. Flipper.rampup = Frampup
  1426. Flipper.Elasticity = FElasticity
  1427. FState = 3
  1428. End If
  1429.  
  1430. End If
  1431. End Sub
  1432.  
  1433. Const LiveDistanceMin = 30 'minimum distance in vp units from flipper base live catch dampening will occur
  1434. Const LiveDistanceMax = 114 'maximum distance in vp units from flipper base live catch dampening will occur (tip protection)
  1435.  
  1436. Sub CheckLiveCatch(ball, Flipper, FCount, parm) 'Experimental new live catch
  1437. Dim Dir
  1438. Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
  1439. Dim LiveCatchBounce 'If live catch is not perfect, it won't freeze ball totally
  1440. Dim CatchTime : CatchTime = GameTime - FCount
  1441.  
  1442. if CatchTime <= LiveCatch and parm > 6 and ABS(Flipper.x - ball.x) > LiveDistanceMin and ABS(Flipper.x - ball.x) < LiveDistanceMax Then
  1443. if CatchTime <= LiveCatch*0.5 Then 'Perfect catch only when catch time happens in the beginning of the window
  1444. LiveCatchBounce = 0
  1445. else
  1446. LiveCatchBounce = Abs((LiveCatch/2) - CatchTime) 'Partial catch when catch happens a bit late
  1447. end If
  1448.  
  1449. If LiveCatchBounce = 0 and ball.velx * Dir > 0 Then ball.velx = 0
  1450. ball.vely = LiveCatchBounce * (16 / LiveCatch) ' Multiplier for inaccuracy bounce
  1451. ball.angmomx= 0
  1452. ball.angmomy= 0
  1453. ball.angmomz= 0
  1454. debug.print "Live catch! Time: " & CatchTime & " Bounce: " & LiveCatchBounce & " parm: " & parm
  1455. End If
  1456.  
  1457. End Sub
  1458.  
  1459. '*****************************************************************************************************
  1460. '*******************************************************************************************************
  1461. 'END nFOZZY FLIPPERS'
  1462.  
  1463.  
  1464. '******************
  1465. ' RealTime Updates
  1466. '******************
  1467.  
  1468. Sub GameTimer_Timer
  1469. BallShadowUpdate
  1470. RollingSound
  1471. LampTimer
  1472. UpdateLED
  1473. RDampen
  1474. LFLogo.RotZ = LeftFlipper.CurrentAngle
  1475. RFlogo.RotZ = RightFlipper.CurrentAngle
  1476. LeftFlipperSh.RotZ = LeftFlipper.currentangle
  1477. RightFlipperSh.RotZ = RightFlipper.currentangle
  1478. End Sub
  1479.  
  1480.  
  1481. '*************************************************
  1482. ' destruk's new vpmCreateBall for ball collision
  1483. ' use it: vpmCreateBall kicker
  1484. '*************************************************
  1485.  
  1486. Set vpmCreateBall = GetRef("mycreateball")
  1487. Function mycreateball(aKicker)
  1488. For cnt = 1 to ubound(ballStatus)
  1489. If ballStatus(cnt) = 0 Then
  1490. If Not IsEmpty(vpmBallImage) Then
  1491. Set CurrentBall(cnt) = aKicker.CreateSizedBall(BSize).Image
  1492. Else
  1493. Set CurrentBall(cnt) = aKicker.CreateSizedBall(BSize)
  1494. End If
  1495. Set mycreateball = aKicker
  1496. currentball(cnt).uservalue = cnt
  1497. ballStatus(cnt) = 1
  1498. ballStatus(0) = ballStatus(0) + 1
  1499. If coff = False Then
  1500. If ballStatus(0) > 1 and XYdata.enabled = False Then XYdata.enabled = True
  1501. End If
  1502. Exit For
  1503. End If
  1504. Next
  1505. End Function
  1506.  
  1507. '**************************************************************
  1508. ' vpm Ball Collision based on the code by Steely & Pinball Ken
  1509. ' added destruk's changes, ball size and height check by koadic
  1510. '**************************************************************
  1511.  
  1512. Const tnopb = 10 'max nr. of balls
  1513. Const nosf = 10 'nr. of sound files
  1514.  
  1515. ReDim CurrentBall(tnopb), BallStatus(tnopb)
  1516. Dim iball, cnt, coff, errMessage
  1517.  
  1518. XYdata.interval = 1
  1519. coff = False
  1520.  
  1521. For cnt = 0 to ubound(BallStatus):BallStatus(cnt) = 0:Next
  1522.  
  1523. ' Create ball in kicker and assign a Ball ID used mostly in non-vpm tables
  1524. Sub CreateBallID(aKicker)
  1525. For cnt = 1 to ubound(ballStatus)
  1526. If ballStatus(cnt) = 0 Then
  1527. Set CurrentBall(cnt) = aKicker.CreateSizedBall(Bsize)
  1528. currentball(cnt).uservalue = cnt
  1529. ballStatus(cnt) = 1
  1530. ballStatus(0) = ballStatus(0) + 1
  1531. If coff = False Then
  1532. If ballStatus(0) > 1 and XYdata.enabled = False Then XYdata.enabled = True
  1533. End If
  1534. Exit For
  1535. End If
  1536. Next
  1537. End Sub
  1538.  
  1539. Sub ClearBallID
  1540. On Error Resume Next
  1541. iball = ActiveBall.uservalue
  1542. currentball(iball).UserValue = 0
  1543. If Err Then Msgbox Err.description & vbCrLf & iball
  1544. ballStatus(iBall) = 0
  1545. ballStatus(0) = ballStatus(0) -1
  1546. On Error Goto 0
  1547. End Sub
  1548.  
  1549. ' Ball data collection and B2B Collision detection. jpsalas: added height check
  1550. ReDim baX(tnopb, 4), baY(tnopb, 4), baZ(tnopb, 4), bVx(tnopb, 4), bVy(tnopb, 4), TotalVel(tnopb, 4)
  1551. Dim cForce, bDistance, xyTime, cFactor, id, id2, id3, B1, B2
  1552.  
  1553. Sub XYdata_Timer()
  1554. xyTime = Timer + (XYdata.interval * .001)
  1555. If id2 >= 4 Then id2 = 0
  1556. id2 = id2 + 1
  1557. For id = 1 to ubound(ballStatus)
  1558. If ballStatus(id) = 1 Then
  1559. baX(id, id2) = round(currentball(id).x, 2)
  1560. baY(id, id2) = round(currentball(id).y, 2)
  1561. baZ(id, id2) = round(currentball(id).z, 2)
  1562. bVx(id, id2) = round(currentball(id).velx, 2)
  1563. bVy(id, id2) = round(currentball(id).vely, 2)
  1564. TotalVel(id, id2) = (bVx(id, id2) ^2 + bVy(id, id2) ^2)
  1565. If TotalVel(id, id2) > TotalVel(0, 0) Then TotalVel(0, 0) = int(TotalVel(id, id2) )
  1566. End If
  1567. Next
  1568.  
  1569. id3 = id2:B2 = 2:B1 = 1
  1570. Do
  1571. If ballStatus(B1) = 1 and ballStatus(B2) = 1 Then
  1572. bDistance = int((TotalVel(B1, id3) + TotalVel(B2, id3) ) ^(1.04 * (CurrentBall(B1).radius + CurrentBall(B2).radius) / 50) )
  1573. If((baX(B1, id3) - baX(B2, id3) ) ^2 + (baY(B1, id3) - baY(B2, id3) ) ^2) < (2800 * ((CurrentBall(B1).radius + CurrentBall(B2).radius) / 50) ^2) + bDistance Then
  1574. If ABS(baZ(B1, id3) - baZ(B2, id3) ) < (CurrentBall(B1).radius + CurrentBall(B2).radius) Then collide B1, B2:Exit Sub
  1575. End If
  1576. End If
  1577. B1 = B1 + 1
  1578. If B1 = ubound(ballstatus) Then Exit Do
  1579. If B1 >= B2 then B1 = 1:B2 = B2 + 1
  1580. Loop
  1581.  
  1582. If ballStatus(0) <= 1 Then XYdata.enabled = False
  1583.  
  1584. If XYdata.interval >= 40 Then coff = True:XYdata.enabled = False
  1585. If Timer > xyTime * 3 Then coff = True:XYdata.enabled = False
  1586. If Timer > xyTime Then XYdata.interval = XYdata.interval + 1
  1587. End Sub
  1588.  
  1589. 'Calculate the collision force and play sound
  1590. Dim cTime, cb1, cb2, avgBallx, cAngle, bAngle1, bAngle2
  1591.  
  1592. Sub Collide(cb1, cb2)
  1593. If TotalVel(0, 0) / 1.8 > cFactor Then cFactor = int(TotalVel(0, 0) / 1.8)
  1594. avgBallx = (bvX(cb2, 1) + bvX(cb2, 2) + bvX(cb2, 3) + bvX(cb2, 4) ) / 4
  1595. If avgBallx < bvX(cb2, id2) + .1 and avgBallx > bvX(cb2, id2) -.1 Then
  1596. If ABS(TotalVel(cb1, id2) - TotalVel(cb2, id2) ) < .000005 Then Exit Sub
  1597. End If
  1598. If Timer < cTime Then Exit Sub
  1599. cTime = Timer + .1
  1600. GetAngle baX(cb1, id3) - baX(cb2, id3), baY(cb1, id3) - baY(cb2, id3), cAngle
  1601. id3 = id3 - 1:If id3 = 0 Then id3 = 4
  1602. GetAngle bVx(cb1, id3), bVy(cb1, id3), bAngle1
  1603. GetAngle bVx(cb2, id3), bVy(cb2, id3), bAngle2
  1604. cForce = Cint((abs(TotalVel(cb1, id3) * Cos(cAngle-bAngle1) ) + abs(TotalVel(cb2, id3) * Cos(cAngle-bAngle2) ) ) )
  1605. If cForce < 4 Then Exit Sub
  1606. cForce = Cint((cForce) / (cFactor / nosf) )
  1607. If cForce > nosf-1 Then cForce = nosf-1
  1608. PlaySound("fx_collide" & cForce)
  1609. End Sub
  1610.  
  1611. ' Get angle
  1612. Dim Xin, Yin, rAngle, Radit, wAngle, Pi
  1613. Pi = Round(4 * Atn(1), 6) '3.1415926535897932384626433832795
  1614.  
  1615. Sub GetAngle(Xin, Yin, wAngle)
  1616. If Sgn(Xin) = 0 Then
  1617. If Sgn(Yin) = 1 Then rAngle = 3 * Pi / 2 Else rAngle = Pi / 2
  1618. If Sgn(Yin) = 0 Then rAngle = 0
  1619. Else
  1620. rAngle = atn(- Yin / Xin)
  1621. End If
  1622. If sgn(Xin) = -1 Then Radit = Pi Else Radit = 0
  1623. If sgn(Xin) = 1 and sgn(Yin) = 1 Then Radit = 2 * Pi
  1624. wAngle = round((Radit + rAngle), 4)
  1625. End Sub
  1626.  
  1627. ' #####################################
  1628. ' ###### Flupper Flasher Domes #####
  1629. ' #####################################
  1630.  
  1631. Dim TestFlashers, TableRef, FlasherLightIntensity, FlasherFlareIntensity, FlasherBloomIntensity, FlasherOffBrightness
  1632.  
  1633. ' *********************************************************************
  1634. TestFlashers = 0 ' *** set this to 1 to check position of flasher object ***
  1635. Set TableRef = Table1 ' *** change this, if your table has another name ***
  1636. FlasherLightIntensity = 0.1 ' *** lower this, if the VPX lights are too bright (i.e. 0.1) ***
  1637. FlasherFlareIntensity = 0.2 ' *** lower this, if the flares are too bright (i.e. 0.1) ***
  1638. FlasherBloomIntensity = 0.4
  1639. FlasherOffBrightness = 0.5 ' *** brightness of the flasher dome when switched off (range 0-2) ***
  1640. ' *********************************************************************
  1641.  
  1642. Dim ObjLevel(20), objbase(20), objlit(20), objflasher(20), objbloom(20), objlight(20)
  1643. Dim tablewidth, tableheight : tablewidth = TableRef.width : tableheight = TableRef.height
  1644. ''initialise the flasher color, you can only choose from "green", "red", "purple", "blue", "white" and "yellow"
  1645. InitFlasher 1, "white" : InitFlasher 2, "blue" : InitFlasher 3, "red" : InitFlasher 4, "blue" : InitFlasher 5, "blue"
  1646. InitFlasher 6, "yellow" : InitFlasher 7, "yellow" : InitFlasher 8, "yellow" : InitFlasher 9, "yellow" : InitFlasher 10, "red"
  1647. '' rotate the flasher with the command below (first argument = flasher nr, second argument = angle in degrees)
  1648. 'RotateFlasher 4,17 : RotateFlasher 5,0 : RotateFlasher 6,90
  1649. 'RotateFlasher 7,0 : RotateFlasher 8,0
  1650. 'RotateFlasher 9,-45 : RotateFlasher 10,90 : RotateFlasher 11,90
  1651. rotateflasher 6,47
  1652. rotateflasher 7,37
  1653. rotateflasher 8, -4
  1654. rotateflasher 9, -52
  1655.  
  1656. Flasherlight5.BulbHaloHeight = 120
  1657. Flasherlight4.BulbHaloHeight = 145
  1658. Flasherlight1.BulbHaloHeight = 55
  1659. Flasherlight2.BulbHaloHeight = 177
  1660. Flasherlight3.BulbHaloHeight = 88
  1661.  
  1662. Sub InitFlasher(nr, col)
  1663. ' store all objects in an array for use in FlashFlasher subroutine
  1664. Set objbase(nr) = Eval("Flasherbase" & nr) : Set objlit(nr) = Eval("Flasherlit" & nr)
  1665. Set objflasher(nr) = Eval("Flasherflash" & nr) : Set objlight(nr) = Eval("Flasherlight" & nr)
  1666. Set objbloom(nr) = Eval("Flasherbloom" & nr)
  1667. ' If the flasher is parallel to the playfield, rotate the VPX flasher object for POV and place it at the correct height
  1668. If objbase(nr).RotY = 0 Then
  1669. objbase(nr).ObjRotZ = atn( (tablewidth/2 - objbase(nr).x) / (objbase(nr).y - tableheight*1.1)) * 180 / 3.14159
  1670. objflasher(nr).RotZ = objbase(nr).ObjRotZ : objflasher(nr).height = objbase(nr).z + 40
  1671. End If
  1672. ' set all effects to invisible and move the lit primitive at the same position and rotation as the base primitive
  1673. objlight(nr).IntensityScale = 0 : objlit(nr).visible = 0 : objlit(nr).material = "Flashermaterial" & nr
  1674. objlit(nr).RotX = objbase(nr).RotX : objlit(nr).RotY = objbase(nr).RotY : objlit(nr).RotZ = objbase(nr).RotZ
  1675. objlit(nr).ObjRotX = objbase(nr).ObjRotX : objlit(nr).ObjRotY = objbase(nr).ObjRotY : objlit(nr).ObjRotZ = objbase(nr).ObjRotZ
  1676. objlit(nr).x = objbase(nr).x : objlit(nr).y = objbase(nr).y : objlit(nr).z = objbase(nr).z
  1677. objbase(nr).BlendDisableLighting = FlasherOffBrightness
  1678. ' set the texture and color of all objects
  1679. select case objbase(nr).image
  1680. Case "dome2basewhite" : objbase(nr).image = "dome2base" & col : objlit(nr).image = "dome2lit" & col :
  1681. Case "ronddomebasewhite" : objbase(nr).image = "ronddomebase" & col : objlit(nr).image = "ronddomelit" & col
  1682. Case "domeearbasewhite" : objbase(nr).image = "domeearbase" & col : objlit(nr).image = "domeearlit" & col
  1683. end select
  1684. If TestFlashers = 0 Then objflasher(nr).imageA = "domeflashwhite" : objflasher(nr).visible = 0 : End If
  1685. select case col
  1686. Case "blue" : objlight(nr).color = RGB(4,120,255) : objflasher(nr).color = RGB(20,155,255) ': objlight(nr).intensity = 5000
  1687. Case "green" : objlight(nr).color = RGB(12,255,4) : objflasher(nr).color = RGB(12,255,4)
  1688. Case "red" : objlight(nr).color = RGB(255,32,4) : objflasher(nr).color = RGB(255,32,4)
  1689. Case "purple" : objlight(nr).color = RGB(230,49,255) : objflasher(nr).color = RGB(255,64,255)
  1690. Case "yellow" : objlight(nr).color = RGB(200,173,25) : objflasher(nr).color = RGB(255,200,50)
  1691. Case "white" : objlight(nr).color = RGB(255,240,150) : objflasher(nr).color = RGB(100,86,59)
  1692. end select
  1693. objlight(nr).colorfull = objlight(nr).color
  1694. If TableRef.ShowDT and ObjFlasher(nr).RotX = -45 Then
  1695. objflasher(nr).height = objflasher(nr).height - 20 * ObjFlasher(nr).y / tableheight
  1696. ObjFlasher(nr).y = ObjFlasher(nr).y + 10
  1697. End If
  1698. 'FlasherFlash4.height = 226
  1699. 'FlasherFlash3.height = 200
  1700. End Sub
  1701.  
  1702. Sub RotateFlasher(nr, angle) : angle = ((angle + 360 - objbase(nr).ObjRotZ) mod 180)/30 : objbase(nr).showframe(angle) : objlit(nr).showframe(angle) : End Sub
  1703.  
  1704. Sub FlashFlasher(nr)
  1705. If not objflasher(nr).TimerEnabled Then objflasher(nr).TimerEnabled = True : objflasher(nr).visible = 1 : objbloom(nr).visible = 1 : objlit(nr).visible = 1 : End If
  1706. objflasher(nr).opacity = 1000 * FlasherFlareIntensity * ObjLevel(nr)^2.5
  1707. objbloom(nr).opacity = 100 * FlasherBloomIntensity * ObjLevel(nr)^2.5
  1708. objlight(nr).IntensityScale = 0.5 * FlasherLightIntensity * ObjLevel(nr)^3
  1709. objbase(nr).BlendDisableLighting = FlasherOffBrightness + 10 * ObjLevel(nr)^3
  1710. objlit(nr).BlendDisableLighting = 10 * ObjLevel(nr)^2
  1711. UpdateMaterial "Flashermaterial" & nr,0,0,0,0,0,0,ObjLevel(nr),RGB(255,255,255),0,0,False,True,0,0,0,0
  1712. ObjLevel(nr) = ObjLevel(nr) * 0.9 - 0.01
  1713. If ObjLevel(nr) < 0 Then objflasher(nr).TimerEnabled = False : objflasher(nr).visible = 0 : objbloom(nr).visible = 0 : objlit(nr).visible = 0 : End If
  1714. End Sub
  1715.  
  1716. Sub FlasherFlash1_Timer() : FlashFlasher(1) : End Sub
  1717. Sub FlasherFlash2_Timer() : FlashFlasher(2) : End Sub
  1718. Sub FlasherFlash3_Timer() : FlashFlasher(3) : End Sub
  1719. Sub FlasherFlash4_Timer() : FlashFlasher(4) : End Sub
  1720. Sub FlasherFlash5_Timer() : FlashFlasher(5) : End Sub
  1721. Sub FlasherFlash6_Timer() : FlashFlasher(6) : End Sub
  1722. Sub FlasherFlash7_Timer() : FlashFlasher(7) : End Sub
  1723. Sub FlasherFlash8_Timer() : FlashFlasher(8) : End Sub
  1724. Sub FlasherFlash9_Timer() : FlashFlasher(9) : End Sub
  1725. Sub FlasherFlash10_Timer() : FlashFlasher(10) : End Sub
  1726.  
  1727. ' ###############################################
  1728. ' ###### NBA Fastbreak flasher dome settings #####
  1729. ' ###############################################
  1730.  
  1731. Sub FlashSol24(flstate)
  1732. If Flstate Then
  1733. Objlevel(1) = 1 : FlasherFlash1_Timer
  1734. Objlevel(2) = 1 : FlasherFlash2_Timer
  1735. End If
  1736. End Sub
  1737.  
  1738. Sub FlashSol17(flstate)
  1739. If Flstate Then
  1740. Objlevel(3) = 1 : FlasherFlash3_Timer
  1741. End If
  1742. End Sub
  1743.  
  1744. Sub FlashSol18(flstate)
  1745. If Flstate Then
  1746. Objlevel(10) = 1 : FlasherFlash10_Timer
  1747. End If
  1748. End Sub
  1749.  
  1750. Sub FlashSol19(flstate)
  1751. If Flstate Then
  1752. Objlevel(4) = 1 : FlasherFlash4_Timer
  1753. End If
  1754. End Sub
  1755.  
  1756. Sub FlashSol20(flstate)
  1757. If Flstate Then
  1758. Objlevel(5) = 1 : FlasherFlash5_Timer
  1759. End If
  1760. End Sub
  1761.  
  1762. Sub FlashRondo(nr, flstate)
  1763. If Flstate Then
  1764. Select Case nr
  1765. Case 67:Objlevel(9) = 1 : FlasherFlash9_Timer
  1766. Case 68:Objlevel(8) = 1 : FlasherFlash8_Timer
  1767. Case 77:Objlevel(6) = 1 : FlasherFlash6_Timer
  1768. Case 78:Objlevel(7) = 1 : FlasherFlash7_Timer
  1769. End Select
  1770. End If
  1771. End Sub
  1772.  
  1773. '***************************************************
  1774. ' JP's VP10 Fading Lamps & Flashers
  1775. ' Based on PD's Fading Light System
  1776. ' SetLamp 0 is Off
  1777. ' SetLamp 1 is On
  1778. ' fading for non opacity objects is 4 steps
  1779. '***************************************************
  1780.  
  1781. Dim LampState(200), FadingLevel(200)
  1782. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  1783.  
  1784. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  1785. 'LampTimer.Interval = 10 'lamp fading speed
  1786. 'LampTimer.Enabled = 1
  1787.  
  1788. ' Lamp & Flasher Timers
  1789.  
  1790. Sub LampTimer()
  1791. Dim chgLamp, num, chg, ii
  1792. chgLamp = Controller.ChangedLamps
  1793. If Not IsEmpty(chgLamp) Then
  1794. For ii = 0 To UBound(chgLamp)
  1795. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  1796. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  1797. Next
  1798. End If
  1799. UpdateLamps
  1800. End Sub
  1801.  
  1802. Sub UpdateLamps
  1803. NFadeLm 11, l11
  1804. FadeDisableLighting2 11, p11, 122
  1805. NfadeLm 12, l12
  1806. FadeDisableLighting2 12, p12, 70
  1807. NfadeLm 13, l13
  1808. FadeDisableLighting2 13, p13, 70
  1809. NfadeLm 14, l14
  1810. FadeDisableLighting2 14, p14, 70
  1811. NfadeLm 15, l15
  1812. FadeDisableLighting2 15, p15, 122
  1813. NfadeLm 16, l16
  1814. FadeDisableLighting2 16, p16, 122
  1815. NfadeLm 17, l17
  1816. FadeDisableLighting2 17, p17, 122
  1817. NfadeLm 18, l18
  1818. FadeDisableLighting2 18, p18, 122
  1819. NfadeLm 21, l21
  1820. FadeDisableLighting2 21, p21, 122
  1821. NfadeLm 22, l22
  1822. FadeDisableLighting2 22, p22, 110
  1823. NfadeLm 23, l23
  1824. FadeDisableLighting2 23, p23, 110
  1825. NfadeLm 24, l24
  1826. FadeDisableLighting2 24, p24, 110
  1827. NfadeLm 25, l25
  1828. FadeDisableLighting2 25, p25, 120
  1829. NfadeLm 26, l26
  1830. NfadeLm 26, l26a
  1831. FadeDisableLighting2 26, p26off, 15
  1832. NfadeLm 27, l27
  1833. FadeDisableLighting2 27, p27, 110
  1834. NfadeLm 28, l28
  1835. FadeDisableLighting2 28, p28, 122
  1836. NfadeLm 31, l31
  1837. FadeDisableLighting2 31, p31, 122
  1838. NfadeLm 32, l32
  1839. FadeDisableLighting2 32, p32, 122
  1840. NfadeLm 33, l33
  1841. FadeDisableLighting2 33, p33, 122
  1842. NfadeLm 34, l34
  1843. FadeDisableLighting2 34, p34, 122
  1844. NfadeLm 35, l35
  1845. FadeDisableLighting2 35, p35, 110
  1846. NfadeLm 36, l36
  1847. FadeDisableLighting2 36, p36, 110
  1848. NfadeLm 37, l37
  1849. NfadeLm 37, l37a
  1850. FadeDisableLighting2 37, p37, 55
  1851. NfadeLm 38, l38
  1852. NfadeLm 38, l38a
  1853. FadeDisableLighting2 38,p38, 90
  1854. NfadeLm 41, l41
  1855. FadeDisableLighting2 41, p41, 110
  1856. NfadeLm 42, l42
  1857. FadeDisableLighting2 42, p42, 110
  1858. NfadeLm 43, l43
  1859. NfadeLm 43, l43a
  1860. FadeDisableLighting2 43, p43, 90
  1861. NfadeLm 44, l44
  1862. FadeDisableLighting2 44, p44, 110
  1863. NfadeLm 45, l45
  1864. FadeDisableLighting2 45, p45, 110
  1865. NfadeLm 46, l46
  1866. FadeDisableLighting2 46, p46, 33
  1867. NfadeLm 47, l47
  1868. FadeDisableLighting2 47, p47, 33
  1869. NfadeLm 48, l48
  1870. FadeDisableLighting2 48, p48, 70
  1871. NfadeLm 51, l51
  1872. NfadeLm 51, l51a
  1873. FadeDisableLighting2 51,p51, 55
  1874. NfadeLm 52, l52
  1875. FadeDisableLighting2 52,p52, 155
  1876. NfadeLm 53, l53
  1877. NfadeLm 53, l53a
  1878. FadeDisableLighting2 53,p53, 300
  1879. NfadeLm 54, l54
  1880. NfadeLm 54, l54a
  1881. FadeDisableLighting2 54,p54, 88
  1882. NfadeLm 55, l55
  1883. NfadeLm 55, l55a
  1884. FadeDisableLighting2 55,p55, 55
  1885. NfadeLm 56, l56
  1886. FadeDisableLighting2 56, p56, 90
  1887. NfadeLm 57, l57
  1888. FadeDisableLighting2 57, p57, 60
  1889. NfadeLm 58, l58
  1890. FadeDisableLighting2 58, p58, 70
  1891. NFadeLm 61, l61b
  1892. NfadeLm 61, l61
  1893. FadeDisableLightingM 61, p61b, 90
  1894. FadeDisableLighting2 61, p61, 90
  1895. NfadeLm 62, l62
  1896. FadeDisableLighting2 62, p62, 110
  1897. NfadeLm 63, l63
  1898. FadeDisableLighting2 63, p63, 110
  1899. NfadeLm 64, l64
  1900. FadeDisableLighting2 64, p64, 110
  1901. NfadeLm 65, l65
  1902. FadeDisableLighting2 65, p65, 110
  1903. NfadeLm 66, l66
  1904. NfadeLm 66, l66a
  1905. FadeDisableLighting2 66,p66, 55
  1906.  
  1907. NfadeL 71, l71
  1908. FadeDisableLighting2 71, p71, 110
  1909. NfadeL 72, l72
  1910. FadeDisableLighting2 72, p72, 110
  1911.  
  1912. NfadeLm 73, l73
  1913. NfadeLm 73, l73a
  1914. FadeDisableLighting2 73, p73, 55
  1915.  
  1916. NfadeLm 74, l74
  1917. FadeDisableLighting2 74, p74, 110
  1918. NfadeLm 75, l75
  1919. FadeDisableLighting2 75, p75, 110
  1920. NFadeLm 76, l76
  1921. NfadeLm 76, l76a
  1922. FadeDisableLighting2 76, p76, 55
  1923. NfadeLm 81, l81
  1924. FadeDisableLighting2 81, p81, 110
  1925. NfadeLm 82, l82
  1926. FadeDisableLighting2 82, p82, 110
  1927. NfadeLm 83, l83
  1928. NfadeLm 83, l83a
  1929. FadeDisableLighting2 83, p83, 55
  1930. NfadeLm 84, l84
  1931. FadeDisableLighting2 84, p84, 110
  1932. NfadeLm 85, l85
  1933. FadeDisableLighting2 85, p85, 110
  1934. NfadeLm 86, l86
  1935. FadeDisableLighting2 86, p86, 110
  1936. NfadeL 87, l87
  1937. NfadeL 88, l88
  1938.  
  1939. ' fadeobj 67, l67, "of_on", "of_a", "of_b", "empty"
  1940. ' fadeobj 68, l68, "of_on", "of_a", "of_b", "empty"
  1941. ' fadeobj 77, l77, "of_on", "of_a", "of_b", "empty"
  1942. ' fadeobj 78, l78, "of_on", "of_a", "of_b", "empty"
  1943. ' flash 67,f67
  1944. ' flash 68,f68
  1945. flash2 67
  1946. flash2 68
  1947. flash2 77
  1948. flash2 78
  1949. 'flash 78,f78
  1950.  
  1951.  
  1952.  
  1953. ' flashers old
  1954. ' fadeobj 117, f17, "rf_on", "rf_a", "rf_b", "empty"
  1955. ' NFadeLm 118, bumper1
  1956. ' fadeobj 118, f18, "rf_on", "rf_a", "rf_b", "empty"
  1957. ' fadeobj 119, f19, "wf_on", "wf_a", "wf_b", "empty"
  1958. ' fadeobj 120, f20, "bf_on", "bf_a", "bf_b", "empty"
  1959. ' fadeobjm 124, f24, "wf_on", "wf_a", "wf_b", "empty"
  1960. ' fadeobj 124, f24b, "bf_on", "bf_a", "bf_b", "empty"
  1961.  
  1962. ' flashers new
  1963. ' flash 117,f17
  1964. ' flash 118,f18
  1965. ' flash 119,f19
  1966. ' flash 120,f20
  1967. ' flashm 124,f24b
  1968. ' flash 124,f24
  1969. End Sub
  1970.  
  1971. ' div lamp subs
  1972.  
  1973. Sub InitLamps()
  1974. Dim x
  1975. For x = 0 to 200
  1976. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  1977. FadingLevel(x) = 4 ' used to track the fading state
  1978. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  1979. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  1980. FlashMax(x) = 1 ' the maximum value when on, usually 1
  1981. FlashMin(x) = 0 ' the minimum value when off, usually 0
  1982. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  1983. Next
  1984. End Sub
  1985.  
  1986. Sub AllLampsOff
  1987. Dim x
  1988. For x = 0 to 200
  1989. SetLamp x, 0
  1990. Next
  1991. End Sub
  1992.  
  1993.  
  1994. const gInsertLevel = 0.5
  1995.  
  1996. Sub FadeDisableLightingM(nr, a, alvl)
  1997. ' debug.print "fade value" & FadingLevel(nr)
  1998. Select Case FadingLevel(nr)
  1999. Case 4
  2000. a.UserValue = a.UserValue - 0.200
  2001. If a.UserValue < 0 Then
  2002. a.UserValue = 0
  2003. 'FadingLevel(nr) = -1
  2004. end If
  2005. a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
  2006. Case 5
  2007. a.UserValue = a.UserValue + 0.200
  2008. If a.UserValue > 1 Then
  2009. a.UserValue = 1
  2010. 'FadingLevel(nr) = -1
  2011. end If
  2012. a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
  2013. End Select
  2014. End Sub
  2015.  
  2016. Sub FadeDisableLighting2(nr, a, alvl)
  2017. 'if nr = 83 then debug.print "fade level: " & a.UserValue
  2018. Select Case FadingLevel(nr)
  2019. Case 4
  2020. a.UserValue = a.UserValue - 0.200
  2021. If a.UserValue < 0 Then
  2022. a.UserValue = 0
  2023. FadingLevel(nr) = 0
  2024. end If
  2025. a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
  2026. Case 5
  2027. a.UserValue = a.UserValue + 0.200
  2028. If a.UserValue > 1 Then
  2029. a.UserValue = 1
  2030. FadingLevel(nr) = 1
  2031. end If
  2032. a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
  2033. End Select
  2034. End Sub
  2035.  
  2036. Sub SetLamp(nr, value)
  2037. If value <> LampState(nr) Then
  2038. LampState(nr) = abs(value)
  2039. FadingLevel(nr) = abs(value) + 4
  2040. End If
  2041. End Sub
  2042.  
  2043. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  2044.  
  2045. Sub NFadeL(nr, object)
  2046. Select Case FadingLevel(nr)
  2047. Case 4:object.state = 0:FadingLevel(nr) = 0
  2048. Case 5:object.state = 1:FadingLevel(nr) = 1
  2049. End Select
  2050. End Sub
  2051.  
  2052. Sub NFadeLm(nr, object)
  2053. Select Case FadingLevel(nr)
  2054. Case 4:object.state = 0
  2055. Case 5:object.state = 1
  2056. End Select
  2057. End Sub
  2058.  
  2059. 'Lights, Ramps & Primitives used as 4 step fading lights
  2060. 'a,b,c,d are the images used from on to off
  2061.  
  2062. Sub FadeObj(nr, object, a, b, c, d)
  2063. Select Case FadingLevel(nr)
  2064. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  2065. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  2066. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  2067. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  2068. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  2069. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  2070. End Select
  2071. End Sub
  2072.  
  2073. Sub FadeObjm(nr, object, a, b, c, d)
  2074. Select Case FadingLevel(nr)
  2075. Case 4:object.image = b
  2076. Case 5:object.image = a
  2077. Case 9:object.image = c
  2078. Case 13:object.image = d
  2079. End Select
  2080. End Sub
  2081.  
  2082. Sub NFadeObj(nr, object, a, b)
  2083. Select Case FadingLevel(nr)
  2084. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  2085. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  2086. End Select
  2087. End Sub
  2088.  
  2089. Sub NFadeObjm(nr, object, a, b)
  2090. Select Case FadingLevel(nr)
  2091. Case 4:object.image = b
  2092. Case 5:object.image = a
  2093. End Select
  2094. End Sub
  2095.  
  2096. ' Flasher objects
  2097.  
  2098. Sub Flash(nr, object)
  2099. Select Case FadingLevel(nr)
  2100. Case 4 'off
  2101. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  2102. If FlashLevel(nr) < FlashMin(nr) Then
  2103. FlashLevel(nr) = FlashMin(nr)
  2104. FadingLevel(nr) = 0 'completely off
  2105. End if
  2106. Object.IntensityScale = FlashLevel(nr)
  2107. Case 5 ' on
  2108. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  2109. If FlashLevel(nr) > FlashMax(nr) Then
  2110. FlashLevel(nr) = FlashMax(nr)
  2111. FadingLevel(nr) = 1 'completely on
  2112. End if
  2113. Object.IntensityScale = FlashLevel(nr)
  2114. End Select
  2115. End Sub
  2116.  
  2117. 'Flashf77
  2118. Sub Flash2(nr)
  2119. 'debug.print FadingLevel(nr)
  2120. Select Case FadingLevel(nr)
  2121. 'Case 4 'off
  2122. 'Flashf77(False)
  2123. Case 5 ' on
  2124. FlashRondo nr, True
  2125. End Select
  2126. End Sub
  2127.  
  2128. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  2129. Object.IntensityScale = FlashLevel(nr)
  2130. End Sub
  2131.  
  2132. Sub Flashm2(nr, object) 'multiple flashers, it just sets the flashlevel
  2133. Flashf77(FlashLevel(nr))
  2134. End Sub
  2135.  
  2136. ' Desktop Objects: Reels & texts (you may also use lights on the desktop)
  2137.  
  2138. ' Reels
  2139.  
  2140. Sub FadeR(nr, object)
  2141. Select Case FadingLevel(nr)
  2142. Case 4:object.SetValue 1:FadingLevel(nr) = 6 'fading to off...
  2143. Case 5:object.SetValue 0:FadingLevel(nr) = 1 'ON
  2144. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  2145. Case 9:object.SetValue 2:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  2146. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  2147. Case 13:object.SetValue 3:FadingLevel(nr) = 0 'Off
  2148. End Select
  2149. End Sub
  2150.  
  2151. Sub FadeRm(nr, object)
  2152. Select Case FadingLevel(nr)
  2153. Case 4:object.SetValue 1
  2154. Case 5:object.SetValue 0
  2155. Case 9:object.SetValue 2
  2156. Case 3:object.SetValue 3
  2157. End Select
  2158. End Sub
  2159.  
  2160. 'Texts
  2161.  
  2162. Sub NFadeT(nr, object, message)
  2163. Select Case FadingLevel(nr)
  2164. Case 4:object.Text = "":FadingLevel(nr) = 0
  2165. Case 5:object.Text = message:FadingLevel(nr) = 1
  2166. End Select
  2167. End Sub
  2168.  
  2169. Sub NFadeTm(nr, object, b)
  2170. Select Case FadingLevel(nr)
  2171. Case 4:object.Text = ""
  2172. Case 5:object.Text = message
  2173. End Select
  2174. End Sub
  2175.  
  2176.  
  2177. '********************
  2178. ' Diverse Help/Sounds
  2179. '********************
  2180.  
  2181. ''Sub ARubbers_Hit(idx):PlaySound "fx_rubber":End Sub
  2182. 'Sub APostRubbers_Hit(idx):PlaySound "fx_rubber":End Sub
  2183. 'Sub AMetals_Hit(idx):PlaySound "fx_MetalHit":End Sub
  2184. 'Sub AGates_Hit(idx):PlaySound "fx_Gate":End Sub
  2185. 'Sub APlastics_Hit(idx):PlaySound "fx_plastichit":End Sub
  2186.  
  2187. Sub WireEnter1_Hit:PlaySound "fx_metalrolling":End Sub
  2188. Sub WireExit1_Hit:StopSound "fx_metalrolling":PlaySound "fx_wirerampexit":End Sub
  2189.  
  2190.  
  2191.  
  2192. Sub RHelp1_Hit:PlaySound "fx_ballhit":End Sub
  2193. Sub RHelp2_Hit:PlaySound "fx_ballhit":End Sub
  2194. Sub RHelp5_Hit:PlaySound "fx_ballhit":End Sub
  2195. Sub RHelp3_Hit
  2196. If ActiveBall.VelY < -10 Then
  2197. ActiveBall.VelY = -10
  2198. End If
  2199. End Sub
  2200.  
  2201. Sub RHelp4_Hit
  2202. ActiveBall.VelX = -5
  2203. End Sub
  2204.  
  2205. '//////////////////////////// MECHANICAL SOUNDS ///////////////////////////
  2206. '// This part in the script is an entire block that is dedicated to the physics sound system.
  2207. '// Various scripts and sounds that may be pretty generic and could suit other WPC systems, but the most are tailored specifically for this table.
  2208.  
  2209. '/////////////////////////////// SOUNDS PARAMETERS //////////////////////////////
  2210. Dim GlobalSoundLevel, CoinSoundLevel, PlungerReleaseSoundLevel, PlungerPullSoundLevel, NudgeLeftSoundLevel
  2211. Dim NudgeRightSoundLevel, NudgeCenterSoundLevel, StartButtonSoundLevel, RollingSoundFactor
  2212.  
  2213. CoinSoundLevel = 1 'volume level; range [0, 1]
  2214. NudgeLeftSoundLevel = 1 'volume level; range [0, 1]
  2215. NudgeRightSoundLevel = 1 'volume level; range [0, 1]
  2216. NudgeCenterSoundLevel = 1 'volume level; range [0, 1]
  2217. StartButtonSoundLevel = 0.1 'volume level; range [0, 1]
  2218. PlungerReleaseSoundLevel = 0.8 '1 wjr 'volume level; range [0, 1]
  2219. PlungerPullSoundLevel = 1 'volume level; range [0, 1]
  2220. RollingSoundFactor = 1.1/5
  2221.  
  2222. '///////////////////////-----Solenoids, Kickers and Flash Relays-----///////////////////////
  2223. Dim FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel, FlipperUpAttackLeftSoundLevel, FlipperUpAttackRightSoundLevel
  2224. Dim FlipperUpSoundLevel, FlipperDownSoundLevel, FlipperLeftHitParm, FlipperRightHitParm
  2225. Dim SlingshotSoundLevel, BumperSoundFactor, KnockerSoundLevel
  2226.  
  2227. FlipperUpAttackMinimumSoundLevel = 0.010 'volume level; range [0, 1]
  2228. FlipperUpAttackMaximumSoundLevel = 0.635 'volume level; range [0, 1]
  2229. FlipperUpSoundLevel = 1.0 'volume level; range [0, 1]
  2230. FlipperDownSoundLevel = 0.45 'volume level; range [0, 1]
  2231. FlipperLeftHitParm = FlipperUpSoundLevel 'sound helper; not configurable
  2232. FlipperRightHitParm = FlipperUpSoundLevel 'sound helper; not configurable
  2233. SlingshotSoundLevel = 0.95 'volume level; range [0, 1]
  2234. BumperSoundFactor = 4.25 'volume multiplier; must not be zero
  2235. KnockerSoundLevel = 1 'volume level; range [0, 1]
  2236.  
  2237. '///////////////////////-----Ball Drops, Bumps and Collisions-----///////////////////////
  2238. Dim RubberStrongSoundFactor, RubberWeakSoundFactor, RubberFlipperSoundFactor,BallWithBallCollisionSoundFactor
  2239. Dim BallBouncePlayfieldSoftFactor, BallBouncePlayfieldHardFactor, PlasticRampDropToPlayfieldSoundLevel, WireRampDropToPlayfieldSoundLevel, DelayedBallDropOnPlayfieldSoundLevel
  2240. Dim WallImpactSoundFactor, MetalImpactSoundFactor, SubwaySoundLevel, SubwayEntrySoundLevel, ScoopEntrySoundLevel
  2241. Dim SaucerLockSoundLevel, SaucerKickSoundLevel
  2242.  
  2243. BallWithBallCollisionSoundFactor = 3.2 'volume multiplier; must not be zero
  2244. RubberStrongSoundFactor = 0.055/5 'volume multiplier; must not be zero
  2245. RubberWeakSoundFactor = 0.075/5 'volume multiplier; must not be zero
  2246. RubberFlipperSoundFactor = 0.075/5 'volume multiplier; must not be zero
  2247. BallBouncePlayfieldSoftFactor = 0.025 'volume multiplier; must not be zero
  2248. BallBouncePlayfieldHardFactor = 0.025 'volume multiplier; must not be zero
  2249. DelayedBallDropOnPlayfieldSoundLevel = 0.8 'volume level; range [0, 1]
  2250. WallImpactSoundFactor = 0.075 'volume multiplier; must not be zero
  2251. MetalImpactSoundFactor = 0.075/3
  2252. SaucerLockSoundLevel = 0.8
  2253. SaucerKickSoundLevel = 0.8
  2254.  
  2255. '///////////////////////-----Gates, Spinners, Rollovers and Targets-----///////////////////////
  2256.  
  2257. Dim GateSoundLevel, TargetSoundFactor, SpinnerSoundLevel, RolloverSoundLevel, DTSoundLevel
  2258.  
  2259. GateSoundLevel = 0.5/5 'volume level; range [0, 1]
  2260. TargetSoundFactor = 0.0025 * 10 'volume multiplier; must not be zero
  2261. DTSoundLevel = 0.25 'volume multiplier; must not be zero
  2262. RolloverSoundLevel = 0.25 'volume level; range [0, 1]
  2263.  
  2264. '///////////////////////-----Ball Release, Guides and Drain-----///////////////////////
  2265. Dim DrainSoundLevel, BallReleaseSoundLevel, BottomArchBallGuideSoundFactor, FlipperBallGuideSoundFactor
  2266.  
  2267. DrainSoundLevel = 0.8 'volume level; range [0, 1]
  2268. BallReleaseSoundLevel = 1 'volume level; range [0, 1]
  2269. BottomArchBallGuideSoundFactor = 0.2 'volume multiplier; must not be zero
  2270. FlipperBallGuideSoundFactor = 0.015 'volume multiplier; must not be zero
  2271.  
  2272. '///////////////////////-----Loops and Lanes-----///////////////////////
  2273. Dim ArchSoundFactor
  2274. ArchSoundFactor = 0.025/5 'volume multiplier; must not be zero
  2275.  
  2276.  
  2277. '///////////////////////////// SOUND PLAYBACK FUNCTIONS ////////////////////////////
  2278. '///////////////////////////// POSITIONAL SOUND PLAYBACK METHODS ////////////////////////////
  2279. ' Positional sound playback methods will play a sound, depending on the X,Y position of the table element or depending on ActiveBall object position
  2280. ' These are similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  2281. ' For surround setup - positional sound playback functions will fade between front and rear surround channels and pan between left and right channels
  2282. ' For stereo setup - positional sound playback functions will only pan between left and right channels
  2283. ' For mono setup - positional sound playback functions will not pan between left and right channels and will not fade between front and rear channels
  2284.  
  2285. ' PlaySound full syntax - PlaySound(string, int loopcount, float volume, float pan, float randompitch, int pitch, bool useexisting, bool restart, float front_rear_fade)
  2286. ' Note - These functions will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  2287. Sub PlaySoundAtLevelStatic(playsoundparams, aVol, tableobj)
  2288. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
  2289. End Sub
  2290.  
  2291. Sub PlaySoundAtLevelExistingStatic(playsoundparams, aVol, tableobj)
  2292. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
  2293. End Sub
  2294.  
  2295. Sub PlaySoundAtLevelStaticLoop(playsoundparams, aVol, tableobj)
  2296. PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
  2297. End Sub
  2298.  
  2299. Sub PlaySoundAtLevelStaticRandomPitch(playsoundparams, aVol, randomPitch, tableobj)
  2300. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
  2301. End Sub
  2302.  
  2303. Sub PlaySoundAtLevelActiveBall(playsoundparams, aVol)
  2304. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 0, 0, AudioFade(ActiveBall)
  2305. End Sub
  2306.  
  2307. Sub PlaySoundAtLevelExistingActiveBall(playsoundparams, aVol)
  2308. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 1, 0, AudioFade(ActiveBall)
  2309. End Sub
  2310.  
  2311. Sub PlaySoundAtLeveTimerActiveBall(playsoundparams, aVol, ballvariable)
  2312. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 0, 0, AudioFade(ballvariable)
  2313. End Sub
  2314.  
  2315. Sub PlaySoundAtLevelTimerExistingActiveBall(playsoundparams, aVol, ballvariable)
  2316. PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 1, 0, AudioFade(ballvariable)
  2317. End Sub
  2318.  
  2319. Sub PlaySoundAtLevelRoll(playsoundparams, aVol, pitch)
  2320. PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
  2321. End Sub
  2322.  
  2323. ' Previous Positional Sound Subs
  2324.  
  2325. Sub PlaySoundAt(soundname, tableobj)
  2326. PlaySound soundname, 1, 1 * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  2327. End Sub
  2328.  
  2329. Sub PlaySoundAtVol(soundname, tableobj, aVol)
  2330. PlaySound soundname, 1, aVol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  2331. End Sub
  2332.  
  2333. Sub PlaySoundAtBall(soundname)
  2334. PlaySoundAt soundname, ActiveBall
  2335. End Sub
  2336.  
  2337. Sub PlaySoundAtBallVol (Soundname, aVol)
  2338. Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 1, AudioFade(ActiveBall)
  2339. End Sub
  2340.  
  2341. Sub PlaySoundAtBallVolM (Soundname, aVol)
  2342. Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 0, AudioFade(ActiveBall)
  2343. End Sub
  2344.  
  2345. Sub PlaySoundAtVolLoops(sound, tableobj, Vol, Loops)
  2346. PlaySound sound, Loops, Vol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  2347. End Sub
  2348.  
  2349.  
  2350. ' *********************************************************************
  2351. ' Supporting Ball & Sound Functions
  2352. ' *********************************************************************
  2353.  
  2354. 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
  2355. Dim tmp
  2356. tmp = tableobj.y * 2 / tableheight-1
  2357. If tmp > 0 Then
  2358. AudioFade = Csng(tmp ^10)
  2359. Else
  2360. AudioFade = Csng(-((- tmp) ^10) )
  2361. End If
  2362. End Function
  2363.  
  2364. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  2365. Dim tmp
  2366. tmp = tableobj.x * 2 / tablewidth-1
  2367. If tmp > 0 Then
  2368. AudioPan = Csng(tmp ^10)
  2369. Else
  2370. AudioPan = Csng(-((- tmp) ^10) )
  2371. End If
  2372. End Function
  2373.  
  2374. Function Vol(ball) ' Calculates the volume of the sound based on the ball speed
  2375. Vol = Csng(BallVel(ball) ^2)
  2376. End Function
  2377.  
  2378. Function Volz(ball) ' Calculates the volume of the sound based on the ball speed
  2379. Volz = Csng((ball.velz) ^2)
  2380. End Function
  2381.  
  2382. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  2383. Pitch = BallVel(ball) * 20
  2384. End Function
  2385.  
  2386. Function BallVel(ball) 'Calculates the ball speed
  2387. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  2388. End Function
  2389.  
  2390. Function VolPlayfieldRoll(ball) ' Calculates the roll volume of the sound based on the ball speed
  2391. VolPlayfieldRoll = RollingSoundFactor * 0.0005 * Csng(BallVel(ball) ^3)
  2392. End Function
  2393.  
  2394. Function PitchPlayfieldRoll(ball) ' Calculates the roll pitch of the sound based on the ball speed
  2395. PitchPlayfieldRoll = BallVel(ball) ^2 * 15
  2396. End Function
  2397.  
  2398. Function RndInt(min, max)
  2399. RndInt = Int(Rnd() * (max-min + 1) + min)' Sets a random number integer between min and max
  2400. End Function
  2401.  
  2402. Function RndNum(min, max)
  2403. RndNum = Rnd() * (max-min) + min' Sets a random number between min and max
  2404. End Function
  2405.  
  2406. '///////////////////////////// GENERAL SOUND SUBROUTINES ////////////////////////////
  2407. Sub SoundStartButton()
  2408. PlaySound ("Start_Button"), 0, StartButtonSoundLevel, 0, 0.25
  2409. End Sub
  2410.  
  2411. Sub SoundNudgeLeft()
  2412. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeLeftSoundLevel * VolumeDial, -0.1, 0.25
  2413. End Sub
  2414.  
  2415. Sub SoundNudgeRight()
  2416. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeRightSoundLevel * VolumeDial, 0.1, 0.25
  2417. End Sub
  2418.  
  2419. Sub SoundNudgeCenter()
  2420. PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeCenterSoundLevel * VolumeDial, 0, 0.25
  2421. End Sub
  2422.  
  2423.  
  2424. Sub SoundPlungerPull()
  2425. PlaySoundAtLevelStatic ("Plunger_Pull_1"), PlungerPullSoundLevel, Plunger
  2426. End Sub
  2427.  
  2428. Sub SoundPlungerReleaseBall()
  2429. PlaySoundAtLevelStatic ("Plunger_Release_Ball"), PlungerReleaseSoundLevel, Plunger
  2430. End Sub
  2431.  
  2432. Sub SoundPlungerReleaseNoBall()
  2433. PlaySoundAtLevelStatic ("Plunger_Release_No_Ball"), PlungerReleaseSoundLevel, Plunger
  2434. End Sub
  2435.  
  2436.  
  2437. '///////////////////////////// KNOCKER SOLENOID ////////////////////////////
  2438. Sub KnockerSolenoid()
  2439. PlaySoundAtLevelStatic SoundFX("Knocker_1",DOFKnocker), KnockerSoundLevel, KnockerPosition
  2440. End Sub
  2441.  
  2442. '///////////////////////////// DRAIN SOUNDS ////////////////////////////
  2443. Sub RandomSoundDrain(drainswitch)
  2444. PlaySoundAtLevelStatic ("Drain_" & Int(Rnd*11)+1), DrainSoundLevel, drainswitch
  2445. End Sub
  2446.  
  2447. '///////////////////////////// TROUGH BALL RELEASE SOLENOID SOUNDS ////////////////////////////
  2448.  
  2449. Sub RandomSoundBallRelease(drainswitch)
  2450. PlaySoundAtLevelStatic SoundFX("BallRelease" & Int(Rnd*7)+1,DOFContactors), BallReleaseSoundLevel, drainswitch
  2451. End Sub
  2452.  
  2453. '///////////////////////////// SLINGSHOT SOLENOID SOUNDS ////////////////////////////
  2454. Sub RandomSoundSlingshotLeft(sling)
  2455. PlaySoundAtLevelStatic SoundFX("Sling_L" & Int(Rnd*10)+1,DOFContactors), SlingshotSoundLevel, Sling
  2456. End Sub
  2457.  
  2458. Sub RandomSoundSlingshotRight(sling)
  2459. PlaySoundAtLevelStatic SoundFX("Sling_R" & Int(Rnd*8)+1,DOFContactors), SlingshotSoundLevel, Sling
  2460. End Sub
  2461.  
  2462. '///////////////////////////// BUMPER SOLENOID SOUNDS ////////////////////////////
  2463. Sub RandomSoundBumperTop(Bump)
  2464. PlaySoundAtLevelStatic SoundFX("Bumpers_Top_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2465. End Sub
  2466.  
  2467. Sub RandomSoundBumperMiddle(Bump)
  2468. PlaySoundAtLevelStatic SoundFX("Bumpers_Middle_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2469. End Sub
  2470.  
  2471. Sub RandomSoundBumperBottom(Bump)
  2472. PlaySoundAtLevelStatic SoundFX("Bumpers_Bottom_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
  2473. End Sub
  2474.  
  2475. '///////////////////////////// FLIPPER BATS SOUND SUBROUTINES ////////////////////////////
  2476. '///////////////////////////// FLIPPER BATS SOLENOID ATTACK SOUND ////////////////////////////
  2477. Sub SoundFlipperUpAttackLeft(flipper)
  2478. FlipperUpAttackLeftSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
  2479. PlaySoundAtLevelStatic ("Flipper_Attack-L01"), FlipperUpAttackLeftSoundLevel, flipper
  2480. End Sub
  2481.  
  2482. Sub SoundFlipperUpAttackRight(flipper)
  2483. FlipperUpAttackRightSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
  2484. PlaySoundAtLevelStatic ("Flipper_Attack-R01"), FlipperUpAttackLeftSoundLevel, flipper
  2485. End Sub
  2486.  
  2487. '///////////////////////////// FLIPPER BATS SOLENOID CORE SOUND ////////////////////////////
  2488. Sub RandomSoundFlipperUpLeft(flipper)
  2489. PlaySoundAtLevelStatic SoundFX("Flipper_L0" & Int(Rnd*11)+1,DOFFlippers), FlipperLeftHitParm, Flipper
  2490. End Sub
  2491.  
  2492. Sub RandomSoundFlipperUpRight(flipper)
  2493. PlaySoundAtLevelStatic SoundFX("Flipper_R0" & Int(Rnd*11)+1,DOFFlippers), FlipperRightHitParm, Flipper
  2494. End Sub
  2495.  
  2496. Sub RandomSoundReflipUpLeft(flipper)
  2497. PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_L0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
  2498. End Sub
  2499.  
  2500. Sub RandomSoundReflipUpRight(flipper)
  2501. PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_R0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
  2502. End Sub
  2503.  
  2504. Sub RandomSoundFlipperDownLeft(flipper)
  2505. PlaySoundAtLevelStatic SoundFX("Flipper_Left_Down_" & Int(Rnd*7)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
  2506. End Sub
  2507.  
  2508. Sub RandomSoundFlipperDownRight(flipper)
  2509. PlaySoundAtLevelStatic SoundFX("Flipper_Right_Down_" & Int(Rnd*8)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
  2510. End Sub
  2511.  
  2512. '///////////////////////////// FLIPPER BATS BALL COLLIDE SOUND ////////////////////////////
  2513.  
  2514.  
  2515.  
  2516. Sub LeftFlipper_Collide(parm)
  2517. FlipperLeftHitParm = parm/10
  2518. If FlipperLeftHitParm > 1 Then
  2519. FlipperLeftHitParm = 1
  2520. End If
  2521. FlipperLeftHitParm = FlipperUpSoundLevel * FlipperLeftHitParm
  2522. CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
  2523. CheckFlipperSlack Activeball, LeftFlipper, LFLogo, parm
  2524. RandomSoundRubberFlipper(parm)
  2525. End Sub
  2526.  
  2527. Sub RightFlipper_Collide(parm)
  2528. FlipperRightHitParm = parm/10
  2529. If FlipperRightHitParm > 1 Then
  2530. FlipperRightHitParm = 1
  2531. End If
  2532. FlipperRightHitParm = FlipperUpSoundLevel * FlipperRightHitParm
  2533. CheckLiveCatch Activeball, RightFlipper, RFCount, parm
  2534. CheckFlipperSlack Activeball, RightFlipper, RFLogo, parm
  2535. RandomSoundRubberFlipper(parm)
  2536. End Sub
  2537.  
  2538. Sub RandomSoundRubberFlipper(parm)
  2539. PlaySoundAtLevelActiveBall ("Flipper_Rubber_" & Int(Rnd*7)+1), parm * RubberFlipperSoundFactor
  2540. End Sub
  2541.  
  2542. '///////////////////////////// ROLLOVER SOUNDS ////////////////////////////
  2543. Sub RandomSoundRollover()
  2544. PlaySoundAtLevelActiveBall ("Rollover_" & Int(Rnd*4)+1), RolloverSoundLevel
  2545. End Sub
  2546.  
  2547. Sub Rollovers_Hit(idx)
  2548. RandomSoundRollover
  2549. End Sub
  2550.  
  2551. '///////////////////////////// VARIOUS PLAYFIELD SOUND SUBROUTINES ////////////////////////////
  2552. '///////////////////////////// RUBBERS AND POSTS ////////////////////////////
  2553. '///////////////////////////// RUBBERS - EVENTS ////////////////////////////
  2554. Sub Rubbers_Hit(idx)
  2555. dim finalspeed
  2556. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2557. If finalspeed > 5 then
  2558. RandomSoundRubberStrong 1
  2559. End if
  2560. If finalspeed <= 5 then
  2561. RandomSoundRubberWeak()
  2562. End If
  2563. End Sub
  2564.  
  2565. '///////////////////////////// RUBBERS AND POSTS - STRONG IMPACTS ////////////////////////////
  2566. Sub RandomSoundRubberStrong(voladj)
  2567. Select Case Int(Rnd*10)+1
  2568. Case 1 : PlaySoundAtLevelActiveBall ("Rubber_Strong_1"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2569. Case 2 : PlaySoundAtLevelActiveBall ("Rubber_Strong_2"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2570. Case 3 : PlaySoundAtLevelActiveBall ("Rubber_Strong_3"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2571. Case 4 : PlaySoundAtLevelActiveBall ("Rubber_Strong_4"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2572. Case 5 : PlaySoundAtLevelActiveBall ("Rubber_Strong_5"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2573. Case 6 : PlaySoundAtLevelActiveBall ("Rubber_Strong_6"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2574. Case 7 : PlaySoundAtLevelActiveBall ("Rubber_Strong_7"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2575. Case 8 : PlaySoundAtLevelActiveBall ("Rubber_Strong_8"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2576. Case 9 : PlaySoundAtLevelActiveBall ("Rubber_Strong_9"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
  2577. Case 10 : PlaySoundAtLevelActiveBall ("Rubber_1_Hard"), Vol(ActiveBall) * RubberStrongSoundFactor * 0.6*voladj
  2578. End Select
  2579. End Sub
  2580.  
  2581. '///////////////////////////// RUBBERS AND POSTS - WEAK IMPACTS ////////////////////////////
  2582. Sub RandomSoundRubberWeak()
  2583. PlaySoundAtLevelActiveBall ("Rubber_" & Int(Rnd*8)+1), Vol(ActiveBall) * RubberWeakSoundFactor
  2584. End Sub
  2585.  
  2586. '///////////////////////////// WALL IMPACTS ////////////////////////////
  2587. Sub Walls_Hit(idx)
  2588. dim finalspeed
  2589. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2590. If finalspeed > 5 then
  2591. RandomSoundRubberStrong 1
  2592. End if
  2593. If finalspeed <= 5 then
  2594. RandomSoundRubberWeak()
  2595. End If
  2596. End Sub
  2597.  
  2598. Sub RandomSoundWall()
  2599. dim finalspeed
  2600. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2601. If finalspeed > 16 then
  2602. Select Case Int(Rnd*5)+1
  2603. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_1"), Vol(ActiveBall) * WallImpactSoundFactor
  2604. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_2"), Vol(ActiveBall) * WallImpactSoundFactor
  2605. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_5"), Vol(ActiveBall) * WallImpactSoundFactor
  2606. Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_7"), Vol(ActiveBall) * WallImpactSoundFactor
  2607. Case 5 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_9"), Vol(ActiveBall) * WallImpactSoundFactor
  2608. End Select
  2609. End if
  2610. If finalspeed >= 6 AND finalspeed <= 16 then
  2611. Select Case Int(Rnd*4)+1
  2612. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_3"), Vol(ActiveBall) * WallImpactSoundFactor
  2613. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
  2614. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
  2615. Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
  2616. End Select
  2617. End If
  2618. If finalspeed < 6 Then
  2619. Select Case Int(Rnd*3)+1
  2620. Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
  2621. Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
  2622. Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
  2623. End Select
  2624. End if
  2625. End Sub
  2626.  
  2627. '///////////////////////////// METAL TOUCH SOUNDS ////////////////////////////
  2628. Sub RandomSoundMetal()
  2629. PlaySoundAtLevelActiveBall ("Metal_Touch_" & Int(Rnd*13)+1), Vol(ActiveBall) * MetalImpactSoundFactor
  2630. End Sub
  2631.  
  2632. '///////////////////////////// METAL - EVENTS ////////////////////////////
  2633.  
  2634. Sub Metals_Hit (idx)
  2635. RandomSoundMetal
  2636. End Sub
  2637.  
  2638. Sub ShooterDiverter_collide(idx)
  2639. RandomSoundMetal
  2640. End Sub
  2641.  
  2642. '///////////////////////////// BOTTOM ARCH BALL GUIDE ////////////////////////////
  2643. '///////////////////////////// BOTTOM ARCH BALL GUIDE - SOFT BOUNCES ////////////////////////////
  2644. Sub RandomSoundBottomArchBallGuide()
  2645. dim finalspeed
  2646. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2647. If finalspeed > 16 then
  2648. PlaySoundAtLevelActiveBall ("Apron_Bounce_"& Int(Rnd*2)+1), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2649. End if
  2650. If finalspeed >= 6 AND finalspeed <= 16 then
  2651. Select Case Int(Rnd*2)+1
  2652. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2653. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2654. End Select
  2655. End If
  2656. If finalspeed < 6 Then
  2657. Select Case Int(Rnd*2)+1
  2658. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2659. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Medium_3"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
  2660. End Select
  2661. End if
  2662. End Sub
  2663.  
  2664. '///////////////////////////// BOTTOM ARCH BALL GUIDE - HARD HITS ////////////////////////////
  2665. Sub RandomSoundBottomArchBallGuideHardHit()
  2666. PlaySoundAtLevelActiveBall ("Apron_Hard_Hit_" & Int(Rnd*3)+1), BottomArchBallGuideSoundFactor * 0.25
  2667. End Sub
  2668.  
  2669. Sub Apron_Hit (idx)
  2670. If Abs(cor.ballvelx(activeball.id) < 4) and cor.ballvely(activeball.id) > 7 then
  2671. RandomSoundBottomArchBallGuideHardHit()
  2672. Else
  2673. RandomSoundBottomArchBallGuide
  2674. End If
  2675. End Sub
  2676.  
  2677. '///////////////////////////// FLIPPER BALL GUIDE ////////////////////////////
  2678. Sub RandomSoundFlipperBallGuide()
  2679. dim finalspeed
  2680. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2681. If finalspeed > 16 then
  2682. Select Case Int(Rnd*2)+1
  2683. Case 1 : PlaySoundAtLevelActiveBall ("Apron_Hard_1"), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2684. Case 2 : PlaySoundAtLevelActiveBall ("Apron_Hard_2"), Vol(ActiveBall) * 0.8 * FlipperBallGuideSoundFactor
  2685. End Select
  2686. End if
  2687. If finalspeed >= 6 AND finalspeed <= 16 then
  2688. PlaySoundAtLevelActiveBall ("Apron_Medium_" & Int(Rnd*3)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2689. End If
  2690. If finalspeed < 6 Then
  2691. PlaySoundAtLevelActiveBall ("Apron_Soft_" & Int(Rnd*7)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
  2692. End If
  2693. End Sub
  2694.  
  2695. '///////////////////////////// TARGET HIT SOUNDS ////////////////////////////
  2696. Sub RandomSoundTargetHitStrong()
  2697. PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+5,DOFTargets), Vol(ActiveBall) * 0.45 * TargetSoundFactor
  2698. End Sub
  2699.  
  2700. Sub RandomSoundTargetHitWeak()
  2701. PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+1,DOFTargets), Vol(ActiveBall) * TargetSoundFactor
  2702. End Sub
  2703.  
  2704. Sub PlayTargetSound()
  2705. dim finalspeed
  2706. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  2707. If finalspeed > 10 then
  2708. RandomSoundTargetHitStrong()
  2709. RandomSoundBallBouncePlayfieldSoft Activeball
  2710. Else
  2711. RandomSoundTargetHitWeak()
  2712. End If
  2713. End Sub
  2714.  
  2715. Sub Targets_Hit (idx)
  2716. PlayTargetSound
  2717. End Sub
  2718.  
  2719. '///////////////////////////// BALL BOUNCE SOUNDS ////////////////////////////
  2720. Sub RandomSoundBallBouncePlayfieldSoft(aBall)
  2721. Select Case Int(Rnd*9)+1
  2722. Case 1 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_1"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
  2723. Case 2 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
  2724. Case 3 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_3"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.8, aBall
  2725. Case 4 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_4"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
  2726. Case 5 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_5"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
  2727. Case 6 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_1"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2728. Case 7 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2729. Case 8 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_5"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
  2730. Case 9 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_7"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.3, aBall
  2731. End Select
  2732. End Sub
  2733.  
  2734. Sub RandomSoundBallBouncePlayfieldHard(aBall)
  2735. PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_" & Int(Rnd*7)+1), volz(aBall) * BallBouncePlayfieldHardFactor, aBall
  2736. End Sub
  2737.  
  2738. '///////////////////////////// DELAYED DROP - TO PLAYFIELD - SOUND ////////////////////////////
  2739. Sub RandomSoundDelayedBallDropOnPlayfield(aBall)
  2740. Select Case Int(Rnd*5)+1
  2741. Case 1 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_1_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2742. Case 2 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_2_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2743. Case 3 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_3_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2744. Case 4 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_4_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2745. Case 5 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_5_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
  2746. End Select
  2747. End Sub
  2748.  
  2749. '///////////////////////////// BALL GATES AND BRACKET GATES SOUNDS ////////////////////////////
  2750.  
  2751. Sub SoundPlayfieldGate()
  2752. PlaySoundAtLevelStatic ("Gate_FastTrigger_" & Int(Rnd*2)+1), GateSoundLevel, Activeball
  2753. End Sub
  2754.  
  2755. Sub SoundHeavyGate()
  2756. PlaySoundAtLevelStatic ("Gate_2"), GateSoundLevel, Activeball
  2757. End Sub
  2758.  
  2759. Sub Gates_hit(idx)
  2760. SoundHeavyGate
  2761. End Sub
  2762.  
  2763. Sub GatesWire_hit(idx)
  2764. SoundPlayfieldGate
  2765. End Sub
  2766.  
  2767. '///////////////////////////// LEFT LANE ENTRANCE - SOUNDS ////////////////////////////
  2768.  
  2769. Sub RandomSoundLeftArch()
  2770. PlaySoundAtLevelActiveBall ("Arch_L" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
  2771. End Sub
  2772.  
  2773. Sub RandomSoundRightArch()
  2774. PlaySoundAtLevelActiveBall ("Arch_R" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
  2775. End Sub
  2776.  
  2777.  
  2778. Sub Arch1_hit()
  2779. If Activeball.velx > 1 Then SoundPlayfieldGate
  2780. StopSound "Arch_L1"
  2781. StopSound "Arch_L2"
  2782. StopSound "Arch_L3"
  2783. StopSound "Arch_L4"
  2784. End Sub
  2785.  
  2786. Sub Arch1_unhit()
  2787. If activeball.velx < -8 Then
  2788. RandomSoundRightArch
  2789. End If
  2790. End Sub
  2791.  
  2792. Sub Arch2_hit()
  2793. If Activeball.velx < 1 Then SoundPlayfieldGate
  2794. StopSound "Arch_R1"
  2795. StopSound "Arch_R2"
  2796. StopSound "Arch_R3"
  2797. StopSound "Arch_R4"
  2798. End Sub
  2799.  
  2800. Sub Arch2_unhit()
  2801. If activeball.velx > 10 Then
  2802. RandomSoundLeftArch
  2803. End If
  2804. End Sub
  2805.  
  2806. '///////////////////////////// SAUCERS (KICKER HOLES) ////////////////////////////
  2807.  
  2808. Sub SoundSaucerLock()
  2809. PlaySoundAtLevelStatic ("Saucer_Enter_" & Int(Rnd*2)+1), SaucerLockSoundLevel, Activeball
  2810. End Sub
  2811.  
  2812. Sub SoundSaucerKick(scenario, saucer)
  2813. Select Case scenario
  2814. Case 0: PlaySoundAtLevelStatic SoundFX("Saucer_Empty", DOFContactors), SaucerKickSoundLevel, saucer
  2815. Case 1: PlaySoundAtLevelStatic SoundFX("Saucer_Kick", DOFContactors), SaucerKickSoundLevel, saucer
  2816. End Select
  2817. End Sub
  2818.  
  2819. '///////////////////////////// BALL COLLISION SOUND ////////////////////////////
  2820. Sub OnBallBallCollision(ball1, ball2, velocity)
  2821. Dim snd
  2822. Select Case Int(Rnd*7)+1
  2823. Case 1 : snd = "Ball_Collide_1"
  2824. Case 2 : snd = "Ball_Collide_2"
  2825. Case 3 : snd = "Ball_Collide_3"
  2826. Case 4 : snd = "Ball_Collide_4"
  2827. Case 5 : snd = "Ball_Collide_5"
  2828. Case 6 : snd = "Ball_Collide_6"
  2829. Case 7 : snd = "Ball_Collide_7"
  2830. End Select
  2831.  
  2832. PlaySound (snd), 0, Csng(velocity) ^2 / 200 * BallWithBallCollisionSoundFactor * VolumeDial, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  2833. End Sub
  2834.  
  2835.  
  2836. '/////////////////////////////////////////////////////////////////
  2837. ' End Mechanical Sounds
  2838. '/////////////////////////////////////////////////////////////////
  2839.  
  2840. '**************************************************************************************************************
  2841. ' Random Ramp Bumps - Best used to compliment the Raised Ramp RollingBall Script
  2842. ' No switches are required. Make ramps have "Hit Event" and create a "Collection" for each of the following.
  2843. ' Adjust Vol (eg .5) & Pitch: RandomBump3 .5, Pitch(ActiveBall)+5
  2844. ' Ramp physics also effect bump sounds. Friction will change ball speed, so sounds will react different.
  2845. ' Hit Threshold will will effect how much force is required to create a bump. Low hit threshold + more bumps.
  2846. ' Other adjustments avialable in the script as noted.
  2847. '**************************************************************************************************************
  2848.  
  2849.  
  2850. Dim NextOrbitHit:NextOrbitHit = 0
  2851.  
  2852. Sub WireRampBumps_Hit(idx)
  2853. if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
  2854. RandomBump3 .5, Pitch(ActiveBall)+5
  2855. ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
  2856. ' Lowering these numbers allow more closely-spaced clunks.
  2857. NextOrbitHit = Timer + .2 + (Rnd * .2)
  2858. end if
  2859. End Sub
  2860.  
  2861. Sub PlasticRampBumps_Hit(idx)
  2862. if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
  2863. RandomBump 2, Pitch(ActiveBall)
  2864. ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
  2865. ' Lowering these numbers allow more closely-spaced clunks.
  2866. NextOrbitHit = Timer + .1 + (Rnd * .2)
  2867. end if
  2868. End Sub
  2869.  
  2870.  
  2871. Sub MetalGuideBumps_Hit(idx)
  2872. if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
  2873. RandomBump2 2, Pitch(ActiveBall)
  2874. ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
  2875. ' Lowering these numbers allow more closely-spaced clunks.
  2876. NextOrbitHit = Timer + .2 + (Rnd * .2)
  2877. end if
  2878. End Sub
  2879.  
  2880. Sub MetalWallBumps_Hit(idx)
  2881. if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
  2882. RandomBump 2, 20000 'Increased pitch to simulate metal wall
  2883. ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
  2884. ' Lowering these numbers allow more closely-spaced clunks.
  2885. NextOrbitHit = Timer + .2 + (Rnd * .2)
  2886. end if
  2887. End Sub
  2888.  
  2889.  
  2890. '' Requires rampbump1 to 7 in Sound Manager
  2891. Sub RandomBump(voladj, freq)
  2892. dim BumpSnd:BumpSnd= "rampbump" & CStr(Int(Rnd*7)+1)
  2893. PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
  2894. End Sub
  2895.  
  2896. ' Requires metalguidebump1 to 2 in Sound Manager
  2897. Sub RandomBump2(voladj, freq)
  2898. dim BumpSnd:BumpSnd= "metalguidebump" & CStr(Int(Rnd*2)+1)
  2899. PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
  2900. End Sub
  2901.  
  2902. ' Requires WireRampBump1 to 5 in Sound Manager
  2903. Sub RandomBump3(voladj, freq)
  2904. dim BumpSnd:BumpSnd= "WireRampBump" & CStr(Int(Rnd*5)+1)
  2905. PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
  2906. End Sub
  2907.  
  2908.  
  2909.  
  2910. ' Stop Bump Sounds - Place triggers for these at the end of the ramps, to ensure that no bump sounds are played after the ball leaves the ramp.
  2911.  
  2912. Sub BumpSTOP1_Hit ()
  2913. dim i:for i=1 to 4:StopSound "WireRampBump" & i:next
  2914. NextOrbitHit = Timer + 1
  2915. End Sub
  2916.  
  2917. Sub BumpSTOP2_Hit ()
  2918. dim i:for i=1 to 4:StopSound "WireRampBump" & i:next
  2919. NextOrbitHit = Timer + 1
  2920. End Sub
  2921.  
  2922.  
  2923.  
  2924. '******************************************************
  2925. ' BALL ROLLING AND DROP SOUNDS
  2926. '******************************************************
  2927.  
  2928. Const tnob = 7 ' total number of balls
  2929. ReDim rolling(tnob)
  2930. InitRolling
  2931.  
  2932. Dim DropCount
  2933. ReDim DropCount(tnob)
  2934.  
  2935. Sub InitRolling
  2936. Dim i
  2937. For i = 0 to tnob
  2938. rolling(i) = False
  2939. Next
  2940. End Sub
  2941.  
  2942. Sub RollingSound()
  2943. Dim BOT, b
  2944. BOT = GetBalls
  2945.  
  2946. ' stop the sound of deleted balls
  2947. For b = UBound(BOT) + 1 to tnob
  2948. rolling(b) = False
  2949. StopSound("BallRoll_" & b)
  2950. Next
  2951.  
  2952. ' exit the sub if no balls on the table
  2953. If UBound(BOT) = -1 Then Exit Sub
  2954.  
  2955. ' play the rolling sound for each ball
  2956.  
  2957. For b = 0 to UBound(BOT)
  2958. If BallVel(BOT(b)) > 1 Then
  2959. rolling(b) = True
  2960. if BOT(b).z < 10 Then 'Ball on playfield
  2961. PlaySound ("BallRoll_" & b), -1, VolPlayfieldRoll(BOT(b)) * 1.1 * VolumeDial, AudioPan(BOT(b)), 0, PitchPlayfieldRoll(BOT(b)), 1, 0, AudioFade(BOT(b))
  2962. Else 'Ball on Raised Ramp
  2963. PlaySound ("BallRoll_" & b), -1, VolPlayfieldRoll(BOT(b)) * 10 * VolumeDial, AudioPan(BOT(b)), 0, PitchPlayfieldRoll(BOT(b))+50000, 1, 0, AudioFade(BOT(b))
  2964. End If
  2965.  
  2966. Else
  2967. If rolling(b) = True Then
  2968. StopSound("BallRoll_" & b)
  2969. rolling(b) = False
  2970. End If
  2971. End If
  2972.  
  2973. '***Ball Drop Sounds***
  2974. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  2975. If DropCount(b) >= 5 Then
  2976. DropCount(b) = 0
  2977. If BOT(b).velz > -7 Then
  2978. RandomSoundBallBouncePlayfieldSoft BOT(b)
  2979. Else
  2980. RandomSoundBallBouncePlayfieldHard BOT(b)
  2981. End If
  2982. End If
  2983. End If
  2984. If DropCount(b) < 5 Then
  2985. DropCount(b) = DropCount(b) + 1
  2986. End If
  2987. Next
  2988. End Sub
  2989.  
  2990.  
  2991. ' ===============================================================================================
  2992. ' LED's display
  2993. ' ===============================================================================================
  2994. Dim Digits(2), digitState
  2995.  
  2996. Digits(0) = Array(led0,led1,led2,led3,led4,led5,led6)
  2997. Digits(1) = Array(led7,led8,led9,led10,led11,led12,led13)
  2998.  
  2999. Sub UpdateLED()
  3000. Dim chgLED, ii, iii, num, chg, stat, digit
  3001. chgLED = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  3002. If Not IsEmpty(chgLED) Then
  3003. For ii = 0 To UBound(chgLED)
  3004. num = chgLED(ii, 0)
  3005. chg = chgLED(ii, 1)
  3006. stat = chgLED(ii, 2)
  3007. iii = 0
  3008. For Each digit In Digits(num)
  3009. If (chg And 1) Then digit.State = (stat And 1)
  3010. chg = chg \ 2
  3011. stat = stat \ 2
  3012. Next
  3013. Next
  3014. End If
  3015. End Sub
  3016.  
  3017. Sub ShotClock_Timer
  3018.  
  3019. If RedClock=1 then ShotClock.Enabled=False
  3020. If RedClock=1 then RedShotClock.Enabled=True
  3021.  
  3022. If LED0.State=1 then SCleft0.visible =true else SCleft0.visible =false
  3023. If LED1.State=1 then SCleft1.visible =true else SCleft1.visible =false
  3024. If LED2.State=1 then SCleft2.visible =true else SCleft2.visible =false
  3025. If LED3.State=1 then SCleft3.visible =true else SCleft3.visible =false
  3026. If LED4.State=1 then SCleft4.visible =true else SCleft4.visible =false
  3027. If LED5.State=1 then SCleft5.visible =true else SCleft5.visible =false
  3028. If LED6.State=1 then SCleft6.visible =true else SCleft6.visible =false
  3029.  
  3030. If LED7.State=1 then SCright0.visible =true else SCright0.visible =false
  3031. If LED8.State=1 then SCRight1.visible =true else SCRight1.visible =false
  3032. If LED9.State=1 then SCRight2.visible =true else SCRight2.visible =false
  3033. If LED10.State=1 then SCRight3.visible =true else SCRight3.visible =false
  3034. If LED11.State=1 then SCRight4.visible =true else SCRight4.visible =false
  3035. If LED12.State=1 then SCRight5.visible =true else SCRight5.visible =false
  3036. If LED13.State=1 then SCRight6.visible =true else SCRight6.visible =false
  3037.  
  3038. If l87.State=1 and VRRoom = 0 then ShootbuttonOn.visible = True else ShootbuttonOn.visible = False
  3039. If l87.State=0 and VRRoom = 0 then ShootbuttonOff.visible = True else ShootbuttonOff.visible = False
  3040. If l87.State=1 and VRRoom = 0 then Shoot_Flash.visible = True else Shoot_Flash.visible =false
  3041. If l87.State=1 and VRRoom > 0 then VR_Shoot_Flash.visible = True else VR_Shoot_Flash.visible =false
  3042.  
  3043. If l88.State=1 and VRRoom = 0 then StartbuttonOn.visible = True else StartbuttonOn.visible = False
  3044. If l88.State=0 and VRRoom = 0 then StartbuttonOff.visible = True else StartbuttonOff.visible = False
  3045. If l88.State=1 and VRRoom > 0 then VR_Start.visible =true else VR_Start.visible =false
  3046.  
  3047. End Sub
  3048.  
  3049. Sub RedShotClock_Timer
  3050.  
  3051. If LED0.State=1 then SCleft0r.visible =true else SCleft0r.visible =false
  3052. If LED1.State=1 then SCleft1r.visible =true else SCleft1r.visible =false
  3053. If LED2.State=1 then SCleft2r.visible =true else SCleft2r.visible =false
  3054. If LED3.State=1 then SCleft3r.visible =true else SCleft3r.visible =false
  3055. If LED4.State=1 then SCleft4r.visible =true else SCleft4r.visible =false
  3056. If LED5.State=1 then SCleft5r.visible =true else SCleft5r.visible =false
  3057. If LED6.State=1 then SCleft6r.visible =true else SCleft6r.visible =false
  3058.  
  3059. If LED7.State=1 then SCright0r.visible =true else SCright0r.visible =false
  3060. If LED8.State=1 then SCRight1r.visible =true else SCRight1r.visible =false
  3061. If LED9.State=1 then SCRight2r.visible =true else SCRight2r.visible =false
  3062. If LED10.State=1 then SCRight3r.visible =true else SCRight3r.visible =false
  3063. If LED11.State=1 then SCRight4r.visible =true else SCRight4r.visible =false
  3064. If LED12.State=1 then SCRight5r.visible =true else SCRight5r.visible =false
  3065. If LED13.State=1 then SCRight6r.visible =true else SCRight6r.visible =false
  3066.  
  3067. If l87.State=1 and VRRoom = 0 then ShootbuttonOn.visible = True else ShootbuttonOn.visible = False
  3068. If l87.State=0 and VRRoom = 0 then ShootbuttonOff.visible = True else ShootbuttonOff.visible = False
  3069. If l87.State=1 and VRRoom = 0 then Shoot_Flash.visible = True else Shoot_Flash.visible =false
  3070. If l87.State=1 and VRRoom > 0 then VR_Shoot_Flash.visible = True else VR_Shoot_Flash.visible =false
  3071.  
  3072. If l88.State=1 and VRRoom = 0 then StartbuttonOn.visible = True else StartbuttonOn.visible = False
  3073. If l88.State=0 and VRRoom = 0 then StartbuttonOff.visible = True else StartbuttonOff.visible = False
  3074. If l88.State=1 and VRRoom > 0 then VR_Start.visible =true else VR_Start.visible =false
  3075.  
  3076. End Sub
  3077.  
  3078. Sub RubberSleeves_Hit()
  3079. dSleeves()
  3080. End Sub
  3081.  
  3082. sub RubberBands_Hit(idx)
  3083. dPosts()
  3084. End Sub
  3085.  
  3086. '******************************************************
  3087. ' TRACK ALL BALL VELOCITIES
  3088. ' FOR RUBBER DAMPENER AND DROP TARGETS
  3089. '******************************************************
  3090.  
  3091. dim cor : set cor = New CoRTracker
  3092.  
  3093. Class CoRTracker
  3094. public ballvel, ballvelx, ballvely
  3095.  
  3096. Private Sub Class_Initialize : redim ballvel(0) : redim ballvelx(0): redim ballvely(0) : End Sub
  3097.  
  3098. Public Sub Update() 'tracks in-ball-velocity
  3099. dim str, b, AllBalls, highestID : allBalls = getballs
  3100.  
  3101. for each b in allballs
  3102. if b.id >= HighestID then highestID = b.id
  3103. Next
  3104.  
  3105. if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
  3106. if uBound(ballvelx) < highestID then redim ballvelx(highestID) 'set bounds
  3107. if uBound(ballvely) < highestID then redim ballvely(highestID) 'set bounds
  3108.  
  3109. for each b in allballs
  3110. ballvel(b.id) = BallSpeed(b)
  3111. ballvelx(b.id) = b.velx
  3112. ballvely(b.id) = b.vely
  3113. Next
  3114. End Sub
  3115. End Class
  3116.  
  3117. Sub RDampen()
  3118. Cor.Update
  3119. End Sub
  3120.  
  3121. '******************************************************
  3122.  
  3123. '****************************************************************************
  3124. 'nFozzy PHYSICS DAMPENERS
  3125.  
  3126. 'These are data mined bounce curves,
  3127. 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
  3128. 'Requires tracking ballspeed to calculate COR
  3129.  
  3130.  
  3131. Sub dPosts()
  3132. RubbersD.dampen Activeball
  3133. End Sub
  3134.  
  3135. Sub dSleeves()
  3136. SleevesD.Dampen Activeball
  3137. End Sub
  3138.  
  3139. dim RubbersD : Set RubbersD = new Dampener 'frubber
  3140. RubbersD.name = "Rubbers"
  3141. RubbersD.debugOn = False 'shows info in textbox "TBPout"
  3142. RubbersD.Print = False 'debug, reports in debugger (in vel, out cor)
  3143. 'cor bounce curve (linear)
  3144. 'for best results, try to match in-game velocity as closely as possible to the desired curve
  3145. 'RubbersD.addpoint 0, 0, 0.935 'point# (keep sequential), ballspeed, CoR (elasticity)
  3146. RubbersD.addpoint 0, 0, 0.935 '0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
  3147. RubbersD.addpoint 1, 3.77, 0.935 '0.96
  3148. RubbersD.addpoint 2, 5.76, 0.942 '0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
  3149. RubbersD.addpoint 3, 15.84, 0.874
  3150. RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
  3151.  
  3152. dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
  3153. SleevesD.name = "Sleeves"
  3154. SleevesD.debugOn = False 'shows info in textbox "TBPout"
  3155. SleevesD.Print = False 'debug, reports in debugger (in vel, out cor)
  3156. SleevesD.CopyCoef RubbersD, 0.85
  3157.  
  3158. Class Dampener
  3159. Public Print, debugOn 'tbpOut.text
  3160. public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
  3161. Public ModIn, ModOut
  3162. Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
  3163.  
  3164. Public Sub AddPoint(aIdx, aX, aY)
  3165. ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
  3166. if gametime > 100 then Report
  3167. End Sub
  3168.  
  3169. public sub Dampen(aBall)
  3170. if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
  3171. dim RealCOR, DesiredCOR, str, coef
  3172. DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
  3173. RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
  3174. coef = desiredcor / realcor
  3175. if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
  3176. "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
  3177. if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)
  3178.  
  3179. aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
  3180. 'playsound "fx_knocker"
  3181. if debugOn then TBPout.text = str
  3182. End Sub
  3183.  
  3184. Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
  3185. dim x : for x = 0 to uBound(aObj.ModIn)
  3186. addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
  3187. Next
  3188. End Sub
  3189.  
  3190.  
  3191. Public Sub Report() 'debug, reports all coords in tbPL.text
  3192. if not debugOn then exit sub
  3193. dim a1, a2 : a1 = ModIn : a2 = ModOut
  3194. dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
  3195. TBPout.text = str
  3196. End Sub
  3197.  
  3198.  
  3199. End Class
  3200.  
  3201.  
  3202. Function LinearEnvelope(xInput, xKeyFrame, yLvl)
  3203. dim y 'Y output
  3204. dim L 'Line
  3205. dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
  3206. if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
  3207. Next
  3208. if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
  3209. Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
  3210.  
  3211. 'Clamp if on the boundry lines
  3212. 'if L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
  3213. 'if L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
  3214. 'clamp 2.0
  3215. if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
  3216. if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
  3217.  
  3218. LinearEnvelope = Y
  3219. End Function
  3220.  
  3221. Dim BallShadow
  3222. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5, BallShadow6, BallShadow7, BallShadow8)
  3223.  
  3224. Sub BallShadowUpdate()
  3225. Dim BOT, b
  3226. BOT = GetBalls
  3227. ' hide shadow of deleted balls
  3228. If UBound(BOT)<(tnob-1) Then
  3229. For b = (UBound(BOT) + 1) to (tnob-1)
  3230. BallShadow(b).visible = 0
  3231. Next
  3232. End If
  3233. ' exit the Sub if no balls on the table
  3234. If UBound(BOT) = -1 Then Exit Sub
  3235. ' render the shadow for each ball
  3236. For b = 0 to UBound(BOT)
  3237. If BOT(b).X < Table1.Width/2 Then
  3238. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/16)) + 5
  3239. Else
  3240. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/16)) - 5
  3241. End If
  3242. ballShadow(b).Y = BOT(b).Y + 10
  3243. If BOT(b).Z > 10 Then
  3244. BallShadow(b).visible = 1
  3245. Else
  3246. BallShadow(b).visible = 0
  3247. End If
  3248. Next
  3249. End Sub
  3250.  
  3251. '////////////////////// ***OPTIONS*** //////////////////////////////
  3252.  
  3253. Dim Cabflash
  3254. If CabinetMode = 1 Then
  3255. SideWalls.visible = 1
  3256. Pincab_Rails.visible = 0
  3257. PinCab_Blades.visible = 0
  3258. for each Cabflash in CabFlashers:Cabflash.height = 450:Next
  3259. for each Cabflash in CabFlashers:Cabflash.Y = 1350:Next
  3260. Else
  3261. SideWalls.visible = 0
  3262. PinCab_Rails.visible = 1
  3263. PinCab_Blades.visible = 1
  3264. for each Cabflash in CabFlashers:Cabflash.height = 250:Next
  3265. for each Cabflash in CabFlashers:Cabflash.Y = 885.563:Next
  3266. End If
  3267.  
  3268. DIM VRRoom, VRThings
  3269. If VRRoom > 0 Then
  3270. ScoreText.visible = 0
  3271. Ramp_central.image = "VR_centre_ramp"
  3272. ramps_lateral.image = "VR_lateral_ramps"
  3273. Ramp_central.blenddisablelighting = 0.5
  3274. ramps_lateral.blenddisablelighting = 0.5
  3275. PinCab_Backglass.blenddisablelighting = 4
  3276. If VRRoom = 1 Then
  3277. for each VRThings in VRCab:VRThings.visible = 1:Next
  3278. for each VRThings in VRStuff:VRThings.visible = 1:Next
  3279. for each VRThings in Desktop:VRThings.visible = 0:Next
  3280. End If
  3281. If VRRoom = 2 Then
  3282. for each VRThings in VRCab:VRThings.visible = 0:Next
  3283. for each VRThings in VRStuff:VRThings.visible = 0:Next
  3284. for each VRThings in Desktop:VRThings.visible = 0:Next
  3285. PinCab_Backglass.visible = 1
  3286. PinCab_Backbox.visible = 1
  3287. PinCab_Backbox.image = "Pincab_Backbox_NBA_Min"
  3288. End If
  3289. Else
  3290. for each VRThings in VRCab:VRThings.visible = 0:Next
  3291. for each VRThings in VRStuff:VRThings.visible = 0:Next
  3292. for each VRThings in Desktop:VRThings.visible = 1:Next
  3293. If DesktopMode then ScoreText.visible = 1 else ScoreText.visible = 0 End If
  3294. Ramp_central.image = "ramp_centre"
  3295. ramps_lateral.image = "ramp_lateral"
  3296. End if
  3297.  
Advertisement
Add Comment
Please, Sign In to add comment