Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' NBA Fastbreak / IPD No. 4023 / March, 1997 / 4 Players
- ' http://www.ipdb.org/machine.cgi?id=4023
- ' VP915 v1.0 by JPSalas 2013
- ' VPX v1.0 by MaX 2016
- ' based on the tables by Aurich and bmiki75
- ' 2018 Mod by Darth Marino. Extra special thanks to DJROBX for helping implement the Shot Clock
- ' Fast Flips implemented by DJRobX and CarnyPriest
- ' VPin Workshop Mod 12/2020
- '**CHANGE LOG **
- ' 005 - iaakki - PF and insert images, first inserts added. All lights moved to different layers
- ' 006 - iaakki - PF material fixed. Adding more inserts, right ramp invisible for now
- ' 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.
- ' 008 - iaakki - fixed missing wall diverters
- ' 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
- ' 010 - tomate - Added some new geometries, aligned rubbers and addded new POV
- ' 011 - iaakki - combined inserts and graphics from separate version
- ' 012 - tomate - New textures
- ' 013 - tomate - Improve plastic textures, shadows on PF, new apron
- ' 014 - tomate - More work on textures
- ' 015 - tomate - Work on file weight, fixed wall problem in player #3, new apron texture, some additional fixes
- ' 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
- ' 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
- ' 018 - tomate - New lighting and color correction with LUTs, new PF with color correction, shadow layer added
- ' 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
- ' 020 - Benji - Added physics to rubber bands
- ' 021 - iaakki - flupper domes partially done
- ' 022 - tomate - Added PF mesh, values of sides passes fixed, force value for sw25 fixed, color correction to PF
- ' 023 - iaakki - flasher domes done
- ' 024 - iaakki - GI redone and connected, PF GI missing from strings 2 and 3, gInsertLevel const added to reduce insert brightness globally
- ' 025 - tomate - Clean script flippers williams logo, blenddisablelighting to Ramp_central added, new water level added, new transparent textures for plastic ramps added
- ' 026 - tomate - fix the height of the bulbs under Jam & Slam ramps, new siderails and sidewalls added, GlobalFlasher added on PF at layer10
- ' 027 - Benji - Added Fleep sound package and DJRobX wire/plastic/metal ramp bumps.
- ' 030 - iaakki - included flipper logos. Flipnudge is having some issues still
- ' 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
- ' 032 - Benji - Removed extra glosiness from new flippers by creating new material for flippers. Got new Flipper Nudge functionality working
- ' 033 - iaakki - Diverter2, Flipper_collide sub, FlipperSlack&Checklivecatch calls fixed and slackyFlips const added -> Flip tricks works
- ' 034 - tomate - fixed kicker sw66 (player # 3) shooting power, adjustments on collideable walls to prevent ball jamming, adjust DL of new bats
- ' 035 - tomate - Primitives of collidable Ramps fixed, usless old collidable objects removed
- ' 036 - sixtoe/tomate - Shadow ball added, gamma correction to ramps decals
- ' 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
- ' 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
- ' 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)
- ' 038 - iaakki - fixed POV and some insert light bulb values
- ' 039 - tomate - fixed upper right rubber, new texture for the ball, POV adjusted to show the full apron
- ' 040 - tomate - adjustments to apron and metals textures, tweaks DL on some objects, change ramp materials to look brighter
- ' 041 - iaakki - top area pf gi redone
- ' 042 - iaakki - Some plastic GI light heights retuned
- ' 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,
- ' 044 - tomate/iaakki - low res for some textures, StandUp targets separation into 3 prims and animation done, modify backwall texture
- ' 045 - tomate/oqq - correct apron wall height plastic under central ramp texture, add movments to bumperRings and separate prims
- ' 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
- ' 046.1 - tomate - yellow targets working
- ' 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
- ' 048 - iaakki - Desktop POV adjusted, standup target bounces reduced, pf friction increased, Flasherbase1 height fixed
- ' 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
- ' 050 - iaakki - Standup targets elasticity reduced. Sw64 surface fixed to 55h, l57 brightness reduced, insert paint layer color adjustment
- ' 051 - tomate - fix Pincab_rails mesh, change material settings and mapped. Fix POV's, now is working in FS and DT mode.
- ' 052 - iaakki - fine tuned flip positions, fixed lamp update functions to reset properly for all lamps.
- ' 053 - iaakki - sw46 and sw63 surface fixed, diverter sounds added
- ' 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
- ' 054.1 - tomate - Restored the old roof of the left ramp as the new one didn´t work
- ' 055 - iaakki- ScSp reflections on by default, cabinetmode raises flasherblooms to 500, flasherlights adjusted and lifted to same level as the plastic.
- ' 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,
- ' RC1 - tomate - make not visible wall over main bumper, set 100% sound effect Volume, set CabinetMode = 0
- ' RC2 - Sixtoe - Adjusted slam ramp, added kicker primitives to basket shots, added additional wall on slingshot back, tweaked a handful of other things
- ' RC3 - Sixtoe - Adjusted flippers, removed sling added in error, changed height of wireexit1
- ' RC4 - iaakki - Round standup target fixed to feel more natural, redclock script error fixed
- ' RC5 - tomate - red clock numbers added
- ' 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
- ' 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
- ' 100 - iaakki - flasherbloom default heights checked, ball counts fixed, default options set
- Option Explicit
- Randomize
- '///////////////////////////////////////////////////
- '///////////////// Table Options ///////////////////
- '///////////////////////////////////////////////////
- 'Make flipper solenoid to alter active ball behavior
- Const FlipSolNudge = 1
- Const slackyFlips = 1
- 'Live catch window size. Higher value will make live catching easier. 8-32
- Const LiveCatch = 16
- '///////////////////////-----General Sound Options-----///////////////////////
- '// VolumeDial:
- '// VolumeDial is the actual global volume multiplier for the mechanical sounds.
- '// Values smaller than 1 will decrease mechanical sounds volume.
- '// Recommended values should be no greater than 1.
- Const VolumeDial = 0.8
- '*************************************
- '***********CABINET MODE**************
- 'Cabinet mode - Will hide the rails and scale the side panels higher
- Const CabinetMode = 1
- '*************************************
- '*************************************
- '**************VR ROOM****************
- '****Turns on VR Room and Cabinet****
- '0 - VR Room off, 1 - Minimal Room, 2 - Ultra Minimal
- VRRoom = 0
- '*************************************
- '*************************************
- '*******FAST FLIPS OPTION*************
- '***REQUIRES PINMAME SAMupdate r4614 OR NEWER!!!!!!!!!!!!!!!!!!
- '*** http://vpuniverse.com/forums/topic/3651-sambuild32-beta-thread/
- '*************************************
- ' 1 = OFF 2 = ON
- Const UseSolenoids = 2
- '*************************************
- '*************************************
- '*********RED SHOT CLOCK MOD**********
- ' 0 = OFF 1 = ON
- RedClock=0
- '*************************************
- Dim DesktopMode:DesktopMode = Table1.ShowDT
- Dim UseVPMDMD:UseVPMDMD = DesktopMode
- On Error Resume Next
- ExecuteGlobal GetTextFile("controller.vbs")
- If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
- On Error Goto 0
- Const BallSize = 50 'add this here to redefine the ball size, placed before LoadVPM.'
- LoadVPM "01120100", "WPC.VBS", 3.49 'minimum core.vbs version
- Dim bsTrough, bsEject, bsSaucer1, bsSaucer2, bsSaucer3, bsSaucer4, mBallCatch, mDefender, MagnetCatch, bgball
- Dim PlungerIM, x, bump1, bump2, bump3, ArenaMod, RedClock, FastFlips, ff
- '************************************
- ramps_lateral.blenddisablelighting=2
- ramp_central.blenddisablelighting=2
- '************************************
- '************Diverter2 animation*************************
- dim DiverterDir
- Sub SolDiverter2(Enabled)
- 'debug.print "diverter2 state: " & Enabled
- If Enabled Then
- Diverter2.IsDropped=1
- DiverterDir = 2
- Diverter2.timerinterval = 5:Diverter2.timerenabled = 1
- PlaySoundAt SoundFX("DiverterOn",DOFContactors),DiverterP2
- else
- Diverter2.IsDropped=0
- DiverterDir = -2
- Diverter2.timerinterval = 5:Diverter2.timerenabled = 1
- PlaySoundAt SoundFX("DiverterOff",DOFContactors),DiverterP2
- End If
- End Sub
- Sub Diverter2_Timer()
- DiverterP2.transY=DiverterP2.transY+DiverterDir
- If DiverterP2.transY>30 AND DiverterDir=2 Then Me.timerenabled=0:DiverterP2.transY=30
- If DiverterP2.transY<0 AND DiverterDir=-2 Then Me.timerenabled=0:DiverterP2.transY=0
- End Sub
- '**************StandUp targets****************************
- 'Sub sw41_Hit:vpmTimer.PulseSw 41:End Sub
- 'Const VolTarg = 1 ' Targets multiplier
- Dim zMultiplier
- DIM target41step
- Sub sw41_Hit
- Select Case Int(Rnd * 4) + 1
- Case 1: zMultiplier = 1.15
- Case 2: zMultiplier = 0.8
- Case 3: zMultiplier = 0.5
- Case 4: zMultiplier = 0.2
- End Select
- 'msgbox "hit 41 zmult: " & zMultiplier
- activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 41:pSW41.TransY = -3:Target41Step = 1:sw41a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
- End Sub
- Sub sw41a_timer()
- Select Case Target41Step
- Case 1:pSW41.TransY = -1
- Case 2:pSW41.TransY = 2
- Case 3:pSW41.TransY = 0:Me.Enabled = 0
- End Select
- Target41Step = Target41Step + 1
- End Sub
- DIM target42step
- Sub sw42_Hit
- Select Case Int(Rnd * 4) + 1
- Case 1: zMultiplier = 1.15
- Case 2: zMultiplier = 0.8
- Case 3: zMultiplier = 0.5
- Case 4: zMultiplier = 0.2
- End Select
- 'msgbox "hit 42 zmult: " & zMultiplier
- activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 42:pSW42.TransY = -3:Target42Step = 1:sw42a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
- End Sub
- Sub sw42a_timer()
- Select Case Target42Step
- Case 1:pSW42.TransY = -1
- Case 2:pSW42.TransY = 2
- Case 3:pSW42.TransY = 0:Me.Enabled = 0
- End Select
- Target42Step = Target42Step + 1
- End Sub
- DIM target43step
- Sub sw43_Hit
- Select Case Int(Rnd * 4) + 1
- Case 1: zMultiplier = 1.15
- Case 2: zMultiplier = 0.8
- Case 3: zMultiplier = 0.5
- Case 4: zMultiplier = 0.2
- End Select
- 'msgbox "hit 43 zmult: " & zMultiplier
- activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 43:pSW43.TransY = -3:Target43Step = 1:sw43a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
- End Sub
- Sub sw43a_timer()
- Select Case Target43Step
- Case 1:pSW43.TransY = -1
- Case 2:pSW43.TransY = 2
- Case 3:pSW43.TransY = 0:Me.Enabled = 0
- End Select
- Target43Step = Target43Step + 1
- End Sub
- DIM target28step
- Sub sw28_Hit
- Select Case Int(Rnd * 4) + 1
- Case 1: zMultiplier = 1.15
- Case 2: zMultiplier = 0.8
- Case 3: zMultiplier = 0.5
- Case 4: zMultiplier = 0.2
- End Select
- 'msgbox "hit 28 zmult: " & zMultiplier
- activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 28:pSW28.TransY = -3:Target28Step = 1:sw28a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
- End Sub
- Sub sw28a_timer()
- Select Case Target28Step
- Case 1:pSW28.TransY = -1
- Case 2:pSW28.TransY = 2
- Case 3:pSW28.TransY = 0:Me.Enabled = 0
- End Select
- Target28Step = Target28Step + 1
- End Sub
- DIM target18step
- Sub sw18_Hit
- Select Case Int(Rnd * 4) + 1
- Case 1: zMultiplier = 1.15
- Case 2: zMultiplier = 0.8
- Case 3: zMultiplier = 0.5
- Case 4: zMultiplier = 0.2
- End Select
- 'msgbox "hit 18 zmult: " & zMultiplier
- activeball.velz = activeball.velz*zMultiplier:vpmTimer.PulseSw 18:pSW18.TransY = -3:Target18Step = 1:sw18a.Enabled = 1:PlaySound SoundFX("fx_target",DOFTargets)
- End Sub
- Sub sw18a_timer()
- Select Case Target18Step
- Case 1:pSW18.TransY = -1
- Case 2:pSW18.TransY = 2
- Case 3:pSW18.TransY = 0:Me.Enabled = 0
- End Select
- Target18Step = Target18Step + 1
- End Sub
- '**************Bumpers animation*******************
- Sub Bumper2_Hit:vpmTimer.PulseSw 23:PlaySound SoundFX("fx_bumper2",DOFContactors):bump2 = 1:Me.TimerEnabled = 1:End Sub
- Sub Bumper2_Timer()
- Select Case bump2
- Case 1:Ring2.HeightTop = 15:Ring2.HeightBottom = 15:bump2 = 2
- Case 2:Ring2.HeightTop = 25:Ring2.HeightBottom = 25:bump2 = 3
- Case 3:Ring2.HeightTop = 35:Ring2.HeightBottom = 35:bump2 = 4
- Case 4:Ring2.HeightTop = 45:Ring2.HeightBottom = 45:Me.TimerEnabled = 0
- End Select
- Bumper2R.State = ABS(Bumper2R.State - 1) 'refresh light
- End Sub
- '*************************************
- Const UseLamps = 0
- 'Const UseGI = 0
- Const UseSync = 0 'set it to 1 if the table runs too fast
- Const HandleMech = 1
- ' Standard Sounds
- Const SSolenoidOn = "fx_Solenoidon"
- Const SSolenoidOff = "fx_SolenoidOff"
- Const SFlipperOn = "fx_flipperup1"
- Const SFlipperoff = "fx_flipperdown"
- Const SCoin = "fx_coin"
- Const cGameName = "nbaf_31"
- Const cSingleLFlip=0
- Const cSingleRFlip=0
- Set GiCallback2 = GetRef("UpdateGI")
- 'sub updategi (no, aValue)
- 'Eval("textbox"&no).text=enabled
- 'debug.print no & " nro and aValue: " & aValue
- 'iaakki: ok NBA gi has few areas
- '[4:35 PM] iaakki: 0 = "string 1"
- '[4:36 PM] iaakki: 1 = "string 2"
- '[4:36 PM] iaakki: 2 = "string 3"
- 'end sub
- Sub UpdateGi(nr,step)
- Dim ii
- Select Case nr
- Case 0 'Top Playfield
- 'string 1
- If step=0 Then
- For each ii in GI0:ii.state=0:Next
- ' For each ii in GIPOA:ii.visible=0:Next
- Else
- For each ii in GI0:ii.state=1:Next
- ' For each ii in GIPOA:ii.visible=1:Next
- End If
- For each ii in GI0:ii.IntensityScale = 0.125 * step:Next
- Case 1 'Bottom Playfield
- 'string 2
- If step=0 Then
- For each ii in GI1:ii.state=0:Next
- GlobalFlasher.visible=0
- PinCab_Blades.image = "PinCab_Blades_Off"
- SideWalls.image = "PinCab_Blades_Off"
- ' For each ii in GIBot:ii.state=0:Next
- ' For each ii in GIBotSides:ii.visible=0:Next
- Else
- For each ii in GI1:ii.state=1:Next
- GlobalFlasher.visible=1
- PinCab_Blades.image = "PinCab_Blades_On"
- SideWalls.image = "PinCab_Blades_On"
- ' For each ii in GIBot:ii.state=1:Next
- ' For each ii in GIBotSides:ii.visible=1:Next
- End If
- For each ii in GI1:ii.IntensityScale = 0.125 * step:Next
- ' For each ii in GIBot:ii.IntensityScale = 0.125 * step:Next
- ' For each ii in GIBotSides:ii.IntensityScale = 0.125 * step:Next
- ' If Step>=7 Then Table1.ColorGradeImage = "ColorGrade_8":Else Table1.ColorGradeImage = "ColorGrade_" & (step+1):End If
- Case 2 'Insert Top
- 'string 3
- If step=0 Then
- For each ii in GI2:ii.state=0:Next
- ' For each ii in GIPOA:ii.visible=0:Next
- Else
- For each ii in GI2:ii.state=1:Next
- ' For each ii in GIPOA:ii.visible=1:Next
- End If
- For each ii in GI2:ii.IntensityScale = 0.125 * step:Next
- End Select
- End Sub
- Sub table1_Init
- vpmInit Me
- Dim ii
- With Controller
- .GameName = cGameName
- .SplashInfoLine = "NBA Fastbreak, Bally 1997"
- ' .Games(cGameName).Settings.Value("rol") = 0 'rotated vpm display
- .HandleMechanics = 0
- .HandleKeyboard = 0
- .ShowDMDOnly = 1
- .ShowFrame = 0
- .ShowTitle = 0
- .Hidden = 0
- ' .Games(cGameName).Settings.Value("dmd_pos_x")=0
- ' .Games(cGameName).Settings.Value("dmd_pos_y")=0
- If Err Then MsgBox Err.Description
- End With
- On Error Goto 0
- Controller.SolMask(0) = 0
- vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the Timer to renable all the solenoids after 2 seconds
- Controller.DIP(0) = &H00
- ' Controller.Run GetPlayerHWnd
- controller.run
- Controller.Switch(22) = 1 'close coin door
- Controller.Switch(24) = 1 'and keep it close
- If ArenaMod=1 then
- ' Wall80.isdropped=false
- ' Wall123.isdropped=false
- else
- ' Wall80.isdropped=True
- ' Wall123.isdropped=True
- End If
- ' Nudging
- vpmNudge.TiltSwitch = 14
- vpmNudge.Sensitivity = 1
- vpmNudge.TiltObj = Array(LeftSlingshot, RightSlingshot, bumper1, bumper2, bumper3)
- ' Trough & Ball Release
- Set bsTrough = New cvpmBallStack
- With bsTrough
- .InitSw 0, 32, 33, 34, 35, 31, 0, 0
- .InitKick BallRelease, 180, 10
- .InitExitSnd SoundFX("fx_Ballrel",DOFContactors), SoundFX("fx_solenoid",DOFContactors)
- .InitEntrySnd "fx_solenoid", "fx_solenoid"
- .IsTrough = True
- .Balls = 4
- End With
- ' Ball Catch Magnet
- Set MagnetCatch = New cvpmMagnet
- With MagnetCatch
- .InitMagnet BCMagnet, 7
- .Solenoid = 8
- .CreateEvents "MagnetCatch"
- End With
- ' Eject
- Set bsEject = New cvpmBallStack
- With bsEject
- .InitSaucer sw25, 25, 165, 15
- .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
- End With
- ' Saucers (In the Paint)
- Set bsSaucer1 = New cvpmBallStack
- With bsSaucer1
- .InitSaucer sw68, 68, 65, 32
- .Kickz = 1.2
- .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
- End With
- Set bsSaucer2 = New cvpmBallStack
- With bsSaucer2
- .InitSaucer sw67, 67, 26, 28
- .Kickz = 1.15
- .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
- End With
- Set bsSaucer3 = New cvpmBallStack
- With bsSaucer3
- .InitSaucer sw66, 66, 337, 28
- .Kickz = 1.15
- .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
- End With
- Set bsSaucer4 = New cvpmBallStack
- With bsSaucer4
- .InitSaucer sw65, 65, 293, 31.5
- .Kickz = 1.2
- .InitExitSnd SoundFX("fx_popper",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
- End With
- ' Defender
- Set mDefender = New cvpmMech
- With mDefender
- .MType = vpmMechOneDirSol + vpmMechStopEnd + vpmMechLinear
- .Sol1 = 37 'Enable
- .Sol2 = 38 'Direction
- .Length = 65
- .Steps = 65
- .AddSw 51, 0, 1
- .AddSw 52, 17, 18
- .AddSw 53, 31, 32
- .AddSw 54, 44, 45
- .AddSw 55, 64, 65
- .CallBack = GetRef("UpdateDefender")
- .Start
- End With
- UpdateDefender 32, 32, 32
- 'Impulse Plunger
- Const IMPowerSetting = 38 ' Plunger Power
- Const IMTime = 1.1 ' Time in seconds for Full Plunge
- Set plungerIM = New cvpmImpulseP
- With plungerIM
- .InitImpulseP swPlunger, IMPowerSetting, IMTime
- .Switch 15
- .Random 0
- .InitExitSnd "fx_plunger2", "fx_plunger"
- .CreateEvents "plungerIM"
- End With
- ' Misc. Initialisation
- LeftSLing.IsDropped = 1:LeftSLing2.IsDropped = 1:LeftSLing3.IsDropped = 1
- RightSLing.IsDropped = 1:RightSLing2.IsDropped = 1:RightSLing3.IsDropped = 1
- LeftSLingH.IsDropped = 1:LeftSLingH2.IsDropped = 1:LeftSLingH3.IsDropped = 1
- RightSLingH.IsDropped = 1:RightSLingH2.IsDropped = 1:RightSLingH3.IsDropped = 1
- For each ii in ADef1:ii.Isdropped = 1:Next
- For each ii in ADef2:ii.visible = 0:ii.Collidable = 0:Next
- BackBall.CreateSizedBall(20).Image = "BasketBall"
- ' Main Timer init
- PinMAMETimer.Interval = PinMAMEInterval
- PinMAMETimer.Enabled = 1
- 'StartShake
- Dim DesktopMode: DesktopMode = Table1.ShowDT
- If DesktopMode = True Then
- EMreel1.visible=true
- Else
- EMreel1.visible=false
- end If
- End Sub
- Sub Table_exit()
- Controller.Stop
- End Sub
- '**********
- ' Keys
- '**********
- Sub table1_KeyDown(ByVal Keycode)
- If KeyCode = PlungerKey Then Controller.Switch(11) = 1
- If keycode = LeftTiltKey Then Nudge 90, 5:SoundNudgeLeft()
- If keycode = RightTiltKey Then Nudge 270, 5:SoundNudgeRight()
- If keycode = CenterTiltKey Then Nudge 0, 3:SoundNudgeCenter()
- If keycode = keyInsertCoin1 or keycode = keyInsertCoin2 or keycode = keyInsertCoin3 or keycode = keyInsertCoin4 Then
- Select Case Int(rnd*3)
- Case 0: PlaySound ("Coin_In_1"), 0, CoinSoundLevel, 0, 0.25
- Case 1: PlaySound ("Coin_In_2"), 0, CoinSoundLevel, 0, 0.25
- Case 2: PlaySound ("Coin_In_3"), 0, CoinSoundLevel, 0, 0.25
- End Select
- End If
- if keycode=StartGameKey then soundStartButton()
- 'nFozzy Begin'
- If keycode = LeftFlipperKey Then FlipperActivate LeftFlipper, LFPress
- If keycode = RightFlipperKey Then FlipperActivate RightFlipper, RFPress
- 'nFozzy End'
- If vpmKeyDown(keycode) Then Exit Sub
- End Sub
- Sub table1_KeyUp(ByVal Keycode)
- 'nFozzy Begin'
- If keycode = LeftFlipperKey Then FlipperDeActivate LeftFlipper, LFPress
- If keycode = RightFlipperKey Then FlipperDeActivate RightFlipper, RFPress
- ' If keycode = LeftFlipperKey Then
- ' lfpress = 0
- ' leftflipper.eostorqueangle = EOSA
- ' leftflipper.eostorque = EOST
- ' End If
- ' If keycode = RightFlipperKey Then
- ' rfpress = 0
- ' rightflipper.eostorqueangle = EOSA
- ' rightflipper.eostorque = EOST
- ' End If
- 'nFozzy End'
- If vpmKeyUp(keycode) Then Exit Sub
- If keycode = PlungerKey Then Controller.Switch(11) = 0
- End Sub
- '*********
- ' Switches
- '********* -20 -15 -7
- Dim LStep, RStep
- Sub LeftSlingShot_Slingshot:LeftSling.IsDropped = 0:PlaySound SoundFX("fx_slingshot1",DOFContactors):vpmTimer.PulseSw 57:LStep = 0:Me.TimerEnabled = 1:End Sub
- Sub LeftSlingShot_Timer
- Select Case LStep
- Case 0:LeftSLing.IsDropped = 0:LeftSLingH.IsDropped = 0
- Case 1: 'pause
- Case 2:LeftSLing.IsDropped = 1:LeftSLing2.IsDropped = 0:LeftSLingH.IsDropped = 1:LeftSLingH2.IsDropped = 0
- Case 3:LeftSLing2.IsDropped = 1:LeftSLing3.IsDropped = 0:LeftSLingH2.IsDropped = 1:LeftSLingH3.IsDropped = 0
- Case 4:LeftSLing3.IsDropped = 1:LeftSLingH3.IsDropped = 1:Me.TimerEnabled = 0
- End Select
- LStep = LStep + 1
- End Sub
- Sub RightSlingShot_Slingshot:RightSling.IsDropped = 0:PlaySound SoundFX("fx_slingshot2",DOFContactors):vpmTimer.PulseSw 58:RStep = 0:Me.TimerEnabled = 1:End Sub
- Sub RightSlingShot_Timer
- Select Case RStep
- Case 0:RightSLing.IsDropped = 0:RightSLingH.IsDropped = 0
- Case 1: 'pause
- Case 2:RightSLing.IsDropped = 1:RightSLing2.IsDropped = 0:RightSLingH.IsDropped = 1:RightSLingH2.IsDropped = 0
- Case 3:RightSLing2.IsDropped = 1:RightSLing3.IsDropped = 0:RightSLingH2.IsDropped = 1:RightSLingH3.IsDropped = 0
- Case 4:RightSLing3.IsDropped = 1:RightSLingH3.IsDropped = 1:Me.TimerEnabled = 0
- End Select
- RStep = RStep + 1
- End Sub
- ' Bumpers
- Sub Bumper1_Hit:vpmTimer.PulseSw 61:RandomSoundBumperMiddle(Bumper1):bump1 = 1:Me.TimerEnabled = 1:End Sub
- Sub Bumper1_Timer()
- Select Case bump1
- Case 1:bump1 = 2: BumperRing1.Z = -30
- Case 2:bump1 = 3: BumperRing1.Z = -20
- Case 3:bump1 = 4: BumperRing1.Z = -10
- Case 4:Me.TimerEnabled = 0: BumperRing1.Z = 0
- End Select
- 'Bumper1R.State = ABS(Bumper1R.State - 1) 'refresh light
- End Sub
- Sub Bumper2_Hit:vpmTimer.PulseSw 23:RandomSoundBumperMiddle(Bumper2):bump2 = 1:Me.TimerEnabled = 1:End Sub
- Sub Bumper2_Timer()
- Select Case bump2
- Case 1:bump2 = 2 : BumperRing2.Z = -30
- Case 2:bump2 = 3 : BumperRing2.Z = -20
- Case 3:bump2 = 4 : BumperRing2.Z = -10
- Case 4:Me.TimerEnabled = 0 : : BumperRing2.Z = 0
- End Select
- ' Bumper2R.State = ABS(Bumper2R.State - 1) 'refresh light
- End Sub
- Sub Bumper3_Hit:vpmTimer.PulseSw 62:PlaySound SoundFX("fx_bumper3",DOFContactors):bump3 = 1:Me.TimerEnabled = 1:End Sub
- Sub Bumper3_Timer()
- Select Case bump3
- Case 1:bump3 = 2: BumperRing3.Z = -30
- Case 2:bump3 = 3: BumperRing3.Z = -20
- Case 3:bump3 = 4: BumperRing3.Z = -10
- Case 4:Me.TimerEnabled = 0: BumperRing3.Z = 0
- End Select
- ' Bumper3R.State = ABS(Bumper3R.State - 1) 'refresh light
- End Sub
- ' Eject holes
- Sub Drain_Hit:ClearBallID:Playsound "fx_drain":bsTrough.AddBall Me:End Sub
- Sub sw25_Hit:Playsound "fx_kicker_enter":bsEject.AddBall 0:End Sub
- Sub sw65_Hit
- PlaySound "fx_kicker_enter"
- bsSaucer4.AddBall 0
- End Sub
- Sub sw66_Hit
- PlaySound "fx_kicker_enter"
- bsSaucer3.AddBall 0
- End Sub
- Sub sw67_Hit
- PlaySound "fx_kicker_enter"
- bsSaucer2.AddBall 0
- End Sub
- Sub sw68_Hit
- PlaySound "fx_kicker_enter"
- bsSaucer1.AddBall 0
- End Sub
- ' Rollovers
- Sub sw26_Hit:Controller.Switch(26) = 1:End Sub
- Sub sw26_UnHit:Controller.Switch(26) = 0:End Sub
- Sub sw16_Hit:Controller.Switch(16) = 1:End Sub
- Sub sw16_UnHit:Controller.Switch(16) = 0:End Sub
- Sub sw17_Hit:Controller.Switch(17) = 1:End Sub
- Sub sw17_UnHit:Controller.Switch(17) = 0:End Sub
- Sub sw27_Hit:Controller.Switch(27) = 1:End Sub
- Sub sw27_UnHit:Controller.Switch(27) = 0:End Sub
- Sub sw56_Hit:Controller.Switch(56) = 1:End Sub
- Sub sw56_UnHit:Controller.Switch(56) = 0:End Sub
- Sub sw38_Hit:Controller.Switch(38) = 1:End Sub
- Sub sw38_UnHit:Controller.Switch(38) = 0:End Sub
- Sub sw48_Hit:Controller.Switch(48) = 1:End Sub
- Sub sw48_UnHit:Controller.Switch(48) = 0:End Sub
- 'Optos
- Sub sw36_Hit:Controller.Switch(36) = 1:End Sub
- Sub sw36_UnHit:Controller.Switch(36) = 0:End Sub
- Sub sw47_Hit:Controller.Switch(47) = 1:End Sub
- Sub sw47_UnHit:Controller.Switch(47) = 0:End Sub
- Sub sw45_Hit:Controller.Switch(45) = 1:End Sub
- Sub sw45_UnHit:Controller.Switch(45) = 0:End Sub
- Sub sw46_Hit:Controller.Switch(46) = 1:PlaySound "fx_metalrolling":ActiveBall.VelY = 10:End Sub
- Sub sw46_UnHit:Controller.Switch(46) = 0:End Sub
- Sub sw44_Hit:Controller.Switch(44) = 1:End Sub
- Sub sw44_UnHit:Controller.Switch(44) = 0:End Sub
- Sub sw37_Hit:Controller.Switch(37) = 1:End Sub
- Sub sw37_UnHit:Controller.Switch(37) = 0:End Sub
- Sub sw64_Hit:Controller.Switch(64) = 1:End Sub
- Sub sw64_UnHit:Controller.Switch(64) = 0:End Sub
- Sub sw63_Hit:Controller.Switch(63) = 1:End Sub '75h
- Sub sw63_UnHit:Controller.Switch(63) = 0:End Sub
- Sub sw115_Hit:Controller.Switch(115) = 1:End Sub
- Sub sw115_UnHit:Controller.Switch(115) = 0:End Sub
- Sub sw117_Hit:Controller.Switch(117) = 1:End Sub
- Sub sw117_UnHit:Controller.Switch(117) = 0:End Sub
- Sub sw12_Hit:Controller.Switch(12) = 1:End Sub
- Sub sw12_UnHit:Controller.Switch(12) = 0:End Sub
- Sub sw1_Hit:BasketFlipper.RotateToStart:End Sub
- Sub sw2_Hit:BasketFlipper.RotateToStart:End Sub
- Sub sw3_Hit:BasketFlipper.RotateToStart:End Sub
- Sub bask0_hit:EMreel1.setvalue (1):End Sub
- Sub bask1_hit:EMreel1.setvalue (2):End Sub
- Sub bask2_hit:EMreel1.setvalue (1):End Sub
- Sub bask3_hit:EMreel1.setvalue (0):End Sub
- '***********
- ' Solenoids
- '***********
- SolCallBack(1) = "Auto_Plunger"
- 'SolCallBack(2) = Not Used
- 'SolCallBack(3) = "vpmSolWall Diverter2,True,"
- SolCallBack(3) = "SolDiverter2"
- SolCallBack(4) = "vpmSolWall Diverter1,True,"
- SolCallBack(5) = "bsEject.SolOut"
- SolCallBack(6) = "RightGate.Open ="
- SolCallBack(7) = "SolBasket"
- 'SolCallBack(8) ' magnet - handled in the magnet definition
- SolCallBack(9) = "bsTrough.SolOut"
- 'SolCallBack(10) = "vpmSolSound ""lSling"","
- 'SolCallBack(11) = "vpmSolSound ""lSling"","
- 'SolCallBack(12) = "vpmSolSound ""Jet1"","
- 'SolCallBack(13) = "vpmSolSound ""Jet1"","
- 'SolCallBack(14) = "vpmSolSound ""Jet1"","
- SolCallBack(15) = "PassRight2"
- SolCallBack(16) = "PassLeft2"
- SolCallBack(17) = "FlashSol17" '"SetLamp 117," 'eject kickout flasher
- SolCallBack(18) = "FlashSol18" '"SetLamp 118," 'left jet bumper
- SolCallBack(19) = "FlashSol19" '"SetLamp 119," 'upper left
- SolCallBack(20) = "FlashSol20" '"SetLamp 120," 'upper right
- SolCallBack(22) = "SetLamp 122," 'trophy insert TODO
- SolCallBack(24) = "FlashSol24" '"SetLamp 124," 'lower right left
- SolCallBack(25) = "PassRight1"
- SolCallBack(26) = "PassLeft3"
- SolCallBack(27) = "PassRight3"
- SolCallBack(28) = "PassLeft4"
- SolCallBack(33) = "bsSaucer1.SolOut"
- SolCallBack(34) = "bsSaucer2.SolOut"
- SolCallBack(35) = "bsSaucer3.SolOut"
- SolCallBack(36) = "bsSaucer4.SolOut"
- 'SolCallBack(37) = Motor Enable (defender) - handled in the mech
- 'SolCallBack(38) = Motor Direction (defender) - handled in the mech
- 'SolCallBack(39) = "ClockEnable"
- 'SolCallBack(40) = "ClockCount"
- Sub Auto_Plunger(Enabled)
- If Enabled Then
- PlungerIM.AutoFire
- End If
- End Sub
- Sub SolBasket(Enabled)
- If Enabled Then
- BackBall.Kick 330, 75
- If bgball=1 then BasketFlipper.RotateToEnd
- bgball=0
- End If
- End Sub
- Sub BackBall1_Hit
- BackBall1.Destroyball
- BallReturn1.CreateSizedBall(20).Image = "BasketBall"
- BallReturn1.Kick 100, 15
- End Sub
- Sub BallReturn2_Hit
- BallReturn2.Destroyball
- BackBall.CreateSizedBall(20).Image = "BasketBall"
- bgball=1
- End Sub
- Sub UpdateDefender(aNewPos, aSpeed, aLastPos)
- ADef1(aLastPos).IsDropped = True
- ADef1(aNewPos).IsDropped = False
- ADef2(aLastPos).visible = 0:ADef2(aLastPos).collidable = 0
- ADef2(aNewPos).visible = 1:ADef2(aNewPos).collidable = 1
- 'DefR.State = ABS(DefR.State -1)
- End Sub
- ' In The Paint
- Sub PassRight1(Enabled)
- If Enabled then
- bsSaucer1.Kickz = 0
- bsSaucer1.InitAltKick 110, 10
- bsSaucer1.ExitAltSol_On
- bsSaucer1.Kickz = 1.2
- End If
- End Sub
- Sub PassRight2(Enabled)
- If Enabled then
- bsSaucer2.Kickz = 0
- bsSaucer2.InitAltKick 70, 12
- bsSaucer2.ExitAltSol_On
- bsSaucer2.Kickz = 1.15
- End If
- End Sub
- Sub PassRight3(Enabled)
- If Enabled then
- bsSaucer3.Kickz = 0
- bsSaucer3.InitAltKick 45, 13
- bsSaucer3.ExitAltSol_On
- bsSaucer3.Kickz = 1.15
- End If
- End Sub
- Sub PassLeft2(Enabled)
- If Enabled then
- bsSaucer2.Kickz = 0
- bsSaucer2.InitAltKick 315, 13
- bsSaucer2.ExitAltSol_On
- bsSaucer2.Kickz = 1.15
- End If
- End Sub
- Sub PassLeft3(Enabled)
- If Enabled then
- bsSaucer3.Kickz = 0
- bsSaucer3.InitAltKick 295, 14
- bsSaucer3.ExitAltSol_On
- bsSaucer3.Kickz = 1.15
- End If
- End Sub
- Sub PassLeft4(Enabled)
- If Enabled then
- bsSaucer4.Kickz = 0
- bsSaucer4.InitAltKick 250, 10
- bsSaucer4.ExitAltSol_On
- bsSaucer4.Kickz = 1.2
- End If
- End Sub
- '***************************************
- ' Special JP Flippers, including:
- ' - tap code by Jimmifingers
- ' - recoil fix to enable dropcatches
- ' - ball hit sound
- '**************************************
- SolCallback(sLRFlipper) = "SolRFlipper"
- SolCallback(sLLFlipper) = "SolLFlipper"
- Const ReflipAngle = 20
- Sub SolLFlipper(Enabled)
- If Enabled Then
- LF.Fire 'leftflipper.rotatetoend
- If leftflipper.currentangle < leftflipper.endangle + ReflipAngle Then
- RandomSoundReflipUpLeft LeftFlipper
- Else
- SoundFlipperUpAttackLeft LeftFlipper
- RandomSoundFlipperUpLeft LeftFlipper
- End If
- Else
- LeftFlipper.RotateToStart
- If LeftFlipper.currentangle < LeftFlipper.startAngle - 5 Then
- RandomSoundFlipperDownLeft LeftFlipper
- End If
- FlipperLeftHitParm = FlipperUpSoundLevel
- End If
- End Sub
- Sub SolRFlipper(Enabled)
- If Enabled Then
- RF.Fire 'rightflipper.rotatetoend
- If rightflipper.currentangle > rightflipper.endangle - ReflipAngle Then
- RandomSoundReflipUpRight RightFlipper
- Else
- SoundFlipperUpAttackRight RightFlipper
- RandomSoundFlipperUpRight RightFlipper
- End If
- Else
- RightFlipper.RotateToStart
- If RightFlipper.currentangle > RightFlipper.startAngle + 5 Then
- RandomSoundFlipperDownRight RightFlipper
- End If
- FlipperRightHitParm = FlipperUpSoundLevel
- End If
- End Sub
- '******************************************************
- ' FLIPPER AND RUBBER CORRECTION
- '******************************************************
- dim LF : Set LF = New FlipperPolarity
- dim RF : Set RF = New FlipperPolarity
- InitPolarity
- Sub InitPolarity()
- dim x, a : a = Array(LF, RF)
- for each x in a
- 'safety coefficient (diminishes polarity correction only)
- 'x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 0 'don't mess with these
- x.AddPoint "Ycoef", 0, RightFlipper.Y-65, 1 'disabled
- x.AddPoint "Ycoef", 1, RightFlipper.Y-11, 1
- x.enabled = True
- 'x.DebugOn = True : stickL.visible = True : tbpl.visible = True : vpmSolFlipsTEMP.DebugOn = True
- x.TimeDelay = 60
- Next
- 'rf.report "Velocity"
- addpt "Velocity", 0, 0, 1
- addpt "Velocity", 1, 0.1, 1.07
- addpt "Velocity", 2, 0.2, 1.15
- addpt "Velocity", 3, 0.3, 1.25
- addpt "Velocity", 4, 0.41, 1.05
- addpt "Velocity", 5, 0.65, 1.0'0.982
- addpt "Velocity", 6, 0.702, 0.968
- addpt "Velocity", 7, 0.95, 0.968
- addpt "Velocity", 8, 1.03, 0.945
- AddPt "Polarity", 0, 0, 0
- AddPt "Polarity", 1, 0.05, -5.5
- AddPt "Polarity", 2, 0.4, -5.5
- AddPt "Polarity", 3, 0.8, -5.5
- AddPt "Polarity", 4, 0.85, -5.25
- AddPt "Polarity", 5, 0.9, -4.25
- AddPt "Polarity", 6, 0.95, -3.75
- AddPt "Polarity", 7, 1, -3.25
- AddPt "Polarity", 8, 1.05, -2.25
- AddPt "Polarity", 9, 1.1, -1.5
- AddPt "Polarity", 10, 1.15, -1
- AddPt "Polarity", 11, 1.2, -0.5
- AddPt "Polarity", 12, 1.25, 0
- AddPt "Polarity", 13, 1.3, 0
- LF.Object = LeftFlipper
- LF.EndPoint = EndPointLp 'you can use just a coordinate, or an object with a .x property. Using a couple of simple primitive objects
- RF.Object = RightFlipper
- RF.EndPoint = EndPointRp
- End Sub
- Sub AddPt(aStr, idx, aX, aY) 'debugger wrapper for adjusting flipper script in-game
- dim a : a = Array(LF, RF)
- dim x : for each x in a
- x.addpoint aStr, idx, aX, aY
- Next
- End Sub
- 'Trigger Hit - .AddBall activeball
- 'Trigger UnHit - .PolarityCorrect activeball
- dim LFFlipBall, RFFlipBall : LFFlipBall = 0 : RFFlipBall = 0
- Sub TriggerLF_Hit() : LF.Addball activeball : LFFlipBall = 1 : End Sub
- Sub TriggerLF_UnHit() : LF.PolarityCorrect activeball : LFFlipBall = 0 : End Sub
- Sub TriggerRF_Hit() : RF.Addball activeball : RFFlipBall = 1 : End Sub
- Sub TriggerRF_UnHit() : RF.PolarityCorrect activeball : RFFlipBall = 0 : End Sub
- 'Methods:
- '.TimeDelay - Delay before trigger shuts off automatically. Default = 80 (ms)
- '.AddPoint - "Polarity", "Velocity", "Ycoef" coordinate points. Use one of these 3 strings, keep coordinates sequential. x = %position on the flipper, y = output
- '.Object - set to flipper reference. Optional.
- '.StartPoint - set start point coord. Unnecessary, if .object is used.
- 'Called with flipper -
- 'ProcessBalls - catches ball data.
- ' - OR -
- '.Fire - fires flipper.rotatetoend automatically + processballs. Requires .Object to be set to the flipper.
- Class FlipperPolarity
- Public DebugOn, Enabled
- Private FlipAt 'Timer variable (IE 'flip at 723,530ms...)
- Public TimeDelay 'delay before trigger turns off and polarity is disabled TODO set time!
- private Flipper, FlipperStart,FlipperEnd, FlipperEndY, LR, PartialFlipCoef
- Private Balls(20), balldata(20)
- dim PolarityIn, PolarityOut
- dim VelocityIn, VelocityOut
- dim YcoefIn, YcoefOut
- Public Sub Class_Initialize
- redim PolarityIn(0) : redim PolarityOut(0) : redim VelocityIn(0) : redim VelocityOut(0) : redim YcoefIn(0) : redim YcoefOut(0)
- Enabled = True : TimeDelay = 50 : LR = 1: dim x : for x = 0 to uBound(balls) : balls(x) = Empty : set Balldata(x) = new SpoofBall : next
- End Sub
- Public Property let Object(aInput) : Set Flipper = aInput : StartPoint = Flipper.x : End Property
- Public Property Let StartPoint(aInput) : if IsObject(aInput) then FlipperStart = aInput.x else FlipperStart = aInput : end if : End Property
- Public Property Get StartPoint : StartPoint = FlipperStart : End Property
- Public Property Let EndPoint(aInput) : FlipperEnd = aInput.x: FlipperEndY = aInput.y: End Property
- Public Property Get EndPoint : EndPoint = FlipperEnd : End Property
- Public Property Get EndPointY: EndPointY = FlipperEndY : End Property
- Public Sub AddPoint(aChooseArray, aIDX, aX, aY) 'Index #, X position, (in) y Position (out)
- Select Case aChooseArray
- case "Polarity" : ShuffleArrays PolarityIn, PolarityOut, 1 : PolarityIn(aIDX) = aX : PolarityOut(aIDX) = aY : ShuffleArrays PolarityIn, PolarityOut, 0
- Case "Velocity" : ShuffleArrays VelocityIn, VelocityOut, 1 :VelocityIn(aIDX) = aX : VelocityOut(aIDX) = aY : ShuffleArrays VelocityIn, VelocityOut, 0
- Case "Ycoef" : ShuffleArrays YcoefIn, YcoefOut, 1 :YcoefIn(aIDX) = aX : YcoefOut(aIDX) = aY : ShuffleArrays YcoefIn, YcoefOut, 0
- End Select
- if gametime > 100 then Report aChooseArray
- End Sub
- Public Sub Report(aChooseArray) 'debug, reports all coords in tbPL.text
- if not DebugOn then exit sub
- dim a1, a2 : Select Case aChooseArray
- case "Polarity" : a1 = PolarityIn : a2 = PolarityOut
- Case "Velocity" : a1 = VelocityIn : a2 = VelocityOut
- Case "Ycoef" : a1 = YcoefIn : a2 = YcoefOut
- case else :tbpl.text = "wrong string" : exit sub
- End Select
- dim str, x : for x = 0 to uBound(a1) : str = str & aChooseArray & " x: " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
- tbpl.text = str
- End Sub
- 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
- Private Sub RemoveBall(aBall)
- dim x : for x = 0 to uBound(balls)
- if TypeName(balls(x) ) = "IBall" then
- if aBall.ID = Balls(x).ID Then
- balls(x) = Empty
- Balldata(x).Reset
- End If
- End If
- Next
- End Sub
- Public Sub Fire()
- Flipper.RotateToEnd
- processballs
- End Sub
- Public Property Get Pos 'returns % position a ball. For debug stuff.
- dim x : for x = 0 to uBound(balls)
- if not IsEmpty(balls(x) ) then
- pos = pSlope(Balls(x).x, FlipperStart, 0, FlipperEnd, 1)
- End If
- Next
- End Property
- Public Sub ProcessBalls() 'save data of balls in flipper range
- FlipAt = GameTime
- dim x : for x = 0 to uBound(balls)
- if not IsEmpty(balls(x) ) then
- balldata(x).Data = balls(x)
- End If
- Next
- PartialFlipCoef = ((Flipper.StartAngle - Flipper.CurrentAngle) / (Flipper.StartAngle - Flipper.EndAngle))
- PartialFlipCoef = abs(PartialFlipCoef-1)
- End Sub
- Private Function FlipperOn() : if gameTime < FlipAt+TimeDelay then FlipperOn = True : End If : End Function 'Timer shutoff for polaritycorrect
- Public Sub PolarityCorrect(aBall)
- if FlipperOn() then
- dim tmp, BallPos, x, IDX, Ycoef : Ycoef = 1
- 'y safety Exit
- if aBall.VelY > -8 then 'ball going down
- RemoveBall aBall
- exit Sub
- end if
- 'Find balldata. BallPos = % on Flipper
- for x = 0 to uBound(Balls)
- if aBall.id = BallData(x).id AND not isempty(BallData(x).id) then
- idx = x
- BallPos = PSlope(BallData(x).x, FlipperStart, 0, FlipperEnd, 1)
- if ballpos > 0.65 then Ycoef = LinearEnvelope(BallData(x).Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
- end if
- Next
- If BallPos = 0 Then 'no ball data meaning the ball is entering and exiting pretty close to the same position, use current values.
- BallPos = PSlope(aBall.x, FlipperStart, 0, FlipperEnd, 1)
- if ballpos > 0.65 then Ycoef = LinearEnvelope(aBall.Y, YcoefIn, YcoefOut) 'find safety coefficient 'ycoef' data
- End If
- 'Velocity correction
- if not IsEmpty(VelocityIn(0) ) then
- Dim VelCoef
- : VelCoef = LinearEnvelope(BallPos, VelocityIn, VelocityOut)
- if partialflipcoef < 1 then VelCoef = PSlope(partialflipcoef, 0, 1, 1, VelCoef)
- if Enabled then aBall.Velx = aBall.Velx*VelCoef
- if Enabled then aBall.Vely = aBall.Vely*VelCoef
- End If
- 'Polarity Correction (optional now)
- if not IsEmpty(PolarityIn(0) ) then
- If StartPoint > EndPoint then LR = -1 'Reverse polarity if left flipper
- dim AddX : AddX = LinearEnvelope(BallPos, PolarityIn, PolarityOut) * LR
- if Enabled then aBall.VelX = aBall.VelX + 1 * (AddX*ycoef*PartialFlipcoef)
- 'debug.print BallPos & " " & AddX & " " & Ycoef & " "& PartialFlipcoef & " "& VelCoef
- 'playsound "fx_knocker"
- End If
- End If
- RemoveBall aBall
- End Sub
- End Class
- '================================
- 'Helper Functions
- Sub ShuffleArray(ByRef aArray, byVal offset) 'shuffle 1d array
- dim x, aCount : aCount = 0
- redim a(uBound(aArray) )
- for x = 0 to uBound(aArray) 'Shuffle objects in a temp array
- if not IsEmpty(aArray(x) ) Then
- if IsObject(aArray(x)) then
- Set a(aCount) = aArray(x)
- Else
- a(aCount) = aArray(x)
- End If
- aCount = aCount + 1
- End If
- Next
- if offset < 0 then offset = 0
- redim aArray(aCount-1+offset) 'Resize original array
- for x = 0 to aCount-1 'set objects back into original array
- if IsObject(a(x)) then
- Set aArray(x) = a(x)
- Else
- aArray(x) = a(x)
- End If
- Next
- End Sub
- Sub ShuffleArrays(aArray1, aArray2, offset)
- ShuffleArray aArray1, offset
- ShuffleArray aArray2, offset
- End Sub
- Function BallSpeed(ball) 'Calculates the ball speed
- BallSpeed = SQR(ball.VelX^2 + ball.VelY^2 + ball.VelZ^2)
- End Function
- Function PSlope(Input, X1, Y1, X2, Y2) 'Set up line via two points, no clamping. Input X, output Y
- dim x, y, b, m : x = input : m = (Y2 - Y1) / (X2 - X1) : b = Y2 - m*X2
- Y = M*x+b
- PSlope = Y
- End Function
- Function NullFunctionZ(aEnabled):End Function '1 argument null function placeholder TODO move me or replac eme
- Class spoofball
- Public X, Y, Z, VelX, VelY, VelZ, ID, Mass, Radius
- Public Property Let Data(aBall)
- With aBall
- x = .x : y = .y : z = .z : velx = .velx : vely = .vely : velz = .velz
- id = .ID : mass = .mass : radius = .radius
- end with
- End Property
- Public Sub Reset()
- x = Empty : y = Empty : z = Empty : velx = Empty : vely = Empty : velz = Empty
- id = Empty : mass = Empty : radius = Empty
- End Sub
- End Class
- Function Distance(ax,ay,bx,by)
- Distance = SQR((ax - bx)^2 + (ay - by)^2)
- End Function
- Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
- DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
- End Function
- '******************** Slacky Flips **************************'
- Dim FlipY
- FlipY = rightflipper.y
- Const Dislocation = 2 'Amount of minimum slack, affect to recovery speed too
- Const SlackHitLimit = 10 '6-16 Lower value will make slack happen with lower collision force
- Const HitForceDivider = 50 '10-100 Lower value will add slack. Set to roughly half of the max hit force(parm) you see when playing
- Const MaxSlack = 4
- Dim SlackAmount
- Sub CheckFlipperSlack(ball, Flipper, Logo, parm)
- If slackyFlips = 1 Then
- SlackAmount = Dislocation + parm / HitForceDivider
- if SlackAmount > MaxSlack then SlackAmount = MaxSlack
- if parm > SlackHitLimit Then
- Flipper.Y = FlipY + SlackAmount
- Logo.Y = FlipY + SlackAmount
- slacktimer.interval = 10
- slacktimer.Enabled = 1
- 'debug.print parm & " parm and SlackAmount " & SlackAmount
- end If
- end If
- end Sub
- Sub slacktimer_timer()
- 'msgbox "location change" & RightFlipper.Y & " and " & LeftFlipper.Y
- if RightFlipper.Y > FlipY + 2 Then
- RightFlipper.Y = RightFlipper.Y - 2
- RFLogo.Y = RFLogo.Y - 2
- else
- RightFlipper.Y = FlipY
- RFLogo.Y = FlipY
- End If
- if LeftFlipper.Y > FlipY + 2 Then
- LeftFlipper.Y = LeftFlipper.Y - 2
- LFLogo.Y = LFLogo.Y - 2
- else
- LeftFlipper.Y = FlipY
- LFLogo.Y = FlipY
- End If
- if LeftFlipper.Y = FlipY and RightFlipper.Y = FlipY Then slacktimer.Enabled = 0
- end Sub
- 'Then you need to add this to the flipper collide sub:
- 'CheckFlipperSlack Activeball, LeftFlipper, LFLogo, parm
- '******************************************************
- ' FLIPPER TRICKS
- '******************************************************
- RightFlipper.timerinterval=-1
- Rightflipper.timerenabled=True
- sub RightFlipper_timer()
- FlipperTricks LeftFlipper, LFPress, LFCount, LFEndAngle, LFState
- FlipperTricks RightFlipper, RFPress, RFCount, RFEndAngle, RFState
- If FlipSolNudge = 1 Then
- FlipperNudge RightFlipper, RFEndAngle, RFEOSNudge, LeftFlipper, LFEndAngle
- FlipperNudge LeftFlipper, LFEndAngle, LFEOSNudge, RightFlipper, RFEndAngle
- End If
- end sub
- Dim LFEOSNudge, RFEOSNudge
- Sub FlipperNudge(Flipper1, Endangle1, EOSNudge1, Flipper2, EndAngle2)
- Dim BOT, b
- If Flipper1.currentangle = Endangle1 and EOSNudge1 <> 1 Then
- EOSNudge1 = 1
- 'debug.print Flipper1.currentangle &" = "& Endangle1 &"--"& Flipper2.currentangle &" = "& EndAngle2
- If Flipper2.currentangle = EndAngle2 Then
- BOT = GetBalls
- 'debug.print "nudge ball " & BOT(0).x
- For b = 0 to Ubound(BOT)
- If FlipperTrigger(BOT(b).x, BOT(b).y, Flipper2) Then
- BOT(b).velx = BOT(b).velx / 1.7
- BOT(b).vely = BOT(b).vely - 1
- end If
- Next
- End If
- Else
- If Flipper1.currentangle <> EndAngle1 then
- EOSNudge1 = 0
- end if
- End If
- End Sub
- '*************************************************
- ' Check ball distance from Flipper for Rem
- '*************************************************
- Function Distance(ax,ay,bx,by)
- Distance = SQR((ax - bx)^2 + (ay - by)^2)
- End Function
- Function DistancePL(px,py,ax,ay,bx,by) ' Distance between a point and a line where point is px,py
- DistancePL = ABS((by - ay)*px - (bx - ax) * py + bx*ay - by*ax)/Distance(ax,ay,bx,by)
- End Function
- Function Radians(Degrees)
- Radians = Degrees * PI /180
- End Function
- Function AnglePP(ax,ay,bx,by)
- AnglePP = Atn2((by - ay),(bx - ax))*180/PI
- End Function
- Function Atn2(dy, dx)
- If dx > 0 Then
- Atn2 = Atn(dy / dx)
- ElseIf dx < 0 Then
- Atn2 = Sgn(dy) * (PI - Atn(Abs(dy / dx)))
- ElseIf dy = 0 Then
- Atn2 = 0
- Else
- Atn2 = Sgn(dy) * PI / 2
- End If
- End Function
- Function DistanceFromFlipper(ballx, bally, Flipper)
- DistanceFromFlipper = DistancePL(ballx, bally, Flipper.x, Flipper.y, Cos(Radians(Flipper.currentangle+90))+Flipper.x, Sin(Radians(Flipper.currentangle+90))+Flipper.y)
- End Function
- Function FlipperTrigger(ballx, bally, Flipper)
- Dim DiffAngle
- DiffAngle = ABS(Flipper.currentangle - AnglePP(Flipper.x, Flipper.y, ballx, bally) - 90)
- If DiffAngle > 180 Then DiffAngle = DiffAngle - 360
- If DistanceFromFlipper(ballx,bally,Flipper) < 48 and DiffAngle <= 90 and Distance(ballx,bally,Flipper.x,Flipper.y) < Flipper.Length Then
- FlipperTrigger = True
- Else
- FlipperTrigger = False
- End If
- End Function
- '*************************************************
- ' End - Check ball distance from Flipper for Rem
- '*************************************************
- dim LFPress, RFPress, LFCount, RFCount
- dim LFState, RFState
- dim EOST, EOSA,Frampup, FElasticity,FReturn
- dim RFEndAngle, LFEndAngle
- EOST = leftflipper.eostorque
- EOSA = leftflipper.eostorqueangle
- Frampup = LeftFlipper.rampup
- FElasticity = LeftFlipper.elasticity
- FReturn = LeftFlipper.return
- Const EOSTnew = 1
- Const EOSAnew = 0.8
- Const EOSRampup = 0
- Dim SOSRampup
- SOSRampup = 2.5
- 'Const LiveCatch = 16
- Const LiveElasticity = 0.45
- Const SOSEM = 0.815
- Const EOSReturn = 0.025
- LFEndAngle = Leftflipper.endangle
- RFEndAngle = RightFlipper.endangle
- Sub FlipperActivate(Flipper, FlipperPress)
- FlipperPress = 1
- Flipper.Elasticity = FElasticity
- Flipper.eostorque = EOST
- Flipper.eostorqueangle = EOSA
- End Sub
- Sub FlipperDeactivate(Flipper, FlipperPress)
- FlipperPress = 0
- Flipper.eostorqueangle = EOSA
- Flipper.eostorque = EOST*EOSReturn/FReturn
- If Abs(Flipper.currentangle) <= Abs(Flipper.endangle) + 0.1 Then
- Dim BOT, b
- BOT = GetBalls
- For b = 0 to UBound(BOT)
- If Distance(BOT(b).x, BOT(b).y, Flipper.x, Flipper.y) < 55 Then 'check for cradle
- If BOT(b).vely >= -0.4 Then BOT(b).vely = -0.4
- End If
- Next
- End If
- End Sub
- Sub FlipperTricks (Flipper, FlipperPress, FCount, FEndAngle, FState)
- Dim Dir
- Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
- If Abs(Flipper.currentangle) > Abs(Flipper.startangle) - 0.05 Then
- If FState <> 1 Then
- Flipper.rampup = SOSRampup
- Flipper.endangle = FEndAngle - 3*Dir
- Flipper.Elasticity = FElasticity * SOSEM
- FCount = 0
- FState = 1
- End If
- ElseIf Abs(Flipper.currentangle) <= Abs(Flipper.endangle) and FlipperPress = 1 then
- if FCount = 0 Then FCount = GameTime
- If FState <> 2 Then
- Flipper.eostorqueangle = EOSAnew
- Flipper.eostorque = EOSTnew
- Flipper.rampup = EOSRampup
- Flipper.endangle = FEndAngle
- FState = 2
- End If
- Elseif Abs(Flipper.currentangle) > Abs(Flipper.endangle) + 0.01 and FlipperPress = 1 Then
- If FState <> 3 Then
- Flipper.eostorque = EOST
- Flipper.eostorqueangle = EOSA
- Flipper.rampup = Frampup
- Flipper.Elasticity = FElasticity
- FState = 3
- End If
- End If
- End Sub
- Const LiveDistanceMin = 30 'minimum distance in vp units from flipper base live catch dampening will occur
- Const LiveDistanceMax = 114 'maximum distance in vp units from flipper base live catch dampening will occur (tip protection)
- Sub CheckLiveCatch(ball, Flipper, FCount, parm) 'Experimental new live catch
- Dim Dir
- Dir = Flipper.startangle/Abs(Flipper.startangle) '-1 for Right Flipper
- Dim LiveCatchBounce 'If live catch is not perfect, it won't freeze ball totally
- Dim CatchTime : CatchTime = GameTime - FCount
- if CatchTime <= LiveCatch and parm > 6 and ABS(Flipper.x - ball.x) > LiveDistanceMin and ABS(Flipper.x - ball.x) < LiveDistanceMax Then
- if CatchTime <= LiveCatch*0.5 Then 'Perfect catch only when catch time happens in the beginning of the window
- LiveCatchBounce = 0
- else
- LiveCatchBounce = Abs((LiveCatch/2) - CatchTime) 'Partial catch when catch happens a bit late
- end If
- If LiveCatchBounce = 0 and ball.velx * Dir > 0 Then ball.velx = 0
- ball.vely = LiveCatchBounce * (16 / LiveCatch) ' Multiplier for inaccuracy bounce
- ball.angmomx= 0
- ball.angmomy= 0
- ball.angmomz= 0
- debug.print "Live catch! Time: " & CatchTime & " Bounce: " & LiveCatchBounce & " parm: " & parm
- End If
- End Sub
- '*****************************************************************************************************
- '*******************************************************************************************************
- 'END nFOZZY FLIPPERS'
- '******************
- ' RealTime Updates
- '******************
- Sub GameTimer_Timer
- BallShadowUpdate
- RollingSound
- LampTimer
- UpdateLED
- RDampen
- LFLogo.RotZ = LeftFlipper.CurrentAngle
- RFlogo.RotZ = RightFlipper.CurrentAngle
- LeftFlipperSh.RotZ = LeftFlipper.currentangle
- RightFlipperSh.RotZ = RightFlipper.currentangle
- End Sub
- '*************************************************
- ' destruk's new vpmCreateBall for ball collision
- ' use it: vpmCreateBall kicker
- '*************************************************
- Set vpmCreateBall = GetRef("mycreateball")
- Function mycreateball(aKicker)
- For cnt = 1 to ubound(ballStatus)
- If ballStatus(cnt) = 0 Then
- If Not IsEmpty(vpmBallImage) Then
- Set CurrentBall(cnt) = aKicker.CreateSizedBall(BSize).Image
- Else
- Set CurrentBall(cnt) = aKicker.CreateSizedBall(BSize)
- End If
- Set mycreateball = aKicker
- currentball(cnt).uservalue = cnt
- ballStatus(cnt) = 1
- ballStatus(0) = ballStatus(0) + 1
- If coff = False Then
- If ballStatus(0) > 1 and XYdata.enabled = False Then XYdata.enabled = True
- End If
- Exit For
- End If
- Next
- End Function
- '**************************************************************
- ' vpm Ball Collision based on the code by Steely & Pinball Ken
- ' added destruk's changes, ball size and height check by koadic
- '**************************************************************
- Const tnopb = 10 'max nr. of balls
- Const nosf = 10 'nr. of sound files
- ReDim CurrentBall(tnopb), BallStatus(tnopb)
- Dim iball, cnt, coff, errMessage
- XYdata.interval = 1
- coff = False
- For cnt = 0 to ubound(BallStatus):BallStatus(cnt) = 0:Next
- ' Create ball in kicker and assign a Ball ID used mostly in non-vpm tables
- Sub CreateBallID(aKicker)
- For cnt = 1 to ubound(ballStatus)
- If ballStatus(cnt) = 0 Then
- Set CurrentBall(cnt) = aKicker.CreateSizedBall(Bsize)
- currentball(cnt).uservalue = cnt
- ballStatus(cnt) = 1
- ballStatus(0) = ballStatus(0) + 1
- If coff = False Then
- If ballStatus(0) > 1 and XYdata.enabled = False Then XYdata.enabled = True
- End If
- Exit For
- End If
- Next
- End Sub
- Sub ClearBallID
- On Error Resume Next
- iball = ActiveBall.uservalue
- currentball(iball).UserValue = 0
- If Err Then Msgbox Err.description & vbCrLf & iball
- ballStatus(iBall) = 0
- ballStatus(0) = ballStatus(0) -1
- On Error Goto 0
- End Sub
- ' Ball data collection and B2B Collision detection. jpsalas: added height check
- ReDim baX(tnopb, 4), baY(tnopb, 4), baZ(tnopb, 4), bVx(tnopb, 4), bVy(tnopb, 4), TotalVel(tnopb, 4)
- Dim cForce, bDistance, xyTime, cFactor, id, id2, id3, B1, B2
- Sub XYdata_Timer()
- xyTime = Timer + (XYdata.interval * .001)
- If id2 >= 4 Then id2 = 0
- id2 = id2 + 1
- For id = 1 to ubound(ballStatus)
- If ballStatus(id) = 1 Then
- baX(id, id2) = round(currentball(id).x, 2)
- baY(id, id2) = round(currentball(id).y, 2)
- baZ(id, id2) = round(currentball(id).z, 2)
- bVx(id, id2) = round(currentball(id).velx, 2)
- bVy(id, id2) = round(currentball(id).vely, 2)
- TotalVel(id, id2) = (bVx(id, id2) ^2 + bVy(id, id2) ^2)
- If TotalVel(id, id2) > TotalVel(0, 0) Then TotalVel(0, 0) = int(TotalVel(id, id2) )
- End If
- Next
- id3 = id2:B2 = 2:B1 = 1
- Do
- If ballStatus(B1) = 1 and ballStatus(B2) = 1 Then
- bDistance = int((TotalVel(B1, id3) + TotalVel(B2, id3) ) ^(1.04 * (CurrentBall(B1).radius + CurrentBall(B2).radius) / 50) )
- 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
- If ABS(baZ(B1, id3) - baZ(B2, id3) ) < (CurrentBall(B1).radius + CurrentBall(B2).radius) Then collide B1, B2:Exit Sub
- End If
- End If
- B1 = B1 + 1
- If B1 = ubound(ballstatus) Then Exit Do
- If B1 >= B2 then B1 = 1:B2 = B2 + 1
- Loop
- If ballStatus(0) <= 1 Then XYdata.enabled = False
- If XYdata.interval >= 40 Then coff = True:XYdata.enabled = False
- If Timer > xyTime * 3 Then coff = True:XYdata.enabled = False
- If Timer > xyTime Then XYdata.interval = XYdata.interval + 1
- End Sub
- 'Calculate the collision force and play sound
- Dim cTime, cb1, cb2, avgBallx, cAngle, bAngle1, bAngle2
- Sub Collide(cb1, cb2)
- If TotalVel(0, 0) / 1.8 > cFactor Then cFactor = int(TotalVel(0, 0) / 1.8)
- avgBallx = (bvX(cb2, 1) + bvX(cb2, 2) + bvX(cb2, 3) + bvX(cb2, 4) ) / 4
- If avgBallx < bvX(cb2, id2) + .1 and avgBallx > bvX(cb2, id2) -.1 Then
- If ABS(TotalVel(cb1, id2) - TotalVel(cb2, id2) ) < .000005 Then Exit Sub
- End If
- If Timer < cTime Then Exit Sub
- cTime = Timer + .1
- GetAngle baX(cb1, id3) - baX(cb2, id3), baY(cb1, id3) - baY(cb2, id3), cAngle
- id3 = id3 - 1:If id3 = 0 Then id3 = 4
- GetAngle bVx(cb1, id3), bVy(cb1, id3), bAngle1
- GetAngle bVx(cb2, id3), bVy(cb2, id3), bAngle2
- cForce = Cint((abs(TotalVel(cb1, id3) * Cos(cAngle-bAngle1) ) + abs(TotalVel(cb2, id3) * Cos(cAngle-bAngle2) ) ) )
- If cForce < 4 Then Exit Sub
- cForce = Cint((cForce) / (cFactor / nosf) )
- If cForce > nosf-1 Then cForce = nosf-1
- PlaySound("fx_collide" & cForce)
- End Sub
- ' Get angle
- Dim Xin, Yin, rAngle, Radit, wAngle, Pi
- Pi = Round(4 * Atn(1), 6) '3.1415926535897932384626433832795
- Sub GetAngle(Xin, Yin, wAngle)
- If Sgn(Xin) = 0 Then
- If Sgn(Yin) = 1 Then rAngle = 3 * Pi / 2 Else rAngle = Pi / 2
- If Sgn(Yin) = 0 Then rAngle = 0
- Else
- rAngle = atn(- Yin / Xin)
- End If
- If sgn(Xin) = -1 Then Radit = Pi Else Radit = 0
- If sgn(Xin) = 1 and sgn(Yin) = 1 Then Radit = 2 * Pi
- wAngle = round((Radit + rAngle), 4)
- End Sub
- ' #####################################
- ' ###### Flupper Flasher Domes #####
- ' #####################################
- Dim TestFlashers, TableRef, FlasherLightIntensity, FlasherFlareIntensity, FlasherBloomIntensity, FlasherOffBrightness
- ' *********************************************************************
- TestFlashers = 0 ' *** set this to 1 to check position of flasher object ***
- Set TableRef = Table1 ' *** change this, if your table has another name ***
- FlasherLightIntensity = 0.1 ' *** lower this, if the VPX lights are too bright (i.e. 0.1) ***
- FlasherFlareIntensity = 0.2 ' *** lower this, if the flares are too bright (i.e. 0.1) ***
- FlasherBloomIntensity = 0.4
- FlasherOffBrightness = 0.5 ' *** brightness of the flasher dome when switched off (range 0-2) ***
- ' *********************************************************************
- Dim ObjLevel(20), objbase(20), objlit(20), objflasher(20), objbloom(20), objlight(20)
- Dim tablewidth, tableheight : tablewidth = TableRef.width : tableheight = TableRef.height
- ''initialise the flasher color, you can only choose from "green", "red", "purple", "blue", "white" and "yellow"
- InitFlasher 1, "white" : InitFlasher 2, "blue" : InitFlasher 3, "red" : InitFlasher 4, "blue" : InitFlasher 5, "blue"
- InitFlasher 6, "yellow" : InitFlasher 7, "yellow" : InitFlasher 8, "yellow" : InitFlasher 9, "yellow" : InitFlasher 10, "red"
- '' rotate the flasher with the command below (first argument = flasher nr, second argument = angle in degrees)
- 'RotateFlasher 4,17 : RotateFlasher 5,0 : RotateFlasher 6,90
- 'RotateFlasher 7,0 : RotateFlasher 8,0
- 'RotateFlasher 9,-45 : RotateFlasher 10,90 : RotateFlasher 11,90
- rotateflasher 6,47
- rotateflasher 7,37
- rotateflasher 8, -4
- rotateflasher 9, -52
- Flasherlight5.BulbHaloHeight = 120
- Flasherlight4.BulbHaloHeight = 145
- Flasherlight1.BulbHaloHeight = 55
- Flasherlight2.BulbHaloHeight = 177
- Flasherlight3.BulbHaloHeight = 88
- Sub InitFlasher(nr, col)
- ' store all objects in an array for use in FlashFlasher subroutine
- Set objbase(nr) = Eval("Flasherbase" & nr) : Set objlit(nr) = Eval("Flasherlit" & nr)
- Set objflasher(nr) = Eval("Flasherflash" & nr) : Set objlight(nr) = Eval("Flasherlight" & nr)
- Set objbloom(nr) = Eval("Flasherbloom" & nr)
- ' If the flasher is parallel to the playfield, rotate the VPX flasher object for POV and place it at the correct height
- If objbase(nr).RotY = 0 Then
- objbase(nr).ObjRotZ = atn( (tablewidth/2 - objbase(nr).x) / (objbase(nr).y - tableheight*1.1)) * 180 / 3.14159
- objflasher(nr).RotZ = objbase(nr).ObjRotZ : objflasher(nr).height = objbase(nr).z + 40
- End If
- ' set all effects to invisible and move the lit primitive at the same position and rotation as the base primitive
- objlight(nr).IntensityScale = 0 : objlit(nr).visible = 0 : objlit(nr).material = "Flashermaterial" & nr
- objlit(nr).RotX = objbase(nr).RotX : objlit(nr).RotY = objbase(nr).RotY : objlit(nr).RotZ = objbase(nr).RotZ
- objlit(nr).ObjRotX = objbase(nr).ObjRotX : objlit(nr).ObjRotY = objbase(nr).ObjRotY : objlit(nr).ObjRotZ = objbase(nr).ObjRotZ
- objlit(nr).x = objbase(nr).x : objlit(nr).y = objbase(nr).y : objlit(nr).z = objbase(nr).z
- objbase(nr).BlendDisableLighting = FlasherOffBrightness
- ' set the texture and color of all objects
- select case objbase(nr).image
- Case "dome2basewhite" : objbase(nr).image = "dome2base" & col : objlit(nr).image = "dome2lit" & col :
- Case "ronddomebasewhite" : objbase(nr).image = "ronddomebase" & col : objlit(nr).image = "ronddomelit" & col
- Case "domeearbasewhite" : objbase(nr).image = "domeearbase" & col : objlit(nr).image = "domeearlit" & col
- end select
- If TestFlashers = 0 Then objflasher(nr).imageA = "domeflashwhite" : objflasher(nr).visible = 0 : End If
- select case col
- Case "blue" : objlight(nr).color = RGB(4,120,255) : objflasher(nr).color = RGB(20,155,255) ': objlight(nr).intensity = 5000
- Case "green" : objlight(nr).color = RGB(12,255,4) : objflasher(nr).color = RGB(12,255,4)
- Case "red" : objlight(nr).color = RGB(255,32,4) : objflasher(nr).color = RGB(255,32,4)
- Case "purple" : objlight(nr).color = RGB(230,49,255) : objflasher(nr).color = RGB(255,64,255)
- Case "yellow" : objlight(nr).color = RGB(200,173,25) : objflasher(nr).color = RGB(255,200,50)
- Case "white" : objlight(nr).color = RGB(255,240,150) : objflasher(nr).color = RGB(100,86,59)
- end select
- objlight(nr).colorfull = objlight(nr).color
- If TableRef.ShowDT and ObjFlasher(nr).RotX = -45 Then
- objflasher(nr).height = objflasher(nr).height - 20 * ObjFlasher(nr).y / tableheight
- ObjFlasher(nr).y = ObjFlasher(nr).y + 10
- End If
- 'FlasherFlash4.height = 226
- 'FlasherFlash3.height = 200
- End Sub
- Sub RotateFlasher(nr, angle) : angle = ((angle + 360 - objbase(nr).ObjRotZ) mod 180)/30 : objbase(nr).showframe(angle) : objlit(nr).showframe(angle) : End Sub
- Sub FlashFlasher(nr)
- If not objflasher(nr).TimerEnabled Then objflasher(nr).TimerEnabled = True : objflasher(nr).visible = 1 : objbloom(nr).visible = 1 : objlit(nr).visible = 1 : End If
- objflasher(nr).opacity = 1000 * FlasherFlareIntensity * ObjLevel(nr)^2.5
- objbloom(nr).opacity = 100 * FlasherBloomIntensity * ObjLevel(nr)^2.5
- objlight(nr).IntensityScale = 0.5 * FlasherLightIntensity * ObjLevel(nr)^3
- objbase(nr).BlendDisableLighting = FlasherOffBrightness + 10 * ObjLevel(nr)^3
- objlit(nr).BlendDisableLighting = 10 * ObjLevel(nr)^2
- UpdateMaterial "Flashermaterial" & nr,0,0,0,0,0,0,ObjLevel(nr),RGB(255,255,255),0,0,False,True,0,0,0,0
- ObjLevel(nr) = ObjLevel(nr) * 0.9 - 0.01
- If ObjLevel(nr) < 0 Then objflasher(nr).TimerEnabled = False : objflasher(nr).visible = 0 : objbloom(nr).visible = 0 : objlit(nr).visible = 0 : End If
- End Sub
- Sub FlasherFlash1_Timer() : FlashFlasher(1) : End Sub
- Sub FlasherFlash2_Timer() : FlashFlasher(2) : End Sub
- Sub FlasherFlash3_Timer() : FlashFlasher(3) : End Sub
- Sub FlasherFlash4_Timer() : FlashFlasher(4) : End Sub
- Sub FlasherFlash5_Timer() : FlashFlasher(5) : End Sub
- Sub FlasherFlash6_Timer() : FlashFlasher(6) : End Sub
- Sub FlasherFlash7_Timer() : FlashFlasher(7) : End Sub
- Sub FlasherFlash8_Timer() : FlashFlasher(8) : End Sub
- Sub FlasherFlash9_Timer() : FlashFlasher(9) : End Sub
- Sub FlasherFlash10_Timer() : FlashFlasher(10) : End Sub
- ' ###############################################
- ' ###### NBA Fastbreak flasher dome settings #####
- ' ###############################################
- Sub FlashSol24(flstate)
- If Flstate Then
- Objlevel(1) = 1 : FlasherFlash1_Timer
- Objlevel(2) = 1 : FlasherFlash2_Timer
- End If
- End Sub
- Sub FlashSol17(flstate)
- If Flstate Then
- Objlevel(3) = 1 : FlasherFlash3_Timer
- End If
- End Sub
- Sub FlashSol18(flstate)
- If Flstate Then
- Objlevel(10) = 1 : FlasherFlash10_Timer
- End If
- End Sub
- Sub FlashSol19(flstate)
- If Flstate Then
- Objlevel(4) = 1 : FlasherFlash4_Timer
- End If
- End Sub
- Sub FlashSol20(flstate)
- If Flstate Then
- Objlevel(5) = 1 : FlasherFlash5_Timer
- End If
- End Sub
- Sub FlashRondo(nr, flstate)
- If Flstate Then
- Select Case nr
- Case 67:Objlevel(9) = 1 : FlasherFlash9_Timer
- Case 68:Objlevel(8) = 1 : FlasherFlash8_Timer
- Case 77:Objlevel(6) = 1 : FlasherFlash6_Timer
- Case 78:Objlevel(7) = 1 : FlasherFlash7_Timer
- End Select
- End If
- End Sub
- '***************************************************
- ' JP's VP10 Fading Lamps & Flashers
- ' Based on PD's Fading Light System
- ' SetLamp 0 is Off
- ' SetLamp 1 is On
- ' fading for non opacity objects is 4 steps
- '***************************************************
- Dim LampState(200), FadingLevel(200)
- Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
- InitLamps() ' turn off the lights and flashers and reset them to the default parameters
- 'LampTimer.Interval = 10 'lamp fading speed
- 'LampTimer.Enabled = 1
- ' Lamp & Flasher Timers
- Sub LampTimer()
- Dim chgLamp, num, chg, ii
- chgLamp = Controller.ChangedLamps
- If Not IsEmpty(chgLamp) Then
- For ii = 0 To UBound(chgLamp)
- LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
- FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
- Next
- End If
- UpdateLamps
- End Sub
- Sub UpdateLamps
- NFadeLm 11, l11
- FadeDisableLighting2 11, p11, 122
- NfadeLm 12, l12
- FadeDisableLighting2 12, p12, 70
- NfadeLm 13, l13
- FadeDisableLighting2 13, p13, 70
- NfadeLm 14, l14
- FadeDisableLighting2 14, p14, 70
- NfadeLm 15, l15
- FadeDisableLighting2 15, p15, 122
- NfadeLm 16, l16
- FadeDisableLighting2 16, p16, 122
- NfadeLm 17, l17
- FadeDisableLighting2 17, p17, 122
- NfadeLm 18, l18
- FadeDisableLighting2 18, p18, 122
- NfadeLm 21, l21
- FadeDisableLighting2 21, p21, 122
- NfadeLm 22, l22
- FadeDisableLighting2 22, p22, 110
- NfadeLm 23, l23
- FadeDisableLighting2 23, p23, 110
- NfadeLm 24, l24
- FadeDisableLighting2 24, p24, 110
- NfadeLm 25, l25
- FadeDisableLighting2 25, p25, 120
- NfadeLm 26, l26
- NfadeLm 26, l26a
- FadeDisableLighting2 26, p26off, 15
- NfadeLm 27, l27
- FadeDisableLighting2 27, p27, 110
- NfadeLm 28, l28
- FadeDisableLighting2 28, p28, 122
- NfadeLm 31, l31
- FadeDisableLighting2 31, p31, 122
- NfadeLm 32, l32
- FadeDisableLighting2 32, p32, 122
- NfadeLm 33, l33
- FadeDisableLighting2 33, p33, 122
- NfadeLm 34, l34
- FadeDisableLighting2 34, p34, 122
- NfadeLm 35, l35
- FadeDisableLighting2 35, p35, 110
- NfadeLm 36, l36
- FadeDisableLighting2 36, p36, 110
- NfadeLm 37, l37
- NfadeLm 37, l37a
- FadeDisableLighting2 37, p37, 55
- NfadeLm 38, l38
- NfadeLm 38, l38a
- FadeDisableLighting2 38,p38, 90
- NfadeLm 41, l41
- FadeDisableLighting2 41, p41, 110
- NfadeLm 42, l42
- FadeDisableLighting2 42, p42, 110
- NfadeLm 43, l43
- NfadeLm 43, l43a
- FadeDisableLighting2 43, p43, 90
- NfadeLm 44, l44
- FadeDisableLighting2 44, p44, 110
- NfadeLm 45, l45
- FadeDisableLighting2 45, p45, 110
- NfadeLm 46, l46
- FadeDisableLighting2 46, p46, 33
- NfadeLm 47, l47
- FadeDisableLighting2 47, p47, 33
- NfadeLm 48, l48
- FadeDisableLighting2 48, p48, 70
- NfadeLm 51, l51
- NfadeLm 51, l51a
- FadeDisableLighting2 51,p51, 55
- NfadeLm 52, l52
- FadeDisableLighting2 52,p52, 155
- NfadeLm 53, l53
- NfadeLm 53, l53a
- FadeDisableLighting2 53,p53, 300
- NfadeLm 54, l54
- NfadeLm 54, l54a
- FadeDisableLighting2 54,p54, 88
- NfadeLm 55, l55
- NfadeLm 55, l55a
- FadeDisableLighting2 55,p55, 55
- NfadeLm 56, l56
- FadeDisableLighting2 56, p56, 90
- NfadeLm 57, l57
- FadeDisableLighting2 57, p57, 60
- NfadeLm 58, l58
- FadeDisableLighting2 58, p58, 70
- NFadeLm 61, l61b
- NfadeLm 61, l61
- FadeDisableLightingM 61, p61b, 90
- FadeDisableLighting2 61, p61, 90
- NfadeLm 62, l62
- FadeDisableLighting2 62, p62, 110
- NfadeLm 63, l63
- FadeDisableLighting2 63, p63, 110
- NfadeLm 64, l64
- FadeDisableLighting2 64, p64, 110
- NfadeLm 65, l65
- FadeDisableLighting2 65, p65, 110
- NfadeLm 66, l66
- NfadeLm 66, l66a
- FadeDisableLighting2 66,p66, 55
- NfadeL 71, l71
- FadeDisableLighting2 71, p71, 110
- NfadeL 72, l72
- FadeDisableLighting2 72, p72, 110
- NfadeLm 73, l73
- NfadeLm 73, l73a
- FadeDisableLighting2 73, p73, 55
- NfadeLm 74, l74
- FadeDisableLighting2 74, p74, 110
- NfadeLm 75, l75
- FadeDisableLighting2 75, p75, 110
- NFadeLm 76, l76
- NfadeLm 76, l76a
- FadeDisableLighting2 76, p76, 55
- NfadeLm 81, l81
- FadeDisableLighting2 81, p81, 110
- NfadeLm 82, l82
- FadeDisableLighting2 82, p82, 110
- NfadeLm 83, l83
- NfadeLm 83, l83a
- FadeDisableLighting2 83, p83, 55
- NfadeLm 84, l84
- FadeDisableLighting2 84, p84, 110
- NfadeLm 85, l85
- FadeDisableLighting2 85, p85, 110
- NfadeLm 86, l86
- FadeDisableLighting2 86, p86, 110
- NfadeL 87, l87
- NfadeL 88, l88
- ' fadeobj 67, l67, "of_on", "of_a", "of_b", "empty"
- ' fadeobj 68, l68, "of_on", "of_a", "of_b", "empty"
- ' fadeobj 77, l77, "of_on", "of_a", "of_b", "empty"
- ' fadeobj 78, l78, "of_on", "of_a", "of_b", "empty"
- ' flash 67,f67
- ' flash 68,f68
- flash2 67
- flash2 68
- flash2 77
- flash2 78
- 'flash 78,f78
- ' flashers old
- ' fadeobj 117, f17, "rf_on", "rf_a", "rf_b", "empty"
- ' NFadeLm 118, bumper1
- ' fadeobj 118, f18, "rf_on", "rf_a", "rf_b", "empty"
- ' fadeobj 119, f19, "wf_on", "wf_a", "wf_b", "empty"
- ' fadeobj 120, f20, "bf_on", "bf_a", "bf_b", "empty"
- ' fadeobjm 124, f24, "wf_on", "wf_a", "wf_b", "empty"
- ' fadeobj 124, f24b, "bf_on", "bf_a", "bf_b", "empty"
- ' flashers new
- ' flash 117,f17
- ' flash 118,f18
- ' flash 119,f19
- ' flash 120,f20
- ' flashm 124,f24b
- ' flash 124,f24
- End Sub
- ' div lamp subs
- Sub InitLamps()
- Dim x
- For x = 0 to 200
- LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
- FadingLevel(x) = 4 ' used to track the fading state
- FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
- FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
- FlashMax(x) = 1 ' the maximum value when on, usually 1
- FlashMin(x) = 0 ' the minimum value when off, usually 0
- FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
- Next
- End Sub
- Sub AllLampsOff
- Dim x
- For x = 0 to 200
- SetLamp x, 0
- Next
- End Sub
- const gInsertLevel = 0.5
- Sub FadeDisableLightingM(nr, a, alvl)
- ' debug.print "fade value" & FadingLevel(nr)
- Select Case FadingLevel(nr)
- Case 4
- a.UserValue = a.UserValue - 0.200
- If a.UserValue < 0 Then
- a.UserValue = 0
- 'FadingLevel(nr) = -1
- end If
- a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
- Case 5
- a.UserValue = a.UserValue + 0.200
- If a.UserValue > 1 Then
- a.UserValue = 1
- 'FadingLevel(nr) = -1
- end If
- a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
- End Select
- End Sub
- Sub FadeDisableLighting2(nr, a, alvl)
- 'if nr = 83 then debug.print "fade level: " & a.UserValue
- Select Case FadingLevel(nr)
- Case 4
- a.UserValue = a.UserValue - 0.200
- If a.UserValue < 0 Then
- a.UserValue = 0
- FadingLevel(nr) = 0
- end If
- a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
- Case 5
- a.UserValue = a.UserValue + 0.200
- If a.UserValue > 1 Then
- a.UserValue = 1
- FadingLevel(nr) = 1
- end If
- a.BlendDisableLighting = alvl * a.UserValue * gInsertLevel 'brightness
- End Select
- End Sub
- Sub SetLamp(nr, value)
- If value <> LampState(nr) Then
- LampState(nr) = abs(value)
- FadingLevel(nr) = abs(value) + 4
- End If
- End Sub
- ' Lights: used for VP10 standard lights, the fading is handled by VP itself
- Sub NFadeL(nr, object)
- Select Case FadingLevel(nr)
- Case 4:object.state = 0:FadingLevel(nr) = 0
- Case 5:object.state = 1:FadingLevel(nr) = 1
- End Select
- End Sub
- Sub NFadeLm(nr, object)
- Select Case FadingLevel(nr)
- Case 4:object.state = 0
- Case 5:object.state = 1
- End Select
- End Sub
- 'Lights, Ramps & Primitives used as 4 step fading lights
- 'a,b,c,d are the images used from on to off
- Sub FadeObj(nr, object, a, b, c, d)
- Select Case FadingLevel(nr)
- Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
- Case 5:object.image = a:FadingLevel(nr) = 1 'ON
- Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
- Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
- Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
- Case 13:object.image = d:FadingLevel(nr) = 0 'Off
- End Select
- End Sub
- Sub FadeObjm(nr, object, a, b, c, d)
- Select Case FadingLevel(nr)
- Case 4:object.image = b
- Case 5:object.image = a
- Case 9:object.image = c
- Case 13:object.image = d
- End Select
- End Sub
- Sub NFadeObj(nr, object, a, b)
- Select Case FadingLevel(nr)
- Case 4:object.image = b:FadingLevel(nr) = 0 'off
- Case 5:object.image = a:FadingLevel(nr) = 1 'on
- End Select
- End Sub
- Sub NFadeObjm(nr, object, a, b)
- Select Case FadingLevel(nr)
- Case 4:object.image = b
- Case 5:object.image = a
- End Select
- End Sub
- ' Flasher objects
- Sub Flash(nr, object)
- Select Case FadingLevel(nr)
- Case 4 'off
- FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
- If FlashLevel(nr) < FlashMin(nr) Then
- FlashLevel(nr) = FlashMin(nr)
- FadingLevel(nr) = 0 'completely off
- End if
- Object.IntensityScale = FlashLevel(nr)
- Case 5 ' on
- FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
- If FlashLevel(nr) > FlashMax(nr) Then
- FlashLevel(nr) = FlashMax(nr)
- FadingLevel(nr) = 1 'completely on
- End if
- Object.IntensityScale = FlashLevel(nr)
- End Select
- End Sub
- 'Flashf77
- Sub Flash2(nr)
- 'debug.print FadingLevel(nr)
- Select Case FadingLevel(nr)
- 'Case 4 'off
- 'Flashf77(False)
- Case 5 ' on
- FlashRondo nr, True
- End Select
- End Sub
- Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
- Object.IntensityScale = FlashLevel(nr)
- End Sub
- Sub Flashm2(nr, object) 'multiple flashers, it just sets the flashlevel
- Flashf77(FlashLevel(nr))
- End Sub
- ' Desktop Objects: Reels & texts (you may also use lights on the desktop)
- ' Reels
- Sub FadeR(nr, object)
- Select Case FadingLevel(nr)
- Case 4:object.SetValue 1:FadingLevel(nr) = 6 'fading to off...
- Case 5:object.SetValue 0:FadingLevel(nr) = 1 'ON
- Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
- Case 9:object.SetValue 2:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
- Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
- Case 13:object.SetValue 3:FadingLevel(nr) = 0 'Off
- End Select
- End Sub
- Sub FadeRm(nr, object)
- Select Case FadingLevel(nr)
- Case 4:object.SetValue 1
- Case 5:object.SetValue 0
- Case 9:object.SetValue 2
- Case 3:object.SetValue 3
- End Select
- End Sub
- 'Texts
- Sub NFadeT(nr, object, message)
- Select Case FadingLevel(nr)
- Case 4:object.Text = "":FadingLevel(nr) = 0
- Case 5:object.Text = message:FadingLevel(nr) = 1
- End Select
- End Sub
- Sub NFadeTm(nr, object, b)
- Select Case FadingLevel(nr)
- Case 4:object.Text = ""
- Case 5:object.Text = message
- End Select
- End Sub
- '********************
- ' Diverse Help/Sounds
- '********************
- ''Sub ARubbers_Hit(idx):PlaySound "fx_rubber":End Sub
- 'Sub APostRubbers_Hit(idx):PlaySound "fx_rubber":End Sub
- 'Sub AMetals_Hit(idx):PlaySound "fx_MetalHit":End Sub
- 'Sub AGates_Hit(idx):PlaySound "fx_Gate":End Sub
- 'Sub APlastics_Hit(idx):PlaySound "fx_plastichit":End Sub
- Sub WireEnter1_Hit:PlaySound "fx_metalrolling":End Sub
- Sub WireExit1_Hit:StopSound "fx_metalrolling":PlaySound "fx_wirerampexit":End Sub
- Sub RHelp1_Hit:PlaySound "fx_ballhit":End Sub
- Sub RHelp2_Hit:PlaySound "fx_ballhit":End Sub
- Sub RHelp5_Hit:PlaySound "fx_ballhit":End Sub
- Sub RHelp3_Hit
- If ActiveBall.VelY < -10 Then
- ActiveBall.VelY = -10
- End If
- End Sub
- Sub RHelp4_Hit
- ActiveBall.VelX = -5
- End Sub
- '//////////////////////////// MECHANICAL SOUNDS ///////////////////////////
- '// This part in the script is an entire block that is dedicated to the physics sound system.
- '// Various scripts and sounds that may be pretty generic and could suit other WPC systems, but the most are tailored specifically for this table.
- '/////////////////////////////// SOUNDS PARAMETERS //////////////////////////////
- Dim GlobalSoundLevel, CoinSoundLevel, PlungerReleaseSoundLevel, PlungerPullSoundLevel, NudgeLeftSoundLevel
- Dim NudgeRightSoundLevel, NudgeCenterSoundLevel, StartButtonSoundLevel, RollingSoundFactor
- CoinSoundLevel = 1 'volume level; range [0, 1]
- NudgeLeftSoundLevel = 1 'volume level; range [0, 1]
- NudgeRightSoundLevel = 1 'volume level; range [0, 1]
- NudgeCenterSoundLevel = 1 'volume level; range [0, 1]
- StartButtonSoundLevel = 0.1 'volume level; range [0, 1]
- PlungerReleaseSoundLevel = 0.8 '1 wjr 'volume level; range [0, 1]
- PlungerPullSoundLevel = 1 'volume level; range [0, 1]
- RollingSoundFactor = 1.1/5
- '///////////////////////-----Solenoids, Kickers and Flash Relays-----///////////////////////
- Dim FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel, FlipperUpAttackLeftSoundLevel, FlipperUpAttackRightSoundLevel
- Dim FlipperUpSoundLevel, FlipperDownSoundLevel, FlipperLeftHitParm, FlipperRightHitParm
- Dim SlingshotSoundLevel, BumperSoundFactor, KnockerSoundLevel
- FlipperUpAttackMinimumSoundLevel = 0.010 'volume level; range [0, 1]
- FlipperUpAttackMaximumSoundLevel = 0.635 'volume level; range [0, 1]
- FlipperUpSoundLevel = 1.0 'volume level; range [0, 1]
- FlipperDownSoundLevel = 0.45 'volume level; range [0, 1]
- FlipperLeftHitParm = FlipperUpSoundLevel 'sound helper; not configurable
- FlipperRightHitParm = FlipperUpSoundLevel 'sound helper; not configurable
- SlingshotSoundLevel = 0.95 'volume level; range [0, 1]
- BumperSoundFactor = 4.25 'volume multiplier; must not be zero
- KnockerSoundLevel = 1 'volume level; range [0, 1]
- '///////////////////////-----Ball Drops, Bumps and Collisions-----///////////////////////
- Dim RubberStrongSoundFactor, RubberWeakSoundFactor, RubberFlipperSoundFactor,BallWithBallCollisionSoundFactor
- Dim BallBouncePlayfieldSoftFactor, BallBouncePlayfieldHardFactor, PlasticRampDropToPlayfieldSoundLevel, WireRampDropToPlayfieldSoundLevel, DelayedBallDropOnPlayfieldSoundLevel
- Dim WallImpactSoundFactor, MetalImpactSoundFactor, SubwaySoundLevel, SubwayEntrySoundLevel, ScoopEntrySoundLevel
- Dim SaucerLockSoundLevel, SaucerKickSoundLevel
- BallWithBallCollisionSoundFactor = 3.2 'volume multiplier; must not be zero
- RubberStrongSoundFactor = 0.055/5 'volume multiplier; must not be zero
- RubberWeakSoundFactor = 0.075/5 'volume multiplier; must not be zero
- RubberFlipperSoundFactor = 0.075/5 'volume multiplier; must not be zero
- BallBouncePlayfieldSoftFactor = 0.025 'volume multiplier; must not be zero
- BallBouncePlayfieldHardFactor = 0.025 'volume multiplier; must not be zero
- DelayedBallDropOnPlayfieldSoundLevel = 0.8 'volume level; range [0, 1]
- WallImpactSoundFactor = 0.075 'volume multiplier; must not be zero
- MetalImpactSoundFactor = 0.075/3
- SaucerLockSoundLevel = 0.8
- SaucerKickSoundLevel = 0.8
- '///////////////////////-----Gates, Spinners, Rollovers and Targets-----///////////////////////
- Dim GateSoundLevel, TargetSoundFactor, SpinnerSoundLevel, RolloverSoundLevel, DTSoundLevel
- GateSoundLevel = 0.5/5 'volume level; range [0, 1]
- TargetSoundFactor = 0.0025 * 10 'volume multiplier; must not be zero
- DTSoundLevel = 0.25 'volume multiplier; must not be zero
- RolloverSoundLevel = 0.25 'volume level; range [0, 1]
- '///////////////////////-----Ball Release, Guides and Drain-----///////////////////////
- Dim DrainSoundLevel, BallReleaseSoundLevel, BottomArchBallGuideSoundFactor, FlipperBallGuideSoundFactor
- DrainSoundLevel = 0.8 'volume level; range [0, 1]
- BallReleaseSoundLevel = 1 'volume level; range [0, 1]
- BottomArchBallGuideSoundFactor = 0.2 'volume multiplier; must not be zero
- FlipperBallGuideSoundFactor = 0.015 'volume multiplier; must not be zero
- '///////////////////////-----Loops and Lanes-----///////////////////////
- Dim ArchSoundFactor
- ArchSoundFactor = 0.025/5 'volume multiplier; must not be zero
- '///////////////////////////// SOUND PLAYBACK FUNCTIONS ////////////////////////////
- '///////////////////////////// POSITIONAL SOUND PLAYBACK METHODS ////////////////////////////
- ' Positional sound playback methods will play a sound, depending on the X,Y position of the table element or depending on ActiveBall object position
- ' These are similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
- ' For surround setup - positional sound playback functions will fade between front and rear surround channels and pan between left and right channels
- ' For stereo setup - positional sound playback functions will only pan between left and right channels
- ' For mono setup - positional sound playback functions will not pan between left and right channels and will not fade between front and rear channels
- ' PlaySound full syntax - PlaySound(string, int loopcount, float volume, float pan, float randompitch, int pitch, bool useexisting, bool restart, float front_rear_fade)
- ' Note - These functions will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
- Sub PlaySoundAtLevelStatic(playsoundparams, aVol, tableobj)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtLevelExistingStatic(playsoundparams, aVol, tableobj)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtLevelStaticLoop(playsoundparams, aVol, tableobj)
- PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), 0, 0, 0, 0, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtLevelStaticRandomPitch(playsoundparams, aVol, randomPitch, tableobj)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtLevelActiveBall(playsoundparams, aVol)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 0, 0, AudioFade(ActiveBall)
- End Sub
- Sub PlaySoundAtLevelExistingActiveBall(playsoundparams, aVol)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ActiveBall), 0, 0, 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub PlaySoundAtLeveTimerActiveBall(playsoundparams, aVol, ballvariable)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 0, 0, AudioFade(ballvariable)
- End Sub
- Sub PlaySoundAtLevelTimerExistingActiveBall(playsoundparams, aVol, ballvariable)
- PlaySound playsoundparams, 0, aVol * VolumeDial, AudioPan(ballvariable), 0, 0, 1, 0, AudioFade(ballvariable)
- End Sub
- Sub PlaySoundAtLevelRoll(playsoundparams, aVol, pitch)
- PlaySound playsoundparams, -1, aVol * VolumeDial, AudioPan(tableobj), randomPitch, 0, 0, 0, AudioFade(tableobj)
- End Sub
- ' Previous Positional Sound Subs
- Sub PlaySoundAt(soundname, tableobj)
- PlaySound soundname, 1, 1 * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtVol(soundname, tableobj, aVol)
- PlaySound soundname, 1, aVol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtBall(soundname)
- PlaySoundAt soundname, ActiveBall
- End Sub
- Sub PlaySoundAtBallVol (Soundname, aVol)
- Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 1, AudioFade(ActiveBall)
- End Sub
- Sub PlaySoundAtBallVolM (Soundname, aVol)
- Playsound soundname, 1,aVol * VolumeDial, AudioPan(ActiveBall), 0,0,0, 0, AudioFade(ActiveBall)
- End Sub
- Sub PlaySoundAtVolLoops(sound, tableobj, Vol, Loops)
- PlaySound sound, Loops, Vol * VolumeDial, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- ' *********************************************************************
- ' Supporting Ball & Sound Functions
- ' *********************************************************************
- 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
- Dim tmp
- tmp = tableobj.y * 2 / tableheight-1
- If tmp > 0 Then
- AudioFade = Csng(tmp ^10)
- Else
- AudioFade = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
- Dim tmp
- tmp = tableobj.x * 2 / tablewidth-1
- If tmp > 0 Then
- AudioPan = Csng(tmp ^10)
- Else
- AudioPan = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function Vol(ball) ' Calculates the volume of the sound based on the ball speed
- Vol = Csng(BallVel(ball) ^2)
- End Function
- Function Volz(ball) ' Calculates the volume of the sound based on the ball speed
- Volz = Csng((ball.velz) ^2)
- End Function
- Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
- Pitch = BallVel(ball) * 20
- End Function
- Function BallVel(ball) 'Calculates the ball speed
- BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
- End Function
- Function VolPlayfieldRoll(ball) ' Calculates the roll volume of the sound based on the ball speed
- VolPlayfieldRoll = RollingSoundFactor * 0.0005 * Csng(BallVel(ball) ^3)
- End Function
- Function PitchPlayfieldRoll(ball) ' Calculates the roll pitch of the sound based on the ball speed
- PitchPlayfieldRoll = BallVel(ball) ^2 * 15
- End Function
- Function RndInt(min, max)
- RndInt = Int(Rnd() * (max-min + 1) + min)' Sets a random number integer between min and max
- End Function
- Function RndNum(min, max)
- RndNum = Rnd() * (max-min) + min' Sets a random number between min and max
- End Function
- '///////////////////////////// GENERAL SOUND SUBROUTINES ////////////////////////////
- Sub SoundStartButton()
- PlaySound ("Start_Button"), 0, StartButtonSoundLevel, 0, 0.25
- End Sub
- Sub SoundNudgeLeft()
- PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeLeftSoundLevel * VolumeDial, -0.1, 0.25
- End Sub
- Sub SoundNudgeRight()
- PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeRightSoundLevel * VolumeDial, 0.1, 0.25
- End Sub
- Sub SoundNudgeCenter()
- PlaySound ("Nudge_" & Int(Rnd*2)+1), 0, NudgeCenterSoundLevel * VolumeDial, 0, 0.25
- End Sub
- Sub SoundPlungerPull()
- PlaySoundAtLevelStatic ("Plunger_Pull_1"), PlungerPullSoundLevel, Plunger
- End Sub
- Sub SoundPlungerReleaseBall()
- PlaySoundAtLevelStatic ("Plunger_Release_Ball"), PlungerReleaseSoundLevel, Plunger
- End Sub
- Sub SoundPlungerReleaseNoBall()
- PlaySoundAtLevelStatic ("Plunger_Release_No_Ball"), PlungerReleaseSoundLevel, Plunger
- End Sub
- '///////////////////////////// KNOCKER SOLENOID ////////////////////////////
- Sub KnockerSolenoid()
- PlaySoundAtLevelStatic SoundFX("Knocker_1",DOFKnocker), KnockerSoundLevel, KnockerPosition
- End Sub
- '///////////////////////////// DRAIN SOUNDS ////////////////////////////
- Sub RandomSoundDrain(drainswitch)
- PlaySoundAtLevelStatic ("Drain_" & Int(Rnd*11)+1), DrainSoundLevel, drainswitch
- End Sub
- '///////////////////////////// TROUGH BALL RELEASE SOLENOID SOUNDS ////////////////////////////
- Sub RandomSoundBallRelease(drainswitch)
- PlaySoundAtLevelStatic SoundFX("BallRelease" & Int(Rnd*7)+1,DOFContactors), BallReleaseSoundLevel, drainswitch
- End Sub
- '///////////////////////////// SLINGSHOT SOLENOID SOUNDS ////////////////////////////
- Sub RandomSoundSlingshotLeft(sling)
- PlaySoundAtLevelStatic SoundFX("Sling_L" & Int(Rnd*10)+1,DOFContactors), SlingshotSoundLevel, Sling
- End Sub
- Sub RandomSoundSlingshotRight(sling)
- PlaySoundAtLevelStatic SoundFX("Sling_R" & Int(Rnd*8)+1,DOFContactors), SlingshotSoundLevel, Sling
- End Sub
- '///////////////////////////// BUMPER SOLENOID SOUNDS ////////////////////////////
- Sub RandomSoundBumperTop(Bump)
- PlaySoundAtLevelStatic SoundFX("Bumpers_Top_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
- End Sub
- Sub RandomSoundBumperMiddle(Bump)
- PlaySoundAtLevelStatic SoundFX("Bumpers_Middle_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
- End Sub
- Sub RandomSoundBumperBottom(Bump)
- PlaySoundAtLevelStatic SoundFX("Bumpers_Bottom_" & Int(Rnd*5)+1,DOFContactors), Vol(ActiveBall) * BumperSoundFactor, Bump
- End Sub
- '///////////////////////////// FLIPPER BATS SOUND SUBROUTINES ////////////////////////////
- '///////////////////////////// FLIPPER BATS SOLENOID ATTACK SOUND ////////////////////////////
- Sub SoundFlipperUpAttackLeft(flipper)
- FlipperUpAttackLeftSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
- PlaySoundAtLevelStatic ("Flipper_Attack-L01"), FlipperUpAttackLeftSoundLevel, flipper
- End Sub
- Sub SoundFlipperUpAttackRight(flipper)
- FlipperUpAttackRightSoundLevel = RndNum(FlipperUpAttackMinimumSoundLevel, FlipperUpAttackMaximumSoundLevel)
- PlaySoundAtLevelStatic ("Flipper_Attack-R01"), FlipperUpAttackLeftSoundLevel, flipper
- End Sub
- '///////////////////////////// FLIPPER BATS SOLENOID CORE SOUND ////////////////////////////
- Sub RandomSoundFlipperUpLeft(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_L0" & Int(Rnd*11)+1,DOFFlippers), FlipperLeftHitParm, Flipper
- End Sub
- Sub RandomSoundFlipperUpRight(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_R0" & Int(Rnd*11)+1,DOFFlippers), FlipperRightHitParm, Flipper
- End Sub
- Sub RandomSoundReflipUpLeft(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_L0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
- End Sub
- Sub RandomSoundReflipUpRight(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_ReFlip_R0" & Int(Rnd*3)+1,DOFFlippers), (RndNum(0.8, 1))*FlipperUpSoundLevel, Flipper
- End Sub
- Sub RandomSoundFlipperDownLeft(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_Left_Down_" & Int(Rnd*7)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
- End Sub
- Sub RandomSoundFlipperDownRight(flipper)
- PlaySoundAtLevelStatic SoundFX("Flipper_Right_Down_" & Int(Rnd*8)+1,DOFFlippers), FlipperDownSoundLevel, Flipper
- End Sub
- '///////////////////////////// FLIPPER BATS BALL COLLIDE SOUND ////////////////////////////
- Sub LeftFlipper_Collide(parm)
- FlipperLeftHitParm = parm/10
- If FlipperLeftHitParm > 1 Then
- FlipperLeftHitParm = 1
- End If
- FlipperLeftHitParm = FlipperUpSoundLevel * FlipperLeftHitParm
- CheckLiveCatch Activeball, LeftFlipper, LFCount, parm
- CheckFlipperSlack Activeball, LeftFlipper, LFLogo, parm
- RandomSoundRubberFlipper(parm)
- End Sub
- Sub RightFlipper_Collide(parm)
- FlipperRightHitParm = parm/10
- If FlipperRightHitParm > 1 Then
- FlipperRightHitParm = 1
- End If
- FlipperRightHitParm = FlipperUpSoundLevel * FlipperRightHitParm
- CheckLiveCatch Activeball, RightFlipper, RFCount, parm
- CheckFlipperSlack Activeball, RightFlipper, RFLogo, parm
- RandomSoundRubberFlipper(parm)
- End Sub
- Sub RandomSoundRubberFlipper(parm)
- PlaySoundAtLevelActiveBall ("Flipper_Rubber_" & Int(Rnd*7)+1), parm * RubberFlipperSoundFactor
- End Sub
- '///////////////////////////// ROLLOVER SOUNDS ////////////////////////////
- Sub RandomSoundRollover()
- PlaySoundAtLevelActiveBall ("Rollover_" & Int(Rnd*4)+1), RolloverSoundLevel
- End Sub
- Sub Rollovers_Hit(idx)
- RandomSoundRollover
- End Sub
- '///////////////////////////// VARIOUS PLAYFIELD SOUND SUBROUTINES ////////////////////////////
- '///////////////////////////// RUBBERS AND POSTS ////////////////////////////
- '///////////////////////////// RUBBERS - EVENTS ////////////////////////////
- Sub Rubbers_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 5 then
- RandomSoundRubberStrong 1
- End if
- If finalspeed <= 5 then
- RandomSoundRubberWeak()
- End If
- End Sub
- '///////////////////////////// RUBBERS AND POSTS - STRONG IMPACTS ////////////////////////////
- Sub RandomSoundRubberStrong(voladj)
- Select Case Int(Rnd*10)+1
- Case 1 : PlaySoundAtLevelActiveBall ("Rubber_Strong_1"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 2 : PlaySoundAtLevelActiveBall ("Rubber_Strong_2"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 3 : PlaySoundAtLevelActiveBall ("Rubber_Strong_3"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 4 : PlaySoundAtLevelActiveBall ("Rubber_Strong_4"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 5 : PlaySoundAtLevelActiveBall ("Rubber_Strong_5"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 6 : PlaySoundAtLevelActiveBall ("Rubber_Strong_6"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 7 : PlaySoundAtLevelActiveBall ("Rubber_Strong_7"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 8 : PlaySoundAtLevelActiveBall ("Rubber_Strong_8"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 9 : PlaySoundAtLevelActiveBall ("Rubber_Strong_9"), Vol(ActiveBall) * RubberStrongSoundFactor*voladj
- Case 10 : PlaySoundAtLevelActiveBall ("Rubber_1_Hard"), Vol(ActiveBall) * RubberStrongSoundFactor * 0.6*voladj
- End Select
- End Sub
- '///////////////////////////// RUBBERS AND POSTS - WEAK IMPACTS ////////////////////////////
- Sub RandomSoundRubberWeak()
- PlaySoundAtLevelActiveBall ("Rubber_" & Int(Rnd*8)+1), Vol(ActiveBall) * RubberWeakSoundFactor
- End Sub
- '///////////////////////////// WALL IMPACTS ////////////////////////////
- Sub Walls_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 5 then
- RandomSoundRubberStrong 1
- End if
- If finalspeed <= 5 then
- RandomSoundRubberWeak()
- End If
- End Sub
- Sub RandomSoundWall()
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 16 then
- Select Case Int(Rnd*5)+1
- Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_1"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_2"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_5"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_7"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 5 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_9"), Vol(ActiveBall) * WallImpactSoundFactor
- End Select
- End if
- If finalspeed >= 6 AND finalspeed <= 16 then
- Select Case Int(Rnd*4)+1
- Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_3"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 4 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
- End Select
- End If
- If finalspeed < 6 Then
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_4"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 2 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_6"), Vol(ActiveBall) * WallImpactSoundFactor
- Case 3 : PlaySoundAtLevelExistingActiveBall ("Wall_Hit_8"), Vol(ActiveBall) * WallImpactSoundFactor
- End Select
- End if
- End Sub
- '///////////////////////////// METAL TOUCH SOUNDS ////////////////////////////
- Sub RandomSoundMetal()
- PlaySoundAtLevelActiveBall ("Metal_Touch_" & Int(Rnd*13)+1), Vol(ActiveBall) * MetalImpactSoundFactor
- End Sub
- '///////////////////////////// METAL - EVENTS ////////////////////////////
- Sub Metals_Hit (idx)
- RandomSoundMetal
- End Sub
- Sub ShooterDiverter_collide(idx)
- RandomSoundMetal
- End Sub
- '///////////////////////////// BOTTOM ARCH BALL GUIDE ////////////////////////////
- '///////////////////////////// BOTTOM ARCH BALL GUIDE - SOFT BOUNCES ////////////////////////////
- Sub RandomSoundBottomArchBallGuide()
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 16 then
- PlaySoundAtLevelActiveBall ("Apron_Bounce_"& Int(Rnd*2)+1), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
- End if
- If finalspeed >= 6 AND finalspeed <= 16 then
- Select Case Int(Rnd*2)+1
- Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
- Case 2 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
- End Select
- End If
- If finalspeed < 6 Then
- Select Case Int(Rnd*2)+1
- Case 1 : PlaySoundAtLevelActiveBall ("Apron_Bounce_Soft_1"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
- Case 2 : PlaySoundAtLevelActiveBall ("Apron_Medium_3"), Vol(ActiveBall) * BottomArchBallGuideSoundFactor
- End Select
- End if
- End Sub
- '///////////////////////////// BOTTOM ARCH BALL GUIDE - HARD HITS ////////////////////////////
- Sub RandomSoundBottomArchBallGuideHardHit()
- PlaySoundAtLevelActiveBall ("Apron_Hard_Hit_" & Int(Rnd*3)+1), BottomArchBallGuideSoundFactor * 0.25
- End Sub
- Sub Apron_Hit (idx)
- If Abs(cor.ballvelx(activeball.id) < 4) and cor.ballvely(activeball.id) > 7 then
- RandomSoundBottomArchBallGuideHardHit()
- Else
- RandomSoundBottomArchBallGuide
- End If
- End Sub
- '///////////////////////////// FLIPPER BALL GUIDE ////////////////////////////
- Sub RandomSoundFlipperBallGuide()
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 16 then
- Select Case Int(Rnd*2)+1
- Case 1 : PlaySoundAtLevelActiveBall ("Apron_Hard_1"), Vol(ActiveBall) * FlipperBallGuideSoundFactor
- Case 2 : PlaySoundAtLevelActiveBall ("Apron_Hard_2"), Vol(ActiveBall) * 0.8 * FlipperBallGuideSoundFactor
- End Select
- End if
- If finalspeed >= 6 AND finalspeed <= 16 then
- PlaySoundAtLevelActiveBall ("Apron_Medium_" & Int(Rnd*3)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
- End If
- If finalspeed < 6 Then
- PlaySoundAtLevelActiveBall ("Apron_Soft_" & Int(Rnd*7)+1), Vol(ActiveBall) * FlipperBallGuideSoundFactor
- End If
- End Sub
- '///////////////////////////// TARGET HIT SOUNDS ////////////////////////////
- Sub RandomSoundTargetHitStrong()
- PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+5,DOFTargets), Vol(ActiveBall) * 0.45 * TargetSoundFactor
- End Sub
- Sub RandomSoundTargetHitWeak()
- PlaySoundAtLevelActiveBall SoundFX("Target_Hit_" & Int(Rnd*4)+1,DOFTargets), Vol(ActiveBall) * TargetSoundFactor
- End Sub
- Sub PlayTargetSound()
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 10 then
- RandomSoundTargetHitStrong()
- RandomSoundBallBouncePlayfieldSoft Activeball
- Else
- RandomSoundTargetHitWeak()
- End If
- End Sub
- Sub Targets_Hit (idx)
- PlayTargetSound
- End Sub
- '///////////////////////////// BALL BOUNCE SOUNDS ////////////////////////////
- Sub RandomSoundBallBouncePlayfieldSoft(aBall)
- Select Case Int(Rnd*9)+1
- Case 1 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_1"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
- Case 2 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
- Case 3 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_3"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.8, aBall
- Case 4 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_4"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.5, aBall
- Case 5 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Soft_5"), volz(aBall) * BallBouncePlayfieldSoftFactor, aBall
- Case 6 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_1"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
- Case 7 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_2"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
- Case 8 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_5"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.2, aBall
- Case 9 : PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_7"), volz(aBall) * BallBouncePlayfieldSoftFactor * 0.3, aBall
- End Select
- End Sub
- Sub RandomSoundBallBouncePlayfieldHard(aBall)
- PlaySoundAtLevelStatic ("Ball_Bounce_Playfield_Hard_" & Int(Rnd*7)+1), volz(aBall) * BallBouncePlayfieldHardFactor, aBall
- End Sub
- '///////////////////////////// DELAYED DROP - TO PLAYFIELD - SOUND ////////////////////////////
- Sub RandomSoundDelayedBallDropOnPlayfield(aBall)
- Select Case Int(Rnd*5)+1
- Case 1 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_1_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
- Case 2 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_2_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
- Case 3 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_3_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
- Case 4 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_4_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
- Case 5 : PlaySoundAtLevelStatic ("Ball_Drop_Playfield_5_Delayed"), DelayedBallDropOnPlayfieldSoundLevel, aBall
- End Select
- End Sub
- '///////////////////////////// BALL GATES AND BRACKET GATES SOUNDS ////////////////////////////
- Sub SoundPlayfieldGate()
- PlaySoundAtLevelStatic ("Gate_FastTrigger_" & Int(Rnd*2)+1), GateSoundLevel, Activeball
- End Sub
- Sub SoundHeavyGate()
- PlaySoundAtLevelStatic ("Gate_2"), GateSoundLevel, Activeball
- End Sub
- Sub Gates_hit(idx)
- SoundHeavyGate
- End Sub
- Sub GatesWire_hit(idx)
- SoundPlayfieldGate
- End Sub
- '///////////////////////////// LEFT LANE ENTRANCE - SOUNDS ////////////////////////////
- Sub RandomSoundLeftArch()
- PlaySoundAtLevelActiveBall ("Arch_L" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
- End Sub
- Sub RandomSoundRightArch()
- PlaySoundAtLevelActiveBall ("Arch_R" & Int(Rnd*4)+1), Vol(ActiveBall) * ArchSoundFactor
- End Sub
- Sub Arch1_hit()
- If Activeball.velx > 1 Then SoundPlayfieldGate
- StopSound "Arch_L1"
- StopSound "Arch_L2"
- StopSound "Arch_L3"
- StopSound "Arch_L4"
- End Sub
- Sub Arch1_unhit()
- If activeball.velx < -8 Then
- RandomSoundRightArch
- End If
- End Sub
- Sub Arch2_hit()
- If Activeball.velx < 1 Then SoundPlayfieldGate
- StopSound "Arch_R1"
- StopSound "Arch_R2"
- StopSound "Arch_R3"
- StopSound "Arch_R4"
- End Sub
- Sub Arch2_unhit()
- If activeball.velx > 10 Then
- RandomSoundLeftArch
- End If
- End Sub
- '///////////////////////////// SAUCERS (KICKER HOLES) ////////////////////////////
- Sub SoundSaucerLock()
- PlaySoundAtLevelStatic ("Saucer_Enter_" & Int(Rnd*2)+1), SaucerLockSoundLevel, Activeball
- End Sub
- Sub SoundSaucerKick(scenario, saucer)
- Select Case scenario
- Case 0: PlaySoundAtLevelStatic SoundFX("Saucer_Empty", DOFContactors), SaucerKickSoundLevel, saucer
- Case 1: PlaySoundAtLevelStatic SoundFX("Saucer_Kick", DOFContactors), SaucerKickSoundLevel, saucer
- End Select
- End Sub
- '///////////////////////////// BALL COLLISION SOUND ////////////////////////////
- Sub OnBallBallCollision(ball1, ball2, velocity)
- Dim snd
- Select Case Int(Rnd*7)+1
- Case 1 : snd = "Ball_Collide_1"
- Case 2 : snd = "Ball_Collide_2"
- Case 3 : snd = "Ball_Collide_3"
- Case 4 : snd = "Ball_Collide_4"
- Case 5 : snd = "Ball_Collide_5"
- Case 6 : snd = "Ball_Collide_6"
- Case 7 : snd = "Ball_Collide_7"
- End Select
- PlaySound (snd), 0, Csng(velocity) ^2 / 200 * BallWithBallCollisionSoundFactor * VolumeDial, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
- End Sub
- '/////////////////////////////////////////////////////////////////
- ' End Mechanical Sounds
- '/////////////////////////////////////////////////////////////////
- '**************************************************************************************************************
- ' Random Ramp Bumps - Best used to compliment the Raised Ramp RollingBall Script
- ' No switches are required. Make ramps have "Hit Event" and create a "Collection" for each of the following.
- ' Adjust Vol (eg .5) & Pitch: RandomBump3 .5, Pitch(ActiveBall)+5
- ' Ramp physics also effect bump sounds. Friction will change ball speed, so sounds will react different.
- ' Hit Threshold will will effect how much force is required to create a bump. Low hit threshold + more bumps.
- ' Other adjustments avialable in the script as noted.
- '**************************************************************************************************************
- Dim NextOrbitHit:NextOrbitHit = 0
- Sub WireRampBumps_Hit(idx)
- if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
- RandomBump3 .5, Pitch(ActiveBall)+5
- ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
- ' Lowering these numbers allow more closely-spaced clunks.
- NextOrbitHit = Timer + .2 + (Rnd * .2)
- end if
- End Sub
- Sub PlasticRampBumps_Hit(idx)
- if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
- RandomBump 2, Pitch(ActiveBall)
- ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
- ' Lowering these numbers allow more closely-spaced clunks.
- NextOrbitHit = Timer + .1 + (Rnd * .2)
- end if
- End Sub
- Sub MetalGuideBumps_Hit(idx)
- if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
- RandomBump2 2, Pitch(ActiveBall)
- ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
- ' Lowering these numbers allow more closely-spaced clunks.
- NextOrbitHit = Timer + .2 + (Rnd * .2)
- end if
- End Sub
- Sub MetalWallBumps_Hit(idx)
- if BallVel(ActiveBall) > .3 and Timer > NextOrbitHit then
- RandomBump 2, 20000 'Increased pitch to simulate metal wall
- ' Schedule the next possible sound time. This prevents it from rapid-firing noises too much.
- ' Lowering these numbers allow more closely-spaced clunks.
- NextOrbitHit = Timer + .2 + (Rnd * .2)
- end if
- End Sub
- '' Requires rampbump1 to 7 in Sound Manager
- Sub RandomBump(voladj, freq)
- dim BumpSnd:BumpSnd= "rampbump" & CStr(Int(Rnd*7)+1)
- PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
- End Sub
- ' Requires metalguidebump1 to 2 in Sound Manager
- Sub RandomBump2(voladj, freq)
- dim BumpSnd:BumpSnd= "metalguidebump" & CStr(Int(Rnd*2)+1)
- PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
- End Sub
- ' Requires WireRampBump1 to 5 in Sound Manager
- Sub RandomBump3(voladj, freq)
- dim BumpSnd:BumpSnd= "WireRampBump" & CStr(Int(Rnd*5)+1)
- PlaySound BumpSnd, 0, Vol(ActiveBall)*voladj, AudioPan(ActiveBall), 0, freq, 0, 1, AudioFade(ActiveBall)
- End Sub
- ' 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.
- Sub BumpSTOP1_Hit ()
- dim i:for i=1 to 4:StopSound "WireRampBump" & i:next
- NextOrbitHit = Timer + 1
- End Sub
- Sub BumpSTOP2_Hit ()
- dim i:for i=1 to 4:StopSound "WireRampBump" & i:next
- NextOrbitHit = Timer + 1
- End Sub
- '******************************************************
- ' BALL ROLLING AND DROP SOUNDS
- '******************************************************
- Const tnob = 7 ' total number of balls
- ReDim rolling(tnob)
- InitRolling
- Dim DropCount
- ReDim DropCount(tnob)
- Sub InitRolling
- Dim i
- For i = 0 to tnob
- rolling(i) = False
- Next
- End Sub
- Sub RollingSound()
- Dim BOT, b
- BOT = GetBalls
- ' stop the sound of deleted balls
- For b = UBound(BOT) + 1 to tnob
- rolling(b) = False
- StopSound("BallRoll_" & b)
- Next
- ' exit the sub if no balls on the table
- If UBound(BOT) = -1 Then Exit Sub
- ' play the rolling sound for each ball
- For b = 0 to UBound(BOT)
- If BallVel(BOT(b)) > 1 Then
- rolling(b) = True
- if BOT(b).z < 10 Then 'Ball on playfield
- PlaySound ("BallRoll_" & b), -1, VolPlayfieldRoll(BOT(b)) * 1.1 * VolumeDial, AudioPan(BOT(b)), 0, PitchPlayfieldRoll(BOT(b)), 1, 0, AudioFade(BOT(b))
- Else 'Ball on Raised Ramp
- PlaySound ("BallRoll_" & b), -1, VolPlayfieldRoll(BOT(b)) * 10 * VolumeDial, AudioPan(BOT(b)), 0, PitchPlayfieldRoll(BOT(b))+50000, 1, 0, AudioFade(BOT(b))
- End If
- Else
- If rolling(b) = True Then
- StopSound("BallRoll_" & b)
- rolling(b) = False
- End If
- End If
- '***Ball Drop Sounds***
- If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
- If DropCount(b) >= 5 Then
- DropCount(b) = 0
- If BOT(b).velz > -7 Then
- RandomSoundBallBouncePlayfieldSoft BOT(b)
- Else
- RandomSoundBallBouncePlayfieldHard BOT(b)
- End If
- End If
- End If
- If DropCount(b) < 5 Then
- DropCount(b) = DropCount(b) + 1
- End If
- Next
- End Sub
- ' ===============================================================================================
- ' LED's display
- ' ===============================================================================================
- Dim Digits(2), digitState
- Digits(0) = Array(led0,led1,led2,led3,led4,led5,led6)
- Digits(1) = Array(led7,led8,led9,led10,led11,led12,led13)
- Sub UpdateLED()
- Dim chgLED, ii, iii, num, chg, stat, digit
- chgLED = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
- If Not IsEmpty(chgLED) Then
- For ii = 0 To UBound(chgLED)
- num = chgLED(ii, 0)
- chg = chgLED(ii, 1)
- stat = chgLED(ii, 2)
- iii = 0
- For Each digit In Digits(num)
- If (chg And 1) Then digit.State = (stat And 1)
- chg = chg \ 2
- stat = stat \ 2
- Next
- Next
- End If
- End Sub
- Sub ShotClock_Timer
- If RedClock=1 then ShotClock.Enabled=False
- If RedClock=1 then RedShotClock.Enabled=True
- If LED0.State=1 then SCleft0.visible =true else SCleft0.visible =false
- If LED1.State=1 then SCleft1.visible =true else SCleft1.visible =false
- If LED2.State=1 then SCleft2.visible =true else SCleft2.visible =false
- If LED3.State=1 then SCleft3.visible =true else SCleft3.visible =false
- If LED4.State=1 then SCleft4.visible =true else SCleft4.visible =false
- If LED5.State=1 then SCleft5.visible =true else SCleft5.visible =false
- If LED6.State=1 then SCleft6.visible =true else SCleft6.visible =false
- If LED7.State=1 then SCright0.visible =true else SCright0.visible =false
- If LED8.State=1 then SCRight1.visible =true else SCRight1.visible =false
- If LED9.State=1 then SCRight2.visible =true else SCRight2.visible =false
- If LED10.State=1 then SCRight3.visible =true else SCRight3.visible =false
- If LED11.State=1 then SCRight4.visible =true else SCRight4.visible =false
- If LED12.State=1 then SCRight5.visible =true else SCRight5.visible =false
- If LED13.State=1 then SCRight6.visible =true else SCRight6.visible =false
- If l87.State=1 and VRRoom = 0 then ShootbuttonOn.visible = True else ShootbuttonOn.visible = False
- If l87.State=0 and VRRoom = 0 then ShootbuttonOff.visible = True else ShootbuttonOff.visible = False
- If l87.State=1 and VRRoom = 0 then Shoot_Flash.visible = True else Shoot_Flash.visible =false
- If l87.State=1 and VRRoom > 0 then VR_Shoot_Flash.visible = True else VR_Shoot_Flash.visible =false
- If l88.State=1 and VRRoom = 0 then StartbuttonOn.visible = True else StartbuttonOn.visible = False
- If l88.State=0 and VRRoom = 0 then StartbuttonOff.visible = True else StartbuttonOff.visible = False
- If l88.State=1 and VRRoom > 0 then VR_Start.visible =true else VR_Start.visible =false
- End Sub
- Sub RedShotClock_Timer
- If LED0.State=1 then SCleft0r.visible =true else SCleft0r.visible =false
- If LED1.State=1 then SCleft1r.visible =true else SCleft1r.visible =false
- If LED2.State=1 then SCleft2r.visible =true else SCleft2r.visible =false
- If LED3.State=1 then SCleft3r.visible =true else SCleft3r.visible =false
- If LED4.State=1 then SCleft4r.visible =true else SCleft4r.visible =false
- If LED5.State=1 then SCleft5r.visible =true else SCleft5r.visible =false
- If LED6.State=1 then SCleft6r.visible =true else SCleft6r.visible =false
- If LED7.State=1 then SCright0r.visible =true else SCright0r.visible =false
- If LED8.State=1 then SCRight1r.visible =true else SCRight1r.visible =false
- If LED9.State=1 then SCRight2r.visible =true else SCRight2r.visible =false
- If LED10.State=1 then SCRight3r.visible =true else SCRight3r.visible =false
- If LED11.State=1 then SCRight4r.visible =true else SCRight4r.visible =false
- If LED12.State=1 then SCRight5r.visible =true else SCRight5r.visible =false
- If LED13.State=1 then SCRight6r.visible =true else SCRight6r.visible =false
- If l87.State=1 and VRRoom = 0 then ShootbuttonOn.visible = True else ShootbuttonOn.visible = False
- If l87.State=0 and VRRoom = 0 then ShootbuttonOff.visible = True else ShootbuttonOff.visible = False
- If l87.State=1 and VRRoom = 0 then Shoot_Flash.visible = True else Shoot_Flash.visible =false
- If l87.State=1 and VRRoom > 0 then VR_Shoot_Flash.visible = True else VR_Shoot_Flash.visible =false
- If l88.State=1 and VRRoom = 0 then StartbuttonOn.visible = True else StartbuttonOn.visible = False
- If l88.State=0 and VRRoom = 0 then StartbuttonOff.visible = True else StartbuttonOff.visible = False
- If l88.State=1 and VRRoom > 0 then VR_Start.visible =true else VR_Start.visible =false
- End Sub
- Sub RubberSleeves_Hit()
- dSleeves()
- End Sub
- sub RubberBands_Hit(idx)
- dPosts()
- End Sub
- '******************************************************
- ' TRACK ALL BALL VELOCITIES
- ' FOR RUBBER DAMPENER AND DROP TARGETS
- '******************************************************
- dim cor : set cor = New CoRTracker
- Class CoRTracker
- public ballvel, ballvelx, ballvely
- Private Sub Class_Initialize : redim ballvel(0) : redim ballvelx(0): redim ballvely(0) : End Sub
- Public Sub Update() 'tracks in-ball-velocity
- dim str, b, AllBalls, highestID : allBalls = getballs
- for each b in allballs
- if b.id >= HighestID then highestID = b.id
- Next
- if uBound(ballvel) < highestID then redim ballvel(highestID) 'set bounds
- if uBound(ballvelx) < highestID then redim ballvelx(highestID) 'set bounds
- if uBound(ballvely) < highestID then redim ballvely(highestID) 'set bounds
- for each b in allballs
- ballvel(b.id) = BallSpeed(b)
- ballvelx(b.id) = b.velx
- ballvely(b.id) = b.vely
- Next
- End Sub
- End Class
- Sub RDampen()
- Cor.Update
- End Sub
- '******************************************************
- '****************************************************************************
- 'nFozzy PHYSICS DAMPENERS
- 'These are data mined bounce curves,
- 'dialed in with the in-game elasticity as much as possible to prevent angle / spin issues.
- 'Requires tracking ballspeed to calculate COR
- Sub dPosts()
- RubbersD.dampen Activeball
- End Sub
- Sub dSleeves()
- SleevesD.Dampen Activeball
- End Sub
- dim RubbersD : Set RubbersD = new Dampener 'frubber
- RubbersD.name = "Rubbers"
- RubbersD.debugOn = False 'shows info in textbox "TBPout"
- RubbersD.Print = False 'debug, reports in debugger (in vel, out cor)
- 'cor bounce curve (linear)
- 'for best results, try to match in-game velocity as closely as possible to the desired curve
- 'RubbersD.addpoint 0, 0, 0.935 'point# (keep sequential), ballspeed, CoR (elasticity)
- RubbersD.addpoint 0, 0, 0.935 '0.96 'point# (keep sequential), ballspeed, CoR (elasticity)
- RubbersD.addpoint 1, 3.77, 0.935 '0.96
- RubbersD.addpoint 2, 5.76, 0.942 '0.967 'dont take this as gospel. if you can data mine rubber elasticitiy, please help!
- RubbersD.addpoint 3, 15.84, 0.874
- RubbersD.addpoint 4, 56, 0.64 'there's clamping so interpolate up to 56 at least
- dim SleevesD : Set SleevesD = new Dampener 'this is just rubber but cut down to 85%...
- SleevesD.name = "Sleeves"
- SleevesD.debugOn = False 'shows info in textbox "TBPout"
- SleevesD.Print = False 'debug, reports in debugger (in vel, out cor)
- SleevesD.CopyCoef RubbersD, 0.85
- Class Dampener
- Public Print, debugOn 'tbpOut.text
- public name, Threshold 'Minimum threshold. Useful for Flippers, which don't have a hit threshold.
- Public ModIn, ModOut
- Private Sub Class_Initialize : redim ModIn(0) : redim Modout(0): End Sub
- Public Sub AddPoint(aIdx, aX, aY)
- ShuffleArrays ModIn, ModOut, 1 : ModIn(aIDX) = aX : ModOut(aIDX) = aY : ShuffleArrays ModIn, ModOut, 0
- if gametime > 100 then Report
- End Sub
- public sub Dampen(aBall)
- if threshold then if BallSpeed(aBall) < threshold then exit sub end if end if
- dim RealCOR, DesiredCOR, str, coef
- DesiredCor = LinearEnvelope(cor.ballvel(aBall.id), ModIn, ModOut )
- RealCOR = BallSpeed(aBall) / cor.ballvel(aBall.id)
- coef = desiredcor / realcor
- if debugOn then str = name & " in vel:" & round(cor.ballvel(aBall.id),2 ) & vbnewline & "desired cor: " & round(desiredcor,4) & vbnewline & _
- "actual cor: " & round(realCOR,4) & vbnewline & "ballspeed coef: " & round(coef, 3) & vbnewline
- if Print then debug.print Round(cor.ballvel(aBall.id),2) & ", " & round(desiredcor,3)
- aBall.velx = aBall.velx * coef : aBall.vely = aBall.vely * coef
- 'playsound "fx_knocker"
- if debugOn then TBPout.text = str
- End Sub
- Public Sub CopyCoef(aObj, aCoef) 'alternative addpoints, copy with coef
- dim x : for x = 0 to uBound(aObj.ModIn)
- addpoint x, aObj.ModIn(x), aObj.ModOut(x)*aCoef
- Next
- End Sub
- Public Sub Report() 'debug, reports all coords in tbPL.text
- if not debugOn then exit sub
- dim a1, a2 : a1 = ModIn : a2 = ModOut
- dim str, x : for x = 0 to uBound(a1) : str = str & x & ": " & round(a1(x),4) & ", " & round(a2(x),4) & vbnewline : next
- TBPout.text = str
- End Sub
- End Class
- Function LinearEnvelope(xInput, xKeyFrame, yLvl)
- dim y 'Y output
- dim L 'Line
- dim ii : for ii = 1 to uBound(xKeyFrame) 'find active line
- if xInput <= xKeyFrame(ii) then L = ii : exit for : end if
- Next
- if xInput > xKeyFrame(uBound(xKeyFrame) ) then L = uBound(xKeyFrame) 'catch line overrun
- Y = pSlope(xInput, xKeyFrame(L-1), yLvl(L-1), xKeyFrame(L), yLvl(L) )
- 'Clamp if on the boundry lines
- 'if L=1 and Y < yLvl(LBound(yLvl) ) then Y = yLvl(lBound(yLvl) )
- 'if L=uBound(xKeyFrame) and Y > yLvl(uBound(yLvl) ) then Y = yLvl(uBound(yLvl) )
- 'clamp 2.0
- if xInput <= xKeyFrame(lBound(xKeyFrame) ) then Y = yLvl(lBound(xKeyFrame) ) 'Clamp lower
- if xInput >= xKeyFrame(uBound(xKeyFrame) ) then Y = yLvl(uBound(xKeyFrame) ) 'Clamp upper
- LinearEnvelope = Y
- End Function
- Dim BallShadow
- BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5, BallShadow6, BallShadow7, BallShadow8)
- Sub BallShadowUpdate()
- Dim BOT, b
- BOT = GetBalls
- ' hide shadow of deleted balls
- If UBound(BOT)<(tnob-1) Then
- For b = (UBound(BOT) + 1) to (tnob-1)
- BallShadow(b).visible = 0
- Next
- End If
- ' exit the Sub if no balls on the table
- If UBound(BOT) = -1 Then Exit Sub
- ' render the shadow for each ball
- For b = 0 to UBound(BOT)
- If BOT(b).X < Table1.Width/2 Then
- BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/16)) + 5
- Else
- BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/16)) - 5
- End If
- ballShadow(b).Y = BOT(b).Y + 10
- If BOT(b).Z > 10 Then
- BallShadow(b).visible = 1
- Else
- BallShadow(b).visible = 0
- End If
- Next
- End Sub
- '////////////////////// ***OPTIONS*** //////////////////////////////
- Dim Cabflash
- If CabinetMode = 1 Then
- SideWalls.visible = 1
- Pincab_Rails.visible = 0
- PinCab_Blades.visible = 0
- for each Cabflash in CabFlashers:Cabflash.height = 450:Next
- for each Cabflash in CabFlashers:Cabflash.Y = 1350:Next
- Else
- SideWalls.visible = 0
- PinCab_Rails.visible = 1
- PinCab_Blades.visible = 1
- for each Cabflash in CabFlashers:Cabflash.height = 250:Next
- for each Cabflash in CabFlashers:Cabflash.Y = 885.563:Next
- End If
- DIM VRRoom, VRThings
- If VRRoom > 0 Then
- ScoreText.visible = 0
- Ramp_central.image = "VR_centre_ramp"
- ramps_lateral.image = "VR_lateral_ramps"
- Ramp_central.blenddisablelighting = 0.5
- ramps_lateral.blenddisablelighting = 0.5
- PinCab_Backglass.blenddisablelighting = 4
- If VRRoom = 1 Then
- for each VRThings in VRCab:VRThings.visible = 1:Next
- for each VRThings in VRStuff:VRThings.visible = 1:Next
- for each VRThings in Desktop:VRThings.visible = 0:Next
- End If
- If VRRoom = 2 Then
- for each VRThings in VRCab:VRThings.visible = 0:Next
- for each VRThings in VRStuff:VRThings.visible = 0:Next
- for each VRThings in Desktop:VRThings.visible = 0:Next
- PinCab_Backglass.visible = 1
- PinCab_Backbox.visible = 1
- PinCab_Backbox.image = "Pincab_Backbox_NBA_Min"
- End If
- Else
- for each VRThings in VRCab:VRThings.visible = 0:Next
- for each VRThings in VRStuff:VRThings.visible = 0:Next
- for each VRThings in Desktop:VRThings.visible = 1:Next
- If DesktopMode then ScoreText.visible = 1 else ScoreText.visible = 0 End If
- Ramp_central.image = "ramp_centre"
- ramps_lateral.image = "ramp_lateral"
- End if
Advertisement
Add Comment
Please, Sign In to add comment