Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Randomize
- 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
- LoadVPM "01500000","DE.VBS",3.10
- '*************************************
- '** Game Specific Code Starts Here **
- '********************************************
- Const cGameName="ckpt_a17",UseSolenoids=2,UseLamps=1,UseSync=1,UseGI=0,SCoin="coin4"
- 'Const SSolenoidOn="solon",SSolenoidOff="soloff",SFlipperOn="FlipperUp",SFlipperOff="FlipperDown",SCoin="coin4"
- Dim DesktopMode: DesktopMode = Table1.ShowDT
- If DesktopMode = True Then 'Show Desktop components
- Ramp16.visible=1
- Ramp15.visible=1
- Primitive13.visible=1
- Else
- Ramp16.visible=0
- Ramp15.visible=0
- Primitive13.visible=0
- End if
- '*************************************************************
- 'Solenoid Call backs
- '**********************************************************************************************************
- SolCallback(1)="bsTrough.SolIn"
- SolCallback(2)="bsTrough.SolOut"
- SolCallback(3)="bsPit.SolOut"
- SolCallback(4)="dtC.SolDropUp"
- SolCallback(5)="dtL.SolDropUp"
- SolCallback(6)="dtR.SolDropUp"
- SolCallback(7)="bsVuk.SolOut"
- SolCallback(8)="AutoPlunger"
- SolCallback(9)="dtR.SolDropDown"
- 'SolCallback(10)=
- SolCallback(11)="PFGI"
- SolCallback(12)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
- SolCallback(13)="SetLamp 113,"
- SolCallback(14)="SetLamp 114,"
- SolCallback(15)="SetLamp 115,"
- SolCallback(16)="SetLamp 116,"
- SolCallback(17)="vpmSolSound SoundFX(""fx_bumper1"",DOFContactors),"
- SolCallback(18)="vpmSolSound SoundFX(""fx_bumper2"",DOFContactors),"
- SolCallback(19)="vpmSolSound SoundFX(""fx_bumper3"",DOFContactors),"
- 'SolCallback(20)="vpmSolSound ""right_slingshot"","
- 'SolCallback(21)="vpmSolSound ""left_slingshot"","
- 'SolCallback(22)= 'Not Used
- 'SolCallback(23)= 'Not Used
- SolCallback(24)="SetLamp 65,"
- SolCallback(25)="SetLamp 135,"
- SolCallback(26)="SetLamp 136,"
- SolCallback(27)="SetLamp 127,"
- SolCallback(28)="SetLamp 128,"
- SolCallback(29)="SetLamp 129,"
- SolCallback(30)="SetLamp 130,"
- SolCallback(31)="SetLamp 131,"
- SolCallback(32)="SetLamp 132,"
- 'SolCallback(38)=
- SolCallback(sLRFlipper) = "SolRFlipper"
- SolCallback(sLLFlipper) = "SolLFlipper"
- Sub SolLFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("fx_Flipperup",DOFFlippers):LeftFlipper.RotateToEnd
- Else
- PlaySound SoundFX("fx_Flipperdown",DOFFlippers):LeftFlipper.RotateToStart
- End If
- End Sub
- Sub SolRFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("fx_Flipperup",DOFFlippers):RightFlipper.RotateToEnd
- Else
- PlaySound SoundFX("fx_Flipperdown",DOFFlippers):RightFlipper.RotateToStart
- End If
- End Sub
- '**********************************************************************************************************
- 'Solenoid Controlled toys
- '**********************************************************************************************************
- Sub AutoPlunger(Enabled)
- If Enabled Then
- Plunger2.Fire
- playsound SoundFX("Popper",DOFContactors)
- Else
- Plunger2.PullBack
- End If
- End Sub
- 'Playfield GI
- Sub PFGI(Enabled)
- If Enabled Then
- dim xx
- For each xx in GI:xx.State = 0: Next
- PlaySound "fx_relay"
- Else
- For each xx in GI:xx.State = 1: Next
- PlaySound "fx_relay"
- End If
- End Sub
- '**********Sling Shot Animations
- ' Rstep and Lstep are the variables that increment the animation
- '****************
- Dim RStep, Lstep
- Sub RightSlingShot_Slingshot
- vpmTimer.PulseSw 22
- PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
- RSling.Visible = 0
- RSling1.Visible = 1
- sling1.rotx = 20
- RStep = 0
- RightSlingShot.TimerEnabled = 1
- ' gi1.State = 0:Gi2.State = 0
- End Sub
- Sub RightSlingShot_Timer
- Select Case RStep
- Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
- Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
- End Select
- RStep = RStep + 1
- End Sub
- Sub LeftSlingShot_Slingshot
- vpmTimer.PulseSw 21
- PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
- LSling.Visible = 0
- LSling1.Visible = 1
- sling2.rotx = 20
- LStep = 0
- LeftSlingShot.TimerEnabled = 1
- ' gi3.State = 0:Gi4.State = 0
- End Sub
- Sub LeftSlingShot_Timer
- Select Case LStep
- Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
- Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0:
- End Select
- LStep = LStep + 1
- End Sub
- '**********************************************************************************************************
- 'Initiate Table
- '**********************************************************************************************************
- Dim bsTrough,dtC,dtL,dtR,bsVuk,bsPit
- Sub Table1_Init
- On Error Resume Next
- With Controller
- .GameName=cGameName
- If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
- .SplashInfoLine = "Checkpoint, Data East 1991"
- .Games(cGameName).Settings.Value("rol") = 0 'rotate DMD to the left
- .HandleMechanics=0
- .HandleKeyboard=0
- .ShowDMDOnly=1
- .ShowFrame=0
- .ShowTitle=0
- .DIP(0)=&H00
- .Run
- End With
- If Err Then MsgBox Err.Description
- On Error Goto 0
- PinMAMETimer.Interval=PinMAMEInterval
- PinMAMETimer.Enabled=1
- vpmNudge.TiltSwitch=1
- vpmNudge.Sensitivity=2
- vpmNudge.TiltObj=Array(Bumper1a,Bumper2a,Bumper3a,LeftSlingshot,RightSlingshot)
- Set bsTrough=New cvpmBallStack
- bsTrough.InitSw 10,13,12,11,0,0,0,0
- bsTrough.InitKick BallRelease,115,3
- bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
- bsTrough.Balls=3
- Set bsVUK=New cvpmBallStack
- bsVUK.InitSw 0,30,0,0,0,0,0,0
- bsVUK.InitKick Kicker2,188,5
- bsVUK.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
- Set bsPit=New cvpmBallStack
- bsPit.InitSaucer Kicker1,37,180,1
- bsPit.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
- Set dtC=New cvpmDropTarget
- dtC.InitDrop Array(Wall1,Wall2,Wall3),Array(41,42,43)
- dtC.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
- Set dtL=New cvpmDropTarget
- dtL.InitDrop Array(Wall4,Wall5,Wall6,Wall7),Array(33,34,35,36)
- dtL.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
- Set dtR=New cvpmDropTarget
- dtR.InitDrop Wall8,44
- dtR.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
- vpmMapLights AllLights
- Plunger2.PullBack
- End Sub
- '**********************************************************************************************************
- 'Plunger code
- '**********************************************************************************************************
- Sub Table1_KeyDown(ByVal KeyCode)
- If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
- If KeyDownHandler(keycode) Then Exit Sub
- End Sub
- Sub Table1_KeyUp(ByVal KeyCode)
- If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
- If KeyUpHandler(keycode) Then Exit Sub
- End Sub
- '**********************************************************************************************************
- Sub Drain_Hit:bsTrough.AddBall Me : playsound"drain5" : End Sub
- Sub Kicker1_Hit:bsPit.AddBall Me : playsound "popper_ball": End Sub
- '********** Subway *********
- Sub Kicker3_Hit:vpmTimer.PulseSw(24) : playsound "MiniExit3" : bsVUK.AddBall Me : End Sub
- Sub Kicker4_Hit:vpmTimer.PulseSw(24) : playsound "MiniExit3" : bsVUK.AddBall Me : End Sub
- 'Drop Targets
- Sub Wall4_Hit:dtL.Hit 1:End Sub '33
- Sub Wall5_Hit:dtL.Hit 2:End Sub '34
- Sub Wall6_Hit:dtL.Hit 3:End Sub '35
- Sub Wall7_Hit:dtL.Hit 4:End Sub '36
- Sub Wall1_Hit:dtC.Hit 1:End Sub '41
- Sub Wall2_Hit:dtC.Hit 2:End Sub '42
- Sub Wall3_Hit:dtC.Hit 3:End Sub '43
- Sub Wall8_Hit:dtR.Hit 1:End Sub '44
- 'Wire Triggers
- Sub Trigger1_Hit:Controller.Switch(14)=1:End Sub '14
- Sub Trigger1_unHit:Controller.Switch(14)=0:End Sub
- Sub Trigger2_Hit:Controller.Switch(25)=1:End Sub '25
- Sub Trigger2_unHit:Controller.Switch(25)=0:End Sub
- Sub Trigger3_Hit:Controller.Switch(26)=1:End Sub '26
- Sub Trigger3_unHit:Controller.Switch(26)=0:End Sub
- Sub Trigger4_Hit:Controller.Switch(27)=1:End Sub '27
- Sub Trigger4_unHit:Controller.Switch(27)=0:End Sub
- Sub LeftOutlane_Hit:Controller.Switch(17)=1:End Sub '17
- Sub LeftOutlane_unHit:Controller.Switch(17)=0:End Sub
- Sub LeftInlane_Hit:Controller.Switch(18)=1:End Sub '18
- Sub LeftInlane_unHit:Controller.Switch(18)=0:End Sub
- Sub RightOutlane_Hit:Controller.Switch(19)=1:End Sub '19
- Sub RightOutlane_unHit:Controller.Switch(19)=0:End Sub
- Sub RightInlane_Hit:Controller.Switch(20)=1:End Sub '20
- Sub RightInlane_unHit:Controller.Switch(20)=0:End Sub
- 'Sub LeftSlingshot_Slingshot:vpmTimer.PulseSw(21):End Sub '21
- 'Sub RightSlingshot_Slingshot:vpmTimer.PulseSw(22):End Sub '22
- 'Ramp Triggers
- Sub Trigger5_Hit:Controller.Switch(28)=1:End Sub '28
- Sub Trigger5_unHit:Controller.Switch(28)=0:End Sub
- Sub Trigger6_Hit:Controller.Switch(29)=1:End Sub '29
- Sub Trigger6_unHit:Controller.Switch(29)=0:End Sub
- 'Spinner
- Sub sw38_Spin: vpmTimer.PulseSw 38 : playsound"fx_spinner" : End Sub
- 'Stand Up Target
- Sub Wall9_Hit:vpmTimer.PulseSw(45):End Sub '45
- Sub FlatTireTarget_Hit:vpmTimer.PulseSw(23):End Sub '23
- Sub DropRamp_Hit()
- playsound "ballhit"
- End Sub
- '********** Bumpers ***********
- 'Dim Bump2,Bump1,Bump3
- Sub Bumper1a_Hit:vpmTimer.PulseSw 46
- B1L3.State = 1:B1L4. State = 1
- Me.TimerEnabled = 1
- End Sub
- Sub Bumper1a_Timer
- B1L3.State = 0:B1L4. State = 0
- Me.Timerenabled = 0
- End Sub
- Sub Bumper2a_Hit:vpmTimer.PulseSw 48
- B1L5.State = 1:B1L6. State = 1
- Me.TimerEnabled = 1
- End Sub
- Sub Bumper2a_Timer
- B1L5.State = 0:B1L6. State = 0
- Me.Timerenabled = 0
- End Sub
- Sub Bumper3a_Hit:vpmTimer.PulseSw 47
- B1L1.State = 1:B1L2. State = 1
- Me.TimerEnabled = 1
- End Sub
- Sub Bumper3a_Timer
- B1L1.State = 0:B1L2. State = 0
- Me.Timerenabled = 0
- 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 = 5 'lamp fading speed
- LampTimer.Enabled = 1
- ' Lamp & Flasher Timers
- Sub LampTimer_Timer()
- 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
- 'Special Handling
- 'If chgLamp(ii,0) = 2 Then solTrough chgLamp(ii,1)
- 'If chgLamp(ii,0) = 4 Then PFGI chgLamp(ii,1)
- Next
- End If
- UpdateLamps
- End Sub
- Sub UpdateLamps()
- NFadeL 1, L1
- NFadeL 2, L2
- NFadeL 3, L3
- NFadeL 4, L4
- NFadeL 5, L5
- NFadeL 6, L6
- NFadeL 9, L9
- NFadeL 10, L10
- NFadeL 11, L11
- NFadeL 12, L12
- NFadeL 13, L13
- NFadeL 14, L14
- NFadeL 18, L18
- NFadeL 19, L19
- NFadeL 20, L20
- NFadeL 21, L21
- NFadeL 22, L22
- NFadeL 17, L17
- 'Flash 1, Flasher1 'Pitstop Sign Red LED
- 'Flash 2, Flasher2 'Pitstop Sign Green LED
- 'Flash 3, Flasher3 'Ramp Sign LED
- 'Flash 8, Flasher8 'Ramp Sign LED
- 'Flash 23, Flasher23 'Hot Nitro Sign LED
- 'Flash 44, Flasher44 'Spinner Sign LED
- 'Flash 45, Flasher45 'Spinner Sign LED
- 'Flash 46, Flasher46 'Spinner Sign LED
- 'Flash 47, Flasher47 'Spinner Sign LED
- 'Flash 48, Flasher48 'Spinner Sign LED
- 'Flash 49, Flasher49 'BakWall
- 'Flash 50, Flasher50 'BakWall
- 'Flash 51, Flasher51 'BakWall
- 'Flash 52, Flasher52 'BakWall
- 'Flash 53, Flasher53 'Ramp Sign LED
- 'Flash 54, Flasher54 'Ramp Sign LED
- NFadeL 23, L23
- NFadeL 24, L24
- NFadeL 25, L25
- NFadeL 26, L26
- NFadeL 27, L27
- NFadeL 28, L28
- NFadeL 29, L29
- NFadeL 30, L30
- NFadeL 31, L31
- NFadeL 32, L32
- NFadeL 33, L33
- NFadeL 34, L34
- NFadeL 35, L35
- NFadeL 36, L36
- NFadeL 37, L37
- NFadeL 38, L38
- NFadeL 39, L39
- NFadeL 40, L40
- NFadeL 41, L41
- NFadeL 42, L42
- NFadeL 43, L43
- NFadeL 44, L44 'Spinner Sign LED
- NFadeL 45, L45 'Spinner Sign LED
- NFadeL 46, L46 'Spinner Sign LED
- NFadeL 47, L47 'Spinner Sign LED
- NFadeL 48, L48 'Spinner Sign LED
- NFadeL 49, L49 'BakWall
- NFadeL 50, L50 'BakWall
- NFadeL 51, L51 'BakWall
- NFadeL 52, L52 'BakWall
- NFadeL 53, L53
- NFadeL 54, L54
- NFadeLm 55, L55
- NFadeL 55, L55b
- NFadeL 56, L56
- NFadeL 57, L57
- NFadeL 58, L58
- NFadeL 59, L59
- NFadeL 60, L60
- NFadeL 64, L64
- 'NFadeL 7, L7 'BakGlass
- 'NFadeL 8, L8 'BakGlass
- 'NFadeL 15, L15 'BakGlass
- 'NFadeL 16, L16 'BakGlass
- 'NFadeL 24, L24
- 'Flash 23, Flasher23 'Hot Nitro Sign LED
- 'Flash 8, Flasher8 'Ramp Sign LED
- 'Flash 53, Flasher53 'Ramp Sign LED
- 'Flash 54, Flasher54 'Ramp Sign LED
- 'NFadeL 55, L55b
- 'NFadeL 61, L61 'Bumper 1
- 'NFadeL 62, L62 'Bumper 2
- 'NFadeL 63, L63 'Bumper 3
- 'Solenid Controlled Lamps
- NFadeL 65, L65
- 'NFadeL 16, L16
- 'NFadeLm 15, L15a
- 'NFadeL 15, L15b
- NFadeLm 113, S113a
- NFadeL 113, S113b
- NFadeL 114, S114
- NFadeLm 115, S115a
- NFadeL 115, S115b
- NFadeL 116, S116
- NFadeLm 127, S127
- NFadeLm 127, S127b
- NFadeLm 128, S128
- NFadeLm 128, S128a
- NFadeLm 129, S129
- NFadeLm 130, S130
- NFadeLm 130, S130b
- NFadeL 131, S131
- NFadeL 132, S132
- NFadeLm 135, S135a
- NFadeLm 135, S135b
- NFadeLm 135, S135c
- NFadeLm 136, S136a
- NFadeLm 136, S136b
- NFadeLm 136, S136c
- 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
- 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) ' used for multiple lights
- 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
- Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
- Object.IntensityScale = FlashLevel(nr)
- End Sub
- '*********************************************************************
- ' Positional Sound Playback Functions
- '*********************************************************************
- ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
- ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
- ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
- Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
- PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
- End Sub
- ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
- Sub PlaySoundAt(soundname, tableobj)
- PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtBall(soundname)
- PlaySoundAt soundname, ActiveBall
- 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 / table1.height-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 / table1.width-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 / 2000)
- 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
- '********************************************************************
- ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
- '********************************************************************
- Const tnob = 5 ' total number of balls
- ReDim rolling(tnob)
- InitRolling
- Sub InitRolling
- Dim i
- For i = 0 to tnob
- rolling(i) = False
- Next
- End Sub
- Sub RollingTimer_Timer()
- Dim BOT, b
- BOT = GetBalls
- ' stop the sound of deleted balls
- For b = UBound(BOT) + 1 to tnob
- rolling(b) = False
- StopSound "fx_ballrolling" & b
- StopSound "fx_plasticrolling" & b
- StopSound "fx_metalrolling" & 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 > 30 Then
- ' ball on plastic ramp
- StopSound "fx_ballrolling" & b
- StopSound "fx_metalrolling" & b
- PlaySound "fx_plasticrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
- Else
- ' ball on playfield
- StopSound "fx_plasticrolling" & b
- StopSound "fx_metalrolling" & b
- PlaySound "fx_ballrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
- End If
- Else
- If rolling(b) Then
- StopSound "fx_ballrolling" & b
- StopSound "fx_plasticrolling" & b
- StopSound "fx_metalrolling" & b
- rolling(b) = False
- End If
- End If
- ' play 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
- PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
- End If
- Next
- End Sub
- '**********************
- ' Ball Collision Sound
- '**********************
- Sub OnBallBallCollision(ball1, ball2, velocity)
- PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
- End Sub
- '*****************************************
- ' ninuzzu's FLIPPER SHADOWS
- '*****************************************
- sub FlipperTimer_Timer()
- FlipperLSh.RotZ = LeftFlipper.currentangle
- FlipperRSh.RotZ = RightFlipper.currentangle
- LFLogo.RotY = LeftFlipper.CurrentAngle
- RFlogo.RotY = RightFlipper.CurrentAngle
- End Sub
- '*****************************************
- ' ninuzzu's BALL SHADOW
- '*****************************************
- Dim BallShadow
- BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
- Sub BallShadowUpdate_timer()
- 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))/7)) + 6
- Else
- BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
- End If
- ballShadow(b).Y = BOT(b).Y + 12
- If BOT(b).Z > 20 Then
- BallShadow(b).visible = 1
- Else
- BallShadow(b).visible = 0
- End If
- Next
- End Sub
- '************************************
- ' What you need to add to your table
- '************************************
- ' a timer called RollingTimer. With a fast interval, like 10
- ' one collision sound, in this script is called fx_collide
- ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
- ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
- '******************************************
- ' Explanation of the rolling sound routine
- '******************************************
- ' sounds are played based on the ball speed and position
- ' the routine checks first for deleted balls and stops the rolling sound.
- ' The For loop goes through all the balls on the table and checks for the ball speed and
- ' if the ball is on the table (height lower than 30) then then it plays the sound
- ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
- ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
- ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
- ' according to the position of the ball on the table.
- '**************************************
- ' Explanation of the collision routine
- '**************************************
- ' The collision is built in VP.
- ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
- ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning
- ' depending of the speed of the collision.
- Sub Pins_Hit (idx)
- PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
- End Sub
- Sub Targets_Hit (idx)
- PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals_Thin_Hit (idx)
- PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals_Medium_Hit (idx)
- PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals2_Hit (idx)
- PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Gates_Hit (idx)
- PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Spinner_Spin
- PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
- End Sub
- Sub Rubbers_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 20 then
- PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End if
- If finalspeed >= 6 AND finalspeed <= 20 then
- RandomSoundRubber()
- End If
- End Sub
- Sub Posts_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 16 then
- PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End if
- If finalspeed >= 6 AND finalspeed <= 16 then
- RandomSoundRubber()
- End If
- End Sub
- Sub RandomSoundRubber()
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Select
- End Sub
- Sub LeftFlipper_Collide(parm)
- RandomSoundFlipper()
- End Sub
- Sub RightFlipper_Collide(parm)
- RandomSoundFlipper()
- End Sub
- Sub RandomSoundFlipper()
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Select
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement