Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Randomize
- Const BallSize = 50
- Const BallMass = 1.5
- Dim Controller,B2SController,objShell,PopupMessage
- Dim B2SOn, B2SOnALT, DOFeffects(9)
- Dim DesktopMode:DesktopMode = Table1.ShowDT
- Dim UseVPMDMD:UseVPMDMD = DesktopMode
- ' Rom Name
- Const cGameName = "spagb_100"
- '
- Const B2ScGameName = "spagb_100b2s"
- LoadCore
- LoadSPAController
- ' Standard Options
- Const UseSolenoids = 1
- Const UseLamps = 0
- Const UseSync = 0
- Const HandleMech = 0
- ' Standard Sounds
- Const SSolenoidOn = "fx_Solenoid"
- Const SSolenoidOff = ""
- 'Dip Switches / Options Menu
- Private vpmDips
- Set vpmShowDips = GetRef("GBShowDips")
- Private Sub GBShowDips
- If Not IsObject(vpmDips) Then ' First time
- Set vpmDips = New cvpmDips
- With vpmDips
- .AddForm 100, 240, "DIP Switches"
- .AddFrame 0, 0, 180, "Country", &H1b,_
- Array("USA", &H00,_
- "Austria", &H01,_
- "Belgium", &H02,_
- "Canada 1", &H03,_
- "Netherlands", &H04,_
- "Finland", &H05,_
- "France", &H06,_
- "Germany", &H07,_
- "Italy", &H08,_
- "Denmark", &H09,_
- "Norway", &H0a,_
- "Sweden", &H0b,_
- "Switzerland", &H0c,_
- "Australia", &H0d,_
- "UK", &H0e,_
- "Greece", &H0f,_
- "New Zealand", &H10,_
- "Spain", &H12,_
- "S.Africa", &H14,_
- "Japan", &H15,_
- "Croatia", &H16,_
- "Middle East", &H17,_
- "Taiwan", &H18,_
- "Russia", &H19,_
- "Canada 2", &H1a)
- End With
- End If
- vpmDips.ViewDips
- End Sub
- '************************************************************************
- ' INIT TABLE
- '************************************************************************
- Dim bsTrough, bsLSaucer, bsRPopper, bsLock, dtLeft, dtRight, plungerIM, mLeftSling, mRightSling
- Sub Table1_Init
- vpmInit Me
- With Controller
- .GameName = cGameName
- If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
- .SplashInfoLine = "Ghostbusters LE (Stern 2016)"
- .HandleKeyboard = 0
- .ShowTitle = 0
- .ShowDMDOnly = 1
- .ShowFrame = 0
- .HandleMechanics = 0
- .Hidden = DesktopMode
- On Error Resume Next
- .Run GetPlayerHWnd
- If Err Then MsgBox Err.Description
- On Error Goto 0
- End With
- ' Main Timer init
- PinMAMETimer.Interval = PinMAMEInterval
- PinMAMETimer.Enabled = 1
- ' Nudging
- vpmNudge.TiltSwitch = 86
- vpmNudge.Sensitivity = 5
- vpmNudge.TiltObj = Array(sw49, sw50, sw51, sw7, sw8)
- 'Trough
- Set bsTrough = New cvpmTrough
- With bsTrough
- .Size = 6
- .InitSwitches Array(20, 19, 18, 17, 16, 15)
- .InitExit BallRelease, 90, 5
- .InitEntrySounds "fx_drain", "", ""
- .InitExitSounds SoundFX(SSolenoidOn,DOFContactors), SoundFX("ballrelease",DOFContactors)
- .Balls = 6
- .CreateEvents "bsTrough", Drain
- End With
- 'Auto Plunger
- Set plungerIM = New cvpmImpulseP
- With plungerIM
- .InitImpulseP sw22, 55, 0.5
- .Switch 22
- .Random 0.05
- .InitExitSnd SoundFX("AutoPlunger",DOFContactors), SoundFX(SSolenoidOn,DOFContactors)
- .CreateEvents "plungerIM"
- End With
- 'Left Scoop
- Set bsLSaucer = new cvpmSaucer
- With bsLSaucer
- .InitKicker ScoopEject, 34, 0, 30, 1.56
- .InitExitVariance 0, 2
- .InitSounds "LeftHole", SoundFX(SSolenoidOn,DOFContactors), SoundFX("kicker_out_left",DOFContactors)
- .CreateEvents "bsLSaucer", ScoopEject
- End With
- 'Right Popper
- Set bsRPopper = new cvpmSaucer
- With bsRPopper
- .InitKicker SubwayEject, 63, 270, 30, 1.56
- .InitSounds "RightHole", SoundFX(SSolenoidOn,DOFContactors), SoundFX("kicker_out_right",DOFContactors)
- .CreateEvents "bsRPopper", SubwayEject
- End With
- 'SubwayLock
- Set bsLock = New cvpmTrough
- With bsLock
- .Size = 3
- .InitSwitches Array(62, 61, 60)
- .InitExit SubwayLockOut, 130, 10
- .InitExitSounds SoundFX(SSolenoidOn,DOFContactors), SoundFX("fx_popper",DOFContactors)
- .Balls = 0
- .CreateEvents "bsLock", SubwayLockIn
- End With
- 'Left Drop Target
- Set dtLeft = New cvpmDropTarget
- With dtLeft
- .InitDrop sw65, 65
- .Initsnd SoundFX("fx_DropTargetDown",DOFDropTargets), SoundFX("fx_DropTargetUp",DOFDropTargets)
- End With
- 'Right Drop Target
- Set dtRight = New cvpmDropTarget
- With dtRight
- .InitDrop sw66, 66
- .Initsnd SoundFX("fx_DropTargetDown",DOFDropTargets), SoundFX("fx_DropTargetUp",DOFDropTargets)
- End With
- 'Magna Slings
- Set mLeftSling = New cvpmMagnet
- With mLeftSling
- .InitMagnet LeftMagnaSling, 55 ' Left Magna Sling Strength (adjust to taste)
- .GrabCenter = True: .Size = 195
- .CreateEvents "mLeftSling"
- End With
- Set mRightSling = New cvpmMagnet
- With mRightSling
- .InitMagnet RightMagnaSling, 55 ' Right Magna Sling Strength (adjust to taste)
- .GrabCenter = True: .Size = 195
- .CreateEvents "mRightSling"
- End With
- 'UpPost/Diverter
- DiverterOn.IsDropped=1
- UpPost.IsDropped=1
- 'Captive Balls
- kickerinit.createball
- kickerinit.kick 0,0
- kickerinit1.createball
- kickerinit1.kick 0,0
- kickerinit2.createball
- kickerinit2.kick 0,0
- kickerinit3.createball
- kickerinit3.kick 0,0
- kickerinit4.createball
- kickerinit4.kick 0,0
- kickerinit5.createball
- kickerinit5.kick 0,0
- Controller.Switch(28) = True
- Controller.Switch(29) = True
- Controller.Switch(30) = True
- Dim bulb
- If DesktopMode Then
- For each bulb in StayPuftFlasher: bulb.intensity = 20 : Next
- SideRails.Visible = True
- Else
- For each bulb in StayPuftFlasher: bulb.intensity = 10 : Next
- SideRails.Visible = False
- End If
- End Sub
- '************************************************************************
- ' KEYS MAPPING
- '************************************************************************
- Sub Table1_KeyDown(ByVal Keycode)
- If keycode = LeftFlipperKey Then Controller.Switch(9) = True
- If keycode = RightFlipperKey Then Controller.Switch(10) = True
- If KeyCode = PlungerKey Then Plunger.Pullback: PlaySoundAt "fx_PlungerPull", Plunger
- If keycode = StartGameKey Then Controller.Switch(78) = True
- If keycode = keyFront Then Controller.Switch(79) = True 'Tournament mode mapped to key 2
- If keycode = keyInsertCoin1 Then vpmTimer.AddTimer 750,"vpmTimer.PulseSw 81'" : PlaysoundAt "fx_Coin", Drain 'Coin door chute #1
- If keycode = keyInsertCoin2 Then vpmTimer.AddTimer 750,"vpmTimer.PulseSw 82'" : PlaysoundAt "fx_Coin", Drain 'Coin door chute #2
- If keycode = keyInsertCoin3 Then vpmTimer.AddTimer 750,"vpmTimer.PulseSw 83'" : PlaysoundAt "fx_Coin", Drain 'Coin door chute #3
- If keycode = keyInsertCoin4 Then vpmTimer.AddTimer 750,"vpmTimer.PulseSw 84'" : PlaysoundAt "fx_Coin", Drain 'Coin door chute #4
- If keycode = keyCancel Then Controller.Switch(0) = True
- If keycode = keyDown Then Controller.Switch(-1) = True
- If keycode = keyUp Then Controller.Switch(-2) = True
- If keycode = keyEnter Then Controller.Switch(-3) = True
- ' If keycode = keySlamDoorHit Then Controller.Switch(89) = True 'Slam Tilt
- ' If keycode = keyCoinDoor Then Controller.Switch(106) = True 'Playfield power interlock
- If keycode = keyBangBack Then vpmNudge.DoNudge 0, 6
- If keycode = LeftTiltKey Then vpmNudge.DoNudge 75, 2:PlaySoundAt SoundFX("fx_nudge", 0), sw1
- If keycode = RightTiltKey Then vpmNudge.DoNudge 285, 2:PlaySoundAt SoundFX("fx_nudge", 0), sw6
- If keycode = CenterTiltKey Then vpmNudge.DoNudge 0, 2:PlaySoundAt SoundFX("fx_nudge", 0), Drain
- If KeyCode = RightMagnaSave OR KeyCode = LeftMagnaSave Then Controller.Switch(76) = True 'LockBar Button (Optional)
- If KeyCode = keyVPMVolume Then vpmVol
- if keycode = 33 then SolShaker true
- End Sub
- Sub Table1_KeyUp(ByVal Keycode)
- If keycode = LeftFlipperKey Then Controller.Switch(9) = False
- If keycode = RightFlipperKey Then Controller.Switch(10) = False
- If KeyCode = PlungerKey Then Plunger.Fire: StopSound "fx_PlungerPull":PlaySoundAt "fx_Plunger", Plunger
- If keycode = StartGameKey Then Controller.Switch(78) = False
- If keycode = keyFront Then Controller.Switch(79) = False 'Tournament mode mapped to key 2
- If keycode = keyCancel Then Controller.Switch(0) = False
- If keycode = keyDown Then Controller.Switch(-1) = False
- If keycode = keyUp Then Controller.Switch(-2) = False
- If keycode = keyEnter Then Controller.Switch(-3) = False
- ' If keycode = keySlamDoorHit Then Controller.Switch(89) = False 'Slam Tilt
- ' If keycode = keyCoinDoor Then Controller.Switch(106) = False 'Playfield power interlock
- If KeyCode = RightMagnaSave OR KeyCode = LeftMagnaSave Then Controller.Switch(76) = False 'LockBar Button (Optional)
- If KeyCode = keyShowOpts Then 'F1 - Show VPM options
- Controller.Pause = True
- Controller.ShowOptsDialog GetPlayerHWnd
- Controller.Pause = False
- End If
- If KeyCode = keyShowKeys Then Controller.Pause = True : vpmShowHelp : Controller.Pause = False 'F2 - Show Keys
- If KeyCode = keyReset Then Controller.Stop : BeginModal : Controller.Run : vpmTimer.Reset : EndModal 'F3 - Reset Emulation
- If KeyCode = keyFrame Then Controller.LockDisplay = Not Controller.LockDisplay 'F4 - Toggle Window Lock
- If KeyCode = keyDoubleSize Then Controller.DoubleSize = Not Controller.DoubleSize 'F5 - Toggle displaysize
- If KeyCode = keyShowDips Then 'F6 - Show Dip Switch / Options Menu
- If IsObject(vpmShowDips) Then Controller.Pause = True : vpmShowDips : Controller.Pause = False
- End If
- End Sub
- ' Help Window
- vpmSystemHelp = "Stern GB keys:" & vbNewLine &_
- vpmKeyName(StartGameKey) & vbTab & "Start Game" & vbNewLine &_
- vpmKeyName(keyFront) & vbTab & "Tournament Mode" & vbNewLine &_
- vpmKeyName(keyInsertCoin1) & vbTab & "Insert Coin #1" & vbNewLine &_
- vpmKeyName(keyInsertCoin2) & vbTab & "Insert Coin #2" & vbNewLine &_
- vpmKeyName(keyInsertCoin3) & vbTab & "Insert Coin #3" & vbNewLine &_
- vpmKeyName(keyInsertCoin4) & vbTab & "Insert Coin #4" & vbNewLine &_
- vpmKeyName(keyCancel) & vbTab & "Service Back" & vbNewLine &_
- vpmKeyName(keyDown) & vbTab & "Service Minus" & vbNewLine &_
- vpmKeyName(keyUp) & vbTab & "Service Plus" & vbNewLine &_
- vpmKeyName(keyEnter) & vbTab & "Service Select"
- Sub Table1_Paused:Controller.Pause = True:End Sub
- Sub Table1_UnPaused:Controller.Pause = False:End Sub
- Sub Table1_Exit:Controller.Stop:End Sub
- '************************************************************************
- ' SOLENOIDS MAPPING
- '************************************************************************
- SolCallBack(1) = "SolTrough" 'Trough
- SolCallBack(2) = "SolAutoPlungerIM" 'AutoPlunger
- SolCallback(3) = "SolLFlipper" 'Left Flipper
- SolCallback(4) = "SolRFlipper" 'Right Flipper
- SolCallback(5)= "SolMiniMagnet mLeftSling," 'Left Sling Magnet
- SolCallback(6)= "SolMiniMagnet mRightSling," 'Right Sling Magnet
- SolCallback(7)= "SolShaker" 'Shaker Motor
- SolCallback(10)= "SolLeftEject" 'Left Scoop
- SolCallback(11)= "SolLockPost" 'Lock Post (Captive Ball)
- SolCallback(12)= "SolUpPost" 'Up Post (Spinner)
- 'SolCallback(14)= "" 'Left Bumper
- 'SolCallback(15)= "" 'Right Bumper
- 'SolCallback(16)= "" 'Bottom Bumper
- SolCallback(18)= "vpmSolGate Gate1, SoundFXDOFALT(""ElGate"",127,DOFPulse,DOFContactors)," 'Electric Gate
- SolCallback(20)= "SolSubwayDiverter" 'Subway Diverter
- SolCallback(21)= "SolSubwayLock" 'Subway Lock
- SolCallback(22)= "SolSubwayEject" 'Subway Eject
- SolCallback(24)= "SolRaiseLDrop" 'Left Drop Target Up
- SolCallback(25)= "SolLowerLDrop" 'Left Drop Target Down
- SolCallback(26)= "SolRaiseRDrop" 'Right Drop Target Up
- SolCallback(27)= "SolLowerRDrop" 'Right Drop Target Down
- SolCallback(30)= "vpmSolSound SoundFXDOFALT(""fx_knocker"",124,DOFPulse,DOFKnocker)," 'Knocker
- 'SolCallback(31)= "" 'Ticket Meter
- 'SolCallback(32)= "" 'Ticket Dispenser
- '************************************************************************
- ' BALL TROUGH
- '************************************************************************
- Sub SolTrough(Enabled)
- If Enabled Then
- DOFALT 120, DOFPulse
- bsTrough.ExitSol_On
- If BsTrough.Balls Then vpmTimer.PulseSw 21
- End If
- End Sub
- '************************************************************************
- ' AUTOPLUNGER
- '************************************************************************
- Sub SolAutoPlungerIM(Enabled)
- If Enabled Then
- DOFALT 120, DOFPulse
- DOFALT 121, DOFPulse
- PlungerIM.AutoFire
- End If
- End Sub
- '************************************************************************
- ' FLIPPERS
- '************************************************************************
- Sub SolLFlipper(Enabled)
- If Enabled Then
- PlaySoundAt SoundFXDOFALT("fx_flipperup",101,DOFOn,DOFFlippers), LeftFlipper
- LeftFlipper.RotateToEnd
- Else
- PlaySoundAt SoundFXDOFALT("fx_flipperdown",101,DOFOff,DOFFlippers), RightFlipper
- LeftFlipper.RotateToStart
- End If
- End Sub
- Sub SolRFlipper(Enabled)
- If Enabled Then
- PlaySoundAt SoundFXDOFALT("fx_flipperup",102,DOFOn,DOFFlippers), LeftFlipper
- RightFlipper.RotateToEnd
- Else
- PlaySoundAt SoundFXDOFALT("fx_flipperdown",102,DOFOff,DOFFlippers), RightFlipper
- RightFlipper.RotateToStart
- End If
- End Sub
- '************************************************************************
- ' MAGNA SLINGS
- '************************************************************************
- Sub SolMiniMagnet(aMag, enabled)
- If enabled Then
- PlayLoopSoundAtVol SoundFXDOFALT("fx_magnet",122,DOFOn,DOFShaker), aMag, 1
- aMag.MagnetOn = True : aMag.Update: aMag.MagnetOn = False 'Fast Pulse
- Else
- DOFALT 122, DOFOff
- StopSound "fx_magnet"
- End If
- End Sub
- '************************************************************************
- ' SHAKER MOTOR
- '************************************************************************
- Sub SolShaker(Enabled)
- If Enabled Then
- DOFALT 123, DOFOn
- cBall.VelX = 0.5 : cBall.VelY = 0.5 : osce=3 : slbreak = .5 'shake toys
- Else
- DOFALT 123, DOFOff
- End If
- End Sub
- '************************************************************************
- ' LEFT SCOOP
- '************************************************************************
- Sub SolLeftEject(enabled)
- If Enabled Then
- DOFALT 125, DOFPulse
- DOFALT 121, DOFPulse
- bsLSaucer.ExitSol_On
- sw34.Enabled=0
- vpmTimer.AddTimer 200, "sw34.Enabled=1 '"
- End If
- End Sub
- '************************************************************************
- ' CAPTIVEBALL LOCK POST
- '************************************************************************
- Sub SolLockPost(Enabled)
- If enabled Then
- DOFALT 126, DOFPulse
- LockPost.IsDropped=1:PlaySoundAt SoundFX("fx_postdown",DOFContactors),sw31
- Else
- DOFALT 126, DOFPulse
- LockPost.IsDropped=0:PlaySoundAt SoundFX("fx_postup",DOFContactors), sw31
- End If
- End Sub
- '************************************************************************
- ' BALL TROUGH
- '************************************************************************
- Sub SolSubwayLock(Enabled)
- If Enabled Then
- DOFALT 129, DOFPulse
- bsLock.ExitSol_On
- End If
- End Sub
- '************************************************************************
- ' SPINNER POST
- '************************************************************************
- Sub SolUpPost(Enabled)
- If enabled Then
- DOFALT 126, DOFPulse
- UpPost.IsDropped=0:PlaySoundAt SoundFX("fx_postup",DOFContactors), sw36
- Else
- DOFALT 126, DOFPulse
- UpPost.IsDropped=1:PlaySoundAt SoundFX("fx_postdown",DOFContactors),sw36
- End If
- End Sub
- '************************************************************************
- ' SUBWAY
- '************************************************************************
- Sub kicker3_hit
- StopSound "fx_wireramp_enter": PlaysoundAt "fx_wireramp_exit", ActiveBall: me.destroyball
- Me.TimerInterval=300: Me.TimerEnabled=1
- End Sub
- Sub kicker3_timer
- Me.TimerEnabled = 0
- kicker2.createSizedBallWithMass BallSize/2, BallMass:kicker2.kick 180,30
- End Sub
- Sub SubwaySnd_Hit: PlaySoundAt "Subway_enter", ActiveBall : End Sub
- Sub SolSubwayDiverter(Enabled)
- If Enabled Then
- DOFALT 128, DOFPulse
- DiverterOff.IsDropped=1:DiverterOn.IsDropped=0:PlaySoundAt SoundFX("DiverterOn",DOFContactors),SubwayLockIn
- Else
- DOFALT 128, DOFPulse
- DiverterOff.IsDropped=0:DiverterOn.IsDropped=1:PlaySoundAt SoundFX("DiverterOff",DOFContactors),SubwayLockIn
- End If
- End Sub
- Sub SolSubwayEject(enabled)
- If Enabled Then
- DOFALT 130, DOFPulse
- DOFALT 121, DOFPulse
- bsRPopper.ExitSol_On
- sw63.Enabled=0
- vpmTimer.AddTimer 200, "sw63.Enabled=1 '"
- End If
- End Sub
- '************************************************************************
- ' SLIMER MOVE
- '************************************************************************
- ' 71-72-73 slimer encoder wheel
- Dim CurSlimerPos:CurSlimerPos = 0
- Const SlimerSpeed = 0.33
- dim LastMotorTime:LastMotorTime = 0
- dim lastMotorDirection:lastMotorDirection = 0
- sub slimerbracket_timer()
- If LampState(281) <92 Then
- ' Don't move directly to ROM position - move incrementally towards it.
- if CurSlimerPos < (LampState(281)*1.85)-110-SlimerSpeed then
- CurSlimerPos = CurSlimerPos + SlimerSpeed
- LastMotorTime = Timer
- if lastMotorDirection <> -1 Then
- ChangeSlimerDirection -1
- end if
- Elseif CurSlimerPos > (LampState(281)*1.85)-110 then
- CurSlimerPos = CurSlimerPos - SlimerSpeed
- LastMotorTime = Timer
- if lastMotorDirection <> 1 Then
- ChangeSlimerDirection 1
- end if
- Elseif LastMotorTime > 0 and Timer > LastMotorTime + 0.08 then
- ChangeSlimerDirection 0
- LastMotorTime = 0
- Else
- End If
- slimerB.rotz=CurSlimerPos
- slimer.rotz=slimerb.rotz
- slimer.X=((280* dCOS(slimerB.rotZ+90))+310)
- slimer.y=(270* dSIN(slimerB.rotZ+90))+500
- slimer.z=((slimer.y/2.7)*-1)+400
- SlimerLight.x=slimer.x
- SlimerLight.y=slimer.y
- SlimerLighta.x=slimer.x
- SlimerLighta.y=slimer.y
- slimerlighta.BulbHaloHeight = slimer.z
- slimershadow.x=slimer.x
- slimershadow.y=slimer.y
- slimershadow.rotz=(slimer.rotz-90)/1.2
- slimershadow.size_y=abs(slimer.roty*1.2)+10
- slimershadow.x=((slimershadow.x-(slimer.z))+100)+slimer.roty
- SlimerOscUpdate:SlimerPlasticHit
- dim xx : For each xx in SLWalls:xx.IsDropped=1:Next
- Dim WallPos:WallPos = int((CurSlimerPos + 45) / 5.2)
- if WallPos>=0 and WallPos < SLWalls.Count Then
- SLWalls(WallPos).IsDropped=0
- end if
- else ' Stop motor sound
- osce=1:osc=0
- StopSound "SlimerMotor"
- DOFALT 138, DOFOff
- End If
- end Sub
- sub ChangeSlimerDirection(cur)
- if (lastMotorDirection = -1 and cur = 1) or (lastMotorDirection = 1 and cur= -1) then ' big change in direction - oscillate high intensity
- osce=2:osc=0
- ' debug.print "Shift"
- elseif cur = 0 then ' Stop
- osce=1:osc=0
- StopSound "SlimerMotor"
- DOFALT 138, DOFOff
- ' debug.print "Stop"
- Else ' Start
- osce=.5:osc=0
- PlayLoopSoundAtVol SoundFXDOFALT("SlimerMotor",138,DOFOn,DOFGear), slimer, 0.25
- ' debug.print "Start"
- end if
- lastMotorDirection = cur
- end sub
- '************************************************************************
- ' SLIMER LEFT PLASTIC HIT
- '************************************************************************
- Dim cdir
- Sub SlimerPlasticHit()
- if lastMotorDirection=-1 and (slimerB.rotz>45 or slimerB.rotz<15) then cdir=-1:slimer.objroty=0
- if lastMotorDirection=1 and (slimerB.rotz>45 or slimerB.rotz<15) then cdir=1:slimer.objroty=0
- if (cdir=-1) and (slimerB.rotz>15 and slimerB.rotz<45) then slimer.objroty=-((slimerB.rotz-15)*2.6)
- if (cdir=-1) and (slimerB.rotz>45 and slimerB.rotz<46) then osce=2
- if (cdir=1) and (slimerB.rotz>15 and slimerB.rotz<48) then slimer.objroty=((45-(slimerB.rotz))*3.2)
- if (cdir=1) and (slimerB.rotz>14 and slimerB.rotz<15) then osce=4
- end sub
- '************************************************************************
- ' SLIMER OSCILLATION
- '************************************************************************
- dim osc,oscE:oscE=1
- sub SlimerOscUpdate()
- if CurSlimerPos > -55 and CurSlimerPos < -53 Then
- ' Ghost "bumps" into play area, also stunts hit shaking
- osce=2
- slbreak=0
- end if
- dim doupdate:doupdate = false
- if osce>0 then
- osc=osc+1
- oscE=osce-0.03
- doupdate = true
- end if
- if slbreak>0 then
- slbreak=slbreak-0.03
- slrotx=slrotx+1
- doupdate = true
- end if
- if doupdate then
- slimer.roty=(dsin(osc*45)*3)*oscE
- slimer.rotx=slimer.roty + (dCos (slrotx*15)*45)*slbreak
- Else
- If Timer>cWait Then
- slimer.roty= (dsin(osc*45)*3)*oscE + (cball.x - ckicker.x)*10
- slimer.rotx= slimer.roty + (dCos (slrotx*15)*45)*slbreak + (0.33-(ckicker.y - cball.y))*10
- End If
- End If
- end sub
- '************************************************************************
- ' SLIMER Hit
- '************************************************************************
- dim slrotx,slbreak
- sub SlWalls_hit(idx)
- vpmtimer.pulseSw 68
- Slwalls(idx).isdropped=1
- PlaySound("fx_collide"), 0, Csng(BallVel(ActiveBall)) ^2 / 1000, Pan(ActiveBall), 0, -10000, 0, 0, AudioFade(ActiveBall)
- slbreak=Csng(BallVel(ActiveBall) ^2 / 500)
- if slbreak > 1.5 then slbreak = 1.5
- slrotx=1
- end Sub
- '************************************************************************
- ' TOYS SHAKE ON NUDGE
- '************************************************************************
- Dim mMagnet, cBall
- Sub WobbleMagnet_Init
- Set mMagnet = new cvpmMagnet
- With mMagnet
- .InitMagnet WobbleMagnet, 2
- .Size = 100
- .CreateEvents mMagnet
- .MagnetOn = True
- End With
- Set cBall = ckicker.createball:ckicker.Kick 0,1:mMagnet.addball cball
- End Sub
- Dim cWait: cWait = Timer +10 'wait 10 seconds
- Sub ShakeTimer_Timer
- If Timer>cWait Then
- staypuft.rotx=180 + (0.33-(ckicker.y - cball.y))*2
- staypuft.roty=(cball.x - ckicker.x)*4
- End If
- end Sub
- '************************************************************************
- ' SCOLERI'S DROP TARGETS
- '************************************************************************
- Sub SolRaiseLDrop(enabled)
- If enabled Then dtLeft.SolDropUp True: l112a.visible = True:DOFALT 119, DOFPulse
- End Sub
- Sub SolRaiseRDrop(enabled)
- If enabled Then dtRight.SolDropUp True: l113a.visible = True:DOFALT 119, DOFPulse
- End Sub
- Sub SolLowerLDrop(enabled)
- If enabled Then dtLeft.SolDropDown True: l112a.visible = False:DOFALT 119, DOFPulse
- End Sub
- Sub SolLowerRDrop(enabled)
- If enabled Then dtRight.SolDropDown True: l113a.visible = False:DOFALT 119, DOFPulse
- End Sub
- '************************************************************************
- ' SWITCHES
- '************************************************************************
- 'rollovers
- Sub sw1_hit: Controller.Switch(1) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw1_unhit:Controller.Switch(1) = 0: End Sub
- Sub sw2_hit: Controller.Switch(2) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw2_unhit:Controller.Switch(2) = 0: End Sub
- Sub sw3_hit: Controller.Switch(3) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw3_unhit:Controller.Switch(3) = 0: End Sub
- Sub sw4_hit: Controller.Switch(4) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw4_unhit:Controller.Switch(4) = 0: End Sub
- Sub sw5_hit: Controller.Switch(5) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw5_unhit:Controller.Switch(5) = 0: End Sub
- Sub sw6_hit: Controller.Switch(6) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw6_unhit:Controller.Switch(6) = 0: End Sub
- Sub sw52_hit: Controller.Switch(52) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw52_unhit:Controller.Switch(52) = 0: End Sub
- Sub sw54_hit: Controller.Switch(54) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 134, DOFOn:End Sub
- Sub sw54_unhit:Controller.Switch(54) = 0: DOFALT 134, DOFOff : End Sub
- Sub sw55_hit: Controller.Switch(55) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 135, DOFOn:End Sub
- Sub sw55_unhit:Controller.Switch(55) = 0: DOFALT 135, DOFOff : End Sub
- Sub sw56_hit: Controller.Switch(56) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 131, DOFOn:End Sub
- Sub sw56_unhit:Controller.Switch(56) = 0: DOFALT 131, DOFOff : End Sub
- Sub sw57_hit: Controller.Switch(57) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 132, DOFOn:End Sub
- Sub sw57_unhit:Controller.Switch(57) = 0: DOFALT 132, DOFOff : End Sub
- Sub sw58_hit: Controller.Switch(58) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 133, DOFOn:End Sub
- Sub sw58_unhit:Controller.Switch(58) = 0: DOFALT 133, DOFOff : End Sub
- 'Slingshots
- Sub sw7_Hit:vpmTimer.PulseSw 7:DOFALT 103, DOFPulse:DOFALT 105, DOFPulse:End Sub
- Sub sw8_Hit:vpmTimer.PulseSw 8:DOFALT 104, DOFPulse:DOFALT 106, DOFPulse:End Sub
- 'StandUp Targets
- Sub sw24_hit:vpmtimer.PulseSw 24: PlaySoundAt SoundFXDOFALT("fx_target",113,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw25_hit:vpmtimer.PulseSw 25: PlaySoundAt SoundFXDOFALT("fx_target",113,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw26_hit:vpmtimer.PulseSw 26: PlaySoundAt SoundFXDOFALT("fx_target",113,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw37_hit:vpmtimer.PulseSw 37: PlaySoundAt SoundFXDOFALT("fx_target",114,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw38_hit:vpmtimer.PulseSw 38: PlaySoundAt SoundFXDOFALT("fx_target",114,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw45_hit:vpmtimer.PulseSw 45: PlaySoundAt SoundFXDOFALT("fx_target",115,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw46_hit:vpmtimer.PulseSw 46: PlaySoundAt SoundFXDOFALT("fx_target",115,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw48_hit:vpmtimer.PulseSw 48: PlaySoundAt SoundFXDOFALT("fx_target",114,DOFPulse,DOFTargets), ActiveBall:End Sub
- Sub sw64_hit:vpmtimer.PulseSw 64: PlaySoundAt SoundFXDOFALT("fx_target",116,DOFPulse,DOFTargets), ActiveBall:End Sub
- 'captive lock rollovers
- Sub sw28_hit: Controller.Switch(28) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw28_unhit:Controller.Switch(28) = 0: End Sub
- Sub sw29_hit: Controller.Switch(29) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw29_unhit:Controller.Switch(29) = 0: End Sub
- Sub sw30_hit: Controller.Switch(30) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw30_unhit:Controller.Switch(30) = 0: End Sub
- Sub sw31_hit: Controller.Switch(31) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw31_unhit:Controller.Switch(31) = 0: End Sub
- Sub sw32_hit: Controller.Switch(32) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw32_unhit:Controller.Switch(32) = 0: End Sub
- Sub sw33_hit: Controller.Switch(33) = 1 : PlaySoundAt "fx_sensor",ActiveBall:End Sub
- Sub sw33_unhit:Controller.Switch(33) = 0: End Sub
- 'Spinner
- Sub sw35_spin:vpmtimer.pulsesw 35: PlaySoundAt "fx_spinner", sw35:DOFALT 117, DOFPulse:End Sub
- 'Up Post opto
- Sub sw36_hit:vpmtimer.pulsesw 36: End Sub
- 'Ramp Switches
- Sub sw40_hit: Controller.Switch(40) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 118, DOFPulse End Sub
- Sub sw40_unhit:Controller.Switch(40) = 0: End Sub
- Sub sw43_hit: Controller.Switch(43) = 1 : PlaySoundAt "fx_sensor",ActiveBall:DOFALT 118, DOFPulse:End Sub
- Sub sw43_unhit:Controller.Switch(43) = 0: End Sub
- 'Bumpers
- Sub sw49_hit:DOFALT 108, DOFPulse:vpmtimer.pulsesw 49:PlaySoundAt SoundFXDOFALT("LeftJet",107,DOFPulse,DOFContactors), ActiveBall:End Sub
- Sub sw50_hit:DOFALT 112, DOFPulse:vpmtimer.pulsesw 50:PlaySoundAt SoundFXDOFALT("RightJet",111,DOFPulse,DOFContactors), ActiveBall:End Sub
- Sub sw51_hit:DOFALT 110, DOFPulse:vpmtimer.pulsesw 51:PlaySoundAt SoundFXDOFALT("BottomJet",109,DOFPulse,DOFContactors), ActiveBall:End Sub
- 'ECTO Goggles opto
- Sub sw59_hit:vpmtimer.pulsesw 59: End Sub
- 'Drop Targets
- Sub sw65_dropped:dtLeft.Hit 1:DOFALT 119, DOFPulse:End Sub
- Sub sw66_dropped:dtRight.Hit 1:DOFALT 119, DOFPulse:End Sub
- '************************************************************************
- ' ECTO GOGGLES
- '************************************************************************
- sub changevideo(vidnum)
- if (vidnum<=9) then
- ectomovie.imagea = "zcd_nunzioScoleri_hit_" & Right("000" & CStr(vidnum+1), 3)
- elseif (vidnum<=47) then
- ectomovie.imagea = "zcd_tonyScoleri_hit_" & Right("000" & CStr(vidnum-9), 3)
- elseif (vidnum<=66) then
- ectomovie.imagea = "zcd_nunzioScoleri_idle_" & Right("000" & CStr(vidnum-47), 3)
- elseif (vidnum<=90) then
- ectomovie.imagea = "zcd_ghost4_idle_" & Right("000" & CStr(vidnum-66), 3)
- ' I think this is a SPA bug - 029 is the first hit sequence, not 001
- elseif (vidnum<=99) Then
- ectomovie.imagea = "zcd_ghost4_hit_" & Right("000" & CStr(vidnum-90+28), 3)
- elseif (vidnum<=127) Then
- ectomovie.imagea = "zcd_ghost4_hit_" & Right("000" & CStr(vidnum-90-9), 3)
- ' end buggy sequence.
- elseif (vidnum<=173) then
- ectomovie.imagea = "zcd_SternLogo_" & Right("000" & CStr(vidnum-128), 3)
- elseif (vidnum=174) Then
- ectomovie.imagea = "zcd_GhostLogo"
- elseif (vidnum<=205) then
- ectomovie.imagea = "zcd_Jackpot_15fps_" & Right("000" & CStr(vidnum-174), 3)
- elseif (vidnum<=236) then
- ectomovie.imagea = "zcd_SuperJackpot_15fps_" & Right("000" & CStr(vidnum-205), 3)
- elseif (vidnum<=276) then
- ectomovie.imagea = "zcd_slimer_idle_" & Right("000" & CStr(vidnum-236), 3)
- elseif (vidnum<=294) then
- ectomovie.imagea = "zcd_slimer_small_hit_" & Right("000" & CStr(vidnum-276), 3)
- elseif (vidnum<=313) then
- ectomovie.imagea = "zcd_tonyScoleri_small_idle_" & Right("000" & CStr(vidnum-294), 3)
- elseif (vidnum<=418) then
- ectomovie.imagea = "zcd_Taxi" & Right("000" & CStr(vidnum-313), 3)
- elseif (vidnum<=464) then
- ectomovie.imagea = "zcd_Cat" & Right("000" & CStr(vidnum-418), 3)
- Else
- ectomovie.imagea = "zcd_GhostLogo"
- end if
- end sub
- ' *********************************************************************
- ' LIGHTS
- ' *********************************************************************
- Dim bulb
- Dim LampState(300), FadingLevel(300)
- Dim FlashSpeedUp(300), FlashSpeedDown(300), FlashMin(300), FlashMax(300), FlashLevel(300)
- InitLamps() ' turn off the lights and flashers and reset them to the default parameters
- LampTimer.Interval = -1 'lamp fading speed
- LampTimer.Enabled = 1
- Sub LampTimer_Timer()
- Dim chgLamp, num, chg, ii, vid
- vid = false
- 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
- 'Debug.print "L" & chgLamp(ii, 0) &" -> " & chgLamp(ii, 1)
- Select Case chgLamp(ii, 0)
- Case 199,201,206,207,208,209,210,211,220,223
- If chgLamp(ii, 1) > 128 Then
- DOFALT chgLamp(ii, 0), DOFOn
- Else
- DOFALT chgLamp(ii, 0), DOFOff
- End If
- End Select
- if chgLamp(ii,0) = 282 or chgLamp(ii,0) = 283 Then
- vid = true
- end if
- Next
- if vid then
- changevideo cInt(LampState(283)) * 256 + cInt(LampState(282))
- end if
- End If
- UpdateLamps
- End Sub
- Sub InitLamps()
- Dim x
- For x = 0 to 300
- 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.5 ' faster speed when turning on the flasher
- FlashSpeedDown(x) = 0.35 ' 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 UpdateLamps()
- SingleLamp l10, 10
- SingleLamp l11, 11
- SingleLamp l13, 13
- SingleLamp l14, 14
- SingleLamp l15, 15
- SingleLamp l16, 16
- SingleLamp l17, 17
- SingleLamp l18, 18
- SingleLamp l19, 19
- SingleLamp l20, 20
- SingleLamp l21, 21
- SingleLamp l22, 22
- SingleLamp l23, 23
- SingleLamp l24, 24
- SingleLamp l25, 25
- SingleLamp l30, 30
- SingleLamp l31, 31
- SingleLamp l32, 32
- SingleLamp l33, 33
- SingleLamp l35, 35
- SingleLamp l36, 36
- SingleLamp l37, 37
- SingleLamp l38, 38
- SingleLamp l39, 39
- SingleLamp l40, 40
- SingleLamp l49, 49
- SingleLamp l54, 54
- SingleLamp l54a, 54
- SingleLamp l56, 56
- SingleLamp l57, 57
- SingleLamp l58, 58
- SingleLamp l59, 59
- SingleLamp l60, 60
- SingleLamp l61, 61
- SingleLamp l65, 65
- SingleLamp l66, 66
- SingleLamp l68, 68
- SingleLamp l69, 69
- SingleLamp l70, 70
- SingleLamp l71, 71
- SingleLamp l72, 72
- SingleLamp l73, 73
- SingleLamp l75, 75
- SingleLamp l76, 76
- SingleLamp l77, 77
- SingleLamp l78, 78
- SingleLamp l79, 79
- SingleLamp l84, 84
- SingleLamp l85, 85
- SingleLamp l89, 89
- SingleLamp Fl91, 91
- SingleLamp Fl91a, 91
- SingleLamp Fl91b, 91
- SinglePrimitive bulb1, 91, 1
- SingleLamp Fl92, 92
- SingleLamp Fl92a, 92
- SingleLamp Fl92b, 92
- SingleLamp Fl92c, 92
- SingleLamp l94, 94
- SingleLamp l95, 95
- SingleLamp l100, 100
- SingleLamp l100a, 100
- SingleLamp l100b, 100
- SingleLamp l101, 101
- SingleLamp l101a, 101
- SingleLamp l101b, 101
- SingleLamp l102, 102
- SingleLamp l102a, 102
- SingleLamp l102b, 102
- SingleLamp l103, 103
- SingleLamp l104, 104
- SingleLamp l105, 105
- SingleLamp l106, 106
- 'SingleLamp l110, 110 'SPA bug, DLL remaps 123 and 110 to 0 making it not quite right..
- SingleLamp l112, 112
- SingleLamp l112a, 112
- SingleLamp l113, 113
- SingleLamp l113a, 113
- 'RGB lamps
- RGBLamp l26r, 28, 27, 26
- RGBLamp l41r, 43, 42, 41
- RGBLamp l45r, 45, 46, 47
- RGBLampR l45a, 45, 46, 47
- RGBLamp l50r, 52, 51, 50
- RGBLamp l62r, 64, 63, 62
- RGBLamp l80r, 82, 81, 80
- RGBLamp l86r, 88, 87, 86
- RGBLamp l96r, 96, 97, 98
- RGBLamp lPuffGlow, 107, 108, 109
- StayPuftColor 107, 108, 109
- 'General Illumination
- CabinetSide 117
- SingleLamp Reflect1, 117
- GIString GILeftSling, 117
- GIString GIPlayfield2, 118
- GIString GIPlayfield3, 119
- GIString GIBackwall, 120
- SinglePrimitive bulb3, 120, 1
- SinglePrimitive bulb4, 120, 1
- SinglePrimitive bulb5, 120, 1
- SinglePrimitive bulb6, 120, 1
- SinglePrimitive bulb7, 120, 1
- GIString GIRightSling, 121
- SlimerLamp 122
- GIString GIEcto, 123
- 'Flashers
- SingleLamp fl125, 125
- SingleLamp fl126, 126
- SingleLamp fl127a, 127
- SingleLamp fl127b, 127
- SinglePrimitive fl127p, 127, 3
- SingleLamp fl128a, 128
- SingleLamp fl128b, 128
- SinglePrimitive fl128p, 128, 3
- If LampState(127+81)>0 AND LampState(128+81)>0 Then HideLamp True
- If LampState(127+81)=0 OR LampState(128+81)=0 Then HideLamp False
- SingleLamp Fl129, 129
- SingleLamp Fl129a, 129
- SingleLamp Fl129b, 129
- SingleLamp Fl129c, 129
- SinglePrimitive fl129p, 129, 3
- SingleLamp Fl130a, 130
- SingleLamp Fl130b, 130
- SingleLamp Fl131a, 131
- SingleLamp Fl131b, 131
- SingleLamp Fl132, 132
- SingleLamp fl133b, 133
- SingleLamp fl133a, 133
- SingleLamp fl134b, 134
- SingleLamp fl134a, 134
- SingleLamp Fl136, 136
- SingleLamp Fl136a, 136
- SingleLamp Fl137, 137
- SingleLamp Fl137a, 137
- SingleLamp l138, 138
- SingleLamp l138a, 138
- SingleLamp l139, 139
- SingleLamp l139a, 139
- SingleLamp l139b, 139
- SingleLamp l139c, 139
- SingleLamp l140a, 140
- SingleLamp l140b, 140
- SingleLamp l141a, 141
- SingleLamp l141b, 141
- SingleLamp Fl142a, 142
- SingleLamp Fl142b, 142
- SinglePrimitive Fl142p, 142, 1
- End Sub
- Sub HideLamp (enabled)
- Fl128a.visible=NOT enabled
- End Sub
- Sub SingleLamp(lampobj, id)
- lampobj.IntensityScale = LampState(id + 81) / 255
- End Sub
- Sub SinglePrimitive(primobj, id, factor)
- primobj.BlendDisableLighting = factor * (LampState(id + 81) / 255)
- End Sub
- Sub RGBLamp(object, AR, AG, AB) 'used for light objects
- Dim r, g, bl
- r = LampState(aR+81)
- g = LampState(aG+81)
- bl = LampState(aB+81)
- Object.IntensityScale = (r+g+(bl*2)) / 500
- Object.ColorFull = RGB(r, g, bl)
- Object.Color = RGB(r, g, bl)
- end Sub
- Sub RGBLampR(object, aR, aG, aB) 'used for flasher objects
- Dim r, g, bl
- r = LampState(aR+81)
- g = LampState(aG+81)
- bl = LampState(aB+81)
- Object.IntensityScale = (r+g+(bl*2)) / 1000
- Object.Color = RGB(r, g, bl)
- end Sub
- Sub SlimerLamp(id)
- dim intensity:intensity = LampState(id + 81) / 255
- slimer.blenddisablelighting = intensity
- slimerlight.IntensityScale = intensity
- slimerlighta.IntensityScale = intensity
- MaterialColor "Slimer", RGB(128+127*intensity,148+107*intensity, 128+127*intensity)
- end sub
- Sub StayPuftColor(AR, AG, AB)
- Dim r, g, bl, comp
- r = LampState(aR+81)*1.4 / 2
- g = LampState(aG+81)*1.4 / 2
- bl = LampState(aB+81) *1.4 / 2
- staypuft.blenddisablelighting = (r+g+(bl*2)) / 1000
- comp = (r+g+bl) / 4 ' Boost contrast to make colors more intense as light gets brighter.
- MaterialColor "Staypuft", RGB(r+128-comp,g+128-comp, bl+128-comp)
- End Sub
- Sub GIString(Coll, id)
- dim Intensity:Intensity = LampState(id + 81)
- dim Obj
- for each obj in Coll
- obj.IntensityScale = intensity / 255
- Next
- End Sub
- Sub CabinetSide (id)
- dim Intensity:Intensity = LampState(id + 81)/255
- MaterialColor "CabSides", RGB (255 * Intensity, 255 * Intensity, 255 * Intensity)
- End Sub
- ' *********************************************************************
- ' Supporting Ball & Sound Functions
- ' *********************************************************************
- Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
- Vol = Csng(BallVel(ball) ^2 / 2000)
- End Function
- Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
- Dim tmp
- tmp = ball.x * 2 / table1.width-1
- If tmp > 0 Then
- Pan = Csng(tmp ^10)
- Else
- Pan = Csng(-((- tmp) ^10) )
- End If
- End Function
- function AudioFade(ball)
- Dim tmp
- tmp = ball.y * 2 / Table1.height-1
- If tmp > 0 Then
- AudioFade = Csng(tmp ^10)
- Else
- AudioFade = Csng(-((- tmp) ^10) )
- End If
- 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
- 'Set position as table object (Use object or light but NOT wall) and Vol to 1
- Sub PlaySoundAt(sound, tableobj)
- PlaySound sound, 1, 1, Pan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- 'Set position as table object and Vol manually.
- Sub PlaySoundAtVol(sound, tableobj, Vol)
- PlaySound sound, 1, Vol, Pan(tableobj), 0, 0, 0, 1, AudioFade(tableobj)
- End Sub
- 'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
- Sub PlaySoundAtBallVol(sound, VolMult)
- PlaySound sound, 0, Vol(ActiveBall) * VolMult, Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
- End Sub
- Sub PlayLoopSoundAtVol(sound, tableobj, Vol)
- PlaySound sound, -1, Vol, Pan(tableobj), 0, 0, 1, 0, AudioFade(tableobj)
- End Sub
- 'Additional DOF sound vs toy/effect helpers:
- Function SoundFX (Sound, Effect)
- If ((Effect = 0 And B2SOn) Or DOFeffects(Effect)=1) Then
- SoundFX = ""
- Else
- SoundFX = Sound
- End If
- End Function
- Function SoundFXDOF (Sound, DOFevent, State, Effect)
- If DOFeffects(Effect)=1 Then
- SoundFXDOF = ""
- DOF DOFevent, State
- ElseIf DOFeffects(Effect)=2 Then
- SoundFXDOF = Sound
- DOF DOFevent, State
- Else
- SoundFXDOF = Sound
- End If
- End Function
- Function SoundFXDOFALT (Sound, DOFevent, State, Effect)
- If DOFeffects(Effect)=1 Then
- SoundFXDOFALT = ""
- DOFALT DOFevent, State
- ElseIf DOFeffects(Effect)=2 Then
- SoundFXDOFALT = Sound
- DOFALT DOFevent, State
- Else
- SoundFXDOFALT = Sound
- End If
- End Function
- Sub DOF(DOFevent, State)
- If B2SOn Then
- If State = 2 Then
- Controller.B2SSetData DOFevent, 1:Controller.B2SSetData DOFevent, 0
- Else
- Controller.B2SSetData DOFevent, State
- End If
- End If
- End Sub
- Sub DOFALT(DOFevent, State)
- If B2SOnALT Then
- If State = 2 Then
- B2SController.B2SSetData DOFevent, 1:B2SController.B2SSetData DOFevent, 0
- Else
- B2SController.B2SSetData DOFevent, State
- End If
- End If
- End Sub
- '*****************
- ' Maths
- '*****************
- Const Pi = 3.1415927
- Function dSin(degrees)
- dsin = sin(degrees * Pi/180)
- End Function
- Function dCos(degrees)
- dcos = cos(degrees * Pi/180)
- End Function
- Function dAtn(degrees)
- dAtn = atn(degrees * Pi/180)
- End Function
- Function RndNum(min, max)
- RndNum = Int(Rnd() * (max-min + 1) ) + min ' Sets a random number between min and max
- End Function
- ' *********************************************************************
- ' Other Sound FX
- ' *********************************************************************
- Sub ShooterEnd_Hit:If ActiveBall.Z > 30 Then Me.TimerInterval=100:Me.TimerEnabled=1:End If:End Sub 'ball is flying
- Sub ShooterEnd_Timer(): Me.TimerEnabled=0 : PlaySoundAt "fx_BallDrop", ShooterEnd: End Sub
- Sub LREnter_Hit():If ActiveBall.VelY < 0 Then PlaySoundAtVol "fx_lrenter", LREnter, 0.5:End If:End Sub 'ball is going up
- Sub LREnter_UnHit():If ActiveBall.VelY > 0 Then StopSound "fx_lrenter":End If:End Sub 'ball is going down
- Sub LREnter1_Hit(): PlaySoundAtVol "fx_lrturn",LREnter1, 0.5:End Sub
- Sub LWREnter_hit: PlaysoundAt "fx_wireramp_enter", ActiveBall:End Sub
- Sub LWREnter1_hit: PlaysoundAt "fx_lrbump", ActiveBall:End Sub
- Sub LWRExit_hit:StopSound "Subway_enter":PlaysoundAt "Subway_exit",LWRExit:End Sub
- Sub RREnter_Hit():If ActiveBall.VelY < 0 Then PlaySoundAt "fx_rrenter1",ActiveBall:End If:End Sub 'ball is going up
- Sub RREnter_UnHit():If ActiveBall.VelY > 0 Then StopSound "fx_rrenter1":End If:End Sub 'ball is going down
- Sub RREnter1_hit: PlaySoundAt "fx_rrenter2", RREnter1 : End Sub
- Sub RWREnter_hit:PlaysoundAt "fx_wireramp_enter", ActiveBall:End Sub
- Sub RWREnter1_hit: PlaysoundAt "fx_lrbump", ActiveBall:End Sub
- Sub RWRExit_hit:StopSound"fx_wireramp_enter":PlaysoundAt "fx_wireramp_exit", ActiveBall:Me.TimerInterval=200:Me.TimerEnabled=1:End Sub
- Sub RWRExit_timer:Me.TimerEnabled=0:PlaysoundAt "fx_BallDrop",RWRExit:End Sub
- Sub OnBallBallCollision(ball1, ball2, velocity)
- PlaySound "fx_collide", 0, Csng(velocity) ^2 / 500, Pan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
- End Sub
- Sub LeftFlipper_Collide(parm)
- RandomSoundFlipper
- End Sub
- Sub Rightflipper_Collide(parm)
- RandomSoundFlipper
- End Sub
- Sub Pins_Hit(idx)
- RandomSoundRubber()
- End Sub
- Sub Posts_Hit(idx)
- RandomSoundRubber()
- End Sub
- Sub Rubbers_Hit(idx)
- RandomSoundRubber()
- End Sub
- Sub Gates_Hit(idx)
- PlaySoundAtBallVol "gate4",1
- End Sub
- Sub RandomSoundRubber()
- Select Case RndNum(1,3)
- Case 1 : PlaySoundAtBallVol "fx_rubber_hit_1",10
- Case 2 : PlaySoundAtBallVol "fx_rubber_hit_2",10
- Case 3 : PlaySoundAtBallVol "fx_rubber_hit_3",10
- End Select
- End Sub
- Sub RandomSoundFlipper()
- Select Case RndNum(1,3)
- Case 1 : PlaySoundAtBallVol "fx_flip_hit_1", 20
- Case 2 : PlaySoundAtBallVol "fx_flip_hit_2", 20
- Case 3 : PlaySoundAtBallVol "fx_flip_hit_3", 20
- End Select
- End Sub
- 'Helpers
- Sub LoopL_Hit : If Activeball.VelY>20 Then Activeball.VelY=18 : End If : End Sub
- ' *********************************************************************
- ' REALTIME UPDATES
- ' *********************************************************************
- Sub GameTimer_Timer
- RollingSoundUpdate
- BallShadowUpdate
- LeftFlipperP.ObjRotZ = LeftFlipper.currentangle
- RightFlipperp.ObjRotZ = RightFlipper.currentangle
- FlipperLSh.RotZ = LeftFlipper.currentangle
- FlipperRSh.RotZ = RightFlipper.currentangle
- sw35p.RotX = -sw35.currentangle
- LeftGate.RotY = Gate1.currentangle
- RightGate.RotY = Gate2.currentangle
- Primitive71.RotX = -Gate3.currentangle
- Primitive69.RotX = -Gate4.currentangle
- Primitive68.RotX = -Gate5.currentangle
- End Sub
- Const tnob = 13 ' total number of balls : 6 (trough) + 6 (Captive Ball) + 1(FakeBall)
- Const fakeballs = 7 ' number of balls created on table start (rolling sound and ballshadow will be skipped)
- ReDim rolling(tnob-fakeballs-1)
- ReDim BallShadow(tnob-fakeballs-1)
- InitRolling:InitBallShadow
- Sub InitRolling
- Dim i
- For i=0 to tnob-fakeballs-1
- rolling(i) = False
- Next
- End Sub
- Sub InitBallShadow
- Dim i
- For i=0 to tnob-fakeballs-1
- ExecuteGlobal "Set BallShadow(" & i & ")=BallShadow" & (i+1) & ":"
- Next
- End Sub
- ' ************************ROLLING SOUND************************
- Sub RollingSoundUpdate()
- Dim BOT, b
- BOT = GetBalls
- ' stop the sound of deleted balls
- If UBound(BOT)<(tnob - 1) Then
- For b = (UBound(BOT) + 1) to (tnob-1)
- rolling(b-fakeballs) = False
- StopSound("fx_ballrolling" & b-fakeballs)
- Next
- End If
- ' exit the Sub if no balls on the table
- If UBound(BOT) = fakeballs-1 Then Exit Sub
- ' play the rolling sound for each ball
- For b = fakeballs to UBound(BOT)
- If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
- rolling(b-fakeballs) = True
- PlaySound("fx_ballrolling" & b-fakeballs), -1, Vol(BOT(b) )*0.25, Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
- Else
- If rolling(b-fakeballs) = True Then
- StopSound("fx_ballrolling" & b-fakeballs)
- rolling(b-fakeballs) = False
- End If
- End If
- Next
- End Sub
- ' **********************BALL SHADOW**********************
- 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-fakeballs).visible = 0
- Next
- End If
- ' exit the Sub if no balls on the table
- If UBound(BOT) = fakeballs-1 Then Exit Sub
- ' render the shadow for each ball
- For b = fakeballs to UBound(BOT)
- If BOT(b).X < Table1.Width/2 Then
- BallShadow(b-fakeballs).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/10)) + 10
- Else
- BallShadow(b-fakeballs).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/10)) - 10
- End If
- BallShadow(b-fakeballs).Y = BOT(b).Y + 20
- If BOT(b).Z > 20 Then
- BallShadow(b-fakeballs).visible = 1
- Else
- BallShadow(b-fakeballs).visible = 0
- End If
- Next
- End Sub
- '#############################################################
- '#############################################################
- '############### VPinSPA Controller loader ###################
- '#############################################################
- '#############################################################
- Const directory = "HKEY_CURRENT_USER\SOFTWARE\Visual Pinball\Controller\"
- Const DOFContactors = 1
- Const DOFKnocker = 2
- Const DOFChimes = 3
- Const DOFBell = 4
- Const DOFGear = 5
- Const DOFShaker = 6
- Const DOFFlippers = 7
- Const DOFTargets = 8
- Const DOFDropTargets = 9
- Const DOFOff = 0
- Const DOFOn = 1
- Const DOFPulse = 2
- Private Sub LoadCore
- On Error Resume Next
- If VPBuildVersion < 0 Or Err Then
- Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") : Err.Clear
- ExecuteGlobal fso.OpenTextFile("core.vbs", 1).ReadAll : If Err Then MsgBox "Can't open ""core.vbs""" : Exit Sub
- ExecuteGlobal fso.OpenTextFile("VPMKeys.vbs", 1).ReadAll : If Err Then MsgBox "Can't open ""vpmkeys.vbs""" : Exit Sub
- Else
- ExecuteGlobal GetTextFile("core.vbs") : If Err Then MsgBox "Can't open ""core.vbs""" : Exit Sub
- ExecuteGlobal GetTextFile("VPMKeys.vbs") : If Err Then MsgBox "Can't open ""vpmkeys.vbs""" : Exit Sub
- End If
- End Sub
- Sub LoadSPAController()
- ' Adaptation of LoadController from Controller.vbs
- Dim FileObj
- Dim DOFConfig
- Dim TextStr2
- Dim tempC
- Dim count
- Dim ISDOF
- Dim Answer
- B2SOn = False
- B2SOnALT = False
- tempC = 0
- on error resume next
- Set objShell = CreateObject("WScript.Shell")
- objShell.RegRead(directory & "ForceDisableB2S")
- If Err.number <> 0 Then
- PopupMessage = "This latest version of Controller.vbs stores its settings in the registry. To adjust the values, you must use VP 10.2 (or newer) and setup your configuration in the DOF section of the -Keys, Nudge and DOF- dialog of Visual Pinball."
- objShell.RegWrite directory & "ForceDisableB2S",0, "REG_DWORD"
- objShell.RegWrite directory & "DOFContactors",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFKnocker",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFChimes",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFBell",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFGear",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFShaker",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFFlippers",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFTargets",2, "REG_DWORD"
- objShell.RegWrite directory & "DOFDropTargets",2, "REG_DWORD"
- MsgBox PopupMessage
- End If
- tempC = objShell.RegRead(directory & "ForceDisableB2S")
- DOFeffects(1)=objShell.RegRead(directory & "DOFContactors")
- DOFeffects(2)=objShell.RegRead(directory & "DOFKnocker")
- DOFeffects(3)=objShell.RegRead(directory & "DOFChimes")
- DOFeffects(4)=objShell.RegRead(directory & "DOFBell")
- DOFeffects(5)=objShell.RegRead(directory & "DOFGear")
- DOFeffects(6)=objShell.RegRead(directory & "DOFShaker")
- DOFeffects(7)=objShell.RegRead(directory & "DOFFlippers")
- DOFeffects(8)=objShell.RegRead(directory & "DOFTargets")
- DOFeffects(9)=objShell.RegRead(directory & "DOFDropTargets")
- Set objShell = nothing
- Set Controller = CreateObject("VPinSPA.Controller")
- If Err Then MsgBox "Can't load SPA"
- If tempC = 0 Then
- On Error Resume Next
- If Controller is Nothing Then
- Err.Clear
- Else
- Set B2SController = CreateObject("B2S.Server")
- If B2SController is Nothing Then
- Err.Clear
- Else
- B2SController.B2SName = B2ScGameName
- B2SController.Run()
- On Error Goto 0
- B2SOn = True
- B2SOnALT = True
- End If
- End If
- End If
- End sub
Advertisement
Add Comment
Please, Sign In to add comment