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
- Const cGameName="bushidoa",UseSolenoids=1,UseLamps=1,UseSync=1,SCoin="Coin3"
- LoadVPM "01130000","SPINBALL.VBS",3.10
- '*************************************************************
- 'Solenoid Call backs
- '**********************************************************************************************************
- 'SolCallback(1)= 'Credit Button Light
- 'SolCallback(2)= 'Coin Lockout
- SolCallBack(3)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker)," 'Knocker
- SolCallback(4)= "bsTrough.SolIn" 'Outhole
- SolCallback(5)= "GameStart" 'Flipper Enable
- 'SolCallBack(6)= "vpmSolSound ""Jet3""," 'Right Bumper
- 'SolCallBack(7)= "vpmSolSound ""Jet3""," 'Middle Bumper
- SolCallBack(8)= "dtL.SolDropUp" 'Left Target Bank
- SolCallback(9)= "bsTrough.SolOut" 'Ball Release
- SolCallBack(10)= "SolLockRelease" 'Lock Ball Release
- SolCallback(13)= "bsThrower.SolOut" 'Ball Launch to Ramp
- SolCallBack(14)= "dtR.SolDropUp" 'Right Target Bank
- 'SolCallBack(15)= "vpmSolSound ""Sling""," 'Right Slingshot - commented out and added to hit event
- 'SolCallBack(16)= "vpmSolSound ""Jet3""," 'Bottom Bumper
- SolCallback(sLRFlipper) = "SolRFlipper"
- SolCallback(sLLFlipper) = "SolLFlipper"
- Sub SolLFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("fx_Flipperup",DOFContactors):LeftFlipper.RotateToEnd
- Else
- PlaySound SoundFX("fx_Flipperdown",DOFContactors):LeftFlipper.RotateToStart
- End If
- End Sub
- Sub SolRFlipper(Enabled)
- If Enabled Then
- PlaySound SoundFX("fx_Flipperup",DOFContactors):RightFlipper.RotateToEnd
- Else
- PlaySound SoundFX("fx_Flipperdown",DOFContactors):RightFlipper.RotateToStart
- End If
- End Sub
- 'Playfield GI
- '*****GI Lights On
- dim xx
- For each xx in GI:xx.State = 1: Next
- Sub GameStart(Enabled)
- vpmNudge.SolGameOn Enabled
- End Sub
- '**********************************************************************************************************
- 'Initiate Table
- '**********************************************************************************************************
- Dim bsTrough, dtL, dtR, bsThrower
- Sub Table1_Init
- vpmInit Me
- On Error Resume Next
- With Controller
- .GameName = cGameName
- If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
- .SplashInfoLine = ""&chr(13)&"You Suck"
- .HandleMechanics=0
- .HandleKeyboard=0
- .ShowDMDOnly=1
- .ShowFrame=0
- .ShowTitle=0
- .hidden = 0
- .Games(cGameName).Settings.Value("sound")=1
- '.PuPHide = 1
- On Error Resume Next
- .Run GetPlayerHWnd
- If Err Then MsgBox Err.Description
- On Error Goto 0
- End With
- On Error Goto 0
- PinMAMETimer.Interval=PinMAMEInterval
- PinMAMETimer.Enabled=1
- vpmNudge.TiltSwitch=33
- vpmNudge.Sensitivity=2
- vpmNudge.TiltObj=Array(Bumper1,Bumper2,Bumper3,RightSlingshot)
- Set bsTrough=New cvpmBallStack
- bsTrough.InitSw 71,31,64,70,0,0,0,0
- bsTrough.InitKick BallRelease,50,6
- bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
- bsTrough.Balls=3
- Set bsThrower=New cvpmBallStack
- bsThrower.InitSaucer sw50,50,0,25
- bsThrower.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
- Set dtL=New cvpmDropTarget
- dtL.InitDrop Array(sw52,sw51,sw53),Array(52,51,53)
- dtL.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
- Set dtR=New cvpmDropTarget
- dtR.InitDrop Array(sw56,sw54,sw55),Array(56,54,55)
- dtR.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
- vpmMapLights AllLights
- L2.IsDropped=1
- L3.IsDropped=1
- End Sub
- '**********************************************************************************************************
- 'Plunger code
- '**********************************************************************************************************
- Sub Table1_KeyDown(ByVal KeyCode)
- If keycode = LeftMagnaSave Then bLutActive = True
- If keycode = RightMagnaSave Then
- If bLutActive Then NextLUT: End If
- End If
- If KeyCode=keyInsertCoin1 Or KeyCode=keyInsertCoin2 or KeyCode=keyInsertCoin3 Then
- Controller.Switch(30)=1
- Exit Sub
- End If
- If KeyCode=RightFlipperKey Then Controller.Switch(45)=1
- If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
- If KeyDownHandler(keycode) Then Exit Sub
- End Sub
- Sub Table1_KeyUp(ByVal KeyCode)
- If keycode = LeftMagnaSave Then bLutActive = False
- If KeyCode=keyInsertCoin1 Or KeyCode=keyInsertCoin2 or KeyCode=keyInsertCoin3 Then
- Controller.Switch(30)=0
- Exit Sub
- End If
- If KeyCode=RightFlipperKey Then Controller.Switch(45)=0
- If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
- If KeyUpHandler(keycode) Then Exit Sub
- End Sub
- '********************************************************************************************************
- ' Drain hole and kickers
- Sub Drain_Hit:bsTrough.AddBall Me : playsound"drain" : End Sub
- Sub sw50_Hit:bsThrower.AddBall 0 : playsound "popper_ball": End Sub
- 'Drop Targets
- Sub Sw52_Dropped:dtL.Hit 1 :End Sub
- Sub Sw51_Dropped:dtL.Hit 2 :End Sub
- Sub Sw53_Dropped:dtL.Hit 3 :End Sub
- Sub Sw56_Dropped:dtR.Hit 1 :End Sub
- Sub Sw54_Dropped:dtR.Hit 2 :End Sub
- Sub Sw55_Dropped:dtR.Hit 3 :End Sub
- 'Wire Triggers
- Sub SW32_Hit:Controller.Switch(32)=1 : playsound"rollover" : End Sub
- Sub SW32_unHit:Controller.Switch(32)=0:End Sub
- Sub SW41_Hit:Controller.Switch(4)=1 : playsound"rollover" : End Sub
- Sub SW41_unHit:Controller.Switch(4)=0:End Sub
- Sub SW41a_Hit:Controller.Switch(4)=1 : playsound"rollover" : End Sub
- Sub SW41s_unHit:Controller.Switch(4)=0:End Sub
- Sub SW42_Hit:Controller.Switch(42)=1 : playsound"rollover" : End Sub
- Sub SW42_unHit:Controller.Switch(42)=0:End Sub
- Sub SW43_Hit:Controller.Switch(43)=1 : playsound"rollover" : End Sub
- Sub SW43_unHit:Controller.Switch(43)=0:End Sub
- Sub SW44_Hit:Controller.Switch(44)=1 : playsound"rollover" : End Sub
- Sub SW44_unHit:Controller.Switch(44)=0:End Sub
- Sub SW60_Hit:Controller.Switch(60)=1 : playsound"rollover" : End Sub
- Sub SW60_unHit:Controller.Switch(60)=0:End Sub
- Sub SW72_Hit:Controller.Switch(72)=1 : playsound"rollover" : End Sub
- Sub SW72_unHit:Controller.Switch(72)=0:End Sub
- Sub SW73_Hit:Controller.Switch(73)=1 : playsound"rollover" : End Sub
- Sub SW73_unHit:Controller.Switch(73)=0:End Sub
- Sub SW74_Hit:Controller.Switch(74)=1 : playsound"rollover" : End Sub
- Sub SW74_unHit:Controller.Switch(74)=0:End Sub
- Sub SW75_Hit:Controller.Switch(75)=1 : playsound"rollover" : End Sub
- Sub SW75_unHit:Controller.Switch(75)=0:End Sub
- Sub SW87_Hit:Controller.Switch(87)=1 : playsound"rollover" : End Sub
- Sub SW87_unHit:Controller.Switch(87)=0:End Sub
- 'Ramp Triggers
- Sub SW65_Hit:Controller.Switch(65)=1 : playsound"rollover" : End Sub
- Sub SW65_unHit:Controller.Switch(65)=0:End Sub
- Sub SW67_Hit:Controller.Switch(67)=1 : playsound"rollover" : End Sub
- Sub SW67_unHit:Controller.Switch(67)=0:End Sub
- Sub SW77_Hit:Controller.Switch(77)=1 : playsound"rollover" : End Sub
- Sub SW77_unHit:Controller.Switch(77)=0:End Sub
- Sub SW86_Hit:Controller.Switch(86)=1 : playsound"rollover" : End Sub
- Sub SW86_unHit:Controller.Switch(86)=0:End Sub
- 'Bumpers
- Sub Bumper1_Hit:vpmTimer.PulseSw 40 : PlayBumperSound : End Sub
- Sub Bumper2_Hit:vpmTimer.PulseSw 66 : PlayBumperSound : End Sub
- Sub Bumper3_Hit:vpmTimer.PulseSw 76 : PlayBumperSound : End Sub
- Sub PlayBumperSound()
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySound SoundFX("fx_bumper_1",DOFContactors)
- Case 2 : PlaySound SoundFX("fx_bumper_2",DOFContactors)
- Case 3 : PlaySound SoundFX("fx_bumper_3",DOFContactors)
- End Select
- End Sub
- 'Stand Up Targets
- Sub S47_Hit:vpmTimer.PulseSw 47:PlaySound"target":End Sub
- Sub S57_Hit:vpmTimer.PulseSw 57:PlaySound"target":End Sub
- Sub S61_Hit:vpmTimer.PulseSw 61:PlaySound"target":End Sub
- Sub S62_Hit:vpmTimer.PulseSw 62:PlaySound"target":End Sub
- Sub S63_Hit:vpmTimer.PulseSw 63:PlaySound"target":End Sub
- '********** Gates **********
- Sub Gate1_Hit:PlaySound "Gate5":End Sub
- Sub Gate2_Hit:PlaySound "Gate5":End Sub
- Sub Gate3_Hit:PlaySound "Gate5":End Sub
- Sub Gate4_Hit:PlaySound "Gate5":End Sub
- Sub Gate5_Hit:PlaySound "Gate5":End Sub
- Sub Gate6_Hit:PlaySound "Gate5":End Sub
- Sub Gate7_Hit:PlaySound "Gate5":End Sub
- '********************************************************************************************************
- ' Lock Ball Release
- '********************************************************************************************************
- Dim LockPos
- LockPos=0
- Dim MasterLock
- MasterLock=Array(L3,L1,L2,L3,L1,L2,L3,L1,L2)
- Dim LockedBalls(3)
- LockedBalls(0)=0:LockedBalls(1)=0:LockedBalls(2)=0:LockedBalls(3)=0
- Dim Release
- Release=0
- Sub SolLockRelease(Enabled)
- If Enabled Then
- Flipper1.RotateToEnd
- Release=1
- Else
- Flipper1.RotateToStart
- Release=0
- End If
- End Sub
- Sub Timer2_Timer
- MasterLock(LockPos).IsDropped=1
- CheckLocked
- LockPos=LockPos+1
- If LockPos>8 Then LockPos=0
- ruleta.RotY = -40*LockPos +40
- prueba.RotZ = -40*LockPos +40
- MasterLock(LockPos).IsDropped=0
- End Sub
- Sub Kicker3_Hit:Kicker3.DestroyBall:Kicker1.CreateBall:LockedBalls(3)=1:Timer2_Timer:End Sub
- 'Sub Trigger1_Hit:ActiveBall.VelY=3:End Sub
- Sub CheckLocked
- L1A.DestroyBall:L1B.DestroyBall:L1C.DestroyBall:L1D.DestroyBall:L1E.DestroyBall
- L1F.DestroyBall:L1G.DestroyBall:L1H.DestroyBall:L1I.DestroyBall
- Select Case LockPos
- Case 0:Controller.Switch(85)=1:If LockedBalls(3)=1 And LockedBalls(0)=0 Then
- Kicker1.DestroyBall
- LockedBalls(0)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1A.CreateBall.Image="L1APic"
- If LockedBalls(1)=1 Then L1D.CreateBall.Image="L1DPic"
- If LockedBalls(2)=1 Then L1G.CreateBall
- Case 1:Controller.Switch(85)=0:If LockedBalls(3)=1 And LockedBalls(0)=0 Then
- Kicker1.DestroyBall
- LockedBalls(0)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1B.CreateBall.Image="L1BPic"
- If LockedBalls(1)=1 Then L1E.CreateBall.Image="L1EPic"
- If LockedBalls(2)=1 Then L1H.CreateBall
- Case 2:Kicker1.Kick 320,5:LockedBalls(3)=0
- If LockedBalls(0)=1 Then L1C.CreateBall.Image="L1CPic"
- If LockedBalls(1)=1 Then L1F.CreateBall
- If LockedBalls(2)=1 Then L1I.CreateBall.Image="L1IPic"
- If Release=1 Then
- L1F.Kick 250,15
- LockedBalls(1)=0
- End If
- Case 3:Controller.Switch(83)=1:If LockedBalls(3)=1 And LockedBalls(2)=0 Then
- Kicker1.DestroyBall
- LockedBalls(2)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1D.CreateBall.Image="L1DPic"
- If LockedBalls(1)=1 Then L1G.CreateBall
- If LockedBalls(2)=1 Then L1A.CreateBall.Image="L1APic"
- Case 4:Controller.Switch(83)=0::If LockedBalls(3)=1 And LockedBalls(2)=0 Then
- Kicker1.DestroyBall
- LockedBalls(2)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1E.CreateBall.Image="L1EPic"
- If LockedBalls(1)=1 Then L1H.CreateBall
- If LockedBalls(2)=1 Then L1B.CreateBall.Image="L1BPic"
- Case 5:Kicker1.Kick 320,5:LockedBalls(3)=0
- If LockedBalls(0)=1 Then L1F.CreateBall
- If LockedBalls(1)=1 Then L1I.CreateBall.Image="L1IPic"
- If LockedBalls(2)=1 Then L1C.CreateBall.Image="L1CPic"
- If Release=1 Then
- L1F.Kick 250,15
- LockedBalls(0)=0
- End If
- Case 6:Controller.Switch(84)=1:If LockedBalls(3)=1 And LockedBalls(1)=0 Then
- Kicker1.DestroyBall
- LockedBalls(1)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1G.CreateBall
- If LockedBalls(1)=1 Then L1A.CreateBall.Image="L1APic"
- If LockedBalls(2)=1 Then L1D.CreateBall.Image="L1DPic"
- Case 7:Controller.Switch(84)=0:If LockedBalls(3)=1 And LockedBalls(1)=0 Then
- Kicker1.DestroyBall
- LockedBalls(1)=1
- LockedBalls(3)=0
- Else
- Kicker1.Kick 320,5
- End If
- If LockedBalls(0)=1 Then L1H.CreateBall
- If LockedBalls(1)=1 Then L1B.CreateBall.Image="L1BPic"
- If LockedBalls(2)=1 Then L1E.CreateBall.Image="L1EPic"
- Case 8:Kicker1.Kick 320,5:LockedBalls(3)=0
- If LockedBalls(0)=1 Then L1I.CreateBall.Image="L1IPic"
- If LockedBalls(1)=1 Then L1C.CreateBall.Image="L1CPic"
- If LockedBalls(2)=1 Then L1F.CreateBall
- If Release=1 Then
- L1F.Kick 250,15
- LockedBalls(2)=0
- End If
- End Select
- Controller.Switch(82)=LockedBalls(0)
- Controller.Switch(80)=LockedBalls(1)
- Controller.Switch(81)=LockedBalls(2)
- End Sub
- '********************************************************************************************************
- 'Objects controlled by light state
- '********************************************************************************************************
- 'Lock Switches
- '80/83 top -- 80=Feeler Yellow, 83=Passage by Zero
- '81/84 left -- 81=Feeler Red, 84=Passage by Zero
- '82/85 right -- 82=Feeler Violet, 85=Passage by Zero
- Set LampCallback=GetRef("UpdateMultipleLamps")
- Dim StartLock,StopLock,SLock1,SLock2
- SLock1=0:SLock2=0
- Sub UpdateMultipleLamps
- StopLock=Light23.State
- If StopLock<>SLock2 Then
- If StopLock=1 Then
- Timer2.Enabled=0
- SLock2=StopLock
- Exit Sub
- End If
- End If
- SLock2=StopLock
- StartLock=Light24.State
- If StartLock<>SLock1 Then
- If StartLock=1 Then
- Timer2.Enabled=1
- Else
- Timer2.Enabled=0
- End If
- End If
- SLock1=StartLock
- End Sub
- '********************************************************************************************************
- '********************************************************************************************************
- 'Inder Bushido
- 'added by Inkochnito
- Sub editDips
- Dim vpmDips:Set vpmDips=New cvpmDips
- With vpmDips
- .AddForm 700,400,"Bushido - DIP switches"
- .AddFrame 2,0,190,"Credits per coin",&H0000000F,Array("1 coin - 1 credit && 2 coin - 3 credits",&H0000000A,"2 coin - 1 credit && 4 coin - 3 credits",&H0000000F,"2 coin - 1 credit",&H0000000D,"1 coin - 1 credit",&H00000009)'SL1-4,3,2,1 (dip 1,2,3,4)
- .AddFrame 2,76,190,"Extra ball stays lit for",49152,Array("8 seconds",0,"10 seconds",32768,"12 seconds",&H00004000,"15 seconds",49152)'SL2-5&6 (dip 16&15)
- .AddFrame 2,152,190,"Balls per game",&H00000800,Array ("3 balls",0,"5 balls",&H00000800)'SL2-1 (dip 12)
- .AddFrame 205,0,190,"Replay threshold",&H000000B0,Array("100 million points",0,"150 million points",&H00000080,"200 million points",&H00000040,"250 million points",&H000000B0)'SL1-5&6 (dip 8&7)
- .AddFrame 205,76,190,"Handicap value",&H00000300,Array("250 million points",0,"300 million points",&H00000100,"350 million points",&H00000200,"400 million points",&H00000300)'SL2-3&4 (dip 10&9)
- .AddLabel 50,205,300,20,"After hitting OK, press F3 to reset game with new settings."
- .ViewDips
- End With
- End Sub
- Set vpmShowDips=GetRef("editDips")
- '**********Sling Shot Animations
- ' Rstep and Lstep are the variables that increment the animation
- '****************
- Dim RStep, Lstep
- Sub RightSlingShot_Slingshot
- vpmTimer.PulseSw 46
- 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
- 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
- '*************
- ' JP'S LUT
- '*************
- Dim bLutActive, LUTImage
- Sub LoadLUT
- Dim x
- x = LoadValue(cGameName, "LUTImage")
- If(x <> "") Then LUTImage = x Else LUTImage = 0
- UpdateLUT
- End Sub
- Sub SaveLUT
- SaveValue cGameName, "LUTImage", LUTImage
- End Sub
- Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
- Sub UpdateLUT
- Select Case LutImage
- Case 0: table1.ColorGradeImage = "LUT0"
- Case 1: table1.ColorGradeImage = "LUT1"
- Case 2: table1.ColorGradeImage = "LUT2"
- Case 3: table1.ColorGradeImage = "LUT3"
- Case 4: table1.ColorGradeImage = "LUT4"
- Case 5: table1.ColorGradeImage = "LUT5"
- Case 6: table1.ColorGradeImage = "LUT6"
- Case 7: table1.ColorGradeImage = "LUT7"
- Case 8: table1.ColorGradeImage = "LUT8"
- Case 9: table1.ColorGradeImage = "LUT9"
- End Select
- 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)
- Next
- ' exit the sub if no balls on the table
- If UBound(BOT) = -1 Then Exit Sub
- For b = 0 to UBound(BOT)
- ' play the rolling sound for each ball
- If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
- rolling(b) = True
- PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
- Else
- If rolling(b) = True Then
- StopSound("fx_ballrolling" & 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
- LFPrim.RotY = LeftFlipper.CurrentAngle
- RFPrim.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 "Gate5", 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
- ' Ramps sounds
- Sub RampSound1_Hit: PlaySound "fx_metalrolling1": End Sub
- Sub RampSound3_Hit: PlaySound "fx_metalrolling1": End Sub
- Sub RampSound9_Hit: PlaySound "fx_plasticrolling1": End Sub
- Sub RampSound10_Hit: PlaySound "fx_plasticrolling1": End Sub
- ' Stop Ramps Sounds
- Sub RampSound2_Hit: StopSound "fx_metalrolling1": End Sub
- Sub RampSound4_Hit: StopSound "fx_metalrolling1": End Sub
- Sub RampSound5_Hit: StopSound "fx_metalrolling1": End Sub
- Sub RampSound6_Hit: StopSound "fx_plasticrolling1": End Sub
- Sub RampSound7_Hit: StopSound "fx_plasticrolling1": End Sub
- Sub RampSound8_Hit: StopSound "fx_plasticrolling1": End Sub
- Sub RampSound11_Hit: StopSound "fx_plasticrolling1": End Sub
- Sub RampSound12_Hit: StopSound "fx_plasticrolling1": End Sub
- Sub Table1_Exit
- If B2SOn Then Controller.Stop
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment